Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: track new landing_v2 features (wip) #1212

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JustARatherRidiculouslyLongUsername
Copy link
Contributor

@JustARatherRidiculouslyLongUsername JustARatherRidiculouslyLongUsername commented Mar 13, 2025

Description

Tracks:

  • Landing v2 being opened
  • Dropdown open
  • Dropdown option being clicked

Clickup

https://app.clickup.com/t/86cy8ykmx

Summary by CodeRabbit

  • New Features
    • Enhanced analytics tracking to improve monitoring of user interactions, including dropdown open events.
    • Updated analytics integration configuration to operate consistently across all environments.

@JustARatherRidiculouslyLongUsername JustARatherRidiculouslyLongUsername added the deploy Triggers deployment of active branch to Staging label Mar 13, 2025
Copy link
Contributor

coderabbitai bot commented Mar 13, 2025

Walkthrough

The pull request updates the tracking functionality and Mixpanel integration. In the tracking service, additional console log statements have been added to the getter and the eventTrack method. A new public method onDropDownOpen is introduced to track dropdown open events. In the index file, the Mixpanel tracking script now bypasses the localhost check, uses a hardcoded project token, and includes a new constant for the Mixpanel library URL.

Changes

File(s) Change Summary
src/app/.../tracking.service.ts Added logging in the tracking getter and eventTrack method; introduced new public method onDropDownOpen(trackingApp: TrackingApp) to track dropdown opens.
src/index.html Modified the Mixpanel script to always execute (removed hostname check), replaced the placeholder token with a hardcoded token, and added a custom library URL.

Sequence Diagram(s)

sequenceDiagram
    participant UI as User Interface
    participant TS as TrackingService
    participant MP as Mixpanel Library

    UI->>TS: Trigger dropdown open event
    TS->>TS: Execute onDropDownOpen(trackingApp)
    TS->>TS: Call eventTrack("Dropdown Open", trackingApp)
    TS->>TS: Log pre-tracking action and properties
    TS->>MP: Send tracking data to Mixpanel
    TS->>TS: Log successful tracking completion
Loading

Suggested labels

size/M

Suggested reviewers

  • ashwin1111

Poem

I'm a little rabbit with a hop so light,
Logging events by day and night.
Dropdowns open with a skip and jump,
Mixpanel tracks each data bump.
In every line of code I delight,
Hopping on changes, feeling just right!

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

PR description must contain a link to a ClickUp (case-insensitive)

@github-actions github-actions bot added the size/XS Extra Small PR label Mar 13, 2025
Copy link

Unit Test Coverage % values
Statements 32.84% ( 4202 / 12794 )
Branches 26.19% ( 1181 / 4508 )
Functions 25.56% ( 901 / 3525 )
Lines 33.04% ( 4137 / 12521 )

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d3fd81d and da7cfcf.

📒 Files selected for processing (2)
  • src/app/core/services/integration/tracking.service.ts (3 hunks)
  • src/index.html (1 hunks)
🧰 Additional context used
🪛 ESLint
src/app/core/services/integration/tracking.service.ts

[error] 58-58: Unexpected console statement.

(no-console)


[error] 68-68: Unexpected console statement.

(no-console)


[error] 72-72: Unexpected console statement.

(no-console)

🪛 GitHub Check: lint
src/app/core/services/integration/tracking.service.ts

[failure] 58-58:
Unexpected console statement


[failure] 68-68:
Unexpected console statement


[failure] 72-72:
Unexpected console statement

🪛 GitHub Actions: TypeScript Lint Check
src/app/core/services/integration/tracking.service.ts

[error] 58-58: ESLint: Unexpected console statement (no-console)

🪛 Gitleaks (8.21.2)
src/index.html

13-13: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: staging_deploy
  • GitHub Check: unit-test
🔇 Additional comments (2)
src/app/core/services/integration/tracking.service.ts (1)

131-133: LGTM - Implementation aligns with PR objective

The new method properly tracks dropdown open events as described in the PR objectives.

src/index.html (1)

14-14: LGTM - Explicit URL declaration

Defining the library URL as a constant is a good practice for ensuring consistent library loading.

@@ -64,9 +65,11 @@
...flattenedObject,
Asset: 'Integration Settings Web'
};
console.log('attempting:', action, properties);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove console log statements

These debugging statements should be removed before merging to production. They violate the ESLint no-console rule and have caused pipeline failures.

-  console.log('attempting:', action, properties);
  try {
    if (this.tracking) {
      this.tracking.track(`${trackingApp ? trackingApp : 'Integration Settings Web'}: ${action}`, properties);
-      console.log(`tracked: ${trackingApp ? trackingApp : 'Integration Settings Web'}: ${action}`, properties);
    }
  } catch (e) {

Also applies to: 72-72

🧰 Tools
🪛 ESLint

[error] 68-68: Unexpected console statement.

(no-console)

🪛 GitHub Check: lint

[failure] 68-68:
Unexpected console statement

Comment on lines 57 to 60
get tracking() {
console.log('got', (window as any).mixpanel);
return (window as any).mixpanel;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove console log statement

This debug console log should be removed before merging to production as it violates the ESLint no-console rule and has caused pipeline failures.

get tracking() {
-  console.log('got', (window as any).mixpanel);
  return (window as any).mixpanel;
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
get tracking() {
console.log('got', (window as any).mixpanel);
return (window as any).mixpanel;
}
get tracking() {
return (window as any).mixpanel;
}
🧰 Tools
🪛 ESLint

[error] 58-58: Unexpected console statement.

(no-console)

🪛 GitHub Check: lint

[failure] 58-58:
Unexpected console statement

🪛 GitHub Actions: TypeScript Lint Check

[error] 58-58: ESLint: Unexpected console statement (no-console)

@@ -8,12 +8,13 @@

<!-- Mixpanel -->
<script type="text/javascript">
if (window.location.hostname !== "localhost") {
if (true) {
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Enable tracking only in production environments

Using if (true) enables Mixpanel tracking in all environments including localhost, which can pollute analytics with development data. Consider using environment-specific conditions instead.

- if (true) {
+ if (window.location.hostname !== "localhost") {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (true) {
if (window.location.hostname !== "localhost") {

Comment on lines +13 to +14
const MIXPANEL_PROJECT_TOKEN = 'dce787f3a74f5ede8264af230a4b4652';
const MIXPANEL_CUSTOM_LIB_URL = 'https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js';
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Avoid hardcoding Mixpanel token in source code

Hardcoding API tokens in the source code is a security risk and could potentially be misused. The static analysis has flagged this as a generic API key leak.

Consider using environment variables or a secure configuration approach instead:

- const MIXPANEL_PROJECT_TOKEN = 'dce787f3a74f5ede8264af230a4b4652';
+ const MIXPANEL_PROJECT_TOKEN = '{{MIXPANEL_PROJECT_TOKEN}}';

🏁 Script executed:

#!/bin/bash
# Check if this Mixpanel token is referenced elsewhere in a more secure way
rg -g "!node_modules" -g "!dist" -g "!*.js.map" "dce787f3a74f5ede8264af230a4b4652" --no-ignore-vcs

# Check if there's an environment-based token loading pattern elsewhere in the codebase
rg -g "!node_modules" -g "!dist" -g "!*.js.map" "MIXPANEL_PROJECT_TOKEN" --no-ignore-vcs

Length of output: 527


Action: Secure Mixpanel Token Configuration

  • In src/index.html (lines 13-14), the Mixpanel project token is hardcoded, exposing a sensitive value.
  • The substitution in run.sh expects a placeholder ({{MIXPANEL_PROJECT_TOKEN}}) to inject the secure token at build time.
  • Please update the code so that the token is defined as a placeholder, as shown below:
- const MIXPANEL_PROJECT_TOKEN = 'dce787f3a74f5ede8264af230a4b4652';
+ const MIXPANEL_PROJECT_TOKEN = '{{MIXPANEL_PROJECT_TOKEN}}';

Implementing this change mitigates the security risk of a hardcoded API key.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const MIXPANEL_PROJECT_TOKEN = 'dce787f3a74f5ede8264af230a4b4652';
const MIXPANEL_CUSTOM_LIB_URL = 'https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js';
const MIXPANEL_PROJECT_TOKEN = '{{MIXPANEL_PROJECT_TOKEN}}';
const MIXPANEL_CUSTOM_LIB_URL = 'https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js';
🧰 Tools
🪛 Gitleaks (8.21.2)

13-13: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

@JustARatherRidiculouslyLongUsername JustARatherRidiculouslyLongUsername added deploy Triggers deployment of active branch to Staging and removed deploy Triggers deployment of active branch to Staging labels Mar 13, 2025
@@ -8,12 +8,13 @@

<!-- Mixpanel -->
<script type="text/javascript">
if (window.location.hostname !== "localhost") {
Copy link
Contributor

Choose a reason for hiding this comment

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

pls revert all these file changes

@@ -124,4 +127,8 @@ export class TrackingService {
onErrorResolve(trackingApp: TrackingApp, properties: ResolveMappingErrorProperty): void {
this.eventTrack('Resolve Mapping Error', trackingApp, properties);
}

onDropDownOpen(trackingApp: TrackingApp): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see any caller to this

@@ -55,6 +55,7 @@ export class TrackingService {
}

get tracking() {
console.log('got', (window as any).mixpanel);
Copy link
Contributor

Choose a reason for hiding this comment

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

fix all linting issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy Triggers deployment of active branch to Staging size/XS Extra Small PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants