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: add support of custom page event name in mixpanel #1622

Merged
merged 17 commits into from
Mar 1, 2024

Conversation

Gauravudia
Copy link
Contributor

@Gauravudia Gauravudia commented Feb 20, 2024

PR Description

Resolves INT-1553

  • Added the support for page custom event name
  • generatePageCustomEventName utility -> Generates a custom event name for a page with given event handlebar
  • Used the handlebars.js library for dynamic event template.
  • useUserDefinedPageEventName - Toggle to decide whether to send a custom page event name
  • userDefinedPageEventTemplate - Setting for event template

Linear task (optional)

https://linear.app/rudderstack/issue/INT-1553/mixpanel-cloud-mode-make-page-and-screen-calls-naming-configurable

Cross Browser Tests

Please confirm you have tested for the following browsers:

  • Chrome
  • Firefox
  • IE11

Sanity Suite

  • All sanity suite test cases pass locally

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Summary by CodeRabbit

  • New Features
    • Introduced the ability for users to define custom event names for page views in Mixpanel integration using templates.

Copy link
Contributor

coderabbitai bot commented Feb 20, 2024

Important

Auto Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

Walkthrough

The update introduces a method for users to generate custom event names for page views in the Mixpanel analytics integration. This is facilitated by a new function that creates these names based on user-defined templates. The Mixpanel class has been enhanced to support this customization, incorporating Handlebars for flexible event name definition.

Changes

Files Change Summary
.../integrations/Mixpanel/util.test.js, .../integrations/Mixpanel/util.js,
.../integrations/Mixpanel/browser.js
Added generatePageCustomEventName function for custom event name generation.
Modified Mixpanel class to support user-defined page event names using templates. Added Handlebars for template processing.

🐇✨
In the realm of code and screen,
A rabbit danced, its code keen.
"Let's name pages uniquely," it cried,
With templates and Handlebars by its side.
Custom events now bloom and shine,
In Mixpanel's world, a tale divine!
🌟📄🎉

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit-tests for this file.
  • 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 tests 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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2791472 and 3bf498b.
Files ignored due to path filters (2)
  • package-lock.json is excluded by: !**/*.json
  • package.json is excluded by: !**/*.json
Files selected for processing (3)
  • packages/analytics-js-integrations/tests/integrations/Mixpanel/util.test.js (17 hunks)
  • packages/analytics-js-integrations/src/integrations/Mixpanel/browser.js (3 hunks)
  • packages/analytics-js-integrations/src/integrations/Mixpanel/util.js (6 hunks)
Additional comments: 4
packages/analytics-js-integrations/src/integrations/Mixpanel/util.js (1)
  • 6-6: The import of Handlebars is correctly added to support the template processing required for generating custom event names. Ensure that Handlebars is listed as a dependency in the project's package.json to avoid runtime errors.
Verification successful

The import of Handlebars in Mixpanel/util.js and its listing as a dependency in the project's package.json file has been successfully verified. This ensures that the necessary support for template processing required for generating custom event names is correctly integrated into the project.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Check if Handlebars is listed as a dependency in package.json
rg '"handlebars":' package.json

Length of output: 61

packages/analytics-js-integrations/src/integrations/Mixpanel/browser.js (2)
  • 18-18: The import of generatePageOrScreenCustomEventName is correctly added to support the generation of custom event names within the Mixpanel class. This is necessary for the feature being introduced.
  • 67-68: The addition of useUserDefinedPageEventName and userDefinedPageEventTemplate properties to the Mixpanel class is correctly implemented. These properties are essential for toggling the custom event name feature and defining the template for event names, respectively. Ensure that these properties are documented in the integration's configuration guide for users.
packages/analytics-js-integrations/__tests__/integrations/Mixpanel/util.test.js (1)
  • 11-11: The import statement for generatePageOrScreenCustomEventName correctly adds the new utility function to the test file, ensuring it can be tested.

@Gauravudia Gauravudia changed the title feat: add support of custom page/screen event name in mixpanel feat: add support of custom page event name in mixpanel Feb 20, 2024
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3bf498b and ee6af0e.
Files selected for processing (3)
  • packages/analytics-js-integrations/tests/integrations/Mixpanel/util.test.js (17 hunks)
  • packages/analytics-js-integrations/src/integrations/Mixpanel/browser.js (3 hunks)
  • packages/analytics-js-integrations/src/integrations/Mixpanel/util.js (6 hunks)
Files skipped from review as they are similar to previous changes (3)
  • packages/analytics-js-integrations/tests/integrations/Mixpanel/util.test.js
  • packages/analytics-js-integrations/src/integrations/Mixpanel/browser.js
  • packages/analytics-js-integrations/src/integrations/Mixpanel/util.js

Copy link

codecov bot commented Feb 20, 2024

Codecov Report

Attention: Patch coverage is 95.83333% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 52.41%. Comparing base (3e315a6) to head (fd19b38).

Files Patch % Lines
...-integrations/src/integrations/Mixpanel/browser.js 90.90% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1622      +/-   ##
===========================================
+ Coverage    52.35%   52.41%   +0.05%     
===========================================
  Files          586      586              
  Lines        16653    16673      +20     
  Branches      3238     3236       -2     
===========================================
+ Hits          8719     8739      +20     
- Misses        6517     6523       +6     
+ Partials      1417     1411       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Feb 20, 2024

size-limit report 📦

Name Size (Base) Size (Current) Size Limit Status
Common Code - No bundling 15.81 KB 15.81 KB (0%) 16.5 KB
Remote Module Federation Mapping - CDN 330 B 330 B (0%) 512 B
Remote Module Federated Plugins - CDN 5.71 KB 5.71 KB (0%) 6 KB
Core ESM - NPM 7.64 KB 7.64 KB (0%) 8 KB
Core CJS - NPM 22.4 KB 22.4 KB (0%) 23 KB
Core - NPM 22.56 KB 22.56 KB (0%) 23 KB
Core Legacy - CDN 42.87 KB 42.87 KB (0%) 44 KB
Core - CDN 22.67 KB 22.67 KB (0%) 23 KB
Core (legacy build) - CDN - v1.1 31.52 KB 31.52 KB (0%) 32 KB
Core - NPM - v1.1 31.57 KB 31.57 KB (0%) 32 KB
Service Worker Module 22.64 KB 22.64 KB (0%) 24 KB
All Integrations (legacy build) - CDN 98.33 KB 98.47 KB (+0.15% ▲) 105 KB

ItsSudip
ItsSudip previously approved these changes Feb 22, 2024
package.json Outdated Show resolved Hide resolved
@bardisg
Copy link
Contributor

bardisg commented Feb 26, 2024

You should not need handlebars to crete event templates, nor any templating engine of that sorts.

Just write a method yourself

Copy link

sonarcloud bot commented Mar 1, 2024

@Gauravudia Gauravudia merged commit ce97106 into develop Mar 1, 2024
11 checks passed
@Gauravudia Gauravudia deleted the feat/mixpanel-userDefined-event-name branch March 1, 2024 05:38
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.

7 participants