Commit 470d538d authored by Enrique Alcántara's avatar Enrique Alcántara

Merge branch '233994_send_usage_data_events' into 'master'

Send Static Site Editor events to Usage Ping API

See merge request gitlab-org/gitlab!47640
parents fd882d51 355277df
...@@ -21,4 +21,7 @@ export const TRACKING_ACTION_CREATE_COMMIT = 'create_commit'; ...@@ -21,4 +21,7 @@ export const TRACKING_ACTION_CREATE_COMMIT = 'create_commit';
export const TRACKING_ACTION_CREATE_MERGE_REQUEST = 'create_merge_request'; export const TRACKING_ACTION_CREATE_MERGE_REQUEST = 'create_merge_request';
export const TRACKING_ACTION_INITIALIZE_EDITOR = 'initialize_editor'; export const TRACKING_ACTION_INITIALIZE_EDITOR = 'initialize_editor';
export const USAGE_PING_TRACKING_ACTION_CREATE_COMMIT = 'static_site_editor_commits';
export const USAGE_PING_TRACKING_ACTION_CREATE_MERGE_REQUEST = 'static_site_editor_merge_requests';
export const MR_META_LOCAL_STORAGE_KEY = 'sse-merge-request-meta-storage-key'; export const MR_META_LOCAL_STORAGE_KEY = 'sse-merge-request-meta-storage-key';
...@@ -10,6 +10,8 @@ import { ...@@ -10,6 +10,8 @@ import {
SUBMIT_CHANGES_MERGE_REQUEST_ERROR, SUBMIT_CHANGES_MERGE_REQUEST_ERROR,
TRACKING_ACTION_CREATE_COMMIT, TRACKING_ACTION_CREATE_COMMIT,
TRACKING_ACTION_CREATE_MERGE_REQUEST, TRACKING_ACTION_CREATE_MERGE_REQUEST,
USAGE_PING_TRACKING_ACTION_CREATE_COMMIT,
USAGE_PING_TRACKING_ACTION_CREATE_MERGE_REQUEST,
} from '../constants'; } from '../constants';
const createBranch = (projectId, branch) => const createBranch = (projectId, branch) =>
...@@ -47,6 +49,7 @@ const createImageActions = (images, markdown) => { ...@@ -47,6 +49,7 @@ const createImageActions = (images, markdown) => {
const commitContent = (projectId, message, branch, sourcePath, content, images) => { const commitContent = (projectId, message, branch, sourcePath, content, images) => {
Tracking.event(document.body.dataset.page, TRACKING_ACTION_CREATE_COMMIT); Tracking.event(document.body.dataset.page, TRACKING_ACTION_CREATE_COMMIT);
Api.trackRedisCounterEvent(USAGE_PING_TRACKING_ACTION_CREATE_COMMIT);
return Api.commitMultiple( return Api.commitMultiple(
projectId, projectId,
...@@ -75,6 +78,7 @@ const createMergeRequest = ( ...@@ -75,6 +78,7 @@ const createMergeRequest = (
targetBranch = DEFAULT_TARGET_BRANCH, targetBranch = DEFAULT_TARGET_BRANCH,
) => { ) => {
Tracking.event(document.body.dataset.page, TRACKING_ACTION_CREATE_MERGE_REQUEST); Tracking.event(document.body.dataset.page, TRACKING_ACTION_CREATE_MERGE_REQUEST);
Api.trackRedisCounterEvent(USAGE_PING_TRACKING_ACTION_CREATE_MERGE_REQUEST);
return Api.createProjectMergeRequest( return Api.createProjectMergeRequest(
projectId, projectId,
......
---
title: Send Static Site Editor events to Usage Ping API
merge_request: 47640
author:
type: added
...@@ -9,6 +9,8 @@ import { ...@@ -9,6 +9,8 @@ import {
SUBMIT_CHANGES_MERGE_REQUEST_ERROR, SUBMIT_CHANGES_MERGE_REQUEST_ERROR,
TRACKING_ACTION_CREATE_COMMIT, TRACKING_ACTION_CREATE_COMMIT,
TRACKING_ACTION_CREATE_MERGE_REQUEST, TRACKING_ACTION_CREATE_MERGE_REQUEST,
USAGE_PING_TRACKING_ACTION_CREATE_COMMIT,
USAGE_PING_TRACKING_ACTION_CREATE_MERGE_REQUEST,
} from '~/static_site_editor/constants'; } from '~/static_site_editor/constants';
import generateBranchName from '~/static_site_editor/services/generate_branch_name'; import generateBranchName from '~/static_site_editor/services/generate_branch_name';
import submitContentChanges from '~/static_site_editor/services/submit_content_changes'; import submitContentChanges from '~/static_site_editor/services/submit_content_changes';
...@@ -201,4 +203,26 @@ describe('submitContentChanges', () => { ...@@ -201,4 +203,26 @@ describe('submitContentChanges', () => {
); );
}); });
}); });
describe('sends the correct Usage Ping tracking event', () => {
beforeEach(() => {
jest.spyOn(Api, 'trackRedisCounterEvent').mockResolvedValue({ data: '' });
});
it('for commiting changes', () => {
return submitContentChanges(buildPayload()).then(() => {
expect(Api.trackRedisCounterEvent).toHaveBeenCalledWith(
USAGE_PING_TRACKING_ACTION_CREATE_COMMIT,
);
});
});
it('for creating a merge request', () => {
return submitContentChanges(buildPayload()).then(() => {
expect(Api.trackRedisCounterEvent).toHaveBeenCalledWith(
USAGE_PING_TRACKING_ACTION_CREATE_MERGE_REQUEST,
);
});
});
});
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment