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

Product analtyics improvements #4794

Merged
merged 2 commits into from
Sep 12, 2024
Merged

Product analtyics improvements #4794

merged 2 commits into from
Sep 12, 2024

Conversation

ritch
Copy link
Contributor

@ritch ritch commented Sep 12, 2024

Adds the ability to disable url tracking and redact given event properties.

Summary by CodeRabbit

  • New Features

    • Introduced options to disable URL tracking and redact sensitive properties in analytics data.
    • Enhanced the Analytics class with new methods for improved data privacy and configurability.
    • Updated consent message to clarify that analytics are anonymous.
  • Bug Fixes

    • Expanded test coverage to validate new functionalities and ensure proper behavior of the Analytics class.
  • Documentation

    • Updated type definitions to reflect new configuration options for analytics tracking.

Copy link
Contributor

coderabbitai bot commented Sep 12, 2024

Walkthrough

The changes introduce enhancements to the Analytics class, focusing on improved event tracking and data privacy. Notable modifications include the removal of the eventRateLimit parameter, the addition of disableUrlTracking and redact features, and the introduction of a new redact method. These updates allow for better control over the data being tracked and the ability to obfuscate sensitive information in event payloads. The test suite has also been expanded to cover these new functionalities.

Changes

Files Change Summary
app/packages/analytics/src/analytics.test.ts Removed eventRateLimit, added disableUrlTracking and redact parameters, and introduced tests for new functionalities.
app/packages/analytics/src/usingAnalytics.ts Expanded AnalyticsInfo type, added private properties for new features, and implemented the redact method.
app/packages/app/src/components/AnalyticsConsent.tsx Modified consent message to clarify that analytics are anonymous, with no changes to functionality.

Possibly related PRs

Poem

🐰 In the meadow, changes bloom,
Analytics grows, dispelling gloom.
With redaction bright and tracking clear,
Privacy's song is what we cheer!
Hopping forth with joy anew,
Data safe, and skies so blue! 🌼


Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0d565b7 and a46ca47.

Files selected for processing (1)
  • app/packages/app/src/components/AnalyticsConsent.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/packages/app/src/components/AnalyticsConsent.tsx

Warning

Review ran into problems

Problems

Git: Failed to clone repository. Please contact CodeRabbit support.


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 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 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.

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.

 - add ability to redact custom properties
 - add ability to disable url tracking
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: 0

Outside diff range and nitpick comments (1)
app/packages/analytics/src/analytics.test.ts (1)

159-176: LGTM, but remove the console.log statement.

The test case for obfuscating URI properties of events looks good. It correctly sets up the Analytics instance with redact set to ["uri"] and verifies that the track method is called with the uri property set to "".

However, there is a console.log statement at line 170 that should be removed:

-    console.log(mockSegment.track.mock.calls[0]);
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4a41ed3 and 0d565b7.

Files selected for processing (2)
  • app/packages/analytics/src/analytics.test.ts (4 hunks)
  • app/packages/analytics/src/usingAnalytics.ts (6 hunks)
Additional context used
Path-based instructions (2)
app/packages/analytics/src/usingAnalytics.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/analytics/src/analytics.test.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

Additional comments not posted (8)
app/packages/analytics/src/usingAnalytics.ts (5)

9-10: LGTM!

The additions to the AnalyticsInfo type are correctly typed and serve to enhance the functionality of the Analytics class by allowing for more granular control over data tracking and privacy.


34-35: LGTM!

The additions of the _disableUrlTracking and _redactedProperties private properties to the Analytics class are correctly typed and initialized, and serve to manage the new functionalities introduced in the class.


43-51: LGTM!

The addition of the redact method to the Analytics class is correctly implemented and serves to handle the redaction of specified properties from the analytics data.


62-65: LGTM!

The updates to the load method are correctly implemented and serve to initialize the new _redactedProperties and _disableUrlTracking properties based on the provided configuration.


92-92: LGTM!

The updates to the page, track, identify, and group methods are correctly implemented and serve to ensure that any properties passed to these methods are processed for redaction, and that URL tracking is disabled when specified.

Also applies to: 99-99, 115-119, 128-128, 134-134

app/packages/analytics/src/analytics.test.ts (3)

80-80: LGTM!

The test case for debouncing duplicate events within the debounce interval looks good. It correctly mocks the Date.now() function to simulate time passing and verifies that the track method is called the expected number of times based on the debounce interval.


141-157: LGTM!

The test case for disabling URL tracking looks good. It correctly sets up the Analytics instance with disableUrlTracking set to true and verifies that the track method is called with context.page.url set to undefined.


178-197: LGTM!

The test case for the redact method looks good. It correctly sets up the Analytics instance with redact set to ["uri"] and verifies that the redact method behaves as expected for various input scenarios, including:

  • Objects with the specified properties (uri) are obfuscated
  • Objects without the specified properties are left intact
  • Empty objects are handled correctly
  • Undefined values are handled correctly

The test case covers all the necessary scenarios and ensures the redact method works properly.

Copy link
Contributor

@benjaminpkane benjaminpkane left a comment

Choose a reason for hiding this comment

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

LGTM

});
analytics.track("random_event", { uri: "@my_name/my_plugin/my_operator" });
// segment should be called with properties.uri = "<redacted>"
console.log(mockSegment.track.mock.calls[0]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
console.log(mockSegment.track.mock.calls[0]);

@ritch ritch merged commit bc7c482 into develop Sep 12, 2024
12 checks passed
@ritch ritch deleted the ritch/pa-ups branch September 12, 2024 21:05
@coderabbitai coderabbitai bot mentioned this pull request Oct 30, 2024
5 tasks
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