Commit a9c1b0c1 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch '216678-sse-track-merge-requests' into 'master'

Track merge requests submitted by SSE

See merge request gitlab-org/gitlab!34105
parents e520e164 d6dfb2e0
......@@ -17,3 +17,4 @@ export const LOAD_CONTENT_ERROR = __(
export const DEFAULT_HEADING = s__('StaticSiteEditor|Static site editor');
export const TRACKING_ACTION_CREATE_COMMIT = 'create_commit';
export const TRACKING_ACTION_CREATE_MERGE_REQUEST = 'create_merge_request';
......@@ -10,6 +10,7 @@ import {
SUBMIT_CHANGES_COMMIT_ERROR,
SUBMIT_CHANGES_MERGE_REQUEST_ERROR,
TRACKING_ACTION_CREATE_COMMIT,
TRACKING_ACTION_CREATE_MERGE_REQUEST,
} from '../constants';
const createBranch = (projectId, branch) =>
......@@ -41,8 +42,15 @@ const commitContent = (projectId, message, branch, sourcePath, content) => {
});
};
const createMergeRequest = (projectId, title, sourceBranch, targetBranch = DEFAULT_TARGET_BRANCH) =>
Api.createProjectMergeRequest(
const createMergeRequest = (
projectId,
title,
sourceBranch,
targetBranch = DEFAULT_TARGET_BRANCH,
) => {
Tracking.event(document.body.dataset.page, TRACKING_ACTION_CREATE_MERGE_REQUEST);
return Api.createProjectMergeRequest(
projectId,
convertObjectPropsToSnakeCase({
title,
......@@ -52,6 +60,7 @@ const createMergeRequest = (projectId, title, sourceBranch, targetBranch = DEFAU
).catch(() => {
throw new Error(SUBMIT_CHANGES_MERGE_REQUEST_ERROR);
});
};
const submitContentChanges = ({ username, projectId, sourcePath, content }) => {
const branch = generateBranchName(username);
......
---
title: Track merge requests submitted by Static Site Editor
merge_request: 34105
author:
type: added
......@@ -8,6 +8,7 @@ import {
SUBMIT_CHANGES_COMMIT_ERROR,
SUBMIT_CHANGES_MERGE_REQUEST_ERROR,
TRACKING_ACTION_CREATE_COMMIT,
TRACKING_ACTION_CREATE_MERGE_REQUEST,
} from '~/static_site_editor/constants';
import generateBranchName from '~/static_site_editor/services/generate_branch_name';
import submitContentChanges from '~/static_site_editor/services/submit_content_changes';
......@@ -83,15 +84,6 @@ describe('submitContentChanges', () => {
});
});
it('sends the correct tracking event when committing content changes', () => {
return submitContentChanges({ username, projectId, sourcePath, content }).then(() => {
expect(trackingSpy).toHaveBeenCalledWith(
document.body.dataset.page,
TRACKING_ACTION_CREATE_COMMIT,
);
});
});
it('notifies error when content could not be committed', () => {
Api.commitMultiple.mockRejectedValueOnce();
......@@ -152,4 +144,24 @@ describe('submitContentChanges', () => {
});
});
});
describe('sends the correct tracking event', () => {
beforeEach(() => {
return submitContentChanges({ username, projectId, sourcePath, content });
});
it('for committing changes', () => {
expect(trackingSpy).toHaveBeenCalledWith(
document.body.dataset.page,
TRACKING_ACTION_CREATE_COMMIT,
);
});
it('for creating a merge request', () => {
expect(trackingSpy).toHaveBeenCalledWith(
document.body.dataset.page,
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