diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-07 12:11:12 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-07 12:11:12 +0300 |
commit | 3822e951cb0ced8b24d79949339684312c8bb2e1 (patch) | |
tree | f616601ae823c4c7ece1eb63bc056bd52a27a7b5 /app/assets/javascripts/tracking | |
parent | 4bcd95583079cb769cfe8fa5350cbf3864f15f99 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/tracking')
-rw-r--r-- | app/assets/javascripts/tracking/dispatch_snowplow_event.js | 8 | ||||
-rw-r--r-- | app/assets/javascripts/tracking/internal_events.js | 27 |
2 files changed, 23 insertions, 12 deletions
diff --git a/app/assets/javascripts/tracking/dispatch_snowplow_event.js b/app/assets/javascripts/tracking/dispatch_snowplow_event.js index 89d90cf89be..99e4a6aa3c7 100644 --- a/app/assets/javascripts/tracking/dispatch_snowplow_event.js +++ b/app/assets/javascripts/tracking/dispatch_snowplow_event.js @@ -15,10 +15,14 @@ export function dispatchSnowplowEvent( let { value } = data; const standardContext = getStandardContext({ extra }); - const contexts = [standardContext]; + let contexts = [standardContext]; if (data.context) { - contexts.push(data.context); + if (Array.isArray(data.context)) { + contexts = [...contexts, ...data.context]; + } else { + contexts.push(data.context); + } } if (value !== undefined) { diff --git a/app/assets/javascripts/tracking/internal_events.js b/app/assets/javascripts/tracking/internal_events.js index cc943163352..9bd0200cad1 100644 --- a/app/assets/javascripts/tracking/internal_events.js +++ b/app/assets/javascripts/tracking/internal_events.js @@ -15,17 +15,24 @@ const InternalEvents = { /** * * @param {string} event + * @param {object} data */ - track_event(event) { + track_event(event, data = {}) { + const { context, ...rest } = data; + + const defaultContext = { + schema: SERVICE_PING_SCHEMA, + data: { + event_name: event, + data_source: 'redis_hll', + }, + }; + const mergedContext = context ? [defaultContext, context] : defaultContext; + API.trackInternalEvent(event); Tracking.event(GITLAB_INTERNAL_EVENT_CATEGORY, event, { - context: { - schema: SERVICE_PING_SCHEMA, - data: { - event_name: event, - data_source: 'redis_hll', - }, - }, + context: mergedContext, + ...rest, }); }, /** @@ -35,8 +42,8 @@ const InternalEvents = { mixin() { return { methods: { - track_event(event) { - InternalEvents.track_event(event); + track_event(event, data = {}) { + InternalEvents.track_event(event, data); }, }, }; |