debian-mirror-gitlab/app/assets/javascripts/tracking/get_standard_context.js
2023-04-23 21:23:45 +05:30

16 lines
497 B
JavaScript

import { getCookie } from '~/lib/utils/common_utils';
import { SNOWPLOW_JS_SOURCE, GOOGLE_ANALYTICS_ID_COOKIE_NAME } from './constants';
export default function getStandardContext({ extra = {} } = {}) {
const { schema, data = {} } = { ...window.gl?.snowplowStandardContext };
return {
schema,
data: {
...data,
source: SNOWPLOW_JS_SOURCE,
google_analytics_id: getCookie(GOOGLE_ANALYTICS_ID_COOKIE_NAME) ?? '',
extra: { ...data.extra, ...extra },
},
};
}