Открыть боковую панель
nt_test121
nt_project_9da4a5yt9x4b
Коммиты
ca9598c1
Коммит
ca9598c1
создал
Авг 23, 2019
по автору
Jeremy Jackson
Зафиксировано автором
Kushal Pandya
Авг 23, 2019
Просмотр файлов
Add logic for respecting browser DNT setting
владелец
e12f7fe0
Изменения
2
Скрыть пробелы
Построчно
Рядом
app/assets/javascripts/tracking.js
Просмотр файла @
ca9598c1
...
...
@@ -15,8 +15,14 @@ const extractData = (el, opts = {}) => {
};
export
default
class
Tracking
{
static
trackable
()
{
return
!
[
'
1
'
,
'
yes
'
].
includes
(
window
.
doNotTrack
||
navigator
.
doNotTrack
||
navigator
.
msDoNotTrack
,
);
}
static
enabled
()
{
return
typeof
window
.
snowplow
===
'
function
'
;
return
typeof
window
.
snowplow
===
'
function
'
&&
this
.
trackable
()
;
}
static
event
(
category
=
document
.
body
.
dataset
.
page
,
event
=
'
generic
'
,
data
=
{})
{
...
...
spec/frontend/tracking_spec.js
Просмотр файла @
ca9598c1
...
...
@@ -15,6 +15,12 @@ describe('Tracking', () => {
snowplowSpy
=
jest
.
spyOn
(
window
,
'
snowplow
'
);
});
afterEach
(()
=>
{
window
.
doNotTrack
=
undefined
;
navigator
.
doNotTrack
=
undefined
;
navigator
.
msDoNotTrack
=
undefined
;
});
it
(
'
tracks to snowplow (our current tracking system)
'
,
()
=>
{
Tracking
.
event
(
'
_category_
'
,
'
_eventName_
'
,
{
label
:
'
_label_
'
});
...
...
@@ -31,6 +37,27 @@ describe('Tracking', () => {
expect
(
snowplowSpy
).
not
.
toHaveBeenCalled
();
});
it
(
'
skips tracking if the user does not want to be tracked (general spec)
'
,
()
=>
{
window
.
doNotTrack
=
'
1
'
;
Tracking
.
event
(
'
_category_
'
,
'
_eventName_
'
);
expect
(
snowplowSpy
).
not
.
toHaveBeenCalled
();
});
it
(
'
skips tracking if the user does not want to be tracked (firefox legacy)
'
,
()
=>
{
navigator
.
doNotTrack
=
'
yes
'
;
Tracking
.
event
(
'
_category_
'
,
'
_eventName_
'
);
expect
(
snowplowSpy
).
not
.
toHaveBeenCalled
();
});
it
(
'
skips tracking if the user does not want to be tracked (IE legacy)
'
,
()
=>
{
navigator
.
msDoNotTrack
=
'
1
'
;
Tracking
.
event
(
'
_category_
'
,
'
_eventName_
'
);
expect
(
snowplowSpy
).
not
.
toHaveBeenCalled
();
});
});
describe
(
'
tracking interface events
'
,
()
=>
{
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать