Skip to content

Commit abed816

Browse files
waleedlatif1waleedlatif
andauthored
fix(standalone): selectively enable vercel speed insights, add annotations for envvars (#808)
* add annotations for environment variables * selectively enable vercel speed insights * use DOCKER_BUILD flag to selectively disable vercel speed insights and analytics * lint * additional info --------- Co-authored-by: waleedlatif <waleedlatif@waleedlatifs-MacBook-Pro.local>
1 parent 6f390c0 commit abed816

File tree

2 files changed

+162
-121
lines changed

2 files changed

+162
-121
lines changed

apps/sim/app/layout.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Analytics } from '@vercel/analytics/next'
22
import { SpeedInsights } from '@vercel/speed-insights/next'
33
import type { Metadata, Viewport } from 'next'
44
import { PublicEnvScript } from 'next-runtime-env'
5+
import { env, isTruthy } from '@/lib/env'
56
import { createLogger } from '@/lib/logs/console/logger'
67
import { TelemetryConsentDialog } from '@/app/telemetry-consent-dialog'
78
import '@/app/globals.css'
@@ -10,6 +11,18 @@ import { ZoomPrevention } from '@/app/zoom-prevention'
1011

1112
const logger = createLogger('RootLayout')
1213

14+
const shouldEnableAnalytics = () => {
15+
if (isTruthy(env.DOCKER_BUILD)) {
16+
return false
17+
}
18+
19+
if (!env.VERCEL_ENV) {
20+
return false
21+
}
22+
23+
return true
24+
}
25+
1326
const BROWSER_EXTENSION_ATTRIBUTES = [
1427
'data-new-gr-c-s-check-loaded',
1528
'data-gr-ext-installed',
@@ -226,8 +239,12 @@ export default function RootLayout({ children }: { children: React.ReactNode })
226239
<ZoomPrevention />
227240
<TelemetryConsentDialog />
228241
{children}
229-
<SpeedInsights />
230-
<Analytics />
242+
{shouldEnableAnalytics() && (
243+
<>
244+
<SpeedInsights />
245+
<Analytics />
246+
</>
247+
)}
231248
</body>
232249
</html>
233250
)

0 commit comments

Comments
 (0)