@jitsu/js 1.9.2 → 1.9.3-canary.801.20240514214630

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/dist/jitsu.cjs.js CHANGED
@@ -169,6 +169,12 @@ function insertTags(code, event, opts = {}) {
169
169
  }
170
170
  }
171
171
  }
172
+ //This weird code is used to mask eval() usage.
173
+ //Although the code can be executed in the browser, some server side bundlers (like Vercel) fails
174
+ //the build if a direct reference to eval() is found.
175
+ let al = "al";
176
+ let ev = "ve".split("").reverse().join("");
177
+ const execF = globalThis[ev + al];
172
178
  function execJs(code, event) {
173
179
  const varName = `jitsu_event_${randomId()}`;
174
180
  window[varName] = event;
@@ -177,7 +183,7 @@ function execJs(code, event) {
177
183
  ${code}
178
184
  })()`;
179
185
  try {
180
- eval(iif);
186
+ execF(iif);
181
187
  }
182
188
  catch (e) {
183
189
  console.error(`[JITSU] Error executing JS code: ${e.message}. Code: `, iif);
@@ -1491,10 +1497,12 @@ function send(method, payload, jitsuConfig, instance, store) {
1491
1497
  console.warn(`[JITSU] ${payload.type} responded with list of ${responseJson.destinations.length} destinations. However, this code is running in server-to-server mode, so destinations will be ignored`, jitsuConfig.debug ? JSON.stringify(responseJson.destinations, null, 2) : undefined);
1492
1498
  }
1493
1499
  else {
1494
- if (jitsuConfig.debug) {
1495
- console.log(`[JITSU] Processing device destinations: `, JSON.stringify(responseJson.destinations, null, 2));
1500
+ if (typeof window !== "undefined") {
1501
+ if (jitsuConfig.debug) {
1502
+ console.log(`[JITSU] Processing device destinations: `, JSON.stringify(responseJson.destinations, null, 2));
1503
+ }
1504
+ return processDestinations(responseJson.destinations, method, adjustedPayload, !!jitsuConfig.debug, instance);
1496
1505
  }
1497
- return processDestinations(responseJson.destinations, method, adjustedPayload, !!jitsuConfig.debug, instance);
1498
1506
  }
1499
1507
  }
1500
1508
  return adjustedPayload;
package/dist/jitsu.es.js CHANGED
@@ -167,6 +167,12 @@ function insertTags(code, event, opts = {}) {
167
167
  }
168
168
  }
169
169
  }
170
+ //This weird code is used to mask eval() usage.
171
+ //Although the code can be executed in the browser, some server side bundlers (like Vercel) fails
172
+ //the build if a direct reference to eval() is found.
173
+ let al = "al";
174
+ let ev = "ve".split("").reverse().join("");
175
+ const execF = globalThis[ev + al];
170
176
  function execJs(code, event) {
171
177
  const varName = `jitsu_event_${randomId()}`;
172
178
  window[varName] = event;
@@ -175,7 +181,7 @@ function execJs(code, event) {
175
181
  ${code}
176
182
  })()`;
177
183
  try {
178
- eval(iif);
184
+ execF(iif);
179
185
  }
180
186
  catch (e) {
181
187
  console.error(`[JITSU] Error executing JS code: ${e.message}. Code: `, iif);
@@ -1489,10 +1495,12 @@ function send(method, payload, jitsuConfig, instance, store) {
1489
1495
  console.warn(`[JITSU] ${payload.type} responded with list of ${responseJson.destinations.length} destinations. However, this code is running in server-to-server mode, so destinations will be ignored`, jitsuConfig.debug ? JSON.stringify(responseJson.destinations, null, 2) : undefined);
1490
1496
  }
1491
1497
  else {
1492
- if (jitsuConfig.debug) {
1493
- console.log(`[JITSU] Processing device destinations: `, JSON.stringify(responseJson.destinations, null, 2));
1498
+ if (typeof window !== "undefined") {
1499
+ if (jitsuConfig.debug) {
1500
+ console.log(`[JITSU] Processing device destinations: `, JSON.stringify(responseJson.destinations, null, 2));
1501
+ }
1502
+ return processDestinations(responseJson.destinations, method, adjustedPayload, !!jitsuConfig.debug, instance);
1494
1503
  }
1495
- return processDestinations(responseJson.destinations, method, adjustedPayload, !!jitsuConfig.debug, instance);
1496
1504
  }
1497
1505
  }
1498
1506
  return adjustedPayload;
package/dist/web/p.js.txt CHANGED
@@ -170,6 +170,12 @@
170
170
  }
171
171
  }
172
172
  }
173
+ //This weird code is used to mask eval() usage.
174
+ //Although the code can be executed in the browser, some server side bundlers (like Vercel) fails
175
+ //the build if a direct reference to eval() is found.
176
+ let al = "al";
177
+ let ev = "ve".split("").reverse().join("");
178
+ const execF = globalThis[ev + al];
173
179
  function execJs(code, event) {
174
180
  const varName = `jitsu_event_${randomId()}`;
175
181
  window[varName] = event;
@@ -178,7 +184,7 @@
178
184
  ${code}
179
185
  })()`;
180
186
  try {
181
- eval(iif);
187
+ execF(iif);
182
188
  }
183
189
  catch (e) {
184
190
  console.error(`[JITSU] Error executing JS code: ${e.message}. Code: `, iif);
@@ -1492,10 +1498,12 @@
1492
1498
  console.warn(`[JITSU] ${payload.type} responded with list of ${responseJson.destinations.length} destinations. However, this code is running in server-to-server mode, so destinations will be ignored`, jitsuConfig.debug ? JSON.stringify(responseJson.destinations, null, 2) : undefined);
1493
1499
  }
1494
1500
  else {
1495
- if (jitsuConfig.debug) {
1496
- console.log(`[JITSU] Processing device destinations: `, JSON.stringify(responseJson.destinations, null, 2));
1501
+ if (typeof window !== "undefined") {
1502
+ if (jitsuConfig.debug) {
1503
+ console.log(`[JITSU] Processing device destinations: `, JSON.stringify(responseJson.destinations, null, 2));
1504
+ }
1505
+ return processDestinations(responseJson.destinations, method, adjustedPayload, !!jitsuConfig.debug, instance);
1497
1506
  }
1498
- return processDestinations(responseJson.destinations, method, adjustedPayload, !!jitsuConfig.debug, instance);
1499
1507
  }
1500
1508
  }
1501
1509
  return adjustedPayload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jitsu/js",
3
- "version": "1.9.2",
3
+ "version": "1.9.3-canary.801.20240514214630",
4
4
  "description": "",
5
5
  "author": "Jitsu Dev Team <dev@jitsu.com>",
6
6
  "main": "dist/jitsu.cjs.js",
@@ -22,7 +22,7 @@
22
22
  "@segment/analytics-next": "^1.46.0",
23
23
  "@types/chalk": "^2.2.0",
24
24
  "@types/jest": "^29.2.0",
25
- "@types/node": "^16.11.7",
25
+ "@types/node": "^18.15.3",
26
26
  "chalk": "^4.1.2",
27
27
  "cookie-parser": "^1.4.6",
28
28
  "ejs": "^3.1.8",
@@ -34,8 +34,8 @@
34
34
  "rollup": "^3.2.5",
35
35
  "ts-jest": "29.0.5",
36
36
  "typescript": "^5.3.3",
37
- "@jitsu/protocols": "1.9.2",
38
- "jsondiffpatch": "1.9.2"
37
+ "jsondiffpatch": "1.9.3-canary.801.20240514214630",
38
+ "@jitsu/protocols": "1.9.3-canary.801.20240514214630"
39
39
  },
40
40
  "dependencies": {
41
41
  "analytics": "0.8.9"
@@ -610,10 +610,12 @@ async function send(
610
610
  jitsuConfig.debug ? JSON.stringify(responseJson.destinations, null, 2) : undefined
611
611
  );
612
612
  } else {
613
- if (jitsuConfig.debug) {
614
- console.log(`[JITSU] Processing device destinations: `, JSON.stringify(responseJson.destinations, null, 2));
613
+ if (typeof window !== "undefined") {
614
+ if (jitsuConfig.debug) {
615
+ console.log(`[JITSU] Processing device destinations: `, JSON.stringify(responseJson.destinations, null, 2));
616
+ }
617
+ return processDestinations(responseJson.destinations, method, adjustedPayload, !!jitsuConfig.debug, instance);
615
618
  }
616
- return processDestinations(responseJson.destinations, method, adjustedPayload, !!jitsuConfig.debug, instance);
617
619
  }
618
620
  }
619
621
  return adjustedPayload;
@@ -56,6 +56,13 @@ function insertTags(code, event: AnalyticsClientEvent, opts: { debug?: boolean }
56
56
  }
57
57
  }
58
58
 
59
+ //This weird code is used to mask eval() usage.
60
+ //Although the code can be executed in the browser, some server side bundlers (like Vercel) fails
61
+ //the build if a direct reference to eval() is found.
62
+ let al = "al";
63
+ let ev = "ve".split("").reverse().join("");
64
+ const execF = globalThis[ev + al];
65
+
59
66
  function execJs(code: string, event: any) {
60
67
  const varName = `jitsu_event_${randomId()}`;
61
68
  window[varName] = event;
@@ -64,7 +71,7 @@ function execJs(code: string, event: any) {
64
71
  ${code}
65
72
  })()`;
66
73
  try {
67
- eval(iif);
74
+ execF(iif);
68
75
  } catch (e) {
69
76
  console.error(`[JITSU] Error executing JS code: ${e.message}. Code: `, iif);
70
77
  } finally {