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.

Return 200 on Shopify pixel errors and update tests for skip behavior

Kiran K91ffbaa76357
diff --git a/apps/web/app/(ee)/api/shopify/pixel/route.ts b/apps/web/app/(ee)/api/shopify/pixel/route.ts
index f36525071c..8ee49fb18d 100644
--- a/apps/web/app/(ee)/api/shopify/pixel/route.ts
+++ b/apps/web/app/(ee)/api/shopify/pixel/route.ts
@@ -1,5 +1,4 @@
import { COMMON_CORS_HEADERS } from "@/lib/api/cors";
-import { handleAndReturnErrorResponse } from "@/lib/api/errors";
import { parseRequestBody } from "@/lib/api/utils";
import {
shopifyCheckoutCache,
@@ -20,6 +19,10 @@ const inputSchema = z.object({
// POST /api/shopify/pixel – Handle the Shopify Pixel events
export const POST = async (req: Request) => {
+ const response = NextResponse.json("OK", {
+ headers: COMMON_CORS_HEADERS,
+ });
+
try {
const { clickId, checkoutToken, shopDomain } = inputSchema.parse(
await parseRequestBody(req),
@@ -31,10 +34,6 @@ export const POST = async (req: Request) => {
shopDomain,
});
- const response = NextResponse.json("OK", {
- headers: COMMON_CORS_HEADERS,
- });
-
if (!checkoutToken) {
console.error("Missing checkoutToken. Skipping the request...");
return response;
@@ -77,7 +76,8 @@ export const POST = async (req: Request) => {
return response;
} catch (error) {
- return handleAndReturnErrorResponse(error, COMMON_CORS_HEADERS);
+ console.error("Error processing Shopify pixel event", error);
+ return response;
}
};
diff --git a/apps/web/playwright/api/shopify/orders.spec.ts b/apps/web/playwright/api/shopify/orders.spec.ts
index 1379c64a33..fa777eae80 100644
--- a/apps/web/playwright/api/shopify/orders.spec.ts
+++ b/apps/web/playwright/api/shopify/orders.spec.ts
@@ -1,6 +1,6 @@
import { nanoid } from "@dub/utils";
import { expect } from "@playwright/test";
-import { apiError, randomName } from "../../utils";
+import { randomName } from "../../utils";
import { trackClick, trackLead } from "../conversions/helpers";
import { test } from "../fixtures";
import { createPartner, deletePartner } from "../partners/helpers";
@@ -12,13 +12,10 @@ import {
postShopifyPixel,
} from "./helpers";
-test("POST /shopify/pixel – missing checkoutToken", async ({ api }) => {
- expect(await api.post("/api/shopify/pixel", { clickId: nanoid(16) })).toEqual(
- apiError({
- code: "bad_request",
- message: "checkoutToken is required.",
- }),
- );
+test("POST /shopify/pixel – skips when checkoutToken is missing", async () => {
+ const pixel = await postShopifyPixel({ clickId: nanoid(16) });
+
+ expect(pixel).toEqual({ status: 200, data: "OK" });
});
test("POST /shopify/integration/webhook – unknown shop", async () => {
@@ -124,7 +121,7 @@ test.describe("Shopify orders/paid", () => {
);
});
- test("webhook with unknown dubClickId waits for pixel", async () => {
+ test("webhook with unknown dubClickId skips the order", async () => {
const checkoutToken = nanoid(10);
const webhook = await postShopifyOrdersPaidWebhook({
@@ -134,7 +131,7 @@ test.describe("Shopify orders/paid", () => {
expect(webhook.status).toEqual(200);
expect(webhook.data).toEqual(
- "[Shopify] Waiting for pixel event to arrive...",
+ "[Shopify] Click event not found. Skipping the order...",
);
});