feat(analytics): add OneDollarStats tracking - #485
Conversation
- Production: loads stonks.js without debug mode - Development: loads stonks.js with data-debug for localhost testing
|
🚅 Deployed to the openchat-pr-485 environment in OpenChat
|
🚀 Preview Deployment Ready
Convex Preview Backend
🤖 Deployed automatically by GitHub Actions |
Greptile SummaryAdded OneDollarStats analytics tracking with environment-aware configuration - production loads the script normally while development includes debug mode for localhost testing. Key Changes:
Issues Found:
Confidence Score: 2/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Browser
participant Root as __root.tsx
participant Theme as Theme Script
participant OneDollar as OneDollarStats
Browser->>Root: Load application
Root->>Browser: Inject head content
Note over Browser,Theme: Theme initialization (inline)
Browser->>Theme: Execute inline script
Theme->>Theme: Read localStorage('openchat-theme')
Theme->>Theme: Apply theme class to html
Theme->>Browser: Theme applied (no flash)
Note over Browser,OneDollar: Analytics initialization (deferred)
Browser->>OneDollar: Load stonks.js (defer)
alt Development Mode
OneDollar->>OneDollar: Init with data-debug="osschat.dev"
OneDollar->>Browser: Log debug info to console
else Production Mode
OneDollar->>OneDollar: Init without debug mode
end
OneDollar->>OneDollar: Start tracking page views
Note over OneDollar: Missing data-site attribute<br/>Analytics may not work properly
Browser->>Root: Render app components
|
| @@ -28,7 +28,6 @@ export const Route = createRootRoute({ | |||
| { rel: "icon", href: "/favicon.ico" }, | |||
| ], | |||
| scripts: [ | |||
There was a problem hiding this comment.
style: Missing comment explaining the inline script's purpose
| scripts: [ | |
| scripts: [ | |
| // Inline script to prevent flash of wrong theme | |
| { |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| import.meta.env.DEV | ||
| ? { | ||
| src: "https://assets.onedollarstats.com/stonks.js", | ||
| defer: true, | ||
| "data-debug": "osschat.dev", | ||
| } | ||
| : { | ||
| src: "https://assets.onedollarstats.com/stonks.js", | ||
| defer: true, | ||
| }, |
There was a problem hiding this comment.
logic: OneDollarStats script missing required site ID - tracking won't work without proper configuration. Check the OneDollarStats dashboard for your site ID and add it via data-site attribute.
| import.meta.env.DEV | |
| ? { | |
| src: "https://assets.onedollarstats.com/stonks.js", | |
| defer: true, | |
| "data-debug": "osschat.dev", | |
| } | |
| : { | |
| src: "https://assets.onedollarstats.com/stonks.js", | |
| defer: true, | |
| }, | |
| import.meta.env.DEV | |
| ? { | |
| src: "https://assets.onedollarstats.com/stonks.js", | |
| defer: true, | |
| "data-site": "your-site-id", | |
| "data-debug": "osschat.dev", | |
| } | |
| : { | |
| src: "https://assets.onedollarstats.com/stonks.js", | |
| defer: true, | |
| "data-site": "your-site-id", | |
| }, |
Do you have a OneDollarStats account set up with a site ID for this project?
Summary
Adds OneDollarStats analytics script for tracking site usage.
Changes
stonks.jswithout debug mode for real analyticsstonks.jswithdata-debug="osschat.dev"to allow localhost testingTesting