Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Improve error logging for rejected promises in recordClick

Steven Tey4cf299bee421
diff --git a/apps/web/lib/tinybird/record-click.ts b/apps/web/lib/tinybird/record-click.ts
index 2e124f262d..8255326c69 100644
--- a/apps/web/lib/tinybird/record-click.ts
+++ b/apps/web/lib/tinybird/record-click.ts
@@ -200,8 +200,35 @@ export async function recordClick({
// Find the rejected promises and log them
if (response.some((result) => result.status === "rejected")) {
- const errors = response.filter((result) => result.status === "rejected");
- console.error("[Record click] - Rejected promises", errors);
+ const errors = response
+ .map((result, index) => {
+ if (result.status === "rejected") {
+ const operations = [
+ "Tinybird click event ingestion",
+ "Redis click cache set",
+ "Redis click ID cache set",
+ "Link clicks increment",
+ "Workspace usage increment",
+ "Workspace usage fetch",
+ ];
+ return {
+ operation: operations[index] || `Operation ${index}`,
+ error: result.reason,
+ errorString: JSON.stringify(result.reason, null, 2),
+ };
+ }
+ return null;
+ })
+ .filter((err): err is NonNullable<typeof err> => err !== null);
+
+ console.error("[Record click] - Rejected promises:", {
+ totalErrors: errors.length,
+ errors: errors.map((err) => ({
+ operation: err.operation,
+ error: err.error,
+ errorString: err.errorString,
+ })),
+ });
}
const [, , , , workspaceRows] = response;