From 020f0eae5baacae492646459d43f9139246f15f6 Mon Sep 17 00:00:00 2001 From: Wells Bunker Date: Wed, 24 Sep 2025 12:31:57 -0600 Subject: [PATCH 1/5] fix default_openai_options --- .../src/assets/public-access-check.ts | 18 ++++++++++++++++++ packages/ai/src/llm/providers/gateway.ts | 10 +++++----- 2 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 packages/access-controls/src/assets/public-access-check.ts diff --git a/packages/access-controls/src/assets/public-access-check.ts b/packages/access-controls/src/assets/public-access-check.ts new file mode 100644 index 000000000..6754284b4 --- /dev/null +++ b/packages/access-controls/src/assets/public-access-check.ts @@ -0,0 +1,18 @@ +export function hasPublicAccess( + publiclyAccessible: boolean, + publicExpiryDate?: string, + publicPassword?: string, + password?: string, +): boolean { + if (!publiclyAccessible) { + return false; + } + const today = new Date(); + if (publicExpiryDate && new Date(publicExpiryDate) < today) { + return false; + } + if (publicPassword && publicPassword !== password) { + return false; + } + return true; +} diff --git a/packages/ai/src/llm/providers/gateway.ts b/packages/ai/src/llm/providers/gateway.ts index 4be511723..e5b32828a 100644 --- a/packages/ai/src/llm/providers/gateway.ts +++ b/packages/ai/src/llm/providers/gateway.ts @@ -13,11 +13,11 @@ export const DEFAULT_ANTHROPIC_OPTIONS = { export const DEFAULT_OPENAI_OPTIONS = { gateway: { order: ['openai'], - openai: { - parallelToolCalls: false, - reasoningEffort: 'minimal', - verbosity: 'low', - }, + }, + openai: { + parallelToolCalls: false, + reasoningEffort: 'minimal', + verbosity: 'low', }, }; From 8b981a47f6134b3fc6ae8f88c516b217d24297a2 Mon Sep 17 00:00:00 2001 From: Wells Bunker Date: Wed, 24 Sep 2025 12:35:04 -0600 Subject: [PATCH 2/5] remove extra file --- .../src/assets/public-access-check.ts | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 packages/access-controls/src/assets/public-access-check.ts diff --git a/packages/access-controls/src/assets/public-access-check.ts b/packages/access-controls/src/assets/public-access-check.ts deleted file mode 100644 index 6754284b4..000000000 --- a/packages/access-controls/src/assets/public-access-check.ts +++ /dev/null @@ -1,18 +0,0 @@ -export function hasPublicAccess( - publiclyAccessible: boolean, - publicExpiryDate?: string, - publicPassword?: string, - password?: string, -): boolean { - if (!publiclyAccessible) { - return false; - } - const today = new Date(); - if (publicExpiryDate && new Date(publicExpiryDate) < today) { - return false; - } - if (publicPassword && publicPassword !== password) { - return false; - } - return true; -} From 53a955dfbeae8bba5ac8b8c877150f3da3499e72 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Wed, 24 Sep 2025 12:39:45 -0600 Subject: [PATCH 3/5] added meta data --- .../src/context/AppVersion/useAppVersion.tsx | 22 ++++++------ .../context/Posthog/BusterPosthogProvider.tsx | 34 ++++++++++++++++--- apps/web/src/routeTree.gen.ts | 21 ++++++++++++ apps/web/src/routes/app.throw.tsx | 23 +++++++++++++ 4 files changed, 83 insertions(+), 17 deletions(-) create mode 100644 apps/web/src/routes/app.throw.tsx diff --git a/apps/web/src/context/AppVersion/useAppVersion.tsx b/apps/web/src/context/AppVersion/useAppVersion.tsx index dfd8eb887..053662da6 100644 --- a/apps/web/src/context/AppVersion/useAppVersion.tsx +++ b/apps/web/src/context/AppVersion/useAppVersion.tsx @@ -1,5 +1,5 @@ import { useQuery } from '@tanstack/react-query'; -import { useCallback, useEffect } from 'react'; +import { useCallback, useEffect, useMemo } from 'react'; import { versionGetAppVersion } from '@/api/query_keys/version'; import { Text } from '@/components/ui/typography'; import { useWindowFocus } from '@/hooks/useWindowFocus'; @@ -53,17 +53,6 @@ export const useAppVersion = () => { }; const AppVersionMessage = () => { - // const [countdown, setCountdown] = useState(180); - // useEffect(() => { - // const interval = setInterval(() => { - // setCountdown((prev) => Math.max(prev - 1, 0)); - // if (countdown === 0) { - // window.location.reload(); - // } - // }, 1000); - // return () => clearInterval(interval); - // }, []); - return ( A new version of the app is available. Please refresh the page to get the latest features. @@ -78,3 +67,12 @@ export const useIsVersionChanged = () => { }); return data; }; + +export const useAppVersionMeta = () => { + const { data } = useQuery({ + ...versionGetAppVersion, + select: (data) => data, + notifyOnChangeProps: ['data'], + }); + return useMemo(() => ({ ...data, browserBuild }), [data]); +}; diff --git a/apps/web/src/context/Posthog/BusterPosthogProvider.tsx b/apps/web/src/context/Posthog/BusterPosthogProvider.tsx index 55bba1fe5..390ff6c21 100644 --- a/apps/web/src/context/Posthog/BusterPosthogProvider.tsx +++ b/apps/web/src/context/Posthog/BusterPosthogProvider.tsx @@ -2,7 +2,6 @@ import { isServer } from '@tanstack/react-query'; import { ClientOnly } from '@tanstack/react-router'; import type { PostHogConfig } from 'posthog-js'; import React, { type PropsWithChildren, useEffect, useState } from 'react'; -import { useGetUserTeams } from '@/api/buster_rest/users'; import { useGetUserBasicInfo, useGetUserOrganization, @@ -10,10 +9,8 @@ import { import { ComponentErrorCard } from '@/components/features/global/ComponentErrorCard'; import { isDev } from '@/config/dev'; import { env } from '@/env'; -import { useMount } from '@/hooks/useMount'; -import packageJson from '../../../package.json'; +import { useAppVersionMeta } from '../AppVersion/useAppVersion'; -const version = packageJson.version; const POSTHOG_KEY = env.VITE_PUBLIC_POSTHOG_KEY; const DEBUG_POSTHOG = false; @@ -41,6 +38,7 @@ const options: Partial = { }; const PosthogWrapper: React.FC = ({ children }) => { + const appVersionMeta = useAppVersionMeta(); const user = useGetUserBasicInfo(); const userOrganizations = useGetUserOrganization(); const userOrganizationId = userOrganizations?.id || ''; @@ -89,8 +87,34 @@ const PosthogWrapper: React.FC = ({ children }) => { organization: userOrganizations, }); posthog.group(userOrganizationId, userOrganizationName); + + // Register app version metadata to be included with all events + if (appVersionMeta) { + posthog.register({ + app_version: appVersionMeta.buildId, + browser_build: appVersionMeta.browserBuild, + server_build: appVersionMeta.buildId, + version_changed: appVersionMeta.buildId !== appVersionMeta.browserBuild, + }); + } } - }, [user?.id, userOrganizationId, userOrganizationName, posthogModules]); + }, [user?.id, userOrganizationId, userOrganizationName, posthogModules, appVersionMeta]); + + // Update app version metadata when it changes after PostHog is initialized + useEffect(() => { + if (posthogModules?.posthog && appVersionMeta) { + const { posthog } = posthogModules; + + if (posthog.__loaded) { + posthog.register({ + app_version: appVersionMeta.buildId, + browser_build: appVersionMeta.browserBuild, + server_build: appVersionMeta.buildId, + version_changed: appVersionMeta.buildId !== appVersionMeta.browserBuild, + }); + } + } + }, [appVersionMeta, posthogModules]); // Show children while loading or if modules failed to load if (isLoading || !posthogModules) { diff --git a/apps/web/src/routeTree.gen.ts b/apps/web/src/routeTree.gen.ts index a536d2d18..fbcaac5bb 100644 --- a/apps/web/src/routeTree.gen.ts +++ b/apps/web/src/routeTree.gen.ts @@ -21,6 +21,7 @@ import { Route as AppIndexRouteImport } from './routes/app/index' import { Route as AuthResetPasswordRouteImport } from './routes/auth.reset-password' import { Route as AuthLogoutRouteImport } from './routes/auth.logout' import { Route as AuthLoginRouteImport } from './routes/auth.login' +import { Route as AppThrowRouteImport } from './routes/app.throw' import { Route as AppSettingsRouteImport } from './routes/app/_settings' import { Route as AppAppRouteImport } from './routes/app/_app' import { Route as EmbedReportReportIdRouteImport } from './routes/embed/report.$reportId' @@ -206,6 +207,11 @@ const AuthLoginRoute = AuthLoginRouteImport.update({ path: '/login', getParentRoute: () => AuthRoute, } as any) +const AppThrowRoute = AppThrowRouteImport.update({ + id: '/throw', + path: '/throw', + getParentRoute: () => AppRoute, +} as any) const AppSettingsRoute = AppSettingsRouteImport.update({ id: '/_settings', getParentRoute: () => AppRoute, @@ -933,6 +939,7 @@ export interface FileRoutesByFullPath { '/auth': typeof AuthRouteWithChildren '/embed': typeof EmbedRouteWithChildren '/healthcheck': typeof HealthcheckRoute + '/app/throw': typeof AppThrowRoute '/auth/login': typeof AuthLoginRoute '/auth/logout': typeof AuthLogoutRoute '/auth/reset-password': typeof AuthResetPasswordRoute @@ -1041,6 +1048,7 @@ export interface FileRoutesByTo { '/embed': typeof EmbedRouteWithChildren '/healthcheck': typeof HealthcheckRoute '/app': typeof AppSettingsRestricted_layoutAdmin_onlyRouteWithChildren + '/app/throw': typeof AppThrowRoute '/auth/login': typeof AuthLoginRoute '/auth/logout': typeof AuthLogoutRoute '/auth/reset-password': typeof AuthResetPasswordRoute @@ -1134,6 +1142,7 @@ export interface FileRoutesById { '/healthcheck': typeof HealthcheckRoute '/app/_app': typeof AppAppRouteWithChildren '/app/_settings': typeof AppSettingsRouteWithChildren + '/app/throw': typeof AppThrowRoute '/auth/login': typeof AuthLoginRoute '/auth/logout': typeof AuthLogoutRoute '/auth/reset-password': typeof AuthResetPasswordRoute @@ -1258,6 +1267,7 @@ export interface FileRouteTypes { | '/auth' | '/embed' | '/healthcheck' + | '/app/throw' | '/auth/login' | '/auth/logout' | '/auth/reset-password' @@ -1366,6 +1376,7 @@ export interface FileRouteTypes { | '/embed' | '/healthcheck' | '/app' + | '/app/throw' | '/auth/login' | '/auth/logout' | '/auth/reset-password' @@ -1458,6 +1469,7 @@ export interface FileRouteTypes { | '/healthcheck' | '/app/_app' | '/app/_settings' + | '/app/throw' | '/auth/login' | '/auth/logout' | '/auth/reset-password' @@ -1669,6 +1681,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof AuthLoginRouteImport parentRoute: typeof AuthRoute } + '/app/throw': { + id: '/app/throw' + path: '/throw' + fullPath: '/app/throw' + preLoaderRoute: typeof AppThrowRouteImport + parentRoute: typeof AppRoute + } '/app/_settings': { id: '/app/_settings' path: '' @@ -3195,12 +3214,14 @@ const AppSettingsRouteWithChildren = AppSettingsRoute._addFileChildren( interface AppRouteChildren { AppAppRoute: typeof AppAppRouteWithChildren AppSettingsRoute: typeof AppSettingsRouteWithChildren + AppThrowRoute: typeof AppThrowRoute AppIndexRoute: typeof AppIndexRoute } const AppRouteChildren: AppRouteChildren = { AppAppRoute: AppAppRouteWithChildren, AppSettingsRoute: AppSettingsRouteWithChildren, + AppThrowRoute: AppThrowRoute, AppIndexRoute: AppIndexRoute, } diff --git a/apps/web/src/routes/app.throw.tsx b/apps/web/src/routes/app.throw.tsx new file mode 100644 index 000000000..42dd2b42d --- /dev/null +++ b/apps/web/src/routes/app.throw.tsx @@ -0,0 +1,23 @@ +import { createFileRoute } from '@tanstack/react-router'; +import { useState } from 'react'; +import { useMount } from '../hooks/useMount'; + +export const Route = createFileRoute('/app/throw')({ + component: RouteComponent, +}); + +function RouteComponent() { + const [throwError, setThrowError] = useState(false); + + useMount(() => { + setTimeout(() => { + setThrowError(true); + }, 1000); + }); + + if (throwError) { + throw new Error('Nate is testing this error'); + } + + return
Hello "/app/throw"! {throwError ? 'Throwing error' : 'Not throwing error'}
; +} From 27d039bd0acfd5f078ef54ffa8502f28aa0856a5 Mon Sep 17 00:00:00 2001 From: dal Date: Wed, 24 Sep 2025 12:55:31 -0600 Subject: [PATCH 4/5] pnpm needed for deploy --- apps/web/src/routes/info/getting-started.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/routes/info/getting-started.tsx b/apps/web/src/routes/info/getting-started.tsx index c6b10bf43..1b727271c 100644 --- a/apps/web/src/routes/info/getting-started.tsx +++ b/apps/web/src/routes/info/getting-started.tsx @@ -10,4 +10,4 @@ export default function GettingStartedPage() { window.location.replace('https://buster.so/sign-up'); }, []); return null; -} \ No newline at end of file +} From e8af5ba7a18b138d72a850ffa075da1fb1062dc1 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Wed, 24 Sep 2025 13:14:07 -0600 Subject: [PATCH 5/5] setup reverse proxy --- .../src/context/Posthog/BusterPosthogProvider.tsx | 4 ++++ apps/web/vercel.json | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 apps/web/vercel.json diff --git a/apps/web/src/context/Posthog/BusterPosthogProvider.tsx b/apps/web/src/context/Posthog/BusterPosthogProvider.tsx index 390ff6c21..31afcc249 100644 --- a/apps/web/src/context/Posthog/BusterPosthogProvider.tsx +++ b/apps/web/src/context/Posthog/BusterPosthogProvider.tsx @@ -35,6 +35,9 @@ const options: Partial = { session_recording: { recordBody: true, }, + api_host: '/phrp/', + ui_host: 'https://us.posthog.com', + defaults: '2025-05-24', }; const PosthogWrapper: React.FC = ({ children }) => { @@ -58,6 +61,7 @@ const PosthogWrapper: React.FC = ({ children }) => { import('posthog-js'), import('posthog-js/react'), ]); + console.log('posthog', posthog); setPosthogModules({ posthog, PostHogProvider }); } catch (error) { diff --git a/apps/web/vercel.json b/apps/web/vercel.json new file mode 100644 index 000000000..24bd1eaaa --- /dev/null +++ b/apps/web/vercel.json @@ -0,0 +1,12 @@ +{ + "rewrites": [ + { + "source": "/phrp/static/(.*)", + "destination": "https://us-assets.i.posthog.com/static/$1" + }, + { + "source": "/phrp/(.*)", + "destination": "https://us.i.posthog.com/$1" + } + ] +}