@ninetailed/experience.js-plugin-google-analytics 1.0.1-beta.0

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.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # google-analytics
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build google-analytics` to build the library.
8
+
9
+ ## Running unit tests
10
+
11
+ Run `nx test google-analytics` to execute the unit tests via [Jest](https://jestjs.io).
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './lib/google-analytics';
package/index.esm.js ADDED
@@ -0,0 +1,1081 @@
1
+ import googleAnalytics from '@analytics/google-analytics';
2
+ import template from 'lodash/template';
3
+
4
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
5
+
6
+ var check = function (it) {
7
+ return it && it.Math == Math && it;
8
+ };
9
+
10
+ // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
11
+ var global$l =
12
+ // eslint-disable-next-line es/no-global-this -- safe
13
+ check(typeof globalThis == 'object' && globalThis) ||
14
+ check(typeof window == 'object' && window) ||
15
+ // eslint-disable-next-line no-restricted-globals -- safe
16
+ check(typeof self == 'object' && self) ||
17
+ check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
18
+ // eslint-disable-next-line no-new-func -- fallback
19
+ (function () { return this; })() || Function('return this')();
20
+
21
+ var objectGetOwnPropertyDescriptor = {};
22
+
23
+ var fails$8 = function (exec) {
24
+ try {
25
+ return !!exec();
26
+ } catch (error) {
27
+ return true;
28
+ }
29
+ };
30
+
31
+ var fails$7 = fails$8;
32
+
33
+ // Detect IE8's incomplete defineProperty implementation
34
+ var descriptors = !fails$7(function () {
35
+ // eslint-disable-next-line es/no-object-defineproperty -- required for testing
36
+ return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
37
+ });
38
+
39
+ var fails$6 = fails$8;
40
+
41
+ var functionBindNative = !fails$6(function () {
42
+ var test = (function () { /* empty */ }).bind();
43
+ // eslint-disable-next-line no-prototype-builtins -- safe
44
+ return typeof test != 'function' || test.hasOwnProperty('prototype');
45
+ });
46
+
47
+ var NATIVE_BIND$1 = functionBindNative;
48
+
49
+ var call$5 = Function.prototype.call;
50
+
51
+ var functionCall = NATIVE_BIND$1 ? call$5.bind(call$5) : function () {
52
+ return call$5.apply(call$5, arguments);
53
+ };
54
+
55
+ var objectPropertyIsEnumerable = {};
56
+
57
+ var $propertyIsEnumerable = {}.propertyIsEnumerable;
58
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
59
+ var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
60
+
61
+ // Nashorn ~ JDK8 bug
62
+ var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
63
+
64
+ // `Object.prototype.propertyIsEnumerable` method implementation
65
+ // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
66
+ objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
67
+ var descriptor = getOwnPropertyDescriptor$1(this, V);
68
+ return !!descriptor && descriptor.enumerable;
69
+ } : $propertyIsEnumerable;
70
+
71
+ var createPropertyDescriptor$2 = function (bitmap, value) {
72
+ return {
73
+ enumerable: !(bitmap & 1),
74
+ configurable: !(bitmap & 2),
75
+ writable: !(bitmap & 4),
76
+ value: value
77
+ };
78
+ };
79
+
80
+ var NATIVE_BIND = functionBindNative;
81
+
82
+ var FunctionPrototype$1 = Function.prototype;
83
+ var bind = FunctionPrototype$1.bind;
84
+ var call$4 = FunctionPrototype$1.call;
85
+ var uncurryThis$a = NATIVE_BIND && bind.bind(call$4, call$4);
86
+
87
+ var functionUncurryThis = NATIVE_BIND ? function (fn) {
88
+ return fn && uncurryThis$a(fn);
89
+ } : function (fn) {
90
+ return fn && function () {
91
+ return call$4.apply(fn, arguments);
92
+ };
93
+ };
94
+
95
+ var uncurryThis$9 = functionUncurryThis;
96
+
97
+ var toString$1 = uncurryThis$9({}.toString);
98
+ var stringSlice = uncurryThis$9(''.slice);
99
+
100
+ var classofRaw = function (it) {
101
+ return stringSlice(toString$1(it), 8, -1);
102
+ };
103
+
104
+ var global$k = global$l;
105
+ var uncurryThis$8 = functionUncurryThis;
106
+ var fails$5 = fails$8;
107
+ var classof = classofRaw;
108
+
109
+ var Object$3 = global$k.Object;
110
+ var split = uncurryThis$8(''.split);
111
+
112
+ // fallback for non-array-like ES3 and non-enumerable old V8 strings
113
+ var indexedObject = fails$5(function () {
114
+ // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
115
+ // eslint-disable-next-line no-prototype-builtins -- safe
116
+ return !Object$3('z').propertyIsEnumerable(0);
117
+ }) ? function (it) {
118
+ return classof(it) == 'String' ? split(it, '') : Object$3(it);
119
+ } : Object$3;
120
+
121
+ var global$j = global$l;
122
+
123
+ var TypeError$6 = global$j.TypeError;
124
+
125
+ // `RequireObjectCoercible` abstract operation
126
+ // https://tc39.es/ecma262/#sec-requireobjectcoercible
127
+ var requireObjectCoercible$2 = function (it) {
128
+ if (it == undefined) throw TypeError$6("Can't call method on " + it);
129
+ return it;
130
+ };
131
+
132
+ // toObject with fallback for non-array-like ES3 strings
133
+ var IndexedObject$1 = indexedObject;
134
+ var requireObjectCoercible$1 = requireObjectCoercible$2;
135
+
136
+ var toIndexedObject$3 = function (it) {
137
+ return IndexedObject$1(requireObjectCoercible$1(it));
138
+ };
139
+
140
+ // `IsCallable` abstract operation
141
+ // https://tc39.es/ecma262/#sec-iscallable
142
+ var isCallable$9 = function (argument) {
143
+ return typeof argument == 'function';
144
+ };
145
+
146
+ var isCallable$8 = isCallable$9;
147
+
148
+ var isObject$5 = function (it) {
149
+ return typeof it == 'object' ? it !== null : isCallable$8(it);
150
+ };
151
+
152
+ var global$i = global$l;
153
+ var isCallable$7 = isCallable$9;
154
+
155
+ var aFunction = function (argument) {
156
+ return isCallable$7(argument) ? argument : undefined;
157
+ };
158
+
159
+ var getBuiltIn$3 = function (namespace, method) {
160
+ return arguments.length < 2 ? aFunction(global$i[namespace]) : global$i[namespace] && global$i[namespace][method];
161
+ };
162
+
163
+ var uncurryThis$7 = functionUncurryThis;
164
+
165
+ var objectIsPrototypeOf = uncurryThis$7({}.isPrototypeOf);
166
+
167
+ var getBuiltIn$2 = getBuiltIn$3;
168
+
169
+ var engineUserAgent = getBuiltIn$2('navigator', 'userAgent') || '';
170
+
171
+ var global$h = global$l;
172
+ var userAgent = engineUserAgent;
173
+
174
+ var process = global$h.process;
175
+ var Deno = global$h.Deno;
176
+ var versions = process && process.versions || Deno && Deno.version;
177
+ var v8 = versions && versions.v8;
178
+ var match, version;
179
+
180
+ if (v8) {
181
+ match = v8.split('.');
182
+ // in old Chrome, versions of V8 isn't V8 = Chrome / 10
183
+ // but their correct versions are not interesting for us
184
+ version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
185
+ }
186
+
187
+ // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
188
+ // so check `userAgent` even if `.v8` exists, but 0
189
+ if (!version && userAgent) {
190
+ match = userAgent.match(/Edge\/(\d+)/);
191
+ if (!match || match[1] >= 74) {
192
+ match = userAgent.match(/Chrome\/(\d+)/);
193
+ if (match) version = +match[1];
194
+ }
195
+ }
196
+
197
+ var engineV8Version = version;
198
+
199
+ /* eslint-disable es/no-symbol -- required for testing */
200
+
201
+ var V8_VERSION = engineV8Version;
202
+ var fails$4 = fails$8;
203
+
204
+ // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
205
+ var nativeSymbol = !!Object.getOwnPropertySymbols && !fails$4(function () {
206
+ var symbol = Symbol();
207
+ // Chrome 38 Symbol has incorrect toString conversion
208
+ // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
209
+ return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
210
+ // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
211
+ !Symbol.sham && V8_VERSION && V8_VERSION < 41;
212
+ });
213
+
214
+ /* eslint-disable es/no-symbol -- required for testing */
215
+
216
+ var NATIVE_SYMBOL$1 = nativeSymbol;
217
+
218
+ var useSymbolAsUid = NATIVE_SYMBOL$1
219
+ && !Symbol.sham
220
+ && typeof Symbol.iterator == 'symbol';
221
+
222
+ var global$g = global$l;
223
+ var getBuiltIn$1 = getBuiltIn$3;
224
+ var isCallable$6 = isCallable$9;
225
+ var isPrototypeOf = objectIsPrototypeOf;
226
+ var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
227
+
228
+ var Object$2 = global$g.Object;
229
+
230
+ var isSymbol$2 = USE_SYMBOL_AS_UID$1 ? function (it) {
231
+ return typeof it == 'symbol';
232
+ } : function (it) {
233
+ var $Symbol = getBuiltIn$1('Symbol');
234
+ return isCallable$6($Symbol) && isPrototypeOf($Symbol.prototype, Object$2(it));
235
+ };
236
+
237
+ var global$f = global$l;
238
+
239
+ var String$2 = global$f.String;
240
+
241
+ var tryToString$1 = function (argument) {
242
+ try {
243
+ return String$2(argument);
244
+ } catch (error) {
245
+ return 'Object';
246
+ }
247
+ };
248
+
249
+ var global$e = global$l;
250
+ var isCallable$5 = isCallable$9;
251
+ var tryToString = tryToString$1;
252
+
253
+ var TypeError$5 = global$e.TypeError;
254
+
255
+ // `Assert: IsCallable(argument) is true`
256
+ var aCallable$1 = function (argument) {
257
+ if (isCallable$5(argument)) return argument;
258
+ throw TypeError$5(tryToString(argument) + ' is not a function');
259
+ };
260
+
261
+ var aCallable = aCallable$1;
262
+
263
+ // `GetMethod` abstract operation
264
+ // https://tc39.es/ecma262/#sec-getmethod
265
+ var getMethod$1 = function (V, P) {
266
+ var func = V[P];
267
+ return func == null ? undefined : aCallable(func);
268
+ };
269
+
270
+ var global$d = global$l;
271
+ var call$3 = functionCall;
272
+ var isCallable$4 = isCallable$9;
273
+ var isObject$4 = isObject$5;
274
+
275
+ var TypeError$4 = global$d.TypeError;
276
+
277
+ // `OrdinaryToPrimitive` abstract operation
278
+ // https://tc39.es/ecma262/#sec-ordinarytoprimitive
279
+ var ordinaryToPrimitive$1 = function (input, pref) {
280
+ var fn, val;
281
+ if (pref === 'string' && isCallable$4(fn = input.toString) && !isObject$4(val = call$3(fn, input))) return val;
282
+ if (isCallable$4(fn = input.valueOf) && !isObject$4(val = call$3(fn, input))) return val;
283
+ if (pref !== 'string' && isCallable$4(fn = input.toString) && !isObject$4(val = call$3(fn, input))) return val;
284
+ throw TypeError$4("Can't convert object to primitive value");
285
+ };
286
+
287
+ var shared$3 = {exports: {}};
288
+
289
+ var global$c = global$l;
290
+
291
+ // eslint-disable-next-line es/no-object-defineproperty -- safe
292
+ var defineProperty$1 = Object.defineProperty;
293
+
294
+ var setGlobal$3 = function (key, value) {
295
+ try {
296
+ defineProperty$1(global$c, key, { value: value, configurable: true, writable: true });
297
+ } catch (error) {
298
+ global$c[key] = value;
299
+ } return value;
300
+ };
301
+
302
+ var global$b = global$l;
303
+ var setGlobal$2 = setGlobal$3;
304
+
305
+ var SHARED = '__core-js_shared__';
306
+ var store$3 = global$b[SHARED] || setGlobal$2(SHARED, {});
307
+
308
+ var sharedStore = store$3;
309
+
310
+ var store$2 = sharedStore;
311
+
312
+ (shared$3.exports = function (key, value) {
313
+ return store$2[key] || (store$2[key] = value !== undefined ? value : {});
314
+ })('versions', []).push({
315
+ version: '3.21.1',
316
+ mode: 'global',
317
+ copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
318
+ license: 'https://github.com/zloirock/core-js/blob/v3.21.1/LICENSE',
319
+ source: 'https://github.com/zloirock/core-js'
320
+ });
321
+
322
+ var global$a = global$l;
323
+ var requireObjectCoercible = requireObjectCoercible$2;
324
+
325
+ var Object$1 = global$a.Object;
326
+
327
+ // `ToObject` abstract operation
328
+ // https://tc39.es/ecma262/#sec-toobject
329
+ var toObject$2 = function (argument) {
330
+ return Object$1(requireObjectCoercible(argument));
331
+ };
332
+
333
+ var uncurryThis$6 = functionUncurryThis;
334
+ var toObject$1 = toObject$2;
335
+
336
+ var hasOwnProperty = uncurryThis$6({}.hasOwnProperty);
337
+
338
+ // `HasOwnProperty` abstract operation
339
+ // https://tc39.es/ecma262/#sec-hasownproperty
340
+ var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
341
+ return hasOwnProperty(toObject$1(it), key);
342
+ };
343
+
344
+ var uncurryThis$5 = functionUncurryThis;
345
+
346
+ var id = 0;
347
+ var postfix = Math.random();
348
+ var toString = uncurryThis$5(1.0.toString);
349
+
350
+ var uid$2 = function (key) {
351
+ return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
352
+ };
353
+
354
+ var global$9 = global$l;
355
+ var shared$2 = shared$3.exports;
356
+ var hasOwn$6 = hasOwnProperty_1;
357
+ var uid$1 = uid$2;
358
+ var NATIVE_SYMBOL = nativeSymbol;
359
+ var USE_SYMBOL_AS_UID = useSymbolAsUid;
360
+
361
+ var WellKnownSymbolsStore = shared$2('wks');
362
+ var Symbol$1 = global$9.Symbol;
363
+ var symbolFor = Symbol$1 && Symbol$1['for'];
364
+ var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
365
+
366
+ var wellKnownSymbol$1 = function (name) {
367
+ if (!hasOwn$6(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
368
+ var description = 'Symbol.' + name;
369
+ if (NATIVE_SYMBOL && hasOwn$6(Symbol$1, name)) {
370
+ WellKnownSymbolsStore[name] = Symbol$1[name];
371
+ } else if (USE_SYMBOL_AS_UID && symbolFor) {
372
+ WellKnownSymbolsStore[name] = symbolFor(description);
373
+ } else {
374
+ WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
375
+ }
376
+ } return WellKnownSymbolsStore[name];
377
+ };
378
+
379
+ var global$8 = global$l;
380
+ var call$2 = functionCall;
381
+ var isObject$3 = isObject$5;
382
+ var isSymbol$1 = isSymbol$2;
383
+ var getMethod = getMethod$1;
384
+ var ordinaryToPrimitive = ordinaryToPrimitive$1;
385
+ var wellKnownSymbol = wellKnownSymbol$1;
386
+
387
+ var TypeError$3 = global$8.TypeError;
388
+ var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
389
+
390
+ // `ToPrimitive` abstract operation
391
+ // https://tc39.es/ecma262/#sec-toprimitive
392
+ var toPrimitive$1 = function (input, pref) {
393
+ if (!isObject$3(input) || isSymbol$1(input)) return input;
394
+ var exoticToPrim = getMethod(input, TO_PRIMITIVE);
395
+ var result;
396
+ if (exoticToPrim) {
397
+ if (pref === undefined) pref = 'default';
398
+ result = call$2(exoticToPrim, input, pref);
399
+ if (!isObject$3(result) || isSymbol$1(result)) return result;
400
+ throw TypeError$3("Can't convert object to primitive value");
401
+ }
402
+ if (pref === undefined) pref = 'number';
403
+ return ordinaryToPrimitive(input, pref);
404
+ };
405
+
406
+ var toPrimitive = toPrimitive$1;
407
+ var isSymbol = isSymbol$2;
408
+
409
+ // `ToPropertyKey` abstract operation
410
+ // https://tc39.es/ecma262/#sec-topropertykey
411
+ var toPropertyKey$2 = function (argument) {
412
+ var key = toPrimitive(argument, 'string');
413
+ return isSymbol(key) ? key : key + '';
414
+ };
415
+
416
+ var global$7 = global$l;
417
+ var isObject$2 = isObject$5;
418
+
419
+ var document = global$7.document;
420
+ // typeof document.createElement is 'object' in old IE
421
+ var EXISTS$1 = isObject$2(document) && isObject$2(document.createElement);
422
+
423
+ var documentCreateElement = function (it) {
424
+ return EXISTS$1 ? document.createElement(it) : {};
425
+ };
426
+
427
+ var DESCRIPTORS$6 = descriptors;
428
+ var fails$3 = fails$8;
429
+ var createElement = documentCreateElement;
430
+
431
+ // Thanks to IE8 for its funny defineProperty
432
+ var ie8DomDefine = !DESCRIPTORS$6 && !fails$3(function () {
433
+ // eslint-disable-next-line es/no-object-defineproperty -- required for testing
434
+ return Object.defineProperty(createElement('div'), 'a', {
435
+ get: function () { return 7; }
436
+ }).a != 7;
437
+ });
438
+
439
+ var DESCRIPTORS$5 = descriptors;
440
+ var call$1 = functionCall;
441
+ var propertyIsEnumerableModule$1 = objectPropertyIsEnumerable;
442
+ var createPropertyDescriptor$1 = createPropertyDescriptor$2;
443
+ var toIndexedObject$2 = toIndexedObject$3;
444
+ var toPropertyKey$1 = toPropertyKey$2;
445
+ var hasOwn$5 = hasOwnProperty_1;
446
+ var IE8_DOM_DEFINE$1 = ie8DomDefine;
447
+
448
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
449
+ var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
450
+
451
+ // `Object.getOwnPropertyDescriptor` method
452
+ // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
453
+ objectGetOwnPropertyDescriptor.f = DESCRIPTORS$5 ? $getOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
454
+ O = toIndexedObject$2(O);
455
+ P = toPropertyKey$1(P);
456
+ if (IE8_DOM_DEFINE$1) try {
457
+ return $getOwnPropertyDescriptor$1(O, P);
458
+ } catch (error) { /* empty */ }
459
+ if (hasOwn$5(O, P)) return createPropertyDescriptor$1(!call$1(propertyIsEnumerableModule$1.f, O, P), O[P]);
460
+ };
461
+
462
+ var objectDefineProperty = {};
463
+
464
+ var DESCRIPTORS$4 = descriptors;
465
+ var fails$2 = fails$8;
466
+
467
+ // V8 ~ Chrome 36-
468
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3334
469
+ var v8PrototypeDefineBug = DESCRIPTORS$4 && fails$2(function () {
470
+ // eslint-disable-next-line es/no-object-defineproperty -- required for testing
471
+ return Object.defineProperty(function () { /* empty */ }, 'prototype', {
472
+ value: 42,
473
+ writable: false
474
+ }).prototype != 42;
475
+ });
476
+
477
+ var global$6 = global$l;
478
+ var isObject$1 = isObject$5;
479
+
480
+ var String$1 = global$6.String;
481
+ var TypeError$2 = global$6.TypeError;
482
+
483
+ // `Assert: Type(argument) is Object`
484
+ var anObject$2 = function (argument) {
485
+ if (isObject$1(argument)) return argument;
486
+ throw TypeError$2(String$1(argument) + ' is not an object');
487
+ };
488
+
489
+ var global$5 = global$l;
490
+ var DESCRIPTORS$3 = descriptors;
491
+ var IE8_DOM_DEFINE = ie8DomDefine;
492
+ var V8_PROTOTYPE_DEFINE_BUG = v8PrototypeDefineBug;
493
+ var anObject$1 = anObject$2;
494
+ var toPropertyKey = toPropertyKey$2;
495
+
496
+ var TypeError$1 = global$5.TypeError;
497
+ // eslint-disable-next-line es/no-object-defineproperty -- safe
498
+ var $defineProperty = Object.defineProperty;
499
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
500
+ var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
501
+ var ENUMERABLE = 'enumerable';
502
+ var CONFIGURABLE$1 = 'configurable';
503
+ var WRITABLE = 'writable';
504
+
505
+ // `Object.defineProperty` method
506
+ // https://tc39.es/ecma262/#sec-object.defineproperty
507
+ objectDefineProperty.f = DESCRIPTORS$3 ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
508
+ anObject$1(O);
509
+ P = toPropertyKey(P);
510
+ anObject$1(Attributes);
511
+ if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
512
+ var current = $getOwnPropertyDescriptor(O, P);
513
+ if (current && current[WRITABLE]) {
514
+ O[P] = Attributes.value;
515
+ Attributes = {
516
+ configurable: CONFIGURABLE$1 in Attributes ? Attributes[CONFIGURABLE$1] : current[CONFIGURABLE$1],
517
+ enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
518
+ writable: false
519
+ };
520
+ }
521
+ } return $defineProperty(O, P, Attributes);
522
+ } : $defineProperty : function defineProperty(O, P, Attributes) {
523
+ anObject$1(O);
524
+ P = toPropertyKey(P);
525
+ anObject$1(Attributes);
526
+ if (IE8_DOM_DEFINE) try {
527
+ return $defineProperty(O, P, Attributes);
528
+ } catch (error) { /* empty */ }
529
+ if ('get' in Attributes || 'set' in Attributes) throw TypeError$1('Accessors not supported');
530
+ if ('value' in Attributes) O[P] = Attributes.value;
531
+ return O;
532
+ };
533
+
534
+ var DESCRIPTORS$2 = descriptors;
535
+ var definePropertyModule$1 = objectDefineProperty;
536
+ var createPropertyDescriptor = createPropertyDescriptor$2;
537
+
538
+ var createNonEnumerableProperty$3 = DESCRIPTORS$2 ? function (object, key, value) {
539
+ return definePropertyModule$1.f(object, key, createPropertyDescriptor(1, value));
540
+ } : function (object, key, value) {
541
+ object[key] = value;
542
+ return object;
543
+ };
544
+
545
+ var redefine$1 = {exports: {}};
546
+
547
+ var uncurryThis$4 = functionUncurryThis;
548
+ var isCallable$3 = isCallable$9;
549
+ var store$1 = sharedStore;
550
+
551
+ var functionToString = uncurryThis$4(Function.toString);
552
+
553
+ // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
554
+ if (!isCallable$3(store$1.inspectSource)) {
555
+ store$1.inspectSource = function (it) {
556
+ return functionToString(it);
557
+ };
558
+ }
559
+
560
+ var inspectSource$2 = store$1.inspectSource;
561
+
562
+ var global$4 = global$l;
563
+ var isCallable$2 = isCallable$9;
564
+ var inspectSource$1 = inspectSource$2;
565
+
566
+ var WeakMap$1 = global$4.WeakMap;
567
+
568
+ var nativeWeakMap = isCallable$2(WeakMap$1) && /native code/.test(inspectSource$1(WeakMap$1));
569
+
570
+ var shared$1 = shared$3.exports;
571
+ var uid = uid$2;
572
+
573
+ var keys = shared$1('keys');
574
+
575
+ var sharedKey$1 = function (key) {
576
+ return keys[key] || (keys[key] = uid(key));
577
+ };
578
+
579
+ var hiddenKeys$3 = {};
580
+
581
+ var NATIVE_WEAK_MAP = nativeWeakMap;
582
+ var global$3 = global$l;
583
+ var uncurryThis$3 = functionUncurryThis;
584
+ var isObject = isObject$5;
585
+ var createNonEnumerableProperty$2 = createNonEnumerableProperty$3;
586
+ var hasOwn$4 = hasOwnProperty_1;
587
+ var shared = sharedStore;
588
+ var sharedKey = sharedKey$1;
589
+ var hiddenKeys$2 = hiddenKeys$3;
590
+
591
+ var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
592
+ var TypeError = global$3.TypeError;
593
+ var WeakMap = global$3.WeakMap;
594
+ var set, get, has;
595
+
596
+ var enforce = function (it) {
597
+ return has(it) ? get(it) : set(it, {});
598
+ };
599
+
600
+ var getterFor = function (TYPE) {
601
+ return function (it) {
602
+ var state;
603
+ if (!isObject(it) || (state = get(it)).type !== TYPE) {
604
+ throw TypeError('Incompatible receiver, ' + TYPE + ' required');
605
+ } return state;
606
+ };
607
+ };
608
+
609
+ if (NATIVE_WEAK_MAP || shared.state) {
610
+ var store = shared.state || (shared.state = new WeakMap());
611
+ var wmget = uncurryThis$3(store.get);
612
+ var wmhas = uncurryThis$3(store.has);
613
+ var wmset = uncurryThis$3(store.set);
614
+ set = function (it, metadata) {
615
+ if (wmhas(store, it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
616
+ metadata.facade = it;
617
+ wmset(store, it, metadata);
618
+ return metadata;
619
+ };
620
+ get = function (it) {
621
+ return wmget(store, it) || {};
622
+ };
623
+ has = function (it) {
624
+ return wmhas(store, it);
625
+ };
626
+ } else {
627
+ var STATE = sharedKey('state');
628
+ hiddenKeys$2[STATE] = true;
629
+ set = function (it, metadata) {
630
+ if (hasOwn$4(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
631
+ metadata.facade = it;
632
+ createNonEnumerableProperty$2(it, STATE, metadata);
633
+ return metadata;
634
+ };
635
+ get = function (it) {
636
+ return hasOwn$4(it, STATE) ? it[STATE] : {};
637
+ };
638
+ has = function (it) {
639
+ return hasOwn$4(it, STATE);
640
+ };
641
+ }
642
+
643
+ var internalState = {
644
+ set: set,
645
+ get: get,
646
+ has: has,
647
+ enforce: enforce,
648
+ getterFor: getterFor
649
+ };
650
+
651
+ var DESCRIPTORS$1 = descriptors;
652
+ var hasOwn$3 = hasOwnProperty_1;
653
+
654
+ var FunctionPrototype = Function.prototype;
655
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
656
+ var getDescriptor = DESCRIPTORS$1 && Object.getOwnPropertyDescriptor;
657
+
658
+ var EXISTS = hasOwn$3(FunctionPrototype, 'name');
659
+ // additional protection from minified / mangled / dropped function names
660
+ var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
661
+ var CONFIGURABLE = EXISTS && (!DESCRIPTORS$1 || (DESCRIPTORS$1 && getDescriptor(FunctionPrototype, 'name').configurable));
662
+
663
+ var functionName = {
664
+ EXISTS: EXISTS,
665
+ PROPER: PROPER,
666
+ CONFIGURABLE: CONFIGURABLE
667
+ };
668
+
669
+ var global$2 = global$l;
670
+ var isCallable$1 = isCallable$9;
671
+ var hasOwn$2 = hasOwnProperty_1;
672
+ var createNonEnumerableProperty$1 = createNonEnumerableProperty$3;
673
+ var setGlobal$1 = setGlobal$3;
674
+ var inspectSource = inspectSource$2;
675
+ var InternalStateModule = internalState;
676
+ var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
677
+
678
+ var getInternalState = InternalStateModule.get;
679
+ var enforceInternalState = InternalStateModule.enforce;
680
+ var TEMPLATE = String(String).split('String');
681
+
682
+ (redefine$1.exports = function (O, key, value, options) {
683
+ var unsafe = options ? !!options.unsafe : false;
684
+ var simple = options ? !!options.enumerable : false;
685
+ var noTargetGet = options ? !!options.noTargetGet : false;
686
+ var name = options && options.name !== undefined ? options.name : key;
687
+ var state;
688
+ if (isCallable$1(value)) {
689
+ if (String(name).slice(0, 7) === 'Symbol(') {
690
+ name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']';
691
+ }
692
+ if (!hasOwn$2(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
693
+ createNonEnumerableProperty$1(value, 'name', name);
694
+ }
695
+ state = enforceInternalState(value);
696
+ if (!state.source) {
697
+ state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
698
+ }
699
+ }
700
+ if (O === global$2) {
701
+ if (simple) O[key] = value;
702
+ else setGlobal$1(key, value);
703
+ return;
704
+ } else if (!unsafe) {
705
+ delete O[key];
706
+ } else if (!noTargetGet && O[key]) {
707
+ simple = true;
708
+ }
709
+ if (simple) O[key] = value;
710
+ else createNonEnumerableProperty$1(O, key, value);
711
+ // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
712
+ })(Function.prototype, 'toString', function toString() {
713
+ return isCallable$1(this) && getInternalState(this).source || inspectSource(this);
714
+ });
715
+
716
+ var objectGetOwnPropertyNames = {};
717
+
718
+ var ceil = Math.ceil;
719
+ var floor = Math.floor;
720
+
721
+ // `ToIntegerOrInfinity` abstract operation
722
+ // https://tc39.es/ecma262/#sec-tointegerorinfinity
723
+ var toIntegerOrInfinity$2 = function (argument) {
724
+ var number = +argument;
725
+ // eslint-disable-next-line no-self-compare -- safe
726
+ return number !== number || number === 0 ? 0 : (number > 0 ? floor : ceil)(number);
727
+ };
728
+
729
+ var toIntegerOrInfinity$1 = toIntegerOrInfinity$2;
730
+
731
+ var max = Math.max;
732
+ var min$1 = Math.min;
733
+
734
+ // Helper for a popular repeating case of the spec:
735
+ // Let integer be ? ToInteger(index).
736
+ // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
737
+ var toAbsoluteIndex$1 = function (index, length) {
738
+ var integer = toIntegerOrInfinity$1(index);
739
+ return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
740
+ };
741
+
742
+ var toIntegerOrInfinity = toIntegerOrInfinity$2;
743
+
744
+ var min = Math.min;
745
+
746
+ // `ToLength` abstract operation
747
+ // https://tc39.es/ecma262/#sec-tolength
748
+ var toLength$1 = function (argument) {
749
+ return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
750
+ };
751
+
752
+ var toLength = toLength$1;
753
+
754
+ // `LengthOfArrayLike` abstract operation
755
+ // https://tc39.es/ecma262/#sec-lengthofarraylike
756
+ var lengthOfArrayLike$1 = function (obj) {
757
+ return toLength(obj.length);
758
+ };
759
+
760
+ var toIndexedObject$1 = toIndexedObject$3;
761
+ var toAbsoluteIndex = toAbsoluteIndex$1;
762
+ var lengthOfArrayLike = lengthOfArrayLike$1;
763
+
764
+ // `Array.prototype.{ indexOf, includes }` methods implementation
765
+ var createMethod = function (IS_INCLUDES) {
766
+ return function ($this, el, fromIndex) {
767
+ var O = toIndexedObject$1($this);
768
+ var length = lengthOfArrayLike(O);
769
+ var index = toAbsoluteIndex(fromIndex, length);
770
+ var value;
771
+ // Array#includes uses SameValueZero equality algorithm
772
+ // eslint-disable-next-line no-self-compare -- NaN check
773
+ if (IS_INCLUDES && el != el) while (length > index) {
774
+ value = O[index++];
775
+ // eslint-disable-next-line no-self-compare -- NaN check
776
+ if (value != value) return true;
777
+ // Array#indexOf ignores holes, Array#includes - not
778
+ } else for (;length > index; index++) {
779
+ if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
780
+ } return !IS_INCLUDES && -1;
781
+ };
782
+ };
783
+
784
+ var arrayIncludes = {
785
+ // `Array.prototype.includes` method
786
+ // https://tc39.es/ecma262/#sec-array.prototype.includes
787
+ includes: createMethod(true),
788
+ // `Array.prototype.indexOf` method
789
+ // https://tc39.es/ecma262/#sec-array.prototype.indexof
790
+ indexOf: createMethod(false)
791
+ };
792
+
793
+ var uncurryThis$2 = functionUncurryThis;
794
+ var hasOwn$1 = hasOwnProperty_1;
795
+ var toIndexedObject = toIndexedObject$3;
796
+ var indexOf = arrayIncludes.indexOf;
797
+ var hiddenKeys$1 = hiddenKeys$3;
798
+
799
+ var push = uncurryThis$2([].push);
800
+
801
+ var objectKeysInternal = function (object, names) {
802
+ var O = toIndexedObject(object);
803
+ var i = 0;
804
+ var result = [];
805
+ var key;
806
+ for (key in O) !hasOwn$1(hiddenKeys$1, key) && hasOwn$1(O, key) && push(result, key);
807
+ // Don't enum bug & hidden keys
808
+ while (names.length > i) if (hasOwn$1(O, key = names[i++])) {
809
+ ~indexOf(result, key) || push(result, key);
810
+ }
811
+ return result;
812
+ };
813
+
814
+ // IE8- don't enum bug keys
815
+ var enumBugKeys$2 = [
816
+ 'constructor',
817
+ 'hasOwnProperty',
818
+ 'isPrototypeOf',
819
+ 'propertyIsEnumerable',
820
+ 'toLocaleString',
821
+ 'toString',
822
+ 'valueOf'
823
+ ];
824
+
825
+ var internalObjectKeys$1 = objectKeysInternal;
826
+ var enumBugKeys$1 = enumBugKeys$2;
827
+
828
+ var hiddenKeys = enumBugKeys$1.concat('length', 'prototype');
829
+
830
+ // `Object.getOwnPropertyNames` method
831
+ // https://tc39.es/ecma262/#sec-object.getownpropertynames
832
+ // eslint-disable-next-line es/no-object-getownpropertynames -- safe
833
+ objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
834
+ return internalObjectKeys$1(O, hiddenKeys);
835
+ };
836
+
837
+ var objectGetOwnPropertySymbols = {};
838
+
839
+ // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
840
+ objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
841
+
842
+ var getBuiltIn = getBuiltIn$3;
843
+ var uncurryThis$1 = functionUncurryThis;
844
+ var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
845
+ var getOwnPropertySymbolsModule$1 = objectGetOwnPropertySymbols;
846
+ var anObject = anObject$2;
847
+
848
+ var concat$1 = uncurryThis$1([].concat);
849
+
850
+ // all object keys, includes non-enumerable and symbols
851
+ var ownKeys$1 = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
852
+ var keys = getOwnPropertyNamesModule.f(anObject(it));
853
+ var getOwnPropertySymbols = getOwnPropertySymbolsModule$1.f;
854
+ return getOwnPropertySymbols ? concat$1(keys, getOwnPropertySymbols(it)) : keys;
855
+ };
856
+
857
+ var hasOwn = hasOwnProperty_1;
858
+ var ownKeys = ownKeys$1;
859
+ var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
860
+ var definePropertyModule = objectDefineProperty;
861
+
862
+ var copyConstructorProperties$1 = function (target, source, exceptions) {
863
+ var keys = ownKeys(source);
864
+ var defineProperty = definePropertyModule.f;
865
+ var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
866
+ for (var i = 0; i < keys.length; i++) {
867
+ var key = keys[i];
868
+ if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
869
+ defineProperty(target, key, getOwnPropertyDescriptor(source, key));
870
+ }
871
+ }
872
+ };
873
+
874
+ var fails$1 = fails$8;
875
+ var isCallable = isCallable$9;
876
+
877
+ var replacement = /#|\.prototype\./;
878
+
879
+ var isForced$1 = function (feature, detection) {
880
+ var value = data[normalize(feature)];
881
+ return value == POLYFILL ? true
882
+ : value == NATIVE ? false
883
+ : isCallable(detection) ? fails$1(detection)
884
+ : !!detection;
885
+ };
886
+
887
+ var normalize = isForced$1.normalize = function (string) {
888
+ return String(string).replace(replacement, '.').toLowerCase();
889
+ };
890
+
891
+ var data = isForced$1.data = {};
892
+ var NATIVE = isForced$1.NATIVE = 'N';
893
+ var POLYFILL = isForced$1.POLYFILL = 'P';
894
+
895
+ var isForced_1 = isForced$1;
896
+
897
+ var global$1 = global$l;
898
+ var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
899
+ var createNonEnumerableProperty = createNonEnumerableProperty$3;
900
+ var redefine = redefine$1.exports;
901
+ var setGlobal = setGlobal$3;
902
+ var copyConstructorProperties = copyConstructorProperties$1;
903
+ var isForced = isForced_1;
904
+
905
+ /*
906
+ options.target - name of the target object
907
+ options.global - target is the global object
908
+ options.stat - export as static methods of target
909
+ options.proto - export as prototype methods of target
910
+ options.real - real prototype method for the `pure` version
911
+ options.forced - export even if the native feature is available
912
+ options.bind - bind methods to the target, required for the `pure` version
913
+ options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
914
+ options.unsafe - use the simple assignment of property instead of delete + defineProperty
915
+ options.sham - add a flag to not completely full polyfills
916
+ options.enumerable - export as enumerable property
917
+ options.noTargetGet - prevent calling a getter on target
918
+ options.name - the .name of the function if it does not match the key
919
+ */
920
+ var _export = function (options, source) {
921
+ var TARGET = options.target;
922
+ var GLOBAL = options.global;
923
+ var STATIC = options.stat;
924
+ var FORCED, target, key, targetProperty, sourceProperty, descriptor;
925
+ if (GLOBAL) {
926
+ target = global$1;
927
+ } else if (STATIC) {
928
+ target = global$1[TARGET] || setGlobal(TARGET, {});
929
+ } else {
930
+ target = (global$1[TARGET] || {}).prototype;
931
+ }
932
+ if (target) for (key in source) {
933
+ sourceProperty = source[key];
934
+ if (options.noTargetGet) {
935
+ descriptor = getOwnPropertyDescriptor(target, key);
936
+ targetProperty = descriptor && descriptor.value;
937
+ } else targetProperty = target[key];
938
+ FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
939
+ // contained in target
940
+ if (!FORCED && targetProperty !== undefined) {
941
+ if (typeof sourceProperty == typeof targetProperty) continue;
942
+ copyConstructorProperties(sourceProperty, targetProperty);
943
+ }
944
+ // add a flag to not completely full polyfills
945
+ if (options.sham || (targetProperty && targetProperty.sham)) {
946
+ createNonEnumerableProperty(sourceProperty, 'sham', true);
947
+ }
948
+ // extend global
949
+ redefine(target, key, sourceProperty, options);
950
+ }
951
+ };
952
+
953
+ var internalObjectKeys = objectKeysInternal;
954
+ var enumBugKeys = enumBugKeys$2;
955
+
956
+ // `Object.keys` method
957
+ // https://tc39.es/ecma262/#sec-object.keys
958
+ // eslint-disable-next-line es/no-object-keys -- safe
959
+ var objectKeys$1 = Object.keys || function keys(O) {
960
+ return internalObjectKeys(O, enumBugKeys);
961
+ };
962
+
963
+ var DESCRIPTORS = descriptors;
964
+ var uncurryThis = functionUncurryThis;
965
+ var call = functionCall;
966
+ var fails = fails$8;
967
+ var objectKeys = objectKeys$1;
968
+ var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
969
+ var propertyIsEnumerableModule = objectPropertyIsEnumerable;
970
+ var toObject = toObject$2;
971
+ var IndexedObject = indexedObject;
972
+
973
+ // eslint-disable-next-line es/no-object-assign -- safe
974
+ var $assign = Object.assign;
975
+ // eslint-disable-next-line es/no-object-defineproperty -- required for testing
976
+ var defineProperty = Object.defineProperty;
977
+ var concat = uncurryThis([].concat);
978
+
979
+ // `Object.assign` method
980
+ // https://tc39.es/ecma262/#sec-object.assign
981
+ var objectAssign = !$assign || fails(function () {
982
+ // should have correct order of operations (Edge bug)
983
+ if (DESCRIPTORS && $assign({ b: 1 }, $assign(defineProperty({}, 'a', {
984
+ enumerable: true,
985
+ get: function () {
986
+ defineProperty(this, 'b', {
987
+ value: 3,
988
+ enumerable: false
989
+ });
990
+ }
991
+ }), { b: 2 })).b !== 1) return true;
992
+ // should work with symbols and should have deterministic property order (V8 bug)
993
+ var A = {};
994
+ var B = {};
995
+ // eslint-disable-next-line es/no-symbol -- safe
996
+ var symbol = Symbol();
997
+ var alphabet = 'abcdefghijklmnopqrst';
998
+ A[symbol] = 7;
999
+ alphabet.split('').forEach(function (chr) { B[chr] = chr; });
1000
+ return $assign({}, A)[symbol] != 7 || objectKeys($assign({}, B)).join('') != alphabet;
1001
+ }) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
1002
+ var T = toObject(target);
1003
+ var argumentsLength = arguments.length;
1004
+ var index = 1;
1005
+ var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
1006
+ var propertyIsEnumerable = propertyIsEnumerableModule.f;
1007
+ while (argumentsLength > index) {
1008
+ var S = IndexedObject(arguments[index++]);
1009
+ var keys = getOwnPropertySymbols ? concat(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S);
1010
+ var length = keys.length;
1011
+ var j = 0;
1012
+ var key;
1013
+ while (length > j) {
1014
+ key = keys[j++];
1015
+ if (!DESCRIPTORS || call(propertyIsEnumerable, S, key)) T[key] = S[key];
1016
+ }
1017
+ } return T;
1018
+ } : $assign;
1019
+
1020
+ var $ = _export;
1021
+ var assign = objectAssign;
1022
+
1023
+ // `Object.assign` method
1024
+ // https://tc39.es/ecma262/#sec-object.assign
1025
+ // eslint-disable-next-line es/no-object-assign -- required for testing
1026
+ $({ target: 'Object', stat: true, forced: Object.assign !== assign }, {
1027
+ assign: assign
1028
+ });
1029
+
1030
+ const HAS_SEEN_COMPONENT = 'hasSeenComponent';
1031
+ const TEMPLATE_OPTIONS = {
1032
+ interpolate: /{{([\s\S]+?)}}/g
1033
+ };
1034
+ const NinetailedGoogleAnalyticsPlugins = options => {
1035
+ const actionTemplate = template(options.actionTemplate || 'Has Seen Component - Audience:{{ audience.id }}', TEMPLATE_OPTIONS);
1036
+ const labelTemplate = template(options.labelTemplate || '{{ baselineOrVariant }}:{{ component.id }}', TEMPLATE_OPTIONS);
1037
+ const trackOverwritePlugin = {
1038
+ name: 'ninetailed:google-analytics',
1039
+ 'track:google-analytics': ({
1040
+ payload,
1041
+ abort
1042
+ }) => {
1043
+ const {
1044
+ event,
1045
+ properties
1046
+ } = payload;
1047
+
1048
+ if (event !== HAS_SEEN_COMPONENT || !properties || !properties.variant || !properties.audience || typeof properties.isPersonalized === 'undefined') {
1049
+ return abort();
1050
+ }
1051
+
1052
+ const {
1053
+ variant,
1054
+ audience,
1055
+ isPersonalized
1056
+ } = properties;
1057
+ const action = actionTemplate({
1058
+ component: variant,
1059
+ audience
1060
+ });
1061
+ const label = labelTemplate({
1062
+ component: variant,
1063
+ audience,
1064
+ baselineOrVariant: isPersonalized ? 'Variant' : 'Baseline'
1065
+ });
1066
+ return Object.assign(Object.assign({}, payload), {
1067
+ event: action,
1068
+ properties: {
1069
+ category: 'Ninetailed',
1070
+ label,
1071
+ nonInteraction: true
1072
+ }
1073
+ });
1074
+ }
1075
+ };
1076
+ return [trackOverwritePlugin, googleAnalytics({
1077
+ trackingId: options.trackingId
1078
+ })];
1079
+ };
1080
+
1081
+ export { NinetailedGoogleAnalyticsPlugins };
package/index.umd.js ADDED
@@ -0,0 +1,88 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@analytics/google-analytics'), require('lodash/template')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@analytics/google-analytics', 'lodash/template'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.GoogleAnalytics = {}, global.googleAnalytics, global.template));
5
+ })(this, (function (exports, googleAnalytics, template) { 'use strict';
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var googleAnalytics__default = /*#__PURE__*/_interopDefaultLegacy(googleAnalytics);
10
+ var template__default = /*#__PURE__*/_interopDefaultLegacy(template);
11
+
12
+ /*! *****************************************************************************
13
+ Copyright (c) Microsoft Corporation.
14
+
15
+ Permission to use, copy, modify, and/or distribute this software for any
16
+ purpose with or without fee is hereby granted.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
19
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
20
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
21
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
22
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
23
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
24
+ PERFORMANCE OF THIS SOFTWARE.
25
+ ***************************************************************************** */
26
+
27
+ var __assign = function() {
28
+ __assign = Object.assign || function __assign(t) {
29
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
30
+ s = arguments[i];
31
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
32
+ }
33
+ return t;
34
+ };
35
+ return __assign.apply(this, arguments);
36
+ };
37
+
38
+ var HAS_SEEN_COMPONENT = 'hasSeenComponent';
39
+ var TEMPLATE_OPTIONS = {
40
+ interpolate: /{{([\s\S]+?)}}/g
41
+ };
42
+ var NinetailedGoogleAnalyticsPlugins = function NinetailedGoogleAnalyticsPlugins(options) {
43
+ var actionTemplate = template__default["default"](options.actionTemplate || 'Has Seen Component - Audience:{{ audience.id }}', TEMPLATE_OPTIONS);
44
+ var labelTemplate = template__default["default"](options.labelTemplate || '{{ baselineOrVariant }}:{{ component.id }}', TEMPLATE_OPTIONS);
45
+ var trackOverwritePlugin = {
46
+ name: 'ninetailed:google-analytics',
47
+ 'track:google-analytics': function (_a) {
48
+ var payload = _a.payload,
49
+ abort = _a.abort;
50
+ var event = payload.event,
51
+ properties = payload.properties;
52
+
53
+ if (event !== HAS_SEEN_COMPONENT || !properties || !properties.variant || !properties.audience || typeof properties.isPersonalized === 'undefined') {
54
+ return abort();
55
+ }
56
+
57
+ var variant = properties.variant,
58
+ audience = properties.audience,
59
+ isPersonalized = properties.isPersonalized;
60
+ var action = actionTemplate({
61
+ component: variant,
62
+ audience: audience
63
+ });
64
+ var label = labelTemplate({
65
+ component: variant,
66
+ audience: audience,
67
+ baselineOrVariant: isPersonalized ? 'Variant' : 'Baseline'
68
+ });
69
+ return __assign(__assign({}, payload), {
70
+ event: action,
71
+ properties: {
72
+ category: 'Ninetailed',
73
+ label: label,
74
+ nonInteraction: true
75
+ }
76
+ });
77
+ }
78
+ };
79
+ return [trackOverwritePlugin, googleAnalytics__default["default"]({
80
+ trackingId: options.trackingId
81
+ })];
82
+ };
83
+
84
+ exports.NinetailedGoogleAnalyticsPlugins = NinetailedGoogleAnalyticsPlugins;
85
+
86
+ Object.defineProperty(exports, '__esModule', { value: true });
87
+
88
+ }));
@@ -0,0 +1,8 @@
1
+ import { AnalyticsPlugin } from 'analytics';
2
+ declare type NinetailedGoogleAnalyticsPluginOptions = {
3
+ trackingId: string;
4
+ actionTemplate?: string;
5
+ labelTemplate?: string;
6
+ };
7
+ export declare const NinetailedGoogleAnalyticsPlugins: (options: NinetailedGoogleAnalyticsPluginOptions) => AnalyticsPlugin[];
8
+ export {};
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@ninetailed/experience.js-plugin-google-analytics",
3
+ "version": "1.0.1-beta.0",
4
+ "main": "./index.umd.js",
5
+ "module": "./index.esm.js",
6
+ "typings": "./index.d.ts",
7
+ "dependencies": {
8
+ "analytics": "^0.8.0",
9
+ "@analytics/google-analytics": "^0.5.3",
10
+ "lodash": "^4.17.21",
11
+ "@ninetailed/experience.js-shared": "1.0.1-beta.0",
12
+ "uuid": "^8.3.2",
13
+ "ts-toolbelt": "^9.6.0",
14
+ "locale-enum": "^1.1.1",
15
+ "i18n-iso-countries": "^7.3.0"
16
+ },
17
+ "peerDependencies": {}
18
+ }