Commit c2be84dd authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '119085-using-snowplow-for-red-error-banner-reporting' into 'master'

Use snowplow for user error reporting in trial

See merge request gitlab-org/gitlab!24430
parents c47e97a0 105ac604
......@@ -111,4 +111,6 @@ export function initUserTracking() {
if (opts.linkClickTracking) window.snowplow('enableLinkClickTracking');
Tracking.bindDocument();
document.dispatchEvent(new Event('SnowplowInitialized'));
}
import 'ee/pages/trials/namespace_select';
import 'ee/trials/track_trial_user_errors';
import 'ee/pages/trials/country_select';
import 'ee/trials/track_trial_user_errors';
import Tracking from '~/tracking';
export default function trackTrialUserErrors() {
const flashText = document.querySelector('.trial-errors .flash-text');
if (flashText) {
const errorMessage = flashText.textContent.trim();
if (errorMessage) {
Tracking.event('trials:create', 'create_trial_error', {
label: 'flash-text',
property: 'message',
value: errorMessage,
});
}
}
}
document.addEventListener('SnowplowInitialized', trackTrialUserErrors);
- if show_trial_errors?(@namespace, @result)
.flash-container
.flash-container.trial-errors
.flash-alert.text-center
= _('We have found the following errors:')
.flash-text
......
---
title: Use snowplow for user error reporting in trial
merge_request: 24430
author:
type: added
import { mockTracking } from 'helpers/tracking_helper';
import trackTrialUserErrors from 'ee/trials/track_trial_user_errors';
describe('trackTrialUserErrors', () => {
let spy;
describe('when an error is present', () => {
const errorMessage = 'You cannot have multiple trials';
beforeEach(() => {
document.body.innerHTML = `
<div class="flash-container trial-errors"
.<div class="flash-alert.text-center">
We have found the following errors:
<div class="flash-text">
${errorMessage}
</div>
</div>
</div>
`;
spy = mockTracking('trials:create', document.body, jest.spyOn);
});
it('tracks the error message', () => {
trackTrialUserErrors();
expect(spy).toHaveBeenCalledWith('trials:create', 'create_trial_error', {
label: 'flash-text',
property: 'message',
value: errorMessage,
});
});
it('tracks the error message when snowplow is initialized', () => {
document.dispatchEvent(new Event('SnowplowInitialized'));
expect(spy).toHaveBeenCalledWith('trials:create', 'create_trial_error', {
label: 'flash-text',
property: 'message',
value: errorMessage,
});
});
});
describe('when no error is present', () => {
beforeEach(() => {
document.body.innerHTML = `
<div id="dummy-wrapper-element">
</div>
`;
});
it('does not track the any error message', () => {
trackTrialUserErrors();
expect(spy).not.toHaveBeenCalled();
});
});
});
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