@@ -16,6 +16,8 @@ import {
1616 createOrganizationTasks ,
1717 getRelevantControls ,
1818} from "./lib/utils" ;
19+ import { env } from "@/env.mjs" ;
20+ import ky from "ky" ;
1921
2022export const createOrganizationAction = authActionClient
2123 . schema ( organizationSchema )
@@ -27,7 +29,7 @@ export const createOrganizationAction = authActionClient
2729 } ,
2830 } )
2931 . action ( async ( { parsedInput, ctx } ) => {
30- const { name, frameworks } = parsedInput ;
32+ const { name, frameworks, website } = parsedInput ;
3133 const { id : userId } = ctx . user ;
3234
3335 if ( ! name ) {
@@ -55,6 +57,19 @@ export const createOrganizationAction = authActionClient
5557 headers : await headers ( ) ,
5658 } ) ;
5759
60+ if ( env . ZAPIER_HUBSPOT_WEBHOOK_URL ) {
61+ await ky . post ( env . ZAPIER_HUBSPOT_WEBHOOK_URL , {
62+ json : {
63+ email : session ?. user . email ,
64+ website : website ,
65+ organization : name ,
66+ frameworks : frameworks ,
67+ first_name : session ?. user . name ?. split ( " " ) [ 0 ] || "" ,
68+ last_name : session ?. user . name ?. split ( " " ) [ 1 ] || "" ,
69+ } ,
70+ } ) ;
71+ }
72+
5873 timings . getAuthSession = ( performance . now ( ) - start ) / 1000 ;
5974
6075 if ( ! session ?. session . activeOrganizationId ) {
@@ -97,7 +112,7 @@ export const createOrganizationAction = authActionClient
97112 start = performance . now ( ) ;
98113 await db . organization . update ( {
99114 where : { id : organizationId } ,
100- data : { stripeCustomerId } ,
115+ data : { stripeCustomerId, website } ,
101116 } ) ;
102117 timings . updateOrganizationWithStripeId =
103118 ( performance . now ( ) - start ) / 1000 ;
0 commit comments