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.

Fix track sales endpoint + test

Steven Tey1829c505970c
diff --git a/apps/web/app/api/track/sale/route.ts b/apps/web/app/api/track/sale/route.ts
index 91c7654031..a7fd6a9d19 100644
--- a/apps/web/app/api/track/sale/route.ts
+++ b/apps/web/app/api/track/sale/route.ts
@@ -185,7 +185,6 @@ export const POST = withWorkspaceEdge(
return NextResponse.json({
...sale,
// for backwards compatibility – will remove soon
- customerId: customerExternalId,
amount,
currency,
invoiceId,
diff --git a/apps/web/tests/tracks/track-sale.test.ts b/apps/web/tests/tracks/track-sale.test.ts
index df12366d57..b312f54407 100644
--- a/apps/web/tests/tracks/track-sale.test.ts
+++ b/apps/web/tests/tracks/track-sale.test.ts
@@ -1,6 +1,9 @@
import { TrackSaleResponse } from "@/lib/types";
import { randomId } from "tests/utils/helpers";
-import { E2E_CUSTOMER_ID } from "tests/utils/resource";
+import {
+ E2E_CUSTOMER_EXTERNAL_ID,
+ E2E_CUSTOMER_ID,
+} from "tests/utils/resource";
import { expect, test } from "vitest";
import { IntegrationHarness } from "../utils/integration";
@@ -20,14 +23,20 @@ test("POST /track/sale", async () => {
path: "/track/sale",
body: {
...sale,
- customerId: E2E_CUSTOMER_ID,
+ externalId: E2E_CUSTOMER_EXTERNAL_ID,
},
});
expect(response.status).toEqual(200);
expect(response.data).toStrictEqual({
eventName: "Subscription",
- customer: expect.any(Object),
+ customer: {
+ id: E2E_CUSTOMER_ID,
+ name: expect.any(String),
+ email: expect.any(String),
+ avatar: expect.any(String),
+ externalId: E2E_CUSTOMER_EXTERNAL_ID,
+ },
sale: {
amount: 100,
currency: sale.currency,
@@ -35,7 +44,6 @@ test("POST /track/sale", async () => {
invoiceId: sale.invoiceId,
metadata: null,
},
- customerId: E2E_CUSTOMER_ID,
amount: sale.amount,
currency: sale.currency,
paymentProcessor: sale.paymentProcessor,
diff --git a/apps/web/tests/utils/resource.ts b/apps/web/tests/utils/resource.ts
index 34e484ba12..3efbf00112 100644
--- a/apps/web/tests/utils/resource.ts
+++ b/apps/web/tests/utils/resource.ts
@@ -4,5 +4,6 @@ export const E2E_LINK = {
};
export const E2E_CLICK_ID = "GWGrkftJdYlZD2mq";
-export const E2E_CUSTOMER_ID = "cus_jTrfVKYN3Buc3F80JoqBiY0g";
+export const E2E_CUSTOMER_ID = "cm25onzuv0001s1bbxchrc0ae";
+export const E2E_CUSTOMER_EXTERNAL_ID = "cus_jTrfVKYN3Buc3F80JoqBiY0g";
export const E2E_WEBHOOK_ID = "wh_1C78FQhIDgpPYpZmyFolg4qJg";