-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Rename tbNew → tbOld #2954
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: main
Are you sure you want to change the base?
Rename tbNew → tbOld #2954
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThis change reverts Tinybird ingestion usage from the “new” client/key to the “old” client/key across multiple endpoints and helpers. It renames exports to TBOld variants, updates imports, and switches authorization tokens. Control flow and payloads remain the same, with one header change in record-click and one POST in a cron route. Changes
Sequence Diagram(s)Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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/lib/tinybird/record-sale.ts (1)
29-34
: Rename export to reflect the tbOld usage.Similar to
recordSaleNewTB
, this export namerecordSaleWithTimestampNewTB
still contains "New" but usestbOld
. Rename it torecordSaleWithTimestampOldTB
for consistency.Apply this diff to rename the export consistently:
-export const recordSaleWithTimestampNewTB = tbOld.buildIngestEndpoint({ +export const recordSaleWithTimestampOldTB = tbOld.buildIngestEndpoint({ datasource: "dub_sale_events", event: saleEventSchemaTB.extend({ timestamp: z.string(), }), });Then update the usage on line 37:
export const recordSaleWithTimestamp = async (payload: any) => { - waitUntil(recordSaleWithTimestampNewTB(payload)); + waitUntil(recordSaleWithTimestampOldTB(payload)); return await recordSaleWithTimestampTB(payload); };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
apps/web/app/(ee)/api/cron/framer/backfill-leads-batch/route.ts
(1 hunks)apps/web/lib/api/audit-logs/record-audit-log.ts
(3 hunks)apps/web/lib/tinybird/client.ts
(1 hunks)apps/web/lib/tinybird/log-conversion-events.ts
(2 hunks)apps/web/lib/tinybird/log-import-error.ts
(1 hunks)apps/web/lib/tinybird/record-click-zod.ts
(2 hunks)apps/web/lib/tinybird/record-click.ts
(1 hunks)apps/web/lib/tinybird/record-lead.ts
(2 hunks)apps/web/lib/tinybird/record-link.ts
(3 hunks)apps/web/lib/tinybird/record-sale.ts
(2 hunks)apps/web/lib/tinybird/record-webhook-event.ts
(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-02T22:46:22.739Z
Learnt from: steven-tey
PR: dubinc/dub#2924
File: apps/web/lib/api/conversions/track-lead.ts:7-7
Timestamp: 2025-10-02T22:46:22.739Z
Learning: In apps/web/lib/api/conversions/track-lead.ts, lead events are cached in Redis for 5 minutes (keys: `leadCache:${customer.id}` and `leadCache:${customer.id}:${stringifiedEventName}`) to provide immediate data availability while Tinybird ingestion happens asynchronously. This caching pattern allows for async-only recording without breaking "wait" mode semantics.
Applied to files:
apps/web/lib/tinybird/record-lead.ts
🧬 Code graph analysis (8)
apps/web/lib/api/audit-logs/record-audit-log.ts (1)
apps/web/lib/tinybird/client.ts (1)
tbOld
(9-12)
apps/web/lib/tinybird/log-import-error.ts (2)
apps/web/lib/tinybird/client.ts (2)
tb
(3-6)tbOld
(9-12)apps/web/lib/zod/schemas/import-error-log.ts (1)
importErrorLogSchema
(3-23)
apps/web/lib/tinybird/record-lead.ts (2)
apps/web/lib/tinybird/client.ts (2)
tb
(3-6)tbOld
(9-12)apps/web/lib/zod/schemas/leads.ts (1)
leadEventSchemaTB
(98-107)
apps/web/lib/tinybird/record-click-zod.ts (1)
apps/web/lib/tinybird/client.ts (1)
tbOld
(9-12)
apps/web/lib/tinybird/record-webhook-event.ts (2)
apps/web/lib/tinybird/client.ts (2)
tb
(3-6)tbOld
(9-12)apps/web/lib/zod/schemas/webhooks.ts (1)
webhookEventSchemaTB
(37-50)
apps/web/lib/tinybird/record-sale.ts (2)
apps/web/lib/tinybird/client.ts (2)
tb
(3-6)tbOld
(9-12)apps/web/lib/zod/schemas/sales.ts (1)
saleEventSchemaTB
(120-137)
apps/web/lib/tinybird/log-conversion-events.ts (1)
apps/web/lib/tinybird/client.ts (1)
tbOld
(9-12)
apps/web/lib/tinybird/record-link.ts (1)
apps/web/lib/tinybird/client.ts (1)
tbOld
(9-12)
⏰ 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 (14)
apps/web/lib/api/audit-logs/record-audit-log.ts (1)
2-2
: LGTM! Consistent migration to tbOld.The changes correctly update the import and rename the endpoint from
recordAuditLogTBNew
torecordAuditLogTBOld
. The dual ingestion pattern is preserved withtbOld
inwaitUntil
and the primarytb
ingest remaining unchanged.Also applies to: 59-59, 83-87
apps/web/app/(ee)/api/cron/framer/backfill-leads-batch/route.ts (1)
304-314
: LGTM! Consistent dual ingestion pattern.The second fetch now correctly uses
TINYBIRD_API_KEY_OLD
for authorization, maintaining the dual ingestion pattern during the Tinybird migration. Both requests send identical click data to ensure data consistency across both Tinybird instances.apps/web/lib/tinybird/client.ts (1)
9-10
: LGTM! Core client renamed from tbNew to tbOld.The export name and token source have been updated consistently. This is a breaking change for any modules importing
tbNew
, but all affected files in this PR have been updated accordingly.apps/web/lib/tinybird/record-webhook-event.ts (1)
3-3
: LGTM! Consistent endpoint migration.The import, endpoint definition, and
waitUntil
call have been updated consistently to usetbOld
. The publicrecordWebhookEvent
function maintains its interface while implementing the dual ingestion pattern.Also applies to: 11-14, 17-17
apps/web/lib/tinybird/record-link.ts (1)
6-6
: LGTM! Complete migration for both payload paths.All changes consistently use
tbOld
:
- Import updated (line 6)
- Endpoint definition renamed (lines 54-58)
- Both single and array payload paths in
recordLink
updated (lines 87, 95)The dual ingestion pattern is correctly implemented for both code paths.
Also applies to: 54-58, 86-96
apps/web/lib/tinybird/record-lead.ts (1)
4-4
: LGTM! Both lead recording endpoints migrated.The migration correctly covers both variants:
recordLead
→recordLeadTBOld
(lines 12-15, 18)recordLeadWithTimestamp
→recordLeadWithTimestampTBOld
(lines 29-34, 37)All
waitUntil
calls updated and public APIs preserved.Also applies to: 12-15, 18-18, 29-34, 37-37
apps/web/lib/tinybird/log-import-error.ts (1)
3-3
: LGTM! Final migration file completed consistently.The import error logging follows the same migration pattern as all other Tinybird integrations:
- Import updated (line 3)
- Endpoint renamed to
logImportErrorTBOld
(lines 11-14)waitUntil
call updated (line 17)This completes the consistent migration across all Tinybird modules in the PR.
Also applies to: 11-14, 17-17
apps/web/lib/tinybird/record-click-zod.ts (3)
3-3
: LGTM! Import updated correctly.The import now includes
tbOld
to support the migration from the "new" to "old" Tinybird client.
51-51
: LGTM! waitUntil call updated correctly.The
waitUntil
call now usesrecordClickZodTBOld
which is consistent with the export rename.
44-48
: No remaining references to the old export. All imports have been updated to recordClickZodTBOld.apps/web/lib/tinybird/record-sale.ts (1)
4-4
: LGTM! Import updated correctly.The import now uses
tbOld
instead oftbNew
to align with the migration.apps/web/lib/tinybird/log-conversion-events.ts (3)
3-3
: LGTM! Import updated correctly.The import now includes
tbOld
to support the migration from the "new" to "old" Tinybird client.
26-26
: LGTM! waitUntil call updated correctly.The
waitUntil
call now useslogConversionEventTBOld
which is consistent with the export rename.
20-23
: No remaining imports of the old export. The rename is confined to this file; no further updates required.
method: "POST", | ||
headers: { | ||
Authorization: `Bearer ${process.env.TINYBIRD_API_KEY_NEW}`, | ||
Authorization: `Bearer ${process.env.TINYBIRD_API_KEY_OLD}`, |
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 | 🟠 Major
🧩 Analysis chain
Verify that TINYBIRD_API_KEY_OLD is set in the environment.
The authorization header now uses TINYBIRD_API_KEY_OLD
. Ensure this environment variable is properly configured in all deployment environments (development, staging, production) to prevent ingestion failures.
Run the following script to check if the environment variable is referenced and documented:
🏁 Script executed:
#!/bin/bash
# Search for TINYBIRD_API_KEY_OLD usage and configuration
rg -n 'TINYBIRD_API_KEY_OLD' -g '!node_modules' -C2
Length of output: 1284
🏁 Script executed:
#!/bin/bash
# Search for TINYBIRD_API_KEY_OLD in environment examples and documentation
rg -n 'TINYBIRD_API_KEY_OLD' -g '.env*' -g '*.md'
Length of output: 0
Add TINYBIRD_API_KEY_OLD to environment documentation
TINYBIRD_API_KEY_OLD is referenced in
- apps/web/lib/tinybird/record-click.ts (line 216)
- apps/web/app/(ee)/api/cron/framer/backfill-leads-batch/route.ts (line 309)
- apps/web/lib/tinybird/client.ts (line 10)
but isn’t listed in .env.example or any README. Document this variable and ensure it’s configured in all deployment environments.
export const recordSaleNewTB = tbOld.buildIngestEndpoint({ | ||
datasource: "dub_sale_events", | ||
event: saleEventSchemaTB, | ||
}); |
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.
Rename export to reflect the tbOld usage.
The export name recordSaleNewTB
still contains "New" but now uses tbOld
. This is inconsistent with other files in this PR where exports were renamed from *TBNew
to *TBOld
(e.g., recordClickZodTBNew
→ recordClickZodTBOld
, logConversionEventTBNew
→ logConversionEventTBOld
). The name should reflect that it uses the "old" client.
Apply this diff to rename the export consistently:
-export const recordSaleNewTB = tbOld.buildIngestEndpoint({
+export const recordSaleOldTB = tbOld.buildIngestEndpoint({
datasource: "dub_sale_events",
event: saleEventSchemaTB,
});
Then update the usage on line 18:
export const recordSale = async (payload: any) => {
- waitUntil(recordSaleNewTB(payload));
+ waitUntil(recordSaleOldTB(payload));
return await recordSaleTB(payload);
};
📝 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.
export const recordSaleNewTB = tbOld.buildIngestEndpoint({ | |
datasource: "dub_sale_events", | |
event: saleEventSchemaTB, | |
}); | |
export const recordSaleOldTB = tbOld.buildIngestEndpoint({ | |
datasource: "dub_sale_events", | |
event: saleEventSchemaTB, | |
}); | |
export const recordSale = async (payload: any) => { | |
waitUntil(recordSaleOldTB(payload)); | |
return await recordSaleTB(payload); | |
}; |
🤖 Prompt for AI Agents
In apps/web/lib/tinybird/record-sale.ts around lines 12 to 15, the exported name
recordSaleNewTB is inconsistent because this module uses tbOld; rename the
export to recordSaleTBOld and update any references (specifically the usage on
line 18) to the new name to match the TBOld naming convention used elsewhere in
this PR.
Summary by CodeRabbit
No user-facing changes; functionality and behavior remain the same.