diff --git a/satellite/analytics/hubspot.go b/satellite/analytics/hubspot.go index 9199a1af4..48addaef3 100644 --- a/satellite/analytics/hubspot.go +++ b/satellite/analytics/hubspot.go @@ -100,18 +100,27 @@ func (q *HubSpotEvents) EnqueueCreateUser(fields TrackCreateUserFields) { firstName = fullName } + newField := func(name, value string) map[string]interface{} { + return map[string]interface{}{ + "name": name, + "value": value, + } + } + createUser := HubSpotEvent{ - Endpoint: "https://api.hubapi.com/crm/v3/objects/contacts?hapikey=" + q.escapedAPIKey, + Endpoint: "https://api.hsforms.com/submissions/v3/integration/submit/20293085/77cfa709-f533-44b8-bf3a-ed1278ca3202?hapikey=" + q.escapedAPIKey, Data: map[string]interface{}{ - "email": fields.Email, - "properties": map[string]interface{}{ - "email": fields.Email, - "firstname": firstName, - "lastname": lastName, - "lifecyclestage": "customer", - "origin_header": fields.OriginHeader, - "signup_referrer": fields.Referrer, - "account_created": true, + "context": map[string]interface{}{ + "hutk": fields.HubspotUTK, + }, + "fields": []map[string]interface{}{ + newField("email", fields.Email), + newField("firstname", firstName), + newField("lastname", lastName), + newField("lifecyclestage", "customer"), + newField("origin_header", fields.OriginHeader), + newField("signup_referrer", fields.Referrer), + newField("account_created", "true"), }, }, } diff --git a/satellite/analytics/service.go b/satellite/analytics/service.go index 5fe996fc4..020664ee9 100644 --- a/satellite/analytics/service.go +++ b/satellite/analytics/service.go @@ -113,6 +113,7 @@ type TrackCreateUserFields struct { HaveSalesContact bool OriginHeader string Referrer string + HubspotUTK string } func (service *Service) enqueueMessage(message segment.Message) { diff --git a/satellite/console/consoleweb/consoleapi/auth.go b/satellite/console/consoleweb/consoleapi/auth.go index a4de69eda..acafa430d 100644 --- a/satellite/console/consoleweb/consoleapi/auth.go +++ b/satellite/console/consoleweb/consoleapi/auth.go @@ -286,6 +286,12 @@ func (a *Auth) Register(w http.ResponseWriter, r *http.Request) { if referrer == "" { referrer = r.Referer() } + hubspotUTK := "" + hubspotCookie, err := r.Cookie("hubspotutk") + if err == nil { + hubspotUTK = hubspotCookie.Value + } + trackCreateUserFields := analytics.TrackCreateUserFields{ ID: user.ID, AnonymousID: loadSession(r), @@ -294,6 +300,7 @@ func (a *Auth) Register(w http.ResponseWriter, r *http.Request) { Type: analytics.Personal, OriginHeader: origin, Referrer: referrer, + HubspotUTK: hubspotUTK, } if user.IsProfessional { trackCreateUserFields.Type = analytics.Professional