From 78fa0c11a360b429bd6b33bf58dc2b5d4edfb3e3 Mon Sep 17 00:00:00 2001 From: Moby von Briesen Date: Fri, 29 Jul 2022 17:27:24 -0400 Subject: [PATCH] satellite/analytics: Add user agent to TrackCreateUser Send UserAgent (as "signup_partner") to Segment and Hubspot. Change-Id: I3313eb902e87b429e7fa8e18afd397a63a3ed07d --- satellite/analytics/hubspot.go | 1 + satellite/analytics/service.go | 4 ++++ satellite/console/consoleweb/consoleapi/auth.go | 1 + 3 files changed, 6 insertions(+) diff --git a/satellite/analytics/hubspot.go b/satellite/analytics/hubspot.go index 8e6bf5ea7..cf7ceb598 100644 --- a/satellite/analytics/hubspot.go +++ b/satellite/analytics/hubspot.go @@ -123,6 +123,7 @@ func (q *HubSpotEvents) EnqueueCreateUser(fields TrackCreateUserFields) { newField("signup_referrer", fields.Referrer), newField("account_created", "true"), newField("have_sales_contact", strconv.FormatBool(fields.HaveSalesContact)), + newField("signup_partner", fields.UserAgent), }, }, } diff --git a/satellite/analytics/service.go b/satellite/analytics/service.go index 1b661078b..92422f9cf 100644 --- a/satellite/analytics/service.go +++ b/satellite/analytics/service.go @@ -140,6 +140,7 @@ type TrackCreateUserFields struct { OriginHeader string Referrer string HubspotUTK string + UserAgent string } func (service *Service) enqueueMessage(message segment.Message) { @@ -179,6 +180,9 @@ func (service *Service) TrackCreateUser(fields TrackCreateUserFields) { if fields.Type == Professional { traits.Set("have_sales_contact", fields.HaveSalesContact) } + if len(fields.UserAgent) > 0 { + traits.Set("signup_partner", fields.UserAgent) + } service.enqueueMessage(segment.Identify{ UserId: fields.ID.String(), diff --git a/satellite/console/consoleweb/consoleapi/auth.go b/satellite/console/consoleweb/consoleapi/auth.go index ec24511a7..07bd20b2f 100644 --- a/satellite/console/consoleweb/consoleapi/auth.go +++ b/satellite/console/consoleweb/consoleapi/auth.go @@ -303,6 +303,7 @@ func (a *Auth) Register(w http.ResponseWriter, r *http.Request) { OriginHeader: origin, Referrer: referrer, HubspotUTK: hubspotUTK, + UserAgent: string(user.UserAgent), } if user.IsProfessional { trackCreateUserFields.Type = analytics.Professional