From 21bd84efc4a6485d3c71428e8b7ff72be36d0d03 Mon Sep 17 00:00:00 2001 From: Wilfred Asomani Date: Fri, 12 Apr 2024 07:59:05 +0000 Subject: [PATCH] satellite/analytics: use new minimal sign up form ID This change uses a new minimal sign up form from hubspot. It also removes code that submits data to legacy professional and basic forms for the old sign up flow. Issue: https://github.com/storj/storj/issues/6907 Change-Id: I474a601f571a676d145cbb97684b5a2d02fc0c1b --- satellite/analytics/hubspot.go | 104 ++------------------------------- satellite/analytics/service.go | 2 - 2 files changed, 4 insertions(+), 102 deletions(-) diff --git a/satellite/analytics/hubspot.go b/satellite/analytics/hubspot.go index 965f137c9156..08702b20ac8d 100644 --- a/satellite/analytics/hubspot.go +++ b/satellite/analytics/hubspot.go @@ -10,7 +10,6 @@ import ( "fmt" "net/http" "net/url" - "strconv" "strings" "sync" "time" @@ -25,18 +24,14 @@ import ( var mon = monkit.Package() const ( - eventPrefix = "pe20293085" + eventPrefix = "pe44965639" expiryBufferTime = 5 * time.Minute // string template for hubspot submission form. %s is a placeholder for the form(ID) being submitted. - hubspotFormTemplate = "https://api.hsforms.com/submissions/v3/integration/submit/20293085/%s" - // This form(ID) is the business account form. - professionalFormID = "cc693502-9d55-4204-ae61-406a19148cfe" - // This form(ID) is the personal account form. - basicFormID = "77cfa709-f533-44b8-bf3a-ed1278ca3202" + hubspotFormTemplate = "https://api.hsforms.com/submissions/v3/integration/submit/44965639/%s" // this form ID is the minimal account form. - minimalFormID = "926d1b53-f21f-486b-9f15-3b3d341cc4e1" + minimalFormID = "ad4cd7b6-1c9c-44b9-b41f-b48611739620" // The hubspot lifecycle stage of all new accounts (Product Qualified Lead). - lifecycleStage = "66198674" + lifecycleStage = "170987588" ) // HubSpotConfig is a configuration struct for Concurrent Sending of Events. @@ -118,97 +113,6 @@ func (q *HubSpotEvents) Run(ctx context.Context) error { } } -// EnqueueCreateUser for creating user in HubSpot. -func (q *HubSpotEvents) EnqueueCreateUser(fields TrackCreateUserFields) { - fullName := fields.FullName - names := strings.SplitN(fullName, " ", 2) - - var firstName string - var lastName string - - if len(names) > 1 { - firstName = names[0] - lastName = names[1] - } else { - firstName = fullName - } - - newField := func(name string, value interface{}) map[string]interface{} { - return map[string]interface{}{ - "name": name, - "value": value, - } - } - - formFields := []map[string]interface{}{ - newField("email", fields.Email), - newField("firstname", firstName), - newField("lastname", lastName), - newField("origin_header", fields.OriginHeader), - newField("signup_referrer", fields.Referrer), - newField("account_created", "true"), - newField("have_sales_contact", strconv.FormatBool(fields.HaveSalesContact)), - newField("signup_partner", fields.UserAgent), - newField("lifecyclestage", lifecycleStage), - } - if fields.SignupCaptcha != nil { - formFields = append(formFields, newField("signup_captcha_score", *fields.SignupCaptcha)) - } - - properties := map[string]interface{}{ - "userid": fields.ID.String(), - "email": fields.Email, - "name": fields.FullName, - "satellite_selected": q.satelliteName, - "account_type": string(fields.Type), - "company_size": fields.EmployeeCount, - "company_name": fields.CompanyName, - "job_title": fields.JobTitle, - } - - var formURL string - - if fields.Type == Professional { - formFields = append(formFields, newField("company", fields.CompanyName)) - formFields = append(formFields, newField("storage_needs", fields.StorageNeeds)) - - properties["storage_needs"] = fields.StorageNeeds - - formURL = fmt.Sprintf(hubspotFormTemplate, professionalFormID) - } else { - formURL = fmt.Sprintf(hubspotFormTemplate, basicFormID) - } - - data := map[string]interface{}{ - "fields": formFields, - } - - if fields.HubspotUTK != "" { - data["context"] = map[string]interface{}{ - "hutk": fields.HubspotUTK, - } - } - - createUser := HubSpotEvent{ - Endpoint: formURL, - Data: data, - } - - sendUserEvent := HubSpotEvent{ - Endpoint: "https://api.hubapi.com/events/v3/send", - Data: map[string]interface{}{ - "email": fields.Email, - "eventName": eventPrefix + "_" + strings.ToLower(q.satelliteName) + "_" + "account_created", - "properties": properties, - }, - } - select { - case q.events <- []HubSpotEvent{createUser, sendUserEvent}: - default: - q.log.Error("create user hubspot event failed, event channel is full") - } -} - // EnqueueCreateUserMinimal is for creating user in HubSpot using the minimal form. func (q *HubSpotEvents) EnqueueCreateUserMinimal(fields TrackCreateUserFields) { newField := func(name string, value interface{}) map[string]interface{} { diff --git a/satellite/analytics/service.go b/satellite/analytics/service.go index 1d5c8feadac1..f121932c3045 100644 --- a/satellite/analytics/service.go +++ b/satellite/analytics/service.go @@ -358,9 +358,7 @@ func (service *Service) TrackCreateUser(fields TrackCreateUserFields) { if fields.FullName == "" { // the new minimal signup flow does not require a name. service.hubspot.EnqueueCreateUserMinimal(fields) - return } - service.hubspot.EnqueueCreateUser(fields) } // TrackUserOnboardingInfo sends onboarding info to Hubspot.