Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/sim/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { generateBrandedMetadata, generateStructuredData } from '@/lib/branding/
import { PostHogProvider } from '@/lib/posthog/provider'
import '@/app/globals.css'

import { OneDollarStats } from '@/components/analytics/onedollarstats'
import { SessionProvider } from '@/lib/session/session-context'
import { season } from '@/app/fonts/season/season'
import { HydrationErrorHandler } from '@/app/hydration-error-handler'
Expand Down Expand Up @@ -55,6 +56,9 @@ export default function RootLayout({ children }: { children: React.ReactNode })
<meta name='format-detection' content='telephone=no' />
<meta httpEquiv='x-ua-compatible' content='ie=edge' />

{/* OneDollarStats Analytics */}
<script defer src='https://assets.onedollarstats.com/stonks.js' />
Comment on lines +59 to +60
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Script loads unconditionally but OneDollarStats component only initializes when DRIZZLE_ODS_API_KEY is set. This wastes bandwidth loading an unused script.

Consider conditionally rendering based on the API key presence or move script loading into the component.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/layout.tsx
Line: 59:60

Comment:
**style:** Script loads unconditionally but `OneDollarStats` component only initializes when `DRIZZLE_ODS_API_KEY` is set. This wastes bandwidth loading an unused script.

Consider conditionally rendering based on the API key presence or move script loading into the component.

How can I resolve this? If you propose a fix, please make it concise.


{/* Blocking script to prevent sidebar dimensions flash on page load */}
<script
dangerouslySetInnerHTML={{
Expand Down Expand Up @@ -166,6 +170,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
</head>
<body className={`${season.variable} font-season`} suppressHydrationWarning>
<HydrationErrorHandler />
<OneDollarStats />
<PostHogProvider>
<ThemeProvider>
<SessionProvider>
Expand Down
23 changes: 23 additions & 0 deletions apps/sim/components/analytics/onedollarstats.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use client'

import { useEffect } from 'react'
import { configure } from 'onedollarstats'
import { env } from '@/lib/env'

export function OneDollarStats() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Missing TSDoc. Per .cursorrules line 144, components must have TSDoc with description, @param, and @returns

Suggested change
export function OneDollarStats() {
/**
* OneDollarStats analytics component. Initializes analytics tracking
* when DRIZZLE_ODS_API_KEY is configured.
*
* @returns null - component has no visual output
*/
export function OneDollarStats() {

Context Used: Context from dashboard - apps/sim/.cursorrules (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/components/analytics/onedollarstats.tsx
Line: 7:7

Comment:
**style:** Missing TSDoc. Per .cursorrules line 144, components must have TSDoc with description, `@param`, and `@returns`

```suggestion
/**
 * OneDollarStats analytics component. Initializes analytics tracking
 * when DRIZZLE_ODS_API_KEY is configured.
 *
 * @returns null - component has no visual output
 */
export function OneDollarStats() {
```

**Context Used:** Context from `dashboard` - apps/sim/.cursorrules ([source](https://app.greptile.com/review/custom-context?memory=867b3993-a968-40e2-b2e0-8ce533acea2e))

How can I resolve this? If you propose a fix, please make it concise.

useEffect(() => {
const shouldInitialize = !!env.DRIZZLE_ODS_API_KEY

if (!shouldInitialize) {
return
}

configure({
collectorUrl: 'https://collector.onedollarstats.com/events',
autocollect: true,
hashRouting: true,
})
Comment on lines +15 to +19
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: DRIZZLE_ODS_API_KEY is checked but never passed to configure(). Analytics packages typically require the API key in their config.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/components/analytics/onedollarstats.tsx
Line: 15:19

Comment:
**logic:** `DRIZZLE_ODS_API_KEY` is checked but never passed to `configure()`. Analytics packages typically require the API key in their config.

How can I resolve this? If you propose a fix, please make it concise.

}, [])

return null
}
1 change: 1 addition & 0 deletions apps/sim/lib/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export const env = createEnv({
TELEMETRY_ENDPOINT: z.string().url().optional(), // Custom telemetry/analytics endpoint
COST_MULTIPLIER: z.number().optional(), // Multiplier for cost calculations
LOG_LEVEL: z.enum(['DEBUG', 'INFO', 'WARN', 'ERROR']).optional(), // Minimum log level to display (defaults to ERROR in production, DEBUG in development)
DRIZZLE_ODS_API_KEY: z.string().min(1).optional(), // OneDollarStats API key for analytics tracking

// External Services
BROWSERBASE_API_KEY: z.string().min(1).optional(), // Browserbase API key for browser automation
Expand Down
6 changes: 4 additions & 2 deletions apps/sim/lib/security/csp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const buildTimeCSPDirectives: CSPDirectives = {
"'unsafe-eval'",
'https://*.google.com',
'https://apis.google.com',
'https://assets.onedollarstats.com',
],

'style-src': ["'self'", "'unsafe-inline'", 'https://fonts.googleapis.com'],
Expand Down Expand Up @@ -92,6 +93,7 @@ export const buildTimeCSPDirectives: CSPDirectives = {
'https://*.supabase.co',
'https://api.github.com',
'https://github.com/*',
'https://collector.onedollarstats.com',
...getHostnameFromUrl(env.NEXT_PUBLIC_BRAND_LOGO_URL),
...getHostnameFromUrl(env.NEXT_PUBLIC_PRIVACY_URL),
...getHostnameFromUrl(env.NEXT_PUBLIC_TERMS_URL),
Expand Down Expand Up @@ -149,12 +151,12 @@ export function generateRuntimeCSP(): string {

return `
default-src 'self';
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://*.google.com https://apis.google.com;
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://*.google.com https://apis.google.com https://assets.onedollarstats.com;
style-src 'self' 'unsafe-inline' https://fonts.googleapis.com;
img-src 'self' data: blob: https://*.googleusercontent.com https://*.google.com https://*.atlassian.com https://cdn.discordapp.com https://*.githubusercontent.com ${brandLogoDomain} ${brandFaviconDomain};
media-src 'self' blob:;
font-src 'self' https://fonts.gstatic.com;
connect-src 'self' ${appUrl} ${ollamaUrl} ${socketUrl} ${socketWsUrl} https://api.browser-use.com https://api.exa.ai https://api.firecrawl.dev https://*.googleapis.com https://*.amazonaws.com https://*.s3.amazonaws.com https://*.blob.core.windows.net https://api.github.com https://github.com/* https://*.atlassian.com https://*.supabase.co ${dynamicDomainsStr};
connect-src 'self' ${appUrl} ${ollamaUrl} ${socketUrl} ${socketWsUrl} https://api.browser-use.com https://api.exa.ai https://api.firecrawl.dev https://*.googleapis.com https://*.amazonaws.com https://*.s3.amazonaws.com https://*.blob.core.windows.net https://api.github.com https://github.com/* https://*.atlassian.com https://*.supabase.co https://collector.onedollarstats.com ${dynamicDomainsStr};
frame-src https://drive.google.com https://docs.google.com https://*.google.com;
frame-ancestors 'self';
form-action 'self';
Expand Down
3 changes: 3 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"cronstrue": "3.3.0",
"drizzle-orm": "^0.44.5",
"mongodb": "6.19.0",
"onedollarstats": "0.0.10",
"postgres": "^3.4.5",
"remark-gfm": "4.0.1",
"socket.io-client": "4.8.1",
Expand Down