File tree 4 files changed +23
-19
lines changed
4 files changed +23
-19
lines changed Original file line number Diff line number Diff line change @@ -35,17 +35,12 @@ export const acceptProgramInviteAction = authPartnerActionClient
35
35
prisma . programInvite . delete ( {
36
36
where : { id : programInvite . id } ,
37
37
} ) ,
38
- prisma . link . update ( {
39
- where : { id : programInvite . linkId } ,
40
- data : {
41
- partnerId : partner . id ,
42
- } ,
43
- } ) ,
44
38
] ) ;
45
39
46
40
waitUntil (
47
41
backfillLinkData ( {
48
- programEnrollmentId : programEnrollment . id ,
42
+ programId : programInvite . programId ,
43
+ partnerId : partner . id ,
49
44
linkId : programInvite . linkId ,
50
45
} ) ,
51
46
) ;
Original file line number Diff line number Diff line change 1
1
import { getEvents } from "@/lib/analytics/get-events" ;
2
+ import { includeTags } from "@/lib/api/links/include-tags" ;
2
3
import { createSaleData } from "@/lib/api/sales/create-sale-data" ;
4
+ import { recordLink } from "@/lib/tinybird" ;
3
5
import { SaleEvent } from "@/lib/types" ;
4
6
import { prisma } from "@dub/prisma" ;
5
7
6
8
export const backfillLinkData = async ( {
7
- programEnrollmentId,
9
+ programId,
10
+ partnerId,
8
11
linkId,
9
12
} : {
10
- programEnrollmentId : string ;
13
+ programId : string ;
14
+ partnerId : string ;
11
15
linkId : string ;
12
16
} ) => {
13
- const link = await prisma . link . findUniqueOrThrow ( {
17
+ const link = await prisma . link . update ( {
14
18
where : {
15
19
id : linkId ,
16
20
} ,
21
+ data : {
22
+ partnerId,
23
+ } ,
24
+ include : includeTags ,
17
25
} ) ;
18
26
27
+ // update in tinybird
28
+ await recordLink ( link ) ;
29
+
19
30
if ( link . sales === 0 ) {
20
31
console . log ( `Link ${ linkId } has no sales, skipping backfill` ) ;
21
32
return ;
22
33
}
23
34
24
35
const programEnrollment = await prisma . programEnrollment . findUniqueOrThrow ( {
25
36
where : {
26
- id : programEnrollmentId ,
37
+ partnerId_programId : {
38
+ partnerId,
39
+ programId,
40
+ } ,
27
41
} ,
28
42
include : {
29
43
program : {
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { prisma } from "@dub/prisma";
7
7
import { Prisma } from "@dub/prisma/client" ;
8
8
import { waitUntil } from "@vercel/functions" ;
9
9
import { DubApiError } from "../errors" ;
10
+ import { includeTags } from "../links/include-tags" ;
10
11
11
12
export const enrollPartner = async ( {
12
13
programId,
@@ -101,13 +102,7 @@ export const enrollPartner = async ({
101
102
data : {
102
103
partnerId : upsertedPartner . id ,
103
104
} ,
104
- include : {
105
- tags : {
106
- select : {
107
- tag : true ,
108
- } ,
109
- } ,
110
- } ,
105
+ include : includeTags ,
111
106
} )
112
107
. then ( ( link ) => recordLink ( link ) ) ,
113
108
// TODO: Remove this once we open up partners.dub.co to everyone
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @dub/ui" ,
3
3
"description" : " UI components for Dub.co" ,
4
- "version" : " 0.2.20 " ,
4
+ "version" : " 0.2.21 " ,
5
5
"sideEffects" : false ,
6
6
"main" : " ./dist/index.js" ,
7
7
"module" : " ./dist/index.mjs" ,
You can’t perform that action at this time.
0 commit comments