zubbl-sdk 1.1.12 → 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 +29 -5
- package/dist/zubbl-sdk.esm.js +29 -5
- package/dist/zubbl-sdk.umd.js +29 -5
- package/package.json +1 -1
package/dist/zubbl-sdk.cjs.js
CHANGED
|
@@ -25,9 +25,13 @@ function setSamplingRatio(ratio) {
|
|
|
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
|
@@ -23,9 +23,13 @@ function setSamplingRatio(ratio) {
|
|
|
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
|
@@ -27,9 +27,13 @@
|
|
|
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
|
});
|