-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add trigger enums #2661
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
Add trigger enums #2661
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
WalkthroughThe changes introduce a new Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API_Route
participant RecordClick
Note over API_Route: Hostname verification
Client->>API_Route: Track visit request
API_Route->>RecordClick: recordClick(..., trigger: "pageview")
RecordClick->>RecordClick: Determine trigger (QR or provided)
RecordClick->>RecordClick: Record click data with trigger
Suggested reviewers
Poem
π Recent review detailsConfiguration used: CodeRabbit UI π Files selected for processing (3)
β Files skipped from review due to trivial changes (1)
π§ Files skipped from review as they are similar to previous changes (2)
β° 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)
β¨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. πͺ§ TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 0
π§Ή Nitpick comments (1)
apps/web/lib/tinybird/record-click.ts (1)
55-55: Consider using a type union for better type safety.While the current
stringtype works, consider using a type union based on theTRIGGER_TYPESconstant for better type safety and IntelliSense support.+ import { TRIGGER_TYPES } from "@/lib/analytics/constants"; + + type TriggerType = typeof TRIGGER_TYPES[number]; - trigger?: string; + trigger?: TriggerType;
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (3)
apps/web/app/(ee)/api/track/visit/route.ts(1 hunks)apps/web/lib/analytics/constants.ts(1 hunks)apps/web/lib/tinybird/record-click.ts(4 hunks)
π§° Additional context used
π§ Learnings (1)
apps/web/lib/analytics/constants.ts (3)
Learnt from: devkiran
PR: dubinc/dub#2637
File: apps/web/app/(ee)/api/singular/webhook/route.ts:0-0
Timestamp: 2025-07-17T06:41:45.598Z
Learning: In the Singular integration (apps/web/app/(ee)/api/singular/webhook/route.ts), the event names in the singularToDubEvent object have intentionally different casing: "Copy GAID" and "copy IDFA". This casing difference is valid and should not be changed, as these are the correct event names expected from Singular.
Learnt from: TWilson023
PR: dubinc/dub#2519
File: apps/web/ui/analytics/utils.ts:35-37
Timestamp: 2025-06-16T19:21:23.506Z
Learning: In the `useAnalyticsFilterOption` function in `apps/web/ui/analytics/utils.ts`, the pattern `options?.context ?? useContext(AnalyticsContext)` is intentionally designed as a complete replacement strategy, not a merge. When `options.context` is provided, it should contain all required fields (`baseApiPath`, `queryString`, `selectedTab`, `requiresUpgrade`) and completely replace the React context, not be merged with it. This is used for dependency injection or testing scenarios.
Learnt from: devkiran
PR: dubinc/dub#2448
File: packages/email/src/templates/partner-program-summary.tsx:0-0
Timestamp: 2025-05-29T04:45:18.504Z
Learning: In the PartnerProgramSummary email template (packages/email/src/templates/partner-program-summary.tsx), the stat titles are hardcoded constants ("Clicks", "Leads", "Sales", "Earnings") that will always match the ICONS object keys after toLowerCase() conversion, so icon lookup failures are not possible.
β° 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: build
π Additional comments (5)
apps/web/lib/analytics/constants.ts (1)
210-216: LGTM! Well-structured trigger enum additions.The updates correctly add the new trigger types
pageviewanddeeplinkto both the display mapping and the types array. The QR label change from "QR Scan" to "QR Code Scan" improves clarity and consistency.apps/web/app/(ee)/api/track/visit/route.ts (1)
101-101: LGTM! Correct usage of the new pageview trigger.The addition of
trigger: "pageview"appropriately categorizes this click recording as a page view event, which aligns with the new trigger types defined in the constants file.apps/web/lib/tinybird/record-click.ts (3)
41-41: LGTM! Well-implemented trigger parameter.The default value of
"link"is appropriate for the majority of click events, and the optional parameter design maintains backward compatibility.Also applies to: 55-55
99-101: LGTM! Correct QR detection override logic.The conditional override to set
trigger = "qr"when QR is detected maintains the existing QR tracking behavior while allowing other trigger types to be explicitly specified.
157-157: LGTM! Trigger properly included in click data.The trigger value is correctly added to the
clickDataobject for analytics tracking.
|
@CodeRabbit final review |
|
Tip For best results, initiate chat on the files or code changes. @steven-tey Looking at this PR comprehensively, this is a well-executed feature addition! Here's my final review: β StrengthsSystematic Implementation:
Clean Data Schema:
Type Safety:
π― Implementation QualityThe changes follow a clear pattern:
π Ready for MergeThe PR successfully:
No issues found - this is ready for merge! π |
Summary by CodeRabbit
New Features
Enhancements