@jitsu/js 1.9.18-canary.1269.20250403142744 → 1.9.18-canary.1288.20250415191203
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/.turbo/turbo-build.log +67 -0
- package/.turbo/turbo-clean.log +5 -0
- package/.turbo/turbo-test.log +2884 -0
- package/__tests__/node/method-queue.test.ts +66 -0
- package/__tests__/node/nodejs.test.ts +306 -0
- package/__tests__/playwright/cases/anonymous-id-bug.html +26 -0
- package/__tests__/playwright/cases/basic.html +32 -0
- package/__tests__/playwright/cases/callbacks.html +21 -0
- package/__tests__/playwright/cases/cookie-names.html +22 -0
- package/__tests__/playwright/cases/disable-user-ids.html +23 -0
- package/__tests__/playwright/cases/dont-send.html +22 -0
- package/__tests__/playwright/cases/ip-policy.html +22 -0
- package/__tests__/playwright/cases/reset.html +32 -0
- package/__tests__/playwright/cases/segment-reference.html +64 -0
- package/__tests__/playwright/cases/url-bug.html +20 -0
- package/__tests__/playwright/integration.test.ts +640 -0
- package/__tests__/simple-syrup.ts +136 -0
- package/dist/jitsu.cjs.js +4 -8
- package/dist/jitsu.es.js +4 -8
- package/dist/web/p.js.txt +4 -8
- package/jest.config.js +13 -0
- package/package/README.md +9 -0
- package/package/dist/analytics-plugin.d.ts +28 -0
- package/package/dist/browser.d.ts +10 -0
- package/package/dist/index.d.ts +28 -0
- package/package/dist/jitsu.cjs.js +2100 -0
- package/package/dist/jitsu.d.ts +78 -0
- package/package/dist/jitsu.es.js +2090 -0
- package/package/dist/method-queue.d.ts +19 -0
- package/package/dist/script-loader.d.ts +8 -0
- package/package/dist/tlds.d.ts +3 -0
- package/package/dist/version.d.ts +3 -0
- package/package/dist/web/p.js.txt +2219 -0
- package/package/package.json +56 -0
- package/package.json +3 -9
- package/playwrite.config.ts +91 -0
- package/rollup.config.js +32 -0
- package/src/analytics-plugin.ts +989 -0
- package/src/browser.ts +163 -0
- package/src/destination-plugins/ga4.ts +138 -0
- package/src/destination-plugins/gtm.ts +142 -0
- package/src/destination-plugins/index.ts +61 -0
- package/src/destination-plugins/logrocket.ts +85 -0
- package/src/destination-plugins/tag.ts +85 -0
- package/src/index.ts +255 -0
- package/src/method-queue.ts +70 -0
- package/src/script-loader.ts +76 -0
- package/src/tlds.ts +27 -0
- package/src/version.ts +6 -0
- package/tsconfig.json +23 -0
- package/tsconfig.test.json +15 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { Application, RequestHandler } from "express";
|
|
2
|
+
import http from "http";
|
|
3
|
+
import https from "https";
|
|
4
|
+
|
|
5
|
+
const express = require("express");
|
|
6
|
+
|
|
7
|
+
const forge = require("node-forge");
|
|
8
|
+
|
|
9
|
+
export type SimpleSyrupOpts = {
|
|
10
|
+
port?: number;
|
|
11
|
+
https?: boolean;
|
|
12
|
+
handlers?: Record<string, RequestHandler>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type SimpleSyrup = {
|
|
16
|
+
app: Application;
|
|
17
|
+
server: http.Server;
|
|
18
|
+
port: number;
|
|
19
|
+
baseUrl: string;
|
|
20
|
+
close: () => Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function getNextAvailablePort(port: number) {
|
|
24
|
+
return new Promise<number>(resolve => {
|
|
25
|
+
const server = http.createServer();
|
|
26
|
+
server.on("error", () => {
|
|
27
|
+
resolve(getNextAvailablePort(port + 1));
|
|
28
|
+
});
|
|
29
|
+
server.on("listening", () => {
|
|
30
|
+
server.close(() => {
|
|
31
|
+
resolve(port);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
server.listen(port);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function generateX509Certificate(altNames: { type: number; value: string }[]) {
|
|
39
|
+
const issuer = [
|
|
40
|
+
{ name: "commonName", value: "localhost" },
|
|
41
|
+
{ name: "organizationName", value: "ACME Corp" },
|
|
42
|
+
{ name: "organizationalUnitName", value: "XYZ Department" },
|
|
43
|
+
];
|
|
44
|
+
const certificateExtensions = [
|
|
45
|
+
{ name: "basicConstraints", cA: true },
|
|
46
|
+
{
|
|
47
|
+
name: "keyUsage",
|
|
48
|
+
keyCertSign: true,
|
|
49
|
+
digitalSignature: true,
|
|
50
|
+
nonRepudiation: true,
|
|
51
|
+
keyEncipherment: true,
|
|
52
|
+
dataEncipherment: true,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "extKeyUsage",
|
|
56
|
+
serverAuth: true,
|
|
57
|
+
clientAuth: true,
|
|
58
|
+
codeSigning: true,
|
|
59
|
+
emailProtection: true,
|
|
60
|
+
timeStamping: true,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "nsCertType",
|
|
64
|
+
client: true,
|
|
65
|
+
server: true,
|
|
66
|
+
email: true,
|
|
67
|
+
objsign: true,
|
|
68
|
+
sslCA: true,
|
|
69
|
+
emailCA: true,
|
|
70
|
+
objCA: true,
|
|
71
|
+
},
|
|
72
|
+
{ name: "subjectAltName", altNames },
|
|
73
|
+
{ name: "subjectKeyIdentifier" },
|
|
74
|
+
];
|
|
75
|
+
const keys = forge.pki.rsa.generateKeyPair(2048);
|
|
76
|
+
const cert = forge.pki.createCertificate();
|
|
77
|
+
cert.validity.notBefore = new Date();
|
|
78
|
+
cert.validity.notAfter = new Date();
|
|
79
|
+
cert.validity.notAfter.setFullYear(cert.validity.notBefore.getFullYear() + 1);
|
|
80
|
+
cert.publicKey = keys.publicKey;
|
|
81
|
+
cert.setSubject(issuer);
|
|
82
|
+
cert.setIssuer(issuer);
|
|
83
|
+
cert.setExtensions(certificateExtensions);
|
|
84
|
+
cert.sign(keys.privateKey);
|
|
85
|
+
return {
|
|
86
|
+
key: forge.pki.privateKeyToPem(keys.privateKey),
|
|
87
|
+
cert: forge.pki.certificateToPem(cert),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function shutdownFunction(server): Promise<void> {
|
|
92
|
+
return new Promise<void>(resolve => {
|
|
93
|
+
let resolved = false;
|
|
94
|
+
const resolveIfNeeded = () => {
|
|
95
|
+
if (!resolved) {
|
|
96
|
+
resolved = true;
|
|
97
|
+
resolve();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
setTimeout(resolveIfNeeded, 5000);
|
|
101
|
+
server.close(resolveIfNeeded);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function createServer(opts: SimpleSyrupOpts = {}): Promise<SimpleSyrup> {
|
|
106
|
+
return new Promise<SimpleSyrup>(async (resolve, reject) => {
|
|
107
|
+
const app: Application = express();
|
|
108
|
+
app.use(express.json());
|
|
109
|
+
const server = opts?.https ? https.createServer(generateX509Certificate([]), app) : http.createServer(app);
|
|
110
|
+
const port = opts?.port ? await getNextAvailablePort(opts.port) : 0;
|
|
111
|
+
server.listen(port, () => {
|
|
112
|
+
const address = server.address();
|
|
113
|
+
if (!address) {
|
|
114
|
+
reject(new Error(`Unable to get server address`));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (typeof address === "string") {
|
|
118
|
+
reject(new Error(`Address is not an of network. This is not supported: ${address} `));
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const port = address.port;
|
|
122
|
+
if (opts?.handlers) {
|
|
123
|
+
for (const [path, handler] of Object.entries(opts?.handlers)) {
|
|
124
|
+
app.all(path, handler);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
resolve({
|
|
128
|
+
app: app,
|
|
129
|
+
port,
|
|
130
|
+
close: () => shutdownFunction(server),
|
|
131
|
+
baseUrl: `${opts.https ? "https" : "http"}://localhost:${port}`,
|
|
132
|
+
server: server,
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
package/dist/jitsu.cjs.js
CHANGED
|
@@ -1462,7 +1462,6 @@ function adjustPayload(payload, config, storage, s2s) {
|
|
|
1462
1462
|
userAgent: runtime.userAgent(),
|
|
1463
1463
|
locale: runtime.language(),
|
|
1464
1464
|
screen: runtime.screen(),
|
|
1465
|
-
ip: runtime.ip ? runtime.ip() : undefined,
|
|
1466
1465
|
traits: payload.type != "identify" && payload.type != "group" ? Object.assign({}, (restoreTraits(storage) || {})) : undefined,
|
|
1467
1466
|
page: {
|
|
1468
1467
|
path: properties.path || (parsedUrl && parsedUrl.pathname),
|
|
@@ -1609,22 +1608,19 @@ function getErrorHandler(opts) {
|
|
|
1609
1608
|
function send(method, payload, jitsuConfig, instance, store) {
|
|
1610
1609
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
1611
1610
|
var _a, _b;
|
|
1611
|
+
const s2s = !!jitsuConfig.s2s;
|
|
1612
|
+
const debugHeader = jitsuConfig.debug ? { "X-Enable-Debug": "true" } : {};
|
|
1613
|
+
const adjustedPayload = adjustPayload(payload, jitsuConfig, store);
|
|
1612
1614
|
if (jitsuConfig.echoEvents) {
|
|
1613
|
-
console.log(`[JITSU DEBUG] sending '${method}' event:`,
|
|
1615
|
+
console.log(`[JITSU DEBUG] sending '${method}' event:`, adjustedPayload);
|
|
1614
1616
|
return;
|
|
1615
1617
|
}
|
|
1616
|
-
const s2s = !!jitsuConfig.s2s;
|
|
1617
1618
|
const url = s2s ? `${jitsuConfig.host}/api/s/s2s/${method}` : `${jitsuConfig.host}/api/s/${method}`;
|
|
1618
1619
|
const fetch = jitsuConfig.fetch || globalThis.fetch;
|
|
1619
1620
|
if (!fetch) {
|
|
1620
1621
|
//don't run it through error handler since error is critical and should be addressed
|
|
1621
1622
|
throw new Error("Please specify fetch function in jitsu plugin initialization, fetch isn't available in global scope");
|
|
1622
1623
|
}
|
|
1623
|
-
const debugHeader = jitsuConfig.debug ? { "X-Enable-Debug": "true" } : {};
|
|
1624
|
-
// if (jitsuConfig.debug) {
|
|
1625
|
-
// console.log(`[JITSU] Sending event to ${url}: `, JSON.stringify(payload, null, 2));
|
|
1626
|
-
// }
|
|
1627
|
-
const adjustedPayload = adjustPayload(payload, jitsuConfig, store);
|
|
1628
1624
|
const abortController = jitsuConfig.fetchTimeoutMs ? new AbortController() : undefined;
|
|
1629
1625
|
const abortTimeout = jitsuConfig.fetchTimeoutMs
|
|
1630
1626
|
? setTimeout(() => {
|
package/dist/jitsu.es.js
CHANGED
|
@@ -1460,7 +1460,6 @@ function adjustPayload(payload, config, storage, s2s) {
|
|
|
1460
1460
|
userAgent: runtime.userAgent(),
|
|
1461
1461
|
locale: runtime.language(),
|
|
1462
1462
|
screen: runtime.screen(),
|
|
1463
|
-
ip: runtime.ip ? runtime.ip() : undefined,
|
|
1464
1463
|
traits: payload.type != "identify" && payload.type != "group" ? Object.assign({}, (restoreTraits(storage) || {})) : undefined,
|
|
1465
1464
|
page: {
|
|
1466
1465
|
path: properties.path || (parsedUrl && parsedUrl.pathname),
|
|
@@ -1607,22 +1606,19 @@ function getErrorHandler(opts) {
|
|
|
1607
1606
|
function send(method, payload, jitsuConfig, instance, store) {
|
|
1608
1607
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
1609
1608
|
var _a, _b;
|
|
1609
|
+
const s2s = !!jitsuConfig.s2s;
|
|
1610
|
+
const debugHeader = jitsuConfig.debug ? { "X-Enable-Debug": "true" } : {};
|
|
1611
|
+
const adjustedPayload = adjustPayload(payload, jitsuConfig, store);
|
|
1610
1612
|
if (jitsuConfig.echoEvents) {
|
|
1611
|
-
console.log(`[JITSU DEBUG] sending '${method}' event:`,
|
|
1613
|
+
console.log(`[JITSU DEBUG] sending '${method}' event:`, adjustedPayload);
|
|
1612
1614
|
return;
|
|
1613
1615
|
}
|
|
1614
|
-
const s2s = !!jitsuConfig.s2s;
|
|
1615
1616
|
const url = s2s ? `${jitsuConfig.host}/api/s/s2s/${method}` : `${jitsuConfig.host}/api/s/${method}`;
|
|
1616
1617
|
const fetch = jitsuConfig.fetch || globalThis.fetch;
|
|
1617
1618
|
if (!fetch) {
|
|
1618
1619
|
//don't run it through error handler since error is critical and should be addressed
|
|
1619
1620
|
throw new Error("Please specify fetch function in jitsu plugin initialization, fetch isn't available in global scope");
|
|
1620
1621
|
}
|
|
1621
|
-
const debugHeader = jitsuConfig.debug ? { "X-Enable-Debug": "true" } : {};
|
|
1622
|
-
// if (jitsuConfig.debug) {
|
|
1623
|
-
// console.log(`[JITSU] Sending event to ${url}: `, JSON.stringify(payload, null, 2));
|
|
1624
|
-
// }
|
|
1625
|
-
const adjustedPayload = adjustPayload(payload, jitsuConfig, store);
|
|
1626
1622
|
const abortController = jitsuConfig.fetchTimeoutMs ? new AbortController() : undefined;
|
|
1627
1623
|
const abortTimeout = jitsuConfig.fetchTimeoutMs
|
|
1628
1624
|
? setTimeout(() => {
|
package/dist/web/p.js.txt
CHANGED
|
@@ -1463,7 +1463,6 @@
|
|
|
1463
1463
|
userAgent: runtime.userAgent(),
|
|
1464
1464
|
locale: runtime.language(),
|
|
1465
1465
|
screen: runtime.screen(),
|
|
1466
|
-
ip: runtime.ip ? runtime.ip() : undefined,
|
|
1467
1466
|
traits: payload.type != "identify" && payload.type != "group" ? Object.assign({}, (restoreTraits(storage) || {})) : undefined,
|
|
1468
1467
|
page: {
|
|
1469
1468
|
path: properties.path || (parsedUrl && parsedUrl.pathname),
|
|
@@ -1610,22 +1609,19 @@
|
|
|
1610
1609
|
function send(method, payload, jitsuConfig, instance, store) {
|
|
1611
1610
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
1612
1611
|
var _a, _b;
|
|
1612
|
+
const s2s = !!jitsuConfig.s2s;
|
|
1613
|
+
const debugHeader = jitsuConfig.debug ? { "X-Enable-Debug": "true" } : {};
|
|
1614
|
+
const adjustedPayload = adjustPayload(payload, jitsuConfig, store);
|
|
1613
1615
|
if (jitsuConfig.echoEvents) {
|
|
1614
|
-
console.log(`[JITSU DEBUG] sending '${method}' event:`,
|
|
1616
|
+
console.log(`[JITSU DEBUG] sending '${method}' event:`, adjustedPayload);
|
|
1615
1617
|
return;
|
|
1616
1618
|
}
|
|
1617
|
-
const s2s = !!jitsuConfig.s2s;
|
|
1618
1619
|
const url = s2s ? `${jitsuConfig.host}/api/s/s2s/${method}` : `${jitsuConfig.host}/api/s/${method}`;
|
|
1619
1620
|
const fetch = jitsuConfig.fetch || globalThis.fetch;
|
|
1620
1621
|
if (!fetch) {
|
|
1621
1622
|
//don't run it through error handler since error is critical and should be addressed
|
|
1622
1623
|
throw new Error("Please specify fetch function in jitsu plugin initialization, fetch isn't available in global scope");
|
|
1623
1624
|
}
|
|
1624
|
-
const debugHeader = jitsuConfig.debug ? { "X-Enable-Debug": "true" } : {};
|
|
1625
|
-
// if (jitsuConfig.debug) {
|
|
1626
|
-
// console.log(`[JITSU] Sending event to ${url}: `, JSON.stringify(payload, null, 2));
|
|
1627
|
-
// }
|
|
1628
|
-
const adjustedPayload = adjustPayload(payload, jitsuConfig, store);
|
|
1629
1625
|
const abortController = jitsuConfig.fetchTimeoutMs ? new AbortController() : undefined;
|
|
1630
1626
|
const abortTimeout = jitsuConfig.fetchTimeoutMs
|
|
1631
1627
|
? setTimeout(() => {
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @type {import("ts-jest").JestConfigWithTsJest} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
//preset: "ts-jest",
|
|
4
|
+
preset: "ts-jest",
|
|
5
|
+
testEnvironment: "node",
|
|
6
|
+
runner: "jest-runner",
|
|
7
|
+
rootDir: "./__tests__/node/",
|
|
8
|
+
globals: {
|
|
9
|
+
'ts-jest': {
|
|
10
|
+
tsConfig: 'tsconfig.test.json'
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { JitsuOptions, PersistentStorage, RuntimeFacade } from "@jitsu/protocols/analytics";
|
|
2
|
+
import { AnalyticsPlugin } from "analytics";
|
|
3
|
+
export declare const parseQuery: (qs?: string) => Record<string, string>;
|
|
4
|
+
export type StorageFactory = (cookieDomain: string, key2Cookie: (key: string) => string) => PersistentStorage;
|
|
5
|
+
export declare function windowRuntime(opts: JitsuOptions): RuntimeFacade;
|
|
6
|
+
export declare const emptyRuntime: (config: JitsuOptions) => RuntimeFacade;
|
|
7
|
+
export declare function isInBrowser(): boolean;
|
|
8
|
+
export type DestinationDescriptor = {
|
|
9
|
+
id: string;
|
|
10
|
+
destinationType: string;
|
|
11
|
+
credentials: any;
|
|
12
|
+
options: any;
|
|
13
|
+
newEvents?: any[];
|
|
14
|
+
deviceOptions: DeviceOptions;
|
|
15
|
+
};
|
|
16
|
+
export type AnalyticsPluginDescriptor = {
|
|
17
|
+
type: "analytics-plugin";
|
|
18
|
+
packageCdn: string;
|
|
19
|
+
moduleVarName: string;
|
|
20
|
+
};
|
|
21
|
+
export type InternalPluginDescriptor = {
|
|
22
|
+
type: "internal-plugin";
|
|
23
|
+
name: string;
|
|
24
|
+
};
|
|
25
|
+
export type DeviceOptions = AnalyticsPluginDescriptor | InternalPluginDescriptor;
|
|
26
|
+
export declare const jitsuAnalyticsPlugin: (jitsuOptions: JitsuOptions, storage: PersistentStorage) => AnalyticsPlugin;
|
|
27
|
+
export declare function randomId(hashString?: string | undefined): string;
|
|
28
|
+
export declare function uuid(): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { JitsuOptions } from "@jitsu/protocols/analytics";
|
|
2
|
+
export type JitsuBrowserOptions = {
|
|
3
|
+
namespace?: string;
|
|
4
|
+
onload?: string;
|
|
5
|
+
initOnly?: boolean;
|
|
6
|
+
} & JitsuOptions;
|
|
7
|
+
export type Parser = {
|
|
8
|
+
path?: (name: string) => string[];
|
|
9
|
+
parse: (arg: string) => any;
|
|
10
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Callback,
|
|
3
|
+
DispatchedEvent,
|
|
4
|
+
ID,
|
|
5
|
+
JSONObject,
|
|
6
|
+
Options,
|
|
7
|
+
AnalyticsInterface,
|
|
8
|
+
JitsuOptions,
|
|
9
|
+
PersistentStorage,
|
|
10
|
+
RuntimeFacade,
|
|
11
|
+
DynamicJitsuOptions,
|
|
12
|
+
} from "@jitsu/protocols/analytics";
|
|
13
|
+
export default function parse(input: any): any;
|
|
14
|
+
export declare const emptyAnalytics: AnalyticsInterface;
|
|
15
|
+
export declare function jitsuAnalytics(_opts: JitsuOptions): AnalyticsInterface;
|
|
16
|
+
export {
|
|
17
|
+
Callback,
|
|
18
|
+
DispatchedEvent,
|
|
19
|
+
ID,
|
|
20
|
+
JSONObject,
|
|
21
|
+
Options,
|
|
22
|
+
AnalyticsInterface,
|
|
23
|
+
JitsuOptions,
|
|
24
|
+
PersistentStorage,
|
|
25
|
+
RuntimeFacade,
|
|
26
|
+
DynamicJitsuOptions,
|
|
27
|
+
};
|
|
28
|
+
export * from "./analytics-plugin";
|