Skip to content

feat(analytics): add OneDollarStats tracking - #485

Merged
leoisadev1 merged 1 commit into
mainfrom
feat/onedollarstats-analytics
Jan 6, 2026
Merged

feat(analytics): add OneDollarStats tracking#485
leoisadev1 merged 1 commit into
mainfrom
feat/onedollarstats-analytics

Conversation

@leoisadev1

Copy link
Copy Markdown
Member

Summary

Adds OneDollarStats analytics script for tracking site usage.

Changes

  • Production: Loads stonks.js without debug mode for real analytics
  • Development: Loads stonks.js with data-debug="osschat.dev" to allow localhost testing

Testing

  • Type check passes

- Production: loads stonks.js without debug mode
- Development: loads stonks.js with data-debug for localhost testing
@railway-app

railway-app Bot commented Jan 6, 2026

Copy link
Copy Markdown

🚅 Deployed to the openchat-pr-485 environment in OpenChat

Service Status Web Updated (UTC)
web 🕒 Building (View Logs) Web Jan 6, 2026 at 11:18 pm

@github-actions

github-actions Bot commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

🚀 Preview Deployment Ready

Environment URL
Frontend https://web-openchat-pr-485.up.railway.app
Convex Dashboard Dashboard

Convex Preview Backend

  • Cloud URL: https://grateful-frog-454.convex.cloud
  • Site URL: https://grateful-frog-454.convex.site

🤖 Deployed automatically by GitHub Actions

@leoisadev1
leoisadev1 merged commit 227144c into main Jan 6, 2026
5 checks passed
@leoisadev1
leoisadev1 deleted the feat/onedollarstats-analytics branch January 6, 2026 23:19
@greptile-apps

greptile-apps Bot commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Added OneDollarStats analytics tracking with environment-aware configuration - production loads the script normally while development includes debug mode for localhost testing.

Key Changes:

  • Integrated stonks.js from OneDollarStats CDN with deferred loading
  • Development mode includes data-debug="osschat.dev" for localhost testing
  • Removed inline comment explaining theme script purpose

Issues Found:

  • Critical: Missing data-site attribute - OneDollarStats requires a site ID to function properly. Without this, the analytics script will load but won't track any data.
  • Minor: Removed helpful comment that explained the theme script's purpose (preventing flash of wrong theme)

Confidence Score: 2/5

  • This PR has a critical configuration issue that will prevent the analytics from working
  • The implementation is structurally correct (conditional loading based on environment, proper defer attribute), but the missing data-site attribute means the OneDollarStats tracking won't actually function. This is a critical omission that defeats the purpose of the PR. Additionally, removing the helpful comment reduces code maintainability.
  • Pay close attention to apps/web/src/routes/__root.tsx - the site ID configuration must be added before this will work

Important Files Changed

Filename Overview
apps/web/src/routes/__root.tsx Added OneDollarStats analytics script with dev/prod configuration, but missing required site ID configuration and removed helpful comment

Sequence Diagram

sequenceDiagram
    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
Loading

@greptile-apps greptile-apps Bot left a comment

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.

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@@ -28,7 +28,6 @@ export const Route = createRootRoute({
{ rel: "icon", href: "/favicon.ico" },
],
scripts: [

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 comment explaining the inline script's purpose

Suggested change
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!

Comment on lines +41 to +50
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,
},

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: 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.

Suggested change
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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant