diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-15 12:07:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-15 12:07:30 +0300 |
commit | 50e177d19bdeeb0fcc7b129b9c30841454df240b (patch) | |
tree | 11b30123cfec778cfa469bc23e17f40a45d43880 /app/assets/javascripts/ide | |
parent | 9cf113df885ac8959b9fab3aab5e50e2532fef75 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/ide')
-rw-r--r-- | app/assets/javascripts/ide/init_gitlab_web_ide.js | 2 | ||||
-rw-r--r-- | app/assets/javascripts/ide/lib/gitlab_web_ide/handle_tracking_event.js | 20 | ||||
-rw-r--r-- | app/assets/javascripts/ide/remote/index.js | 2 |
3 files changed, 24 insertions, 0 deletions
diff --git a/app/assets/javascripts/ide/init_gitlab_web_ide.js b/app/assets/javascripts/ide/init_gitlab_web_ide.js index e3fbce25cd2..4d3cefcb107 100644 --- a/app/assets/javascripts/ide/init_gitlab_web_ide.js +++ b/app/assets/javascripts/ide/init_gitlab_web_ide.js @@ -7,6 +7,7 @@ import csrf from '~/lib/utils/csrf'; import { getBaseConfig } from './lib/gitlab_web_ide/get_base_config'; import { setupRootElement } from './lib/gitlab_web_ide/setup_root_element'; import { GITLAB_WEB_IDE_FEEDBACK_ISSUE } from './constants'; +import { handleTracking } from './lib/gitlab_web_ide/handle_tracking_event'; const buildRemoteIdeURL = (ideRemotePath, remoteHost, remotePathArg) => { const remotePath = cleanLeadingSeparator(remotePathArg); @@ -72,6 +73,7 @@ export const initGitlabWebIDE = async (el) => { fontFamily: editorFontFamily, format: editorFontFormat, }, + handleTracking, async handleStartRemote({ remoteHost, remotePath, connectionToken }) { const confirmed = await confirmAction( __('Are you sure you want to leave the Web IDE? All unsaved changes will be lost.'), diff --git a/app/assets/javascripts/ide/lib/gitlab_web_ide/handle_tracking_event.js b/app/assets/javascripts/ide/lib/gitlab_web_ide/handle_tracking_event.js new file mode 100644 index 00000000000..615dad02386 --- /dev/null +++ b/app/assets/javascripts/ide/lib/gitlab_web_ide/handle_tracking_event.js @@ -0,0 +1,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); + } +}; diff --git a/app/assets/javascripts/ide/remote/index.js b/app/assets/javascripts/ide/remote/index.js index fb8db20c0c1..6966786ca4e 100644 --- a/app/assets/javascripts/ide/remote/index.js +++ b/app/assets/javascripts/ide/remote/index.js @@ -1,6 +1,7 @@ import { startRemote } from '@gitlab/web-ide'; import { getBaseConfig, setupRootElement } from '~/ide/lib/gitlab_web_ide'; import { isSameOriginUrl, joinPaths } from '~/lib/utils/url_utility'; +import { handleTracking } from '~/ide/lib/gitlab_web_ide/handle_tracking_event'; /** * @param {Element} rootEl @@ -36,5 +37,6 @@ export const mountRemoteIDE = async (el) => { // TODO Handle error better handleError: visitReturnUrl, handleClose: visitReturnUrl, + handleTracking, }); }; |