Commit 2a62528c authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch 'tracking-event-value' into 'master'

Change default of `value` as a number

See merge request gitlab-org/gitlab!61334
parents 7e327e00 bcc1e117
...@@ -48,7 +48,7 @@ const createEventPayload = (el, { suffix = '' } = {}) => { ...@@ -48,7 +48,7 @@ const createEventPayload = (el, { suffix = '' } = {}) => {
const action = (trackAction || trackEvent) + (suffix || ''); const action = (trackAction || trackEvent) + (suffix || '');
let value = trackValue || el.value || undefined; let value = trackValue || el.value || undefined;
if (el.type === 'checkbox' && !el.checked) value = false; if (el.type === 'checkbox' && !el.checked) value = 0;
let extra = trackExtra; let extra = trackExtra;
......
...@@ -232,7 +232,7 @@ describe('Tracking', () => { ...@@ -232,7 +232,7 @@ describe('Tracking', () => {
Tracking.bindDocument('_category_'); // only happens once Tracking.bindDocument('_category_'); // only happens once
setHTMLFixture(` setHTMLFixture(`
<input data-track-${term}="click_input1" data-track-label="_label_" value="_value_"/> <input data-track-${term}="click_input1" data-track-label="_label_" value="_value_"/>
<input data-track-${term}="click_input2" data-track-value="_value_override_" value="_value_"/> <input data-track-${term}="click_input2" data-track-value="_value_override_" value=0/>
<input type="checkbox" data-track-${term}="toggle_checkbox" value="_value_" checked/> <input type="checkbox" data-track-${term}="toggle_checkbox" value="_value_" checked/>
<input class="dropdown" data-track-${term}="toggle_dropdown"/> <input class="dropdown" data-track-${term}="toggle_dropdown"/>
<div data-track-${term}="nested_event"><span class="nested"></span></div> <div data-track-${term}="nested_event"><span class="nested"></span></div>
...@@ -272,7 +272,7 @@ describe('Tracking', () => { ...@@ -272,7 +272,7 @@ describe('Tracking', () => {
checkbox.click(); // unchecking checkbox.click(); // unchecking
expect(eventSpy).toHaveBeenCalledWith('_category_', 'toggle_checkbox', { expect(eventSpy).toHaveBeenCalledWith('_category_', 'toggle_checkbox', {
value: false, value: 0,
}); });
checkbox.click(); // checking checkbox.click(); // checking
......
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