-
Notifications
You must be signed in to change notification settings - Fork 434
feat: add local logging for analytics events #8718
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
base: x
Are you sure you want to change the base?
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
WalkthroughAnalytics event tracking now logs events locally before dispatching. A try-catch block constructs and logs each event with its name and properties, swallowing any logging failures silently. This adds observability without altering the primary event flow. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Analytics
participant Logger
participant PostMessage/HTTP
Client->>Analytics: trackEvent(eventName, eventProps)
rect rgb(230, 245, 230)
Note over Analytics,Logger: New logging phase
Analytics->>Logger: Attempt to log event locally
alt Logging succeeds
Logger-->>Analytics: ✓ logged
else Logging fails
Logger-->>Analytics: ⚠ error (suppressed)
end
end
rect rgb(230, 240, 250)
Note over Analytics,PostMessage/HTTP: Existing dispatch (unchanged)
Analytics->>PostMessage/HTTP: postMessage or HTTP request
PostMessage/HTTP-->>Analytics: ✓ sent
end
Analytics-->>Client: ✓ done
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes The change adds straightforward logging as a non-breaking side effect. Reviewers should verify that the new import resolves correctly, error handling is appropriate, and logging doesn't impact performance. Single-file change with predictable patterns. Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
packages/shared/src/analytics/index.ts
(2 hunks)
⏰ 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). (3)
- GitHub Check: unittest (20.x)
- GitHub Check: lint (20.x)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
packages/shared/src/analytics/index.ts (1)
9-9
: Import resolves correctly. Dependency verified.The
../logger/utils
module exists and properly exportsconsoleFunc
. The import statement at line 9 is valid and follows the established pattern used elsewhere in the codebase.
const logMessage = `Event: ${eventName}${ | ||
eventProps ? ` | Props: ${JSON.stringify(eventProps)}` : '' | ||
}`; | ||
utils.consoleFunc(logMessage); |
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.
跟 @LogToLocal 装饰器的作用冲突了,是会记录重复日志吧
Summary by CodeRabbit