coveo.analytics 2.30.41 → 2.30.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- export declare const libVersion = "2.30.41";
1
+ export declare const libVersion = "2.30.43";
package/dist/library.cjs CHANGED
@@ -731,7 +731,7 @@ function sha1(bytes) {
731
731
  const v5 = v35('v5', 0x50, sha1);
732
732
  var uuidv5 = v5;
733
733
 
734
- var libVersion = "2.30.41" ;
734
+ var libVersion = "2.30.43" ;
735
735
 
736
736
  var getFormattedLocation = function (location) {
737
737
  return "".concat(location.protocol, "//").concat(location.hostname).concat(location.pathname.indexOf('/') === 0 ? location.pathname : "/".concat(location.pathname)).concat(location.search);
@@ -83048,13 +83048,14 @@ function isReactNative() {
83048
83048
 
83049
83049
  var doNotTrackValues = ['1', 1, 'yes', true];
83050
83050
  function doNotTrack() {
83051
- return (hasNavigator() &&
83052
- [
83053
- navigator.globalPrivacyControl,
83054
- navigator.doNotTrack,
83055
- navigator.msDoNotTrack,
83056
- window.doNotTrack,
83057
- ].some(function (value) { return doNotTrackValues.indexOf(value) !== -1; }));
83051
+ var checks = [];
83052
+ if (hasWindow()) {
83053
+ checks.push(window.doNotTrack);
83054
+ }
83055
+ if (hasNavigator()) {
83056
+ checks.push(navigator.doNotTrack, navigator.msDoNotTrack, navigator.globalPrivacyControl);
83057
+ }
83058
+ return checks.some(function (value) { return doNotTrackValues.indexOf(value) !== -1; });
83058
83059
  }
83059
83060
 
83060
83061
  var donottrack = /*#__PURE__*/Object.freeze({
@@ -598,7 +598,7 @@ function sha1(bytes) {
598
598
  const v5 = v35('v5', 0x50, sha1);
599
599
  var uuidv5 = v5;
600
600
 
601
- const libVersion = "2.30.41" ;
601
+ const libVersion = "2.30.43" ;
602
602
 
603
603
  const getFormattedLocation = (location) => `${location.protocol}//${location.hostname}${location.pathname.indexOf('/') === 0 ? location.pathname : `/${location.pathname}`}${location.search}`;
604
604
 
@@ -1263,13 +1263,14 @@ function isReactNative() {
1263
1263
 
1264
1264
  const doNotTrackValues = ['1', 1, 'yes', true];
1265
1265
  function doNotTrack() {
1266
- return (hasNavigator() &&
1267
- [
1268
- navigator.globalPrivacyControl,
1269
- navigator.doNotTrack,
1270
- navigator.msDoNotTrack,
1271
- window.doNotTrack,
1272
- ].some((value) => doNotTrackValues.indexOf(value) !== -1));
1266
+ const checks = [];
1267
+ if (hasWindow()) {
1268
+ checks.push(window.doNotTrack);
1269
+ }
1270
+ if (hasNavigator()) {
1271
+ checks.push(navigator.doNotTrack, navigator.msDoNotTrack, navigator.globalPrivacyControl);
1272
+ }
1273
+ return checks.some((value) => doNotTrackValues.indexOf(value) !== -1);
1273
1274
  }
1274
1275
 
1275
1276
  const Version = 'v15';
package/dist/library.js CHANGED
@@ -731,7 +731,7 @@ function sha1(bytes) {
731
731
  const v5 = v35('v5', 0x50, sha1);
732
732
  var uuidv5 = v5;
733
733
 
734
- var libVersion = "2.30.41" ;
734
+ var libVersion = "2.30.43" ;
735
735
 
736
736
  var getFormattedLocation = function (location) {
737
737
  return "".concat(location.protocol, "//").concat(location.hostname).concat(location.pathname.indexOf('/') === 0 ? location.pathname : "/".concat(location.pathname)).concat(location.search);
@@ -83048,13 +83048,14 @@ function isReactNative() {
83048
83048
 
83049
83049
  var doNotTrackValues = ['1', 1, 'yes', true];
83050
83050
  function doNotTrack() {
83051
- return (hasNavigator() &&
83052
- [
83053
- navigator.globalPrivacyControl,
83054
- navigator.doNotTrack,
83055
- navigator.msDoNotTrack,
83056
- window.doNotTrack,
83057
- ].some(function (value) { return doNotTrackValues.indexOf(value) !== -1; }));
83051
+ var checks = [];
83052
+ if (hasWindow()) {
83053
+ checks.push(window.doNotTrack);
83054
+ }
83055
+ if (hasNavigator()) {
83056
+ checks.push(navigator.doNotTrack, navigator.msDoNotTrack, navigator.globalPrivacyControl);
83057
+ }
83058
+ return checks.some(function (value) { return doNotTrackValues.indexOf(value) !== -1; });
83058
83059
  }
83059
83060
 
83060
83061
  var donottrack = /*#__PURE__*/Object.freeze({
package/dist/library.mjs CHANGED
@@ -729,7 +729,7 @@ function sha1(bytes) {
729
729
  const v5 = v35('v5', 0x50, sha1);
730
730
  var uuidv5 = v5;
731
731
 
732
- var libVersion = "2.30.41" ;
732
+ var libVersion = "2.30.43" ;
733
733
 
734
734
  var getFormattedLocation = function (location) {
735
735
  return "".concat(location.protocol, "//").concat(location.hostname).concat(location.pathname.indexOf('/') === 0 ? location.pathname : "/".concat(location.pathname)).concat(location.search);
@@ -83046,13 +83046,14 @@ function isReactNative() {
83046
83046
 
83047
83047
  var doNotTrackValues = ['1', 1, 'yes', true];
83048
83048
  function doNotTrack() {
83049
- return (hasNavigator() &&
83050
- [
83051
- navigator.globalPrivacyControl,
83052
- navigator.doNotTrack,
83053
- navigator.msDoNotTrack,
83054
- window.doNotTrack,
83055
- ].some(function (value) { return doNotTrackValues.indexOf(value) !== -1; }));
83049
+ var checks = [];
83050
+ if (hasWindow()) {
83051
+ checks.push(window.doNotTrack);
83052
+ }
83053
+ if (hasNavigator()) {
83054
+ checks.push(navigator.doNotTrack, navigator.msDoNotTrack, navigator.globalPrivacyControl);
83055
+ }
83056
+ return checks.some(function (value) { return doNotTrackValues.indexOf(value) !== -1; });
83056
83057
  }
83057
83058
 
83058
83059
  var donottrack = /*#__PURE__*/Object.freeze({
@@ -667,7 +667,7 @@ const addPageViewToHistory = (pageViewValue) => __awaiter(void 0, void 0, void 0
667
667
  yield store.addElementAsync(historyElement);
668
668
  });
669
669
 
670
- const libVersion = "2.30.41" ;
670
+ const libVersion = "2.30.43" ;
671
671
 
672
672
  const getFormattedLocation = (location) => `${location.protocol}//${location.hostname}${location.pathname.indexOf('/') === 0 ? location.pathname : `/${location.pathname}`}${location.search}`;
673
673
 
@@ -1264,13 +1264,14 @@ function isReactNative() {
1264
1264
 
1265
1265
  const doNotTrackValues = ['1', 1, 'yes', true];
1266
1266
  function doNotTrack() {
1267
- return (hasNavigator() &&
1268
- [
1269
- navigator.globalPrivacyControl,
1270
- navigator.doNotTrack,
1271
- navigator.msDoNotTrack,
1272
- window.doNotTrack,
1273
- ].some((value) => doNotTrackValues.indexOf(value) !== -1));
1267
+ const checks = [];
1268
+ if (hasWindow()) {
1269
+ checks.push(window.doNotTrack);
1270
+ }
1271
+ if (hasNavigator()) {
1272
+ checks.push(navigator.doNotTrack, navigator.msDoNotTrack, navigator.globalPrivacyControl);
1273
+ }
1274
+ return checks.some((value) => doNotTrackValues.indexOf(value) !== -1);
1274
1275
  }
1275
1276
 
1276
1277
  const Version = 'v15';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coveo.analytics",
3
- "version": "2.30.41",
3
+ "version": "2.30.43",
4
4
  "description": "📈 Coveo analytics client (node and browser compatible) ",
5
5
  "main": "dist/library.cjs",
6
6
  "module": "dist/browser.mjs",
@@ -2,6 +2,7 @@ describe('doNotTrack', () => {
2
2
  let doNotTrack: () => boolean;
3
3
  function initModule(
4
4
  hasNav: boolean,
5
+ hasWin: boolean,
5
6
  options?: {
6
7
  navigatorGlobalPrivacyControl?: any;
7
8
  navigatorDoNotTrack?: any;
@@ -12,6 +13,7 @@ describe('doNotTrack', () => {
12
13
  jest.resetModules();
13
14
  jest.mock('./detector', () => ({
14
15
  hasNavigator: () => hasNav,
16
+ hasWindow: () => hasWin,
15
17
  }));
16
18
  if (hasNav) {
17
19
  Object.defineProperty(<any>navigator, 'globalPrivacyControl', {
@@ -32,6 +34,8 @@ describe('doNotTrack', () => {
32
34
  },
33
35
  configurable: true,
34
36
  });
37
+ }
38
+ if (hasWin) {
35
39
  Object.defineProperty(<any>window, 'doNotTrack', {
36
40
  get() {
37
41
  return options!.windowDoNotTrack;
@@ -41,30 +45,30 @@ describe('doNotTrack', () => {
41
45
  }
42
46
  doNotTrack = require('./donottrack').doNotTrack;
43
47
  }
44
- describe('without a Navigator', () => {
48
+ describe('without a Navigator and without window', () => {
45
49
  it('should be false', () => {
46
- initModule(false);
50
+ initModule(false, false);
47
51
 
48
52
  expect(doNotTrack()).toBeFalsy();
49
53
  });
50
54
  });
51
55
  describe('with a Navigator', () => {
52
56
  it('should respect GPC false', () => {
53
- initModule(true, {
57
+ initModule(true, false, {
54
58
  navigatorGlobalPrivacyControl: false,
55
59
  });
56
60
 
57
61
  expect(doNotTrack()).toBeFalsy();
58
62
  });
59
63
  it('should respect GPC true', () => {
60
- initModule(true, {
64
+ initModule(true, false, {
61
65
  navigatorGlobalPrivacyControl: true,
62
66
  });
63
67
 
64
68
  expect(doNotTrack()).toBeTruthy();
65
69
  });
66
70
  it('should respect GPC undefined', () => {
67
- initModule(true, {
71
+ initModule(true, false, {
68
72
  navigatorGlobalPrivacyControl: undefined,
69
73
  });
70
74
 
@@ -73,7 +77,7 @@ describe('doNotTrack', () => {
73
77
 
74
78
  [true, 'yes', '1'].forEach((value) => {
75
79
  it('should fallback on `navigator.doNotTrack`: ' + JSON.stringify(value), () => {
76
- initModule(true, {
80
+ initModule(true, false, {
77
81
  navigatorDoNotTrack: value,
78
82
  });
79
83
 
@@ -81,23 +85,16 @@ describe('doNotTrack', () => {
81
85
  });
82
86
 
83
87
  it('should fallback on `navigator.msDoNotTrack`: ' + JSON.stringify(value), () => {
84
- initModule(true, {
88
+ initModule(true, false, {
85
89
  navigatorMsDoNotTrack: value,
86
90
  });
87
91
  expect(doNotTrack()).toBeTruthy();
88
92
  });
89
-
90
- it('should fallback on `window.doNotTrack`: ' + JSON.stringify(value), () => {
91
- initModule(true, {
92
- windowDoNotTrack: value,
93
- });
94
- expect(doNotTrack()).toBeTruthy();
95
- });
96
93
  });
97
94
 
98
95
  [false, 'no', '0', 'unspecified'].forEach((value) => {
99
96
  it('should fallback on `navigator.doNotTrack`: ' + JSON.stringify(value), () => {
100
- initModule(true, {
97
+ initModule(true, false, {
101
98
  navigatorDoNotTrack: value,
102
99
  });
103
100
 
@@ -105,18 +102,43 @@ describe('doNotTrack', () => {
105
102
  });
106
103
 
107
104
  it('should fallback on `navigator.msDoNotTrack`: ' + JSON.stringify(value), () => {
108
- initModule(true, {
105
+ initModule(true, false, {
109
106
  navigatorMsDoNotTrack: value,
110
107
  });
111
108
  expect(doNotTrack()).toBeFalsy();
112
109
  });
110
+ });
111
+ });
112
+
113
+ describe('with a Window', () => {
114
+ [true, 'yes', '1'].forEach((value) => {
115
+ it('should fallback on `window.doNotTrack`: ' + JSON.stringify(value), () => {
116
+ initModule(false, true, {
117
+ windowDoNotTrack: value,
118
+ });
119
+ expect(doNotTrack()).toBeTruthy();
120
+ });
121
+ });
113
122
 
123
+ [false, 'no', '0', 'unspecified'].forEach((value) => {
114
124
  it('should fallback on `window.doNotTrack`: ' + JSON.stringify(value), () => {
115
- initModule(true, {
125
+ initModule(false, true, {
116
126
  windowDoNotTrack: value,
117
127
  });
118
128
  expect(doNotTrack()).toBeFalsy();
119
129
  });
120
130
  });
121
131
  });
132
+
133
+ describe('with a Navigator and a Window', () => {
134
+ it('should fallback on `window.doNotTrack` if all navigator properties are falsy', () => {
135
+ initModule(true, true, {
136
+ navigatorDoNotTrack: false,
137
+ navigatorGlobalPrivacyControl: undefined,
138
+ navigatorMsDoNotTrack: '0',
139
+ windowDoNotTrack: 1,
140
+ });
141
+ expect(doNotTrack()).toBeTruthy();
142
+ });
143
+ });
122
144
  });
package/src/donottrack.ts CHANGED
@@ -1,23 +1,22 @@
1
1
  // Read the Mozilla Do Not Track Field Guide
2
2
  // (https://developer.mozilla.org/en-US/docs/Web/Security/Do_not_track_field_guide),
3
3
  // for information on how to use the donottrack
4
- // gathering data of actions of an user as long as it is not associated to the
4
+ // gathering data of actions of a user as long as it is not associated to the
5
5
  // identity of that user, doNotTrack is not enabled here.
6
6
 
7
- import {hasNavigator} from './detector';
7
+ import {hasNavigator, hasWindow} from './detector';
8
8
 
9
9
  const doNotTrackValues = ['1', 1, 'yes', true];
10
10
 
11
11
  export function doNotTrack(): boolean {
12
- return (
13
- hasNavigator() &&
14
- [
15
- (<any>navigator).globalPrivacyControl,
16
- (<any>navigator).doNotTrack,
17
- (<any>navigator).msDoNotTrack,
18
- (<any>window).doNotTrack,
19
- ].some((value) => doNotTrackValues.indexOf(value) !== -1)
20
- );
12
+ const checks: any[] = [];
13
+ if (hasWindow()) {
14
+ checks.push((<any>window).doNotTrack);
15
+ }
16
+ if (hasNavigator()) {
17
+ checks.push((<any>navigator).doNotTrack, (<any>navigator).msDoNotTrack, (<any>navigator).globalPrivacyControl);
18
+ }
19
+ return checks.some((value) => doNotTrackValues.indexOf(value) !== -1);
21
20
  }
22
21
 
23
22
  export default doNotTrack;