-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add workspace_id, domain, and key to dub_clicks_metadata #2996
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded@steven-tey has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 53 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughAdds Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
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. 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: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/scripts/seed-data.ts (1)
88-125: Missing workspace_id, domain, and key fields in seedClicks function.The
seedClicksfunction generates click events fordub_click_eventsbut doesn't include the newly requiredworkspace_id,domain, andkeyfields. This will cause validation failures since theclickEventSchemaTBschema now requires these fields.Add the missing fields to the click event data:
return { timestamp: new Date( Date.now() - Math.floor(Math.random() * 30 * 24 * 60 * 60 * 1000), ).toISOString(), click_id: nanoid(16), + workspace_id: "ws_cl7pj5kq4006835rbjlt2ofka", link_id: link.id, + domain: link.domain, + key: link.shortLink.split("/")[1], url: link.url, country,
🧹 Nitpick comments (2)
apps/web/lib/zod/schemas/clicks.ts (1)
38-58: Consider adding workspace_id, domain, and key to clickEventSchemaTBEndpoint.The
clickEventSchemaTBEndpointschema (used for the endpoint response) doesn't include the newly addedworkspace_id,domain, andkeyfields, whileclickEventSchemaTBdoes. This inconsistency may cause issues if the endpoint schema is used to validate or transform click events.If these fields should be exposed in endpoint responses, update the schema:
export const clickEventSchemaTBEndpoint = z.object({ event: z.literal("click"), timestamp: z.string(), click_id: z.string(), + workspace_id: z.string(), link_id: z.string(), + domain: z.string(), + key: z.string(), url: z.string(),apps/web/lib/tinybird/record-click.ts (1)
140-143: Consider requiring workspaceId for data quality.The code falls back to an empty string when
workspaceIdis not provided (workspaceId || ""). This could lead to click events being stored without workspace context, potentially complicating analytics and billing calculations.Consider one of these approaches:
- Make workspaceId required if workspace context is critical:
- workspaceId?: string; + workspaceId: string;
- Add validation to warn about missing workspaceId:
const clickData = { timestamp: timestamp || new Date(Date.now()).toISOString(), identity_hash: identityHash, click_id: clickId, - workspace_id: workspaceId || "", + workspace_id: workspaceId || "", link_id: linkId, domain, key,+ if (!workspaceId) { + console.warn(`[Record click] Click recorded without workspace context: ${linkId}`); + }
- Document when it's acceptable to record clicks without workspaceId.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (17)
apps/web/app/(ee)/api/cron/framer/backfill-leads-batch/route.ts(1 hunks)apps/web/app/(ee)/api/track/click/route.ts(1 hunks)apps/web/app/(ee)/api/track/open/route.ts(1 hunks)apps/web/app/(ee)/api/track/visit/route.ts(1 hunks)apps/web/lib/firstpromoter/import-customers.ts(1 hunks)apps/web/lib/middleware/link.ts(7 hunks)apps/web/lib/partnerstack/import-customers.ts(1 hunks)apps/web/lib/rewardful/import-customers.ts(1 hunks)apps/web/lib/tinybird/record-click-zod.ts(1 hunks)apps/web/lib/tinybird/record-click.ts(3 hunks)apps/web/lib/tinybird/record-fake-click.ts(1 hunks)apps/web/lib/tolt/import-customers.ts(1 hunks)apps/web/lib/zod/schemas/clicks.ts(1 hunks)apps/web/scripts/fillout/backfill-customer-leads.ts(1 hunks)apps/web/scripts/framer/3-backfill-tb-events.ts(1 hunks)apps/web/scripts/perplexity/backfill-leads.ts(1 hunks)apps/web/scripts/seed-data.ts(1 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). (1)
- GitHub Check: build
🔇 Additional comments (22)
apps/web/lib/tolt/import-customers.ts (1)
203-213: LGTM! Click metadata enrichment is correctly implemented.The
recordClickinvocation now properly includesworkspaceId,domain, andkeyfields, aligning with the PR objective to enrich click event tracking. All data sources are validated earlier in the function flow, and the parameter ordering is consistent with the updated signature.apps/web/lib/firstpromoter/import-customers.ts (1)
225-235: LGTM! Workspace context properly added to click tracking.The addition of
workspaceId: workspace.idenriches the click event with workspace context, which aligns with the PR objective. The workspace is guaranteed to be non-null due to thefindUniqueOrThrowcall on line 17.apps/web/app/(ee)/api/track/open/route.ts (1)
110-124: LGTM! WorkspaceId parameter correctly positioned.The reordering of the
workspaceIdparameter is consistent with the broader payload standardization across the codebase. The null check on lines 101-106 ensurescachedLink.projectIdis valid before being used.apps/web/scripts/fillout/backfill-customer-leads.ts (1)
76-110: LGTM! Click event payload correctly enriched with workspace context.The addition of
workspace_id,domain, andkeyfields enriches the backfill click events with proper workspace and link context. All data sources are guaranteed to be valid:
workspace.idfromfindUniqueOrThrowon line 41link.domainandlink.keyfrom filtered partner linksapps/web/app/(ee)/api/track/click/route.ts (1)
132-146: LGTM! WorkspaceId parameter correctly positioned.The reordering of the
workspaceIdparameter improves consistency across the codebase. The null check on lines 88-93 ensurescachedLink.projectIdis valid before therecordClickcall.apps/web/lib/middleware/link.ts (8)
154-154: Good extraction of workspaceId for reuse across all click paths.Extracting
workspaceIdfromcachedLink.projectIdat line 154 enables consistent workspace context tracking across all redirect paths (root domain, custom URI, cloaking, iOS/Android redirects, geo-targeting, and regular redirects).
272-285: LGTM! Root domain click tracking includes workspace context.
324-338: LGTM! Custom URI scheme click tracking includes workspace context.
364-378: LGTM! Cloaking/rewrite click tracking includes workspace context.
406-420: LGTM! iOS redirect click tracking includes workspace context.
477-491: LGTM! Android redirect click tracking includes workspace context.
513-527: LGTM! Geo-targeting click tracking includes workspace context.
549-563: LGTM! Regular redirect click tracking includes workspace context.apps/web/scripts/perplexity/backfill-leads.ts (1)
131-165: LGTM! Backfill click data properly enriched with workspace context.The addition of
workspace_id,domain, andkeyfields ensures historical click data has consistent metadata with current tracking. All data sources are guaranteed to be valid:
workspace.idfromfindUniqueOrThrowon line 46link.domainandlink.keyfrom the filtered partner linksapps/web/lib/rewardful/import-customers.ts (1)
190-200: LGTM! Workspace context properly added to Rewardful click tracking.The addition of
workspaceId: workspace.idenriches the Rewardful import click events with workspace context. The workspace is guaranteed to be non-null due to thefindUniqueOrThrowcall on line 18.apps/web/app/(ee)/api/track/visit/route.ts (1)
86-99: Null safety for workspaceId is properly handled — no changes required.The verification confirms that
workspaceIdis optional in therecordClickfunction signature (workspaceId?: string), and theprojectIdfield inRedisLinkPropsis also optional (projectId?: string). Downstream handling inrecordClickconverts undefined values to an empty string (workspace_id: workspaceId || ""at line 140), and any conditional operations that depend on a non-empty workspace ID are properly guarded with null/undefined checks (e.g.,workspaceId && url &&at line 206, andif (workspaceId && hasWebhooks)at line 282). The code change is safe and correct as written.apps/web/scripts/framer/3-backfill-tb-events.ts (1)
159-162: LGTM!The addition of
workspace_id,domain, andkeyfields to the click data payload aligns correctly with the updated Tinybird schema. All values are properly sourced from the workspace and link objects.apps/web/lib/partnerstack/import-customers.ts (1)
230-240: LGTM!The
recordClickcall now correctly includesworkspaceIdfromworkspace.id, and the field ordering aligns with the updated function signature.apps/web/app/(ee)/api/cron/framer/backfill-leads-batch/route.ts (1)
215-218: LGTM!The backfill logic correctly adds
workspace_id,domain, andkeyto the click data payload, ensuring compliance with the updated Tinybird schema.apps/web/scripts/seed-data.ts (1)
161-164: LGTM!The
seedLeadsfunction correctly includesworkspace_id,domain, andkeyfields in the lead event payload.apps/web/lib/tinybird/record-click.ts (1)
36-36: LGTM! workspaceId is now optional in the function signature.The parameter change from
workspaceId: string | undefinedtoworkspaceId?: stringimproves the API ergonomics while maintaining backward compatibility.Also applies to: 53-53
apps/web/lib/zod/schemas/clicks.ts (1)
8-11: No validation issues found — allrecordClickinvocations provide the required fields.All 16
recordClickcalls across the codebase include the four required fields:workspaceId,linkId,domain, andkey. No code paths are missing these fields, so validation failures from incomplete data are not a concern.
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
Summary by CodeRabbit