Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Remove HubSpot contact creation (#714)

never not exploringa32bd71616e3
diff --git a/supabase/functions/new_user/index.ts b/supabase/functions/new_user/index.ts
index b2a80f9c1..7d2d38cb7 100644
--- a/supabase/functions/new_user/index.ts
+++ b/supabase/functions/new_user/index.ts
@@ -36,59 +36,6 @@ function sendToLoops(body: any) {
})
}
-function createHubspotContact(userData: {
- id: string
- email: string
- raw_user_meta_data?: {
- full_name?: string
- name?: string
- is_fragments_user?: boolean
- }
-}) {
- const name =
- userData.raw_user_meta_data?.full_name || userData.raw_user_meta_data?.name
-
- // Fix for names without spaces - firstName should be the entire name, lastName should be undefined
- let firstName: string | undefined
- let lastName: string | undefined
-
- if (name) {
- const nameParts = name.split(' ')
- if (nameParts.length > 1) {
- firstName = nameParts[0]
- lastName = nameParts[1]
- } else {
- firstName = name // Use the entire name as firstName if no space is found
- }
- }
-
- // For HubSpot checkbox fields, we need to pass "true" or "false" as strings
- const isFragmentsUser = userData.raw_user_meta_data?.is_fragments_user
- ? 'true'
- : 'false'
-
- // Map Supabase user data to HubSpot properties
- const hubspotContactData = {
- properties: {
- email: userData.email,
- firstname: firstName,
- lastname: lastName,
- db_user_id: userData.id,
- db_is_fragments_user: isFragmentsUser,
- },
- }
-
- return fetch('https://api.hubapi.com/crm/v3/objects/contacts', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- Authorization: `Bearer ${Deno.env.get('ACCESS_TOKEN_HUBSPOT')}`,
- },
- body: JSON.stringify(hubspotContactData),
- })
-}
-
serve(async (req) => {
/**
* Creates a new contact in Loops.so on a new created user in users table.
@@ -100,7 +47,7 @@ serve(async (req) => {
console.log(`New user with email: ${userEmail} created`)
const errors: {
- service: 'Loops' | 'Slack' | 'HubSpot'
+ service: 'Loops' | 'Slack'
message: string
}[] = []
@@ -131,26 +78,6 @@ serve(async (req) => {
})
}
- // Create HubSpot contact
- try {
- const hubspotResponse = await createHubspotContact(userRecord)
- if (hubspotResponse.ok) {
- console.log('Successfully created HubSpot contact')
- } else {
- const errMessage = await hubspotResponse.text()
- errors.push({
- service: 'HubSpot',
- message: errMessage,
- })
- }
- } catch (error) {
- console.error(`Failed to create HubSpot contact: ${error}`)
- errors.push({
- service: 'HubSpot',
- message: error.message,
- })
- }
-
if (errors.length == 0) {
return new Response(undefined, { status: 200 })
} else {