Skip to content

Conversation

@ofek1weiss
Copy link
Contributor

@ofek1weiss ofek1weiss commented Sep 2, 2025

null

Summary by CodeRabbit

  • New Features
    • Introduced the ability to register groups (with type, identifier, and optional properties) within anonymous tracking, enabling cleaner segmentation of analytics by organization, team, or project.
    • Honors privacy preferences: when do-not-track is enabled, group registration is skipped with no side effects.
    • Backward compatible and requires no configuration changes; integrates seamlessly with existing tracking flows to enrich event context without impacting current behavior.

@linear
Copy link

linear bot commented Sep 2, 2025

@ofek1weiss ofek1weiss temporarily deployed to elementary_test_env September 2, 2025 12:55 — with GitHub Actions Inactive
@coderabbitai
Copy link

coderabbitai bot commented Sep 2, 2025

Walkthrough

Adds a new public method register_group to AnonymousTracking that no-ops when tracking is disabled and otherwise delegates to the superclass implementation. No other changes.

Changes

Cohort / File(s) Summary
Tracking: group registration delegation
elementary/tracking/anonymous_tracking.py
Introduced register_group(group_type, group_identifier, group_props=None): returns early if _do_not_track is True; otherwise calls super().register_group(...). No other code modified.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Client
    participant AT as AnonymousTracking
    participant PT as Parent Tracking (super)

    Client->>AT: register_group(type, id, props?)
    alt Tracking disabled (_do_not_track=True)
        AT-->>Client: return (no-op)
        Note right of AT: Skips any tracking calls
    else Tracking enabled
        AT->>PT: register_group(type, id, props?)
        PT-->>AT: ack
        AT-->>Client: return
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I thump my paws in tidy loops,
A group appears—then neatly swoops;
If hush is set, I softly stop,
Else up the chain I kindly hop.
Carrot logs aligned and tight—
Delegation done just right. 🥕

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch app-56-do-not-identify-group-when-tracking-is-disabled

🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 2, 2025

👋 @ofek1weiss
Thank you for raising your pull request.
Please make sure to add tests and document all user-facing changes.
You can do this by editing the docs files in this pull request.

Copy link

@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: 1

🧹 Nitpick comments (1)
elementary/tracking/anonymous_tracking.py (1)

91-97: Tiny clarity boost: document no-op behavior

Add a brief docstring noting that the method returns early when tracking is disabled.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0cd4382 and 5cde43e.

📒 Files selected for processing (1)
  • elementary/tracking/anonymous_tracking.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
elementary/tracking/anonymous_tracking.py (1)
elementary/tracking/tracking_interface.py (2)
  • register_group (33-36)
  • register_group (66-70)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: code-quality
🔇 Additional comments (1)
elementary/tracking/anonymous_tracking.py (1)

91-97: No callers depend on self.groups when tracking is disabled All register_group calls become no-ops and _send_anonymous_event early-returns, and no code reads self.groups outside of the skipped event dispatch.

Comment on lines +91 to +97
def register_group(
self, group_type: str, group_identifier: str, group_props: Optional[dict] = None
) -> None:
if self._do_not_track:
return
return super().register_group(group_type, group_identifier, group_props)

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Make register_group exception-safe; analytics must never break CLI

Mirror the defensive pattern used in _send_anonymous_event by swallowing PostHog errors. Also no need to return the super() call since return type is None.

 def register_group(
     self, group_type: str, group_identifier: str, group_props: Optional[dict] = None
 ) -> None:
     if self._do_not_track:
         return
-    return super().register_group(group_type, group_identifier, group_props)
+    try:
+        super().register_group(group_type, group_identifier, group_props)
+    except Exception:
+        logger.debug("Unable to register tracking group.", exc_info=True)
📝 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
def register_group(
self, group_type: str, group_identifier: str, group_props: Optional[dict] = None
) -> None:
if self._do_not_track:
return
return super().register_group(group_type, group_identifier, group_props)
def register_group(
self, group_type: str, group_identifier: str, group_props: Optional[dict] = None
) -> None:
if self._do_not_track:
return
try:
super().register_group(group_type, group_identifier, group_props)
except Exception:
logger.debug("Unable to register tracking group.", exc_info=True)
🤖 Prompt for AI Agents
In elementary/tracking/anonymous_tracking.py around lines 91 to 97, change
register_group so it does not return the super call and is exception-safe: if
self._do_not_track return early, otherwise call super().register_group(...)
inside a try/except block that catches PostHog/network/other exceptions and
swallows them (optionally logging at debug level) so analytics errors cannot
raise out of the CLI.

@ofek1weiss ofek1weiss merged commit fd4bfd8 into master Sep 2, 2025
6 checks passed
@ofek1weiss ofek1weiss deleted the app-56-do-not-identify-group-when-tracking-is-disabled branch September 2, 2025 14:22
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.

3 participants