Commit 0c173189 authored by Rajendra Kadam's avatar Rajendra Kadam Committed by Olena Horal-Koretska

Tracking event value spec fixes

parent d830b385
......@@ -204,7 +204,7 @@ Below is a list of supported `data-track-*` attributes:
| `data-track-action` | true | Action the user is taking. Clicks must be prepended with `click` and activations must be prepended with `activate`. For example, focusing a form field would be `activate_form_input` and clicking a button would be `click_button`. Replaces `data-track-event`, which was [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/290962) in GitLab 13.11. |
| `data-track-label` | false | The `label` as described in our [Structured event taxonomy](#structured-event-taxonomy). |
| `data-track-property` | false | The `property` as described in our [Structured event taxonomy](#structured-event-taxonomy). |
| `data-track-value` | false | The `value` as described in our [Structured event taxonomy](#structured-event-taxonomy). If omitted, this is the element's `value` property or an empty string. For checkboxes, the default value is the element's checked attribute or `false` when unchecked. |
| `data-track-value` | false | The `value` as described in our [Structured event taxonomy](#structured-event-taxonomy). If omitted, this is the element's `value` property or `undefined`. For checkboxes, the default value is the element's checked attribute or `0` when unchecked. |
| `data-track-extra` | false | A key-value pairs object passed as a valid JSON string. This is added to the `extra` property in our [`gitlab_standard`](#gitlab_standard) schema. |
| `data-track-context` | false | The `context` as described in our [Structured event taxonomy](#structured-event-taxonomy). |
......@@ -369,7 +369,7 @@ button.addEventListener('click', () => {
property: 'template_preview',
extra: {
templateVariant: 'primary',
valid: true,
valid: 1,
},
});
});
......
......@@ -231,9 +231,9 @@ describe('Tracking', () => {
eventSpy = jest.spyOn(Tracking, 'event');
Tracking.bindDocument('_category_'); // only happens once
setHTMLFixture(`
<input data-track-${term}="click_input1" data-track-label="_label_" 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 data-track-${term}="click_input1" data-track-label="_label_" value=0 />
<input data-track-${term}="click_input2" data-track-value=0 value=0/>
<input type="checkbox" data-track-${term}="toggle_checkbox" value=1 checked/>
<input class="dropdown" data-track-${term}="toggle_dropdown"/>
<div data-track-${term}="nested_event"><span class="nested"></span></div>
<input data-track-bogus="click_bogusinput" data-track-label="_label_" value="_value_"/>
......@@ -248,7 +248,7 @@ describe('Tracking', () => {
expect(eventSpy).toHaveBeenCalledWith('_category_', 'click_input1', {
label: '_label_',
value: '_value_',
value: '0',
});
});
......@@ -262,7 +262,7 @@ describe('Tracking', () => {
document.querySelector(`[data-track-${term}="click_input2"]`).click();
expect(eventSpy).toHaveBeenCalledWith('_category_', 'click_input2', {
value: '_value_override_',
value: '0',
});
});
......@@ -278,7 +278,7 @@ describe('Tracking', () => {
checkbox.click(); // checking
expect(eventSpy).toHaveBeenCalledWith('_category_', 'toggle_checkbox', {
value: '_value_',
value: '1',
});
});
......@@ -341,8 +341,8 @@ describe('Tracking', () => {
beforeEach(() => {
eventSpy = jest.spyOn(Tracking, 'event');
setHTMLFixture(`
<input data-track-${term}="render" data-track-label="label1" value="_value_" data-track-property="_property_"/>
<span data-track-${term}="render" data-track-label="label2" data-track-value="_value_">
<input data-track-${term}="render" data-track-label="label1" value=1 data-track-property="_property_"/>
<span data-track-${term}="render" data-track-label="label2" data-track-value=1>
Something
</span>
<input data-track-${term}="_render_bogus_" data-track-label="label3" value="_value_" data-track-property="_property_"/>
......@@ -357,7 +357,7 @@ describe('Tracking', () => {
'render',
{
label: 'label1',
value: '_value_',
value: '1',
property: '_property_',
},
],
......@@ -366,7 +366,7 @@ describe('Tracking', () => {
'render',
{
label: 'label2',
value: '_value_',
value: '1',
},
],
]);
......
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