zubbl-sdk 1.1.11 → 1.1.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/dist/zubbl-sdk.cjs.js +30 -6
- package/dist/zubbl-sdk.esm.js +30 -6
- package/dist/zubbl-sdk.umd.js +30 -6
- package/package.json +4 -2
package/dist/zubbl-sdk.cjs.js
CHANGED
|
@@ -21,13 +21,17 @@ function shouldSample() {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
function setSamplingRatio(ratio) {
|
|
24
|
-
if (ratio
|
|
24
|
+
if (ratio < 0 || ratio > 1) throw new Error("Sampling ratio must be between 0 and 1");
|
|
25
25
|
sampleRatio = ratio;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
// ✅ Updated emitEndpoint to use new telemetry pipeline
|
|
28
29
|
function emitEndpoint(payload) {
|
|
29
30
|
if (!shouldSample()) return;
|
|
30
|
-
|
|
31
|
+
const enriched = { ...payload, ts: Date.now(), source: "sdk" };
|
|
32
|
+
endpointBuffer.push(enriched);
|
|
33
|
+
console.log("[Zubbl SDK][Telemetry] Queued endpoint:", enriched);
|
|
34
|
+
|
|
31
35
|
if (!debounceTimer) {
|
|
32
36
|
debounceTimer = setTimeout(flushEndpointBuffer, 200);
|
|
33
37
|
}
|
|
@@ -41,14 +45,34 @@ async function flushEndpointBuffer() {
|
|
|
41
45
|
const batch = [...endpointBuffer];
|
|
42
46
|
endpointBuffer = [];
|
|
43
47
|
debounceTimer = null;
|
|
48
|
+
|
|
49
|
+
const telemetryUrl =
|
|
50
|
+
process.env.ZUBBL_TELEMETRY_URL || `${config.baseUrl.replace(/\/$/, "")}/sdk/log`;
|
|
51
|
+
|
|
52
|
+
console.log("[Zubbl SDK][Telemetry] Flushing batch:", {
|
|
53
|
+
url: telemetryUrl,
|
|
54
|
+
count: batch.length,
|
|
55
|
+
sampleRatio,
|
|
56
|
+
payload: batch,
|
|
57
|
+
});
|
|
58
|
+
|
|
44
59
|
try {
|
|
45
|
-
await fetch(
|
|
60
|
+
const resp = await fetch(telemetryUrl, {
|
|
46
61
|
method: "POST",
|
|
47
|
-
headers: {
|
|
62
|
+
headers: {
|
|
63
|
+
"Content-Type": "application/json",
|
|
64
|
+
"X-Zubbl-SDK-Token": config.apiKey || "missing",
|
|
65
|
+
},
|
|
48
66
|
body: JSON.stringify(batch),
|
|
49
67
|
});
|
|
68
|
+
|
|
69
|
+
const text = await resp.text();
|
|
70
|
+
console.log("[Zubbl SDK][Telemetry] Response:", {
|
|
71
|
+
status: resp.status,
|
|
72
|
+
body: text,
|
|
73
|
+
});
|
|
50
74
|
} catch (err) {
|
|
51
|
-
console.error("[Zubbl SDK] Failed to send
|
|
75
|
+
console.error("[Zubbl SDK][Telemetry] Failed to send batch:", err);
|
|
52
76
|
}
|
|
53
77
|
}
|
|
54
78
|
|
|
@@ -67,7 +91,7 @@ async function zubblFetch(input, init = {}, context = {}) {
|
|
|
67
91
|
app_id: context.app_id || config.appId,
|
|
68
92
|
external_user_id: context.external_user_id,
|
|
69
93
|
method: init.method || "GET",
|
|
70
|
-
|
|
94
|
+
path: url.pathname, // 🔥 fixed: always "path"
|
|
71
95
|
status: response?.status ?? 0,
|
|
72
96
|
latency_ms,
|
|
73
97
|
});
|
package/dist/zubbl-sdk.esm.js
CHANGED
|
@@ -19,13 +19,17 @@ function shouldSample() {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function setSamplingRatio(ratio) {
|
|
22
|
-
if (ratio
|
|
22
|
+
if (ratio < 0 || ratio > 1) throw new Error("Sampling ratio must be between 0 and 1");
|
|
23
23
|
sampleRatio = ratio;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
// ✅ Updated emitEndpoint to use new telemetry pipeline
|
|
26
27
|
function emitEndpoint(payload) {
|
|
27
28
|
if (!shouldSample()) return;
|
|
28
|
-
|
|
29
|
+
const enriched = { ...payload, ts: Date.now(), source: "sdk" };
|
|
30
|
+
endpointBuffer.push(enriched);
|
|
31
|
+
console.log("[Zubbl SDK][Telemetry] Queued endpoint:", enriched);
|
|
32
|
+
|
|
29
33
|
if (!debounceTimer) {
|
|
30
34
|
debounceTimer = setTimeout(flushEndpointBuffer, 200);
|
|
31
35
|
}
|
|
@@ -39,14 +43,34 @@ async function flushEndpointBuffer() {
|
|
|
39
43
|
const batch = [...endpointBuffer];
|
|
40
44
|
endpointBuffer = [];
|
|
41
45
|
debounceTimer = null;
|
|
46
|
+
|
|
47
|
+
const telemetryUrl =
|
|
48
|
+
process.env.ZUBBL_TELEMETRY_URL || `${config.baseUrl.replace(/\/$/, "")}/sdk/log`;
|
|
49
|
+
|
|
50
|
+
console.log("[Zubbl SDK][Telemetry] Flushing batch:", {
|
|
51
|
+
url: telemetryUrl,
|
|
52
|
+
count: batch.length,
|
|
53
|
+
sampleRatio,
|
|
54
|
+
payload: batch,
|
|
55
|
+
});
|
|
56
|
+
|
|
42
57
|
try {
|
|
43
|
-
await fetch(
|
|
58
|
+
const resp = await fetch(telemetryUrl, {
|
|
44
59
|
method: "POST",
|
|
45
|
-
headers: {
|
|
60
|
+
headers: {
|
|
61
|
+
"Content-Type": "application/json",
|
|
62
|
+
"X-Zubbl-SDK-Token": config.apiKey || "missing",
|
|
63
|
+
},
|
|
46
64
|
body: JSON.stringify(batch),
|
|
47
65
|
});
|
|
66
|
+
|
|
67
|
+
const text = await resp.text();
|
|
68
|
+
console.log("[Zubbl SDK][Telemetry] Response:", {
|
|
69
|
+
status: resp.status,
|
|
70
|
+
body: text,
|
|
71
|
+
});
|
|
48
72
|
} catch (err) {
|
|
49
|
-
console.error("[Zubbl SDK] Failed to send
|
|
73
|
+
console.error("[Zubbl SDK][Telemetry] Failed to send batch:", err);
|
|
50
74
|
}
|
|
51
75
|
}
|
|
52
76
|
|
|
@@ -65,7 +89,7 @@ async function zubblFetch(input, init = {}, context = {}) {
|
|
|
65
89
|
app_id: context.app_id || config.appId,
|
|
66
90
|
external_user_id: context.external_user_id,
|
|
67
91
|
method: init.method || "GET",
|
|
68
|
-
|
|
92
|
+
path: url.pathname, // 🔥 fixed: always "path"
|
|
69
93
|
status: response?.status ?? 0,
|
|
70
94
|
latency_ms,
|
|
71
95
|
});
|
package/dist/zubbl-sdk.umd.js
CHANGED
|
@@ -23,13 +23,17 @@
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function setSamplingRatio(ratio) {
|
|
26
|
-
if (ratio
|
|
26
|
+
if (ratio < 0 || ratio > 1) throw new Error("Sampling ratio must be between 0 and 1");
|
|
27
27
|
sampleRatio = ratio;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
// ✅ Updated emitEndpoint to use new telemetry pipeline
|
|
30
31
|
function emitEndpoint(payload) {
|
|
31
32
|
if (!shouldSample()) return;
|
|
32
|
-
|
|
33
|
+
const enriched = { ...payload, ts: Date.now(), source: "sdk" };
|
|
34
|
+
endpointBuffer.push(enriched);
|
|
35
|
+
console.log("[Zubbl SDK][Telemetry] Queued endpoint:", enriched);
|
|
36
|
+
|
|
33
37
|
if (!debounceTimer) {
|
|
34
38
|
debounceTimer = setTimeout(flushEndpointBuffer, 200);
|
|
35
39
|
}
|
|
@@ -43,14 +47,34 @@
|
|
|
43
47
|
const batch = [...endpointBuffer];
|
|
44
48
|
endpointBuffer = [];
|
|
45
49
|
debounceTimer = null;
|
|
50
|
+
|
|
51
|
+
const telemetryUrl =
|
|
52
|
+
process.env.ZUBBL_TELEMETRY_URL || `${config.baseUrl.replace(/\/$/, "")}/sdk/log`;
|
|
53
|
+
|
|
54
|
+
console.log("[Zubbl SDK][Telemetry] Flushing batch:", {
|
|
55
|
+
url: telemetryUrl,
|
|
56
|
+
count: batch.length,
|
|
57
|
+
sampleRatio,
|
|
58
|
+
payload: batch,
|
|
59
|
+
});
|
|
60
|
+
|
|
46
61
|
try {
|
|
47
|
-
await fetch(
|
|
62
|
+
const resp = await fetch(telemetryUrl, {
|
|
48
63
|
method: "POST",
|
|
49
|
-
headers: {
|
|
64
|
+
headers: {
|
|
65
|
+
"Content-Type": "application/json",
|
|
66
|
+
"X-Zubbl-SDK-Token": config.apiKey || "missing",
|
|
67
|
+
},
|
|
50
68
|
body: JSON.stringify(batch),
|
|
51
69
|
});
|
|
70
|
+
|
|
71
|
+
const text = await resp.text();
|
|
72
|
+
console.log("[Zubbl SDK][Telemetry] Response:", {
|
|
73
|
+
status: resp.status,
|
|
74
|
+
body: text,
|
|
75
|
+
});
|
|
52
76
|
} catch (err) {
|
|
53
|
-
console.error("[Zubbl SDK] Failed to send
|
|
77
|
+
console.error("[Zubbl SDK][Telemetry] Failed to send batch:", err);
|
|
54
78
|
}
|
|
55
79
|
}
|
|
56
80
|
|
|
@@ -69,7 +93,7 @@
|
|
|
69
93
|
app_id: context.app_id || config.appId,
|
|
70
94
|
external_user_id: context.external_user_id,
|
|
71
95
|
method: init.method || "GET",
|
|
72
|
-
|
|
96
|
+
path: url.pathname, // 🔥 fixed: always "path"
|
|
73
97
|
status: response?.status ?? 0,
|
|
74
98
|
latency_ms,
|
|
75
99
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zubbl-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.13",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "Zubbl SDK for secure policy enforcement (browser, Node, universal)",
|
|
5
6
|
"main": "dist/zubbl-sdk.cjs.js",
|
|
6
7
|
"module": "dist/zubbl-sdk.esm.js",
|
|
@@ -21,13 +22,14 @@
|
|
|
21
22
|
"scripts": {
|
|
22
23
|
"build": "rollup -c",
|
|
23
24
|
"prepublishOnly": "npm run build",
|
|
24
|
-
"test": "
|
|
25
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
|
|
25
26
|
},
|
|
26
27
|
"repository": "https://github.com/zubbl/zubbl-sdk",
|
|
27
28
|
"author": "Zubbl",
|
|
28
29
|
"license": "MIT",
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
32
|
+
"jest": "^30.1.3",
|
|
31
33
|
"rollup": "^4.2.0"
|
|
32
34
|
},
|
|
33
35
|
"dependencies": {
|