File tree 4 files changed +40
-15
lines changed
app/api/capacity-notification
components/welcome/featured
4 files changed +40
-15
lines changed Original file line number Diff line number Diff line change 1
1
import { NextRequest , NextResponse } from "next/server" ;
2
-
3
- async function saveEmailForNotification ( email : string ) : Promise < boolean > {
4
- try {
5
- // TODO: Implement actual storage logic
6
- // DB? hubspot?
7
- console . log ( `Saving email for capacity notification: ${ email } ` ) ;
8
-
9
- return true ;
10
- } catch ( error ) {
11
- console . error ( "Failed to save email for notification:" , error ) ;
12
- return false ;
13
- }
14
- }
2
+ import { submitCapacityNotification } from "@/lib/analytics/hubspot" ;
15
3
16
4
export async function POST ( req : NextRequest ) : Promise < NextResponse > {
17
5
try {
@@ -29,7 +17,7 @@ export async function POST(req: NextRequest): Promise<NextResponse> {
29
17
) ;
30
18
}
31
19
32
- const success = await saveEmailForNotification ( email ) ;
20
+ const success = await submitCapacityNotification ( email ) ;
33
21
34
22
if ( success ) {
35
23
return NextResponse . json ( { success : true } , { status : 200 } ) ;
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ export function PlayerOverlay({
92
92
93
93
const handleCommunityClick = ( ) => {
94
94
track ( "capacity_community_clicked" ) ;
95
- window . open ( "ttps ://discord.com/invite/hxyNHeSzCK" , "_blank" ) ;
95
+ window . open ( "https ://discord.com/invite/hxyNHeSzCK" , "_blank" ) ;
96
96
} ;
97
97
98
98
if ( isLoading ) {
Original file line number Diff line number Diff line change @@ -62,3 +62,38 @@ export async function submitToHubspot(user: PrivyUser) {
62
62
console . error ( "Error submitting to HubSpot:" , error ) ;
63
63
}
64
64
}
65
+
66
+ export async function submitCapacityNotification (
67
+ email : string ,
68
+ ) : Promise < boolean > {
69
+ try {
70
+ const fields : HubspotField [ ] = [
71
+ { name : "email" , value : email } ,
72
+ { name : "source" , value : "capacity_notification" } ,
73
+ ] ;
74
+
75
+ const url = `https://api.hsforms.com/submissions/v3/integration/submit/${ HubspotConfig . portalId } /${ HubspotConfig . capacityFormId } ` ;
76
+
77
+ const response = await fetch ( url , {
78
+ method : "POST" ,
79
+ headers : {
80
+ "Content-Type" : "application/json" ,
81
+ } ,
82
+ body : JSON . stringify ( {
83
+ fields,
84
+ } ) ,
85
+ } ) ;
86
+
87
+ if ( ! response . ok ) {
88
+ const errorData = await response . json ( ) ;
89
+ throw new Error (
90
+ `Failed to submit to HubSpot: ${ errorData . error || response . statusText } ` ,
91
+ ) ;
92
+ }
93
+
94
+ return true ;
95
+ } catch ( error ) {
96
+ console . error ( "Error submitting capacity notification to HubSpot:" , error ) ;
97
+ return false ;
98
+ }
99
+ }
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ const IntercomConfig = z.object({
16
16
const HubspotConfig = z . object ( {
17
17
portalId : z . string ( ) . min ( 1 ) ,
18
18
formId : z . string ( ) . min ( 1 ) ,
19
+ capacityFormId : z . string ( ) . min ( 1 ) ,
19
20
} ) ;
20
21
21
22
const MixpanelConfig = z . object ( {
@@ -74,6 +75,7 @@ const envConfig = {
74
75
hubspot : {
75
76
portalId : process . env . NEXT_PUBLIC_HUBSPOT_PORTAL_ID ,
76
77
formId : process . env . NEXT_PUBLIC_HUBSPOT_FORM_ID ,
78
+ capacityFormId : process . env . NEXT_PUBLIC_HUBSPOT_FORM_ID_CAPACITY ,
77
79
} ,
78
80
} as const ;
79
81
You can’t perform that action at this time.
0 commit comments