Skip to content

Commit a249450

Browse files
committed
Add link details to commission.created webhook event
1 parent 65cde14 commit a249450

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

apps/web/lib/partners/create-partner-commission.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,14 @@ export const createPartnerCommission = async ({
274274
},
275275
include: {
276276
customer: true,
277+
link: {
278+
select: {
279+
id: true,
280+
shortLink: true,
281+
domain: true,
282+
key: true,
283+
},
284+
},
277285
},
278286
});
279287

apps/web/lib/webhook/sample-events/commission-created.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,11 @@
3535
"sales": 1,
3636
"saleAmount": 50000,
3737
"createdAt": "2025-07-16T10:48:01.739Z"
38+
},
39+
"link": {
40+
"id": "cm0lcuvtz000xcutmqw4a7wi3",
41+
"shortLink": "https://dub.sh/track-test",
42+
"domain": "dub.sh",
43+
"key": "track-test"
3844
}
3945
}

apps/web/lib/zod/schemas/commissions.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { DATE_RANGE_INTERVAL_PRESETS } from "@/lib/analytics/constants";
22
import { CommissionStatus, CommissionType } from "@dub/prisma/client";
33
import * as z from "zod/v4";
44
import { CustomerSchema } from "./customers";
5+
import { LinkSchema } from "./links";
56
import { getPaginationQuerySchema } from "./misc";
67
import { EnrolledPartnerSchema, WebhookPartnerSchema } from "./partners";
78
import { parseDateSchema } from "./utils";
@@ -44,6 +45,12 @@ export const CommissionEnrichedSchema = CommissionSchema.extend({
4445
export const CommissionWebhookSchema = CommissionSchema.extend({
4546
partner: WebhookPartnerSchema,
4647
customer: CustomerSchema.nullish(), // customer can be null for click-based / custom commissions
48+
link: LinkSchema.pick({
49+
id: true,
50+
shortLink: true,
51+
domain: true,
52+
key: true,
53+
}).nullable(),
4754
});
4855

4956
export const COMMISSIONS_MAX_PAGE_SIZE = 100;

0 commit comments

Comments
 (0)