@blotoutio/providers-klaviyo-sdk 0.40.0 → 0.41.1

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
@@ -26,10 +26,103 @@ const capture = (rule, value) => {
26
26
  return value;
27
27
  };
28
28
 
29
+ const sdkVersion = "0.41.1" ;
30
+ const tag = () => ({
31
+ sdkVersion,
32
+ isIdentified: sessionStorage.getItem('identifiedByKlaviyo') === '1',
33
+ });
34
+
35
+ const canLog = () => {
36
+ try {
37
+ return localStorage.getItem('edgeTagDebug') === '1';
38
+ }
39
+ catch {
40
+ return false;
41
+ }
42
+ };
43
+ const logger = {
44
+ log: (...args) => {
45
+ if (canLog()) {
46
+ console.log(...args);
47
+ }
48
+ },
49
+ error: (...args) => {
50
+ if (canLog()) {
51
+ console.error(...args);
52
+ }
53
+ },
54
+ info: (...args) => {
55
+ if (canLog()) {
56
+ console.info(...args);
57
+ }
58
+ },
59
+ trace: (...args) => {
60
+ if (canLog()) {
61
+ console.trace(...args);
62
+ }
63
+ },
64
+ table: (...args) => {
65
+ if (canLog()) {
66
+ console.table(...args);
67
+ }
68
+ },
69
+ dir: (...args) => {
70
+ if (canLog()) {
71
+ console.dir(...args);
72
+ }
73
+ },
74
+ };
75
+
76
+ const RETRY_COUNT = 5;
77
+ const RETRY_INTERVAL = 2000;
78
+ let klaviyoSdkCheckCount = 0;
79
+ const registerIdentifiedPolling = () => {
80
+ const timer = setInterval(() => {
81
+ var _a;
82
+ try {
83
+ if (klaviyoSdkCheckCount > RETRY_COUNT) {
84
+ clearInterval(timer);
85
+ }
86
+ (_a = window === null || window === void 0 ? void 0 : window.klaviyo) === null || _a === void 0 ? void 0 : _a.isIdentified().then((identified) => {
87
+ if (identified) {
88
+ sessionStorage.setItem('identifiedByKlaviyo', '1');
89
+ clearInterval(timer);
90
+ }
91
+ });
92
+ }
93
+ catch (e) {
94
+ logger.error(e);
95
+ clearInterval(timer);
96
+ }
97
+ finally {
98
+ klaviyoSdkCheckCount++;
99
+ }
100
+ }, RETRY_INTERVAL);
101
+ return () => {
102
+ clearInterval(timer);
103
+ };
104
+ };
105
+
106
+ const init = () => {
107
+ try {
108
+ if (!window) {
109
+ return;
110
+ }
111
+ if (sessionStorage.getItem('identifiedByKlaviyo') !== '1') {
112
+ registerIdentifiedPolling();
113
+ }
114
+ }
115
+ catch (error) {
116
+ logger.error(error);
117
+ }
118
+ };
119
+
29
120
  // eslint-disable-next-line @nx/enforce-module-boundaries
30
121
  const data = {
31
122
  name: packageName,
123
+ init,
32
124
  capture,
125
+ tag,
33
126
  };
34
127
  try {
35
128
  if (window) {
package/index.js CHANGED
@@ -27,10 +27,103 @@ var ProvidersKlaviyoSdk = (function () {
27
27
  return value;
28
28
  };
29
29
 
30
+ const sdkVersion = "0.41.1" ;
31
+ const tag = () => ({
32
+ sdkVersion,
33
+ isIdentified: sessionStorage.getItem('identifiedByKlaviyo') === '1',
34
+ });
35
+
36
+ const canLog = () => {
37
+ try {
38
+ return localStorage.getItem('edgeTagDebug') === '1';
39
+ }
40
+ catch {
41
+ return false;
42
+ }
43
+ };
44
+ const logger = {
45
+ log: (...args) => {
46
+ if (canLog()) {
47
+ console.log(...args);
48
+ }
49
+ },
50
+ error: (...args) => {
51
+ if (canLog()) {
52
+ console.error(...args);
53
+ }
54
+ },
55
+ info: (...args) => {
56
+ if (canLog()) {
57
+ console.info(...args);
58
+ }
59
+ },
60
+ trace: (...args) => {
61
+ if (canLog()) {
62
+ console.trace(...args);
63
+ }
64
+ },
65
+ table: (...args) => {
66
+ if (canLog()) {
67
+ console.table(...args);
68
+ }
69
+ },
70
+ dir: (...args) => {
71
+ if (canLog()) {
72
+ console.dir(...args);
73
+ }
74
+ },
75
+ };
76
+
77
+ const RETRY_COUNT = 5;
78
+ const RETRY_INTERVAL = 2000;
79
+ let klaviyoSdkCheckCount = 0;
80
+ const registerIdentifiedPolling = () => {
81
+ const timer = setInterval(() => {
82
+ var _a;
83
+ try {
84
+ if (klaviyoSdkCheckCount > RETRY_COUNT) {
85
+ clearInterval(timer);
86
+ }
87
+ (_a = window === null || window === void 0 ? void 0 : window.klaviyo) === null || _a === void 0 ? void 0 : _a.isIdentified().then((identified) => {
88
+ if (identified) {
89
+ sessionStorage.setItem('identifiedByKlaviyo', '1');
90
+ clearInterval(timer);
91
+ }
92
+ });
93
+ }
94
+ catch (e) {
95
+ logger.error(e);
96
+ clearInterval(timer);
97
+ }
98
+ finally {
99
+ klaviyoSdkCheckCount++;
100
+ }
101
+ }, RETRY_INTERVAL);
102
+ return () => {
103
+ clearInterval(timer);
104
+ };
105
+ };
106
+
107
+ const init = () => {
108
+ try {
109
+ if (!window) {
110
+ return;
111
+ }
112
+ if (sessionStorage.getItem('identifiedByKlaviyo') !== '1') {
113
+ registerIdentifiedPolling();
114
+ }
115
+ }
116
+ catch (error) {
117
+ logger.error(error);
118
+ }
119
+ };
120
+
30
121
  // eslint-disable-next-line @nx/enforce-module-boundaries
31
122
  const data = {
32
123
  name: packageName,
124
+ init,
33
125
  capture,
126
+ tag,
34
127
  };
35
128
  try {
36
129
  if (window) {
package/index.mjs CHANGED
@@ -24,10 +24,103 @@ const capture = (rule, value) => {
24
24
  return value;
25
25
  };
26
26
 
27
+ const sdkVersion = "0.41.1" ;
28
+ const tag = () => ({
29
+ sdkVersion,
30
+ isIdentified: sessionStorage.getItem('identifiedByKlaviyo') === '1',
31
+ });
32
+
33
+ const canLog = () => {
34
+ try {
35
+ return localStorage.getItem('edgeTagDebug') === '1';
36
+ }
37
+ catch {
38
+ return false;
39
+ }
40
+ };
41
+ const logger = {
42
+ log: (...args) => {
43
+ if (canLog()) {
44
+ console.log(...args);
45
+ }
46
+ },
47
+ error: (...args) => {
48
+ if (canLog()) {
49
+ console.error(...args);
50
+ }
51
+ },
52
+ info: (...args) => {
53
+ if (canLog()) {
54
+ console.info(...args);
55
+ }
56
+ },
57
+ trace: (...args) => {
58
+ if (canLog()) {
59
+ console.trace(...args);
60
+ }
61
+ },
62
+ table: (...args) => {
63
+ if (canLog()) {
64
+ console.table(...args);
65
+ }
66
+ },
67
+ dir: (...args) => {
68
+ if (canLog()) {
69
+ console.dir(...args);
70
+ }
71
+ },
72
+ };
73
+
74
+ const RETRY_COUNT = 5;
75
+ const RETRY_INTERVAL = 2000;
76
+ let klaviyoSdkCheckCount = 0;
77
+ const registerIdentifiedPolling = () => {
78
+ const timer = setInterval(() => {
79
+ var _a;
80
+ try {
81
+ if (klaviyoSdkCheckCount > RETRY_COUNT) {
82
+ clearInterval(timer);
83
+ }
84
+ (_a = window === null || window === void 0 ? void 0 : window.klaviyo) === null || _a === void 0 ? void 0 : _a.isIdentified().then((identified) => {
85
+ if (identified) {
86
+ sessionStorage.setItem('identifiedByKlaviyo', '1');
87
+ clearInterval(timer);
88
+ }
89
+ });
90
+ }
91
+ catch (e) {
92
+ logger.error(e);
93
+ clearInterval(timer);
94
+ }
95
+ finally {
96
+ klaviyoSdkCheckCount++;
97
+ }
98
+ }, RETRY_INTERVAL);
99
+ return () => {
100
+ clearInterval(timer);
101
+ };
102
+ };
103
+
104
+ const init = () => {
105
+ try {
106
+ if (!window) {
107
+ return;
108
+ }
109
+ if (sessionStorage.getItem('identifiedByKlaviyo') !== '1') {
110
+ registerIdentifiedPolling();
111
+ }
112
+ }
113
+ catch (error) {
114
+ logger.error(error);
115
+ }
116
+ };
117
+
27
118
  // eslint-disable-next-line @nx/enforce-module-boundaries
28
119
  const data = {
29
120
  name: packageName,
121
+ init,
30
122
  capture,
123
+ tag,
31
124
  };
32
125
  try {
33
126
  if (window) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-klaviyo-sdk",
3
- "version": "0.40.0",
3
+ "version": "0.41.1",
4
4
  "description": "Klaviyo Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",