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.

Remove expired Shopify and sync-utm cron cutover shims (#4477)

Kiran K2226102dbacd
diff --git a/apps/web/app/(ee)/api/cron/groups/sync-utm/route.ts b/apps/web/app/(ee)/api/cron/groups/sync-utm/route.ts
deleted file mode 100644
index 3f1fb5abce..0000000000
--- a/apps/web/app/(ee)/api/cron/groups/sync-utm/route.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { withCron } from "@/lib/cron/with-cron";
-import { syncGroupUtmJob } from "@/lib/jobs/handlers/sync-group-utm-job";
-import * as z from "zod/v4";
-import { logAndRespond } from "../../utils";
-export const dynamic = "force-dynamic";
-
-const schema = z.object({
- groupId: z.string(),
- partnerIds: z.array(z.string()).optional(),
- startAfterProgramEnrollmentId: z.string().optional(),
-});
-
-// TODO:
-// Remove this route after few hours of deployment
-
-// POST /api/cron/groups/sync-utm
-export const POST = withCron(async ({ rawBody }) => {
- const { groupId, partnerIds, startAfterProgramEnrollmentId } = schema.parse(
- JSON.parse(rawBody),
- );
-
- await syncGroupUtmJob.dispatch({
- groupId,
- partnerIds,
- startAfterProgramEnrollmentId,
- });
-
- return logAndRespond("OK");
-});
diff --git a/apps/web/app/(ee)/api/cron/shopify/order-paid/route.ts b/apps/web/app/(ee)/api/cron/shopify/order-paid/route.ts
deleted file mode 100644
index 8f8c72646f..0000000000
--- a/apps/web/app/(ee)/api/cron/shopify/order-paid/route.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-import { DubApiError } from "@/lib/api/errors";
-import { withCron } from "@/lib/cron/with-cron";
-import { shopifyCheckoutCache } from "@/lib/integrations/shopify/checkout-cache";
-import { processShopifyOrderJob } from "@/lib/jobs/handlers/process-shopify-order-job";
-import * as z from "zod/v4";
-import { logAndRespond } from "../../utils";
-
-export const dynamic = "force-dynamic";
-
-const schema = z.object({
- workspaceId: z.string(),
- checkoutToken: z.string(),
-});
-
-const MAX_PIXEL_WAIT_RETRIES = 5;
-
-// POST /api/cron/shopify/order-paid
-// Cutover shim for in-flight QStash messages with the old
-// { workspaceId, checkoutToken } body. Remove after a week.
-export const POST = withCron(async ({ req, rawBody }) => {
- const { workspaceId, checkoutToken } = schema.parse(JSON.parse(rawBody));
-
- const checkout = await shopifyCheckoutCache.get(checkoutToken);
-
- if (!checkout.order) {
- return logAndRespond(
- `[Shopify] Order with checkout token ${checkoutToken} not found. Skipping...`,
- );
- }
-
- const { clickId, order } = checkout;
-
- // clickId is empty, order is not from a Dub link
- if (clickId === "") {
- await shopifyCheckoutCache.delete(checkoutToken);
- return logAndRespond(`[Shopify] Order is not from a Dub link. Skipping...`);
- }
-
- // clickId is found, process the order for the new customer
- if (clickId) {
- await processShopifyOrderJob.execute({
- workspaceId,
- clickId,
- order,
- });
-
- return logAndRespond("[Shopify] Order event processed successfully.");
- }
-
- const retried = Number(req.headers.get("Upstash-Retried") ?? "0");
-
- // Give up waiting for the pixel after a few QStash attempts (2xx stops retries)
- if (retried >= MAX_PIXEL_WAIT_RETRIES) {
- return logAndRespond(
- `[Shopify] Click event not found after ${retried} retries for checkout ${checkoutToken}. Skipping...`,
- );
- }
-
- // Wait for the click event to come from Shopify pixel
- throw new DubApiError({
- code: "bad_request",
- message:
- "[Shopify] Click event not found. Waiting for Shopify pixel event...",
- });
-});