-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next' into feat/community-release-improvements
- Loading branch information
Showing
93 changed files
with
1,283 additions
and
603 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -690,7 +690,8 @@ | |
"xyflow", | ||
"Sonner", | ||
"sonner", | ||
"cmdk" | ||
"cmdk", | ||
"Keymap" | ||
], | ||
"flagWords": [], | ||
"patterns": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 35 additions & 23 deletions
58
apps/api/src/app/analytics/usecases/hubspot-identify-form/hubspot-identify-form.usecase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,49 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { HttpService } from '@nestjs/axios'; | ||
import { firstValueFrom } from 'rxjs'; | ||
import { Injectable, Logger } from '@nestjs/common'; | ||
import { AxiosError } from 'axios'; | ||
import { HubspotIdentifyFormCommand } from './hubspot-identify-form.command'; | ||
|
||
const LOG_CONTEXT = 'HubspotIdentifyFormUsecase'; | ||
|
||
@Injectable() | ||
export class HubspotIdentifyFormUsecase { | ||
private readonly hubspotPortalId = '44416662'; | ||
private readonly hubspotFormId = 'fc39aa98-4285-4322-9514-52da978baae8'; | ||
|
||
constructor(private httpService: HttpService) {} | ||
|
||
async execute(command: HubspotIdentifyFormCommand): Promise<{ success: boolean; hubspotResponse?: any }> { | ||
const hubspotSubmitUrl = `https://api.hsforms.com/submissions/v3/integration/submit/${this.hubspotPortalId}/${this.hubspotFormId}`; | ||
|
||
const hubspotData = { | ||
fields: [ | ||
{ name: 'email', value: command.email }, | ||
{ name: 'lastname', value: command.lastName || 'Unknown' }, | ||
{ name: 'firstname', value: command.firstName || 'Unknown' }, | ||
{ name: 'app_organizationid', value: command.organizationId }, | ||
], | ||
context: { | ||
hutk: command.hubspotContext, | ||
pageUri: command.pageUri, | ||
pageName: command.pageName, | ||
}, | ||
}; | ||
async execute(command: HubspotIdentifyFormCommand) { | ||
try { | ||
const hubspotSubmitUrl = `https://api.hsforms.com/submissions/v3/integration/submit/${this.hubspotPortalId}/${this.hubspotFormId}`; | ||
|
||
const response = await firstValueFrom(this.httpService.post(hubspotSubmitUrl, hubspotData)); | ||
const hubspotData = { | ||
fields: [ | ||
{ name: 'email', value: command.email }, | ||
{ name: 'lastname', value: command.lastName || 'Unknown' }, | ||
{ name: 'firstname', value: command.firstName || 'Unknown' }, | ||
{ name: 'app_organizationid', value: command.organizationId }, | ||
], | ||
context: { | ||
hutk: command.hubspotContext, | ||
pageUri: command.pageUri, | ||
pageName: command.pageName, | ||
}, | ||
}; | ||
|
||
return { | ||
success: true, | ||
hubspotResponse: response.data, | ||
}; | ||
await this.httpService.post(hubspotSubmitUrl, hubspotData); | ||
} catch (error) { | ||
if (error instanceof AxiosError) { | ||
Logger.error( | ||
`Failed to submit to Hubspot message=${error.message}, status=${error.status}`, | ||
{ | ||
organizationId: command.organizationId, | ||
response: error.response?.data, | ||
}, | ||
LOG_CONTEXT | ||
); | ||
} else { | ||
throw error; | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.