Commit bb42f323 authored by anna_vovchenko's avatar anna_vovchenko Committed by Anna Vovchenko

Changed the tracking event to contain invalid character

parent 6b3867a3
...@@ -60,10 +60,7 @@ export default { ...@@ -60,10 +60,7 @@ export default {
data() { data() {
return { return {
isTipDismissed: Cookies.get(AWS_TIP_DISMISSED_COOKIE_NAME) === 'true', isTipDismissed: Cookies.get(AWS_TIP_DISMISSED_COOKIE_NAME) === 'true',
isValidationErrorEventSent: { validationErrorEventProperty: '',
displaysMaskedError: false,
displaysVariableReferenceError: false,
},
}; };
}, },
computed: { computed: {
...@@ -162,7 +159,6 @@ export default { ...@@ -162,7 +159,6 @@ export default {
this.trackVariableValidationErrors(); this.trackVariableValidationErrors();
}, },
deep: true, deep: true,
immediate: true,
}, },
}, },
methods: { methods: {
...@@ -213,23 +209,24 @@ export default { ...@@ -213,23 +209,24 @@ export default {
} }
}, },
trackVariableValidationErrors() { trackVariableValidationErrors() {
if (this.displayMaskedError && !this.isValidationErrorEventSent.displaysMaskedError) { if (this.variable.secret_value?.length && !this.validationErrorEventProperty) {
this.track(EVENT_ACTION, { property: 'displaysMaskedError' }); if (this.displayMaskedError && this.maskableRegex?.length) {
this.isValidationErrorEventSent.displaysMaskedError = true; const supportedChars = this.maskableRegex.replace('^', '').replace(/{(\d,)}\$/, '');
const regex = new RegExp(supportedChars, 'g');
const error = this.variable.secret_value.replace(regex, '');
this.track(EVENT_ACTION, { property: error });
this.validationErrorEventProperty = error;
}
if (this.containsVariableReference) {
this.track(EVENT_ACTION, { property: '$' });
this.validationErrorEventProperty = '$';
} }
if (
this.containsVariableReference &&
!this.isValidationErrorEventSent.displaysVariableReferenceError
) {
this.track(EVENT_ACTION, { property: 'displaysVariableReferenceError' });
this.isValidationErrorEventSent.displaysVariableReferenceError = true;
} }
}, },
resetValidationErrorEvents() { resetValidationErrorEvents() {
this.isValidationErrorEventSent = { this.validationErrorEventProperty = '';
displaysMaskedError: false,
displaysVariableReferenceError: false,
};
}, },
}, },
}; };
......
...@@ -17,8 +17,10 @@ describe('Ci variable modal', () => { ...@@ -17,8 +17,10 @@ describe('Ci variable modal', () => {
let store; let store;
let trackingSpy; let trackingSpy;
const maskableRegex = '^[a-zA-Z0-9_+=/@:.~-]{8,}$';
const createComponent = (method, options = {}) => { const createComponent = (method, options = {}) => {
store = createStore({ isGroup: options.isGroup }); store = createStore({ maskableRegex, isGroup: options.isGroup });
wrapper = method(CiVariableModal, { wrapper = method(CiVariableModal, {
attachTo: document.body, attachTo: document.body,
stubs: { stubs: {
...@@ -247,7 +249,7 @@ describe('Ci variable modal', () => { ...@@ -247,7 +249,7 @@ describe('Ci variable modal', () => {
it('sends the correct tracking event', () => { it('sends the correct tracking event', () => {
expect(trackingSpy).toHaveBeenCalledWith(undefined, EVENT_ACTION, { expect(trackingSpy).toHaveBeenCalledWith(undefined, EVENT_ACTION, {
label: EVENT_LABEL, label: EVENT_LABEL,
property: 'displaysMaskedError', property: ';',
}); });
}); });
}); });
...@@ -264,7 +266,6 @@ describe('Ci variable modal', () => { ...@@ -264,7 +266,6 @@ describe('Ci variable modal', () => {
}; };
createComponent(mount); createComponent(mount);
store.state.variable = validMaskandKeyVariable; store.state.variable = validMaskandKeyVariable;
store.state.maskableRegex = /^[a-zA-Z0-9_+=/@:.~-]{8,}$/;
}); });
it('does not disable the submit button', () => { it('does not disable the submit button', () => {
......
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