diff --git a/satellite/analytics/service.go b/satellite/analytics/service.go index 4ac0b2036..5dc8b0996 100644 --- a/satellite/analytics/service.go +++ b/satellite/analytics/service.go @@ -526,7 +526,7 @@ func (service *Service) TrackAccountVerified(userID uuid.UUID, email string) { // TrackEvent sends an arbitrary event associated with user ID to Segment. // It is used for tracking occurrences of client-side events. -func (service *Service) TrackEvent(eventName string, userID uuid.UUID, email string, customProps map[string]string) { +func (service *Service) TrackEvent(eventName string, userID uuid.UUID, email, uiType string, customProps map[string]string) { if !service.config.Enabled { return } @@ -539,6 +539,7 @@ func (service *Service) TrackEvent(eventName string, userID uuid.UUID, email str props := segment.NewProperties() props.Set("email", email) + props.Set("ui_type", uiType) for key, value := range customProps { props.Set(key, value) @@ -553,7 +554,7 @@ func (service *Service) TrackEvent(eventName string, userID uuid.UUID, email str // TrackErrorEvent sends an arbitrary error event associated with user ID to Segment. // It is used for tracking occurrences of client-side errors. -func (service *Service) TrackErrorEvent(userID uuid.UUID, email string, source string) { +func (service *Service) TrackErrorEvent(userID uuid.UUID, email, source, uiType string) { if !service.config.Enabled { return } @@ -561,6 +562,7 @@ func (service *Service) TrackErrorEvent(userID uuid.UUID, email string, source s props := segment.NewProperties() props.Set("email", email) props.Set("source", source) + props.Set("ui_type", uiType) service.enqueueMessage(segment.Track{ UserId: userID.String(), @@ -571,7 +573,7 @@ func (service *Service) TrackErrorEvent(userID uuid.UUID, email string, source s // TrackLinkEvent sends an arbitrary event and link associated with user ID to Segment. // It is used for tracking occurrences of client-side events. -func (service *Service) TrackLinkEvent(eventName string, userID uuid.UUID, email, link string) { +func (service *Service) TrackLinkEvent(eventName string, userID uuid.UUID, email, link, uiType string) { if !service.config.Enabled { return } @@ -585,6 +587,7 @@ func (service *Service) TrackLinkEvent(eventName string, userID uuid.UUID, email props := segment.NewProperties() props.Set("link", link) props.Set("email", email) + props.Set("ui_type", uiType) service.enqueueMessage(segment.Track{ UserId: userID.String(), diff --git a/satellite/console/consoleweb/consoleapi/analytics.go b/satellite/console/consoleweb/consoleapi/analytics.go index 58c67cc45..955f32ff3 100644 --- a/satellite/console/consoleweb/consoleapi/analytics.go +++ b/satellite/console/consoleweb/consoleapi/analytics.go @@ -40,6 +40,7 @@ type eventTriggeredBody struct { EventName string `json:"eventName"` Link string `json:"link"` ErrorEventSource string `json:"errorEventSource"` + UIType string `json:"uiType"` Props map[string]string `json:"props"` } @@ -70,11 +71,11 @@ func (a *Analytics) EventTriggered(w http.ResponseWriter, r *http.Request) { } if et.ErrorEventSource != "" { - a.analytics.TrackErrorEvent(user.ID, user.Email, et.ErrorEventSource) + a.analytics.TrackErrorEvent(user.ID, user.Email, et.ErrorEventSource, et.UIType) } else if et.Link != "" { - a.analytics.TrackLinkEvent(et.EventName, user.ID, user.Email, et.Link) + a.analytics.TrackLinkEvent(et.EventName, user.ID, user.Email, et.Link, et.UIType) } else { - a.analytics.TrackEvent(et.EventName, user.ID, user.Email, et.Props) + a.analytics.TrackEvent(et.EventName, user.ID, user.Email, et.UIType, et.Props) } w.WriteHeader(http.StatusOK) } diff --git a/web/satellite/src/api/analytics.ts b/web/satellite/src/api/analytics.ts index 65bf6482f..853093d8c 100644 --- a/web/satellite/src/api/analytics.ts +++ b/web/satellite/src/api/analytics.ts @@ -24,6 +24,7 @@ export class AnalyticsHttpApi { const path = `${this.ROOT_PATH}/event`; const body = { eventName: eventName, + uiType: __UI_TYPE__, }; if (props) { body['props'] = props; @@ -51,6 +52,7 @@ export class AnalyticsHttpApi { const body = { eventName: eventName, link: link, + uiType: __UI_TYPE__, }; const response = await this.http.post(path, JSON.stringify(body)); if (response.ok) { @@ -73,6 +75,7 @@ export class AnalyticsHttpApi { const path = `${this.ROOT_PATH}/page`; const body = { pageName: pageName, + uiType: __UI_TYPE__, }; const response = await this.http.post(path, JSON.stringify(body)); if (response.ok) { @@ -95,6 +98,7 @@ export class AnalyticsHttpApi { const path = `${this.ROOT_PATH}/event`; const body = { eventName: AnalyticsEvent.UI_ERROR, + uiType: __UI_TYPE__, }; if (source) { diff --git a/web/satellite/src/types/vite-env.d.ts b/web/satellite/src/types/vite-env.d.ts new file mode 100644 index 000000000..e1abf3ea8 --- /dev/null +++ b/web/satellite/src/types/vite-env.d.ts @@ -0,0 +1,4 @@ +// Copyright (C) 2023 Storj Labs, Inc. +// See LICENSE for copying information. + +declare const __UI_TYPE__: string; diff --git a/web/satellite/vite.config-vuetify.js b/web/satellite/vite.config-vuetify.js index ddd266fbb..255071874 100644 --- a/web/satellite/vite.config-vuetify.js +++ b/web/satellite/vite.config-vuetify.js @@ -22,7 +22,10 @@ export default defineConfig({ }, }), ], - define: { 'process.env': {} }, + define: { + 'process.env': {}, + __UI_TYPE__: JSON.stringify('vuetify'), + }, resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), diff --git a/web/satellite/vite.config.js b/web/satellite/vite.config.js index 6a5a45c4b..01898a6f0 100644 --- a/web/satellite/vite.config.js +++ b/web/satellite/vite.config.js @@ -66,6 +66,7 @@ export default defineConfig(({ mode }) => { }, define: { 'process.env': {}, + __UI_TYPE__: JSON.stringify('legacy'), }, test: { globals: true,