@ascua/metrics 0.0.238 → 0.0.240

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.
@@ -0,0 +1,80 @@
1
+ import Metric from './base';
2
+ import { assert } from '@ember/debug';
3
+ import script from '@ascua/metrics/utils/customerio';
4
+
5
+ const src = 'script[src*="customer"]';
6
+
7
+ export default class extends Metric {
8
+
9
+ name = 'customer';
10
+
11
+ init() {
12
+
13
+ super.init(...arguments);
14
+
15
+ if (window._cio) return;
16
+
17
+ if (!this.config.id) return;
18
+
19
+ switch (this.config.optimised) {
20
+ case true:
21
+ script.optimised(this.config);
22
+ break;
23
+ default:
24
+ script.original(this.config);
25
+ break;
26
+ }
27
+
28
+ }
29
+
30
+ willDestroy() {
31
+
32
+ document.querySelectorAll(src).forEach(e => {
33
+ e.parentElement.removeChild(e);
34
+ });
35
+
36
+ delete window._cio;
37
+
38
+ }
39
+
40
+ clear() {
41
+
42
+ if (!window._cio) return;
43
+
44
+ window._cio.reset();
45
+
46
+ }
47
+
48
+ identify(id, data) {
49
+
50
+ if (!window._cio) return;
51
+
52
+ assert(`You must pass an 'id' as the first argument to ${this.toString()}:identify()`, id);
53
+
54
+ let event = Object.assign({}, data, {
55
+ user_id: id,
56
+ });
57
+
58
+ window._cio.identify(event);
59
+
60
+ }
61
+
62
+ trackPage(data) {
63
+
64
+ if (!window._cio) return;
65
+
66
+ window._cio.page(undefined, data);
67
+
68
+ }
69
+
70
+ trackEvent(name, data) {
71
+
72
+ if (!window._cio) return;
73
+
74
+ assert(`You must pass a 'name' as the first argument to ${this.toString()}:trackEvent()`, name);
75
+
76
+ window._cio.track(name, data);
77
+
78
+ }
79
+
80
+ }
@@ -0,0 +1,32 @@
1
+ export function original(config) {
2
+
3
+ /* eslint-disable */
4
+ window._cio = window._cio || [];
5
+ (function() {
6
+ var a,b,c;a=function(f){return function(){window._cio.push([f].
7
+ concat(Array.prototype.slice.call(arguments,0)))}};b=["load","identify",
8
+ "sidentify","track","page"];for(c=0;c<b.length;c++){window._cio[b[c]]=a(b[c])};
9
+ var t = document.createElement('script'),s = document.getElementsByTagName('script')[0];
10
+ t.async = true; t.id = 'cio-tracker';
11
+ t.setAttribute('data-site-id', config.id);
12
+ t.setAttribute('data-base-url', 'https://eu.customerioforms.com');
13
+ t.setAttribute('data-use-array-params', 'true');
14
+ t.setAttribute('data-auto-track-page', 'false');
15
+ t.setAttribute('data-use-in-app', 'true');
16
+ t.src = 'https://assets.customer.io/assets/track-eu.js';
17
+ s.parentNode.insertBefore(t, s);
18
+ })();
19
+ /* eslint-enable */
20
+
21
+ }
22
+
23
+ export function optimised(config) {
24
+
25
+ original(config);
26
+
27
+ }
28
+
29
+ export default {
30
+ original,
31
+ optimised,
32
+ }
@@ -0,0 +1 @@
1
+ export { default } from '@ascua/metrics/metrics/customerio';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ascua/metrics",
3
- "version": "0.0.238",
3
+ "version": "0.0.240",
4
4
  "description": "Small description for @ascua/metrics goes here",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -25,5 +25,5 @@
25
25
  "publishConfig": {
26
26
  "access": "public"
27
27
  },
28
- "gitHead": "c69b7174d17ae756556f9a48371b61859d18c237"
28
+ "gitHead": "a6864fd1bee57ea9989b142745ec2e2c6ff673f3"
29
29
  }