Skip to content

Extended user telemetry and opt in flow#9

Merged
skosijer merged 5 commits intomainfrom
stevank/eng-510/extended-opt-in-telemetry
Jul 30, 2025
Merged

Extended user telemetry and opt in flow#9
skosijer merged 5 commits intomainfrom
stevank/eng-510/extended-opt-in-telemetry

Conversation

@skosijer
Copy link
Copy Markdown
Contributor

@skosijer skosijer commented Jul 29, 2025

Tracking the following events:
image

Also tracking the app usage such as page view, clicks, session time etc.

The whole tracking is behind an opt in screen that gets shown to each user individually:
image

Explore the events here:
https://us.posthog.com/project/86753/activity/explore

image

@skosijer skosijer requested review from kapicic and mlanlazc July 29, 2025 13:33
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @skosijer, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a comprehensive user telemetry system with an explicit opt-in flow, allowing the application to collect anonymous usage data to improve its features and stability. It integrates client-side and server-side tracking for various user interactions and application events, ensuring user privacy through a dedicated consent mechanism. Additionally, it updates the default LLM model used by the application.

Highlights

  • Telemetry System Implementation: A new, comprehensive telemetry system has been implemented to track various user interactions (e.g., chat prompts, retries, reverts, app deployments) and application errors, providing valuable insights into product usage and stability.
  • User Opt-in Flow: A dedicated consent screen is introduced at the application's entry point, requiring users to explicitly opt-in or opt-out of telemetry data collection. This enhances user privacy and control over their data.
  • Client-side and Server-side Integration: Telemetry tracking is now integrated across both the client (for general usage metrics like page views and clicks) and server (for specific backend events like chat prompts and deployments), ensuring a holistic view of application usage.
  • Database Schema Update: The user profile in the database has been extended with a telemetryEnabled flag, allowing the system to persistently store and respect individual user consent preferences.
  • LLM Model Update: The default Large Language Model (LLM) used by the application has been updated from claude-3-5-sonnet-latest to claude-4-sonnet-20250514.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a comprehensive user telemetry system with an opt-in flow. The changes are extensive, touching many parts of the application from the backend APIs to the frontend components. Key additions include a new telemetry consent page, client-side telemetry initialization, and tracking for various user actions like chat prompts, retries, forks, and app deployments.

The code is generally well-structured and the new features seem to be implemented correctly. I have a few suggestions to improve security, correctness, and maintainability, primarily concerning a hardcoded API key, a potential redirect loop, and some code simplifications for better consistency.

Comment thread .env.example
NEXT_PUBLIC_LOG_LEVEL=debug
NEXT_PUBLIC_TUNNEL_FORWARDING_URL=
BASE_URL=http://localhost:3000
NEXT_PUBLIC_POSTHOG_KEY=phc_C1L7Idffoa2oRT54XZDGh4GSdOPFgzliJiusFnVV8Wz
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.

high

It appears a public PostHog key has been committed. While this is a public key, it's best practice to avoid committing any credentials, even if they are for example files. This helps prevent accidental usage of a development/testing key in production or other environments.

Please replace this with a placeholder value.

NEXT_PUBLIC_POSTHOG_KEY=<YOUR_POSTHOG_PUBLIC_KEY>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is a public key for tracking telemetry, it's also present on the client when the app gets deployed, so it's fine.

Comment thread app/components/DataLoader.tsx
Comment thread app/api/telemetry-consent/route.ts Outdated
Comment thread app/api/telemetry-consent/route.ts Outdated
Comment thread app/components/DataLoader.tsx Outdated
Comment thread app/api/telemetry/route.ts
Comment thread app/lib/telemetry/telemetry-manager.ts Outdated
Copy link
Copy Markdown
Contributor

@mlanlazc mlanlazc left a comment

Choose a reason for hiding this comment

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

Looks very good 👏

@skosijer skosijer force-pushed the stevank/eng-510/extended-opt-in-telemetry branch from 6a82309 to 432c139 Compare July 30, 2025 14:11
@skosijer skosijer merged commit 2641f16 into main Jul 30, 2025
3 checks passed
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.

2 participants