@ninetailed/experience.js-plugin-google-analytics 7.18.11 → 7.18.13

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/index.cjs.js CHANGED
@@ -19,6 +19,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19
19
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
20
  PERFORMANCE OF THIS SOFTWARE.
21
21
  ***************************************************************************** */
22
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
23
+
22
24
 
23
25
  function __awaiter(thisArg, _arguments, P, generator) {
24
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -28,7 +30,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
28
30
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
29
31
  step((generator = generator.apply(thisArg, _arguments || [])).next());
30
32
  });
31
- }
33
+ }
34
+
35
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
36
+ var e = new Error(message);
37
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
38
+ };
32
39
 
33
40
  const TEMPLATE_OPTIONS = {
34
41
  interpolate: /{{([\s\S]+?)}}/g
@@ -79,4 +86,4 @@ class NinetailedGoogleAnalyticsPlugin extends experience_jsPluginAnalytics.Ninet
79
86
  }
80
87
 
81
88
  exports.NinetailedGoogleAnalyticsPlugin = NinetailedGoogleAnalyticsPlugin;
82
- exports["default"] = NinetailedGoogleAnalyticsPlugin;
89
+ exports.default = NinetailedGoogleAnalyticsPlugin;
package/index.esm.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./src/index";
2
+ export { default } from "./src/index";
package/index.esm.js CHANGED
@@ -1,6 +1,38 @@
1
1
  import { NinetailedAnalyticsPlugin } from '@ninetailed/experience.js-plugin-analytics';
2
2
  import { template } from '@ninetailed/experience.js-shared';
3
3
 
4
+ /******************************************************************************
5
+ Copyright (c) Microsoft Corporation.
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
11
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
13
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
15
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16
+ PERFORMANCE OF THIS SOFTWARE.
17
+ ***************************************************************************** */
18
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
19
+
20
+
21
+ function __awaiter(thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ }
30
+
31
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
32
+ var e = new Error(message);
33
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
34
+ };
35
+
4
36
  const TEMPLATE_OPTIONS = {
5
37
  interpolate: /{{([\s\S]+?)}}/g
6
38
  };
@@ -13,37 +45,38 @@ const isGoogleAnalyticsInitialized = () => {
13
45
  class NinetailedGoogleAnalyticsPlugin extends NinetailedAnalyticsPlugin {
14
46
  constructor(options = {}) {
15
47
  super();
16
- this.name = 'ninetailed:google-analytics';
17
48
  this.options = options;
49
+ this.name = 'ninetailed:google-analytics';
18
50
  }
19
51
  onTrackExperience() {
20
52
  return Promise.resolve();
21
53
  }
22
- async onTrackComponent(properties) {
23
- if (!isGoogleAnalyticsInitialized()) {
24
- return;
25
- }
26
- const {
27
- variant,
28
- audience,
29
- isPersonalized
30
- } = properties;
31
- const action = template(this.options.actionTemplate || 'Has Seen Component - Audience:{{ audience.id }}', {
32
- component: variant,
33
- audience
34
- }, TEMPLATE_OPTIONS.interpolate);
35
- const label = template(this.options.labelTemplate || '{{ baselineOrVariant }}:{{ component.id }}', {
36
- component: variant,
37
- audience,
38
- baselineOrVariant: isPersonalized ? 'Variant' : 'Baseline'
39
- }, TEMPLATE_OPTIONS.interpolate);
40
-
41
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
42
- // @ts-ignore
43
- window.gtag('event', action, {
44
- category: 'Ninetailed',
45
- label,
46
- nonInteraction: true
54
+ onTrackComponent(properties) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ if (!isGoogleAnalyticsInitialized()) {
57
+ return;
58
+ }
59
+ const {
60
+ variant,
61
+ audience,
62
+ isPersonalized
63
+ } = properties;
64
+ const action = template(this.options.actionTemplate || 'Has Seen Component - Audience:{{ audience.id }}', {
65
+ component: variant,
66
+ audience
67
+ }, TEMPLATE_OPTIONS.interpolate);
68
+ const label = template(this.options.labelTemplate || '{{ baselineOrVariant }}:{{ component.id }}', {
69
+ component: variant,
70
+ audience,
71
+ baselineOrVariant: isPersonalized ? 'Variant' : 'Baseline'
72
+ }, TEMPLATE_OPTIONS.interpolate);
73
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
74
+ // @ts-ignore
75
+ window.gtag('event', action, {
76
+ category: 'Ninetailed',
77
+ label,
78
+ nonInteraction: true
79
+ });
47
80
  });
48
81
  }
49
82
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-plugin-google-analytics",
3
- "version": "7.18.11",
3
+ "version": "7.18.13",
4
4
  "description": "Ninetailed SDK plugin for Google Analytics",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -28,8 +28,8 @@
28
28
  },
29
29
  "sideEffects": false,
30
30
  "dependencies": {
31
- "@ninetailed/experience.js": "7.18.11",
32
- "@ninetailed/experience.js-plugin-analytics": "7.18.11",
33
- "@ninetailed/experience.js-shared": "7.18.11"
31
+ "@ninetailed/experience.js": "7.18.13",
32
+ "@ninetailed/experience.js-plugin-analytics": "7.18.13",
33
+ "@ninetailed/experience.js-shared": "7.18.13"
34
34
  }
35
35
  }