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

disable analytics.page() when url tracking disabled #4801

Merged
merged 1 commit into from
Sep 24, 2024
Merged

Conversation

ritch
Copy link
Contributor

@ritch ritch commented Sep 16, 2024

What changes are proposed in this pull request?

Disables the segment.page() call when disableUrlTracking is true.

How is this patch tested? If it is not, please explain why.

Added an automated test.

Summary by CodeRabbit

  • New Features
    • Enhanced page tracking functionality with improved control over URL tracking based on user settings.
  • Bug Fixes
    • Added tests to ensure correct behavior of the page tracking method under various conditions.
  • Documentation
    • Updated logic in the Analytics class to clarify the conditions under which URL tracking is disabled.

Copy link
Contributor

coderabbitai bot commented Sep 16, 2024

Walkthrough

The changes introduce a new test suite for the analytics.page() method within the Analytics class, adding tests to verify its functionality. A condition is added to the page method to check for the _disableUrlTracking property, preventing page URL tracking when this option is enabled. Additionally, a logging line in the test has been removed for cleaner output.

Changes

Files Change Summary
app/packages/analytics/src/analytics.test.ts Added a test suite for analytics.page(), including tests for tracking functionality and the disableUrlTracking option. Removed a logging line for mock calls.
app/packages/analytics/src/usingAnalytics.ts Modified the page method in the Analytics class to include a check for _disableUrlTracking, enhancing control over URL tracking behavior.

Possibly related PRs

  • add product analytics rate limiting #4784: This PR enhances the Analytics class by adding the ability to disable URL tracking, which directly relates to the changes in the main PR that also involve testing the disableUrlTracking feature in the analytics.page() method.
  • Product analtyics improvements #4794: This PR introduces the disableUrlTracking parameter in the AnalyticsInfo type and modifies the Analytics class to manage this functionality, aligning with the main PR's focus on testing the behavior of the analytics.page() method when URL tracking is disabled.

Suggested reviewers

  • benjaminpkane
  • kaixi-wang

🐇 In the meadow, the analytics hop,
With tests that ensure they never stop.
Page tracking now can be turned away,
A toggle for bunnies to play all day!
Clean outputs make the logs a delight,
Hooray for changes that feel just right! 🌼


Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f7d7a10 and 5209940.

Files selected for processing (2)
  • app/packages/analytics/src/analytics.test.ts (1 hunks)
  • app/packages/analytics/src/usingAnalytics.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • app/packages/analytics/src/analytics.test.ts
  • app/packages/analytics/src/usingAnalytics.ts

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

Copy link
Contributor

@imanjra imanjra left a comment

Choose a reason for hiding this comment

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

LGTM

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 (2)
app/packages/analytics/src/usingAnalytics.ts (1)

96-96: LGTM: Effective implementation of URL tracking disable

The update to the page method successfully implements the PR objective by preventing the segment.page() call when URL tracking is disabled. The condition is well-placed alongside the existing check.

For improved readability, consider using parentheses to group the conditions:

if (!this._segment || this._disableUrlTracking) return;

This change would make the condition more explicit and easier to understand at a glance.

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

210-233: LGTM! Consider adding an assertion for the page name.

The new test suite for analytics.page() is well-structured and covers both the default behavior and the case when URL tracking is disabled. Good job on improving the test coverage!

Consider adding an assertion in the first test case to verify that mockSegment.page is called with the correct page name:

expect(mockSegment.page).toHaveBeenCalledWith("my_page");

This would ensure that the page name is correctly passed to the underlying segment library.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 12dac08 and 493d6a9.

Files selected for processing (2)
  • app/packages/analytics/src/analytics.test.ts (1 hunks)
  • app/packages/analytics/src/usingAnalytics.ts (2 hunks)
Additional context used
Path-based instructions (2)
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.

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.

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

35-35: LGTM: New property for disabling URL tracking

The addition of the _disableUrlTracking property with a default value of false and a clear comment explaining its purpose is a good implementation. It aligns well with the PR objective and provides a way to control URL tracking behavior.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@ritch ritch merged commit e94cde0 into develop Sep 24, 2024
11 checks passed
@ritch ritch deleted the fix/pa-page-track branch September 24, 2024 23:25
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.

None yet

2 participants