-
Notifications
You must be signed in to change notification settings - Fork 204
disable group registration when tracking is disabled #2001
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 group registration when tracking is disabled #2001
Conversation
WalkthroughAdds 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
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
👋 @ofek1weiss |
There was a problem hiding this 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 behaviorAdd 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.
📒 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 onself.groupswhen tracking is disabled Allregister_groupcalls become no-ops and_send_anonymous_eventearly-returns, and no code readsself.groupsoutside of the skipped event dispatch.
| 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) | ||
|
|
There was a problem hiding this comment.
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.
| 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.
null
Summary by CodeRabbit