Welcome to mirror list, hosted at ThFree Co, Russian Federation.

handle_tracking_event.js « gitlab_web_ide « lib « ide « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 615dad023860140653429bb4dd954e6ca5a87cbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { snakeCase } from 'lodash';
import { convertObjectPropsToSnakeCase } from '~/lib/utils/common_utils';
import Tracking from '~/tracking';

export const handleTracking = ({ name, data }) => {
  const snakeCaseEventName = snakeCase(name);

  if (data && Object.keys(data).length) {
    Tracking.event(undefined, snakeCaseEventName, {
      /* See GitLab snowplow schema for a definition of the extra field
       * https://docs.gitlab.com/ee/development/snowplow/schemas.html#gitlab_standard.
       */
      extra: convertObjectPropsToSnakeCase(data, {
        deep: true,
      }),
    });
  } else {
    Tracking.event(undefined, snakeCaseEventName);
  }
};