zubbl-sdk 1.1.13 → 1.1.15

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.
@@ -25,7 +25,6 @@ function setSamplingRatio(ratio) {
25
25
  sampleRatio = ratio;
26
26
  }
27
27
 
28
- // ✅ Updated emitEndpoint to use new telemetry pipeline
29
28
  function emitEndpoint(payload) {
30
29
  if (!shouldSample()) return;
31
30
  const enriched = { ...payload, ts: Date.now(), source: "sdk" };
@@ -49,20 +48,28 @@ async function flushEndpointBuffer() {
49
48
  const telemetryUrl =
50
49
  process.env.ZUBBL_TELEMETRY_URL || `${config.baseUrl.replace(/\/$/, "")}/sdk/log`;
51
50
 
51
+ const headers = {
52
+ "Content-Type": "application/json",
53
+ Authorization: `Bearer ${config.apiKey}`,
54
+ "X-Tenant-Id": config.tenantId,
55
+ "X-App-Id": config.appId,
56
+ };
57
+ const firstWithUser = batch.find(ev => ev.external_user_id);
58
+ if (firstWithUser?.external_user_id) {
59
+ headers["X-External-User-Id"] = firstWithUser.external_user_id;
60
+ }
52
61
  console.log("[Zubbl SDK][Telemetry] Flushing batch:", {
53
62
  url: telemetryUrl,
54
63
  count: batch.length,
55
64
  sampleRatio,
56
65
  payload: batch,
66
+ headers,
57
67
  });
58
68
 
59
69
  try {
60
70
  const resp = await fetch(telemetryUrl, {
61
71
  method: "POST",
62
- headers: {
63
- "Content-Type": "application/json",
64
- "X-Zubbl-SDK-Token": config.apiKey || "missing",
65
- },
72
+ headers,
66
73
  body: JSON.stringify(batch),
67
74
  });
68
75
 
@@ -91,7 +98,7 @@ async function zubblFetch(input, init = {}, context = {}) {
91
98
  app_id: context.app_id || config.appId,
92
99
  external_user_id: context.external_user_id,
93
100
  method: init.method || "GET",
94
- path: url.pathname, // 🔥 fixed: always "path"
101
+ path: url.pathname, // fixed to "path"
95
102
  status: response?.status ?? 0,
96
103
  latency_ms,
97
104
  });
@@ -23,7 +23,6 @@ function setSamplingRatio(ratio) {
23
23
  sampleRatio = ratio;
24
24
  }
25
25
 
26
- // ✅ Updated emitEndpoint to use new telemetry pipeline
27
26
  function emitEndpoint(payload) {
28
27
  if (!shouldSample()) return;
29
28
  const enriched = { ...payload, ts: Date.now(), source: "sdk" };
@@ -47,20 +46,28 @@ async function flushEndpointBuffer() {
47
46
  const telemetryUrl =
48
47
  process.env.ZUBBL_TELEMETRY_URL || `${config.baseUrl.replace(/\/$/, "")}/sdk/log`;
49
48
 
49
+ const headers = {
50
+ "Content-Type": "application/json",
51
+ Authorization: `Bearer ${config.apiKey}`,
52
+ "X-Tenant-Id": config.tenantId,
53
+ "X-App-Id": config.appId,
54
+ };
55
+ const firstWithUser = batch.find(ev => ev.external_user_id);
56
+ if (firstWithUser?.external_user_id) {
57
+ headers["X-External-User-Id"] = firstWithUser.external_user_id;
58
+ }
50
59
  console.log("[Zubbl SDK][Telemetry] Flushing batch:", {
51
60
  url: telemetryUrl,
52
61
  count: batch.length,
53
62
  sampleRatio,
54
63
  payload: batch,
64
+ headers,
55
65
  });
56
66
 
57
67
  try {
58
68
  const resp = await fetch(telemetryUrl, {
59
69
  method: "POST",
60
- headers: {
61
- "Content-Type": "application/json",
62
- "X-Zubbl-SDK-Token": config.apiKey || "missing",
63
- },
70
+ headers,
64
71
  body: JSON.stringify(batch),
65
72
  });
66
73
 
@@ -89,7 +96,7 @@ async function zubblFetch(input, init = {}, context = {}) {
89
96
  app_id: context.app_id || config.appId,
90
97
  external_user_id: context.external_user_id,
91
98
  method: init.method || "GET",
92
- path: url.pathname, // 🔥 fixed: always "path"
99
+ path: url.pathname, // fixed to "path"
93
100
  status: response?.status ?? 0,
94
101
  latency_ms,
95
102
  });
@@ -27,7 +27,6 @@
27
27
  sampleRatio = ratio;
28
28
  }
29
29
 
30
- // ✅ Updated emitEndpoint to use new telemetry pipeline
31
30
  function emitEndpoint(payload) {
32
31
  if (!shouldSample()) return;
33
32
  const enriched = { ...payload, ts: Date.now(), source: "sdk" };
@@ -51,20 +50,28 @@
51
50
  const telemetryUrl =
52
51
  process.env.ZUBBL_TELEMETRY_URL || `${config.baseUrl.replace(/\/$/, "")}/sdk/log`;
53
52
 
53
+ const headers = {
54
+ "Content-Type": "application/json",
55
+ Authorization: `Bearer ${config.apiKey}`,
56
+ "X-Tenant-Id": config.tenantId,
57
+ "X-App-Id": config.appId,
58
+ };
59
+ const firstWithUser = batch.find(ev => ev.external_user_id);
60
+ if (firstWithUser?.external_user_id) {
61
+ headers["X-External-User-Id"] = firstWithUser.external_user_id;
62
+ }
54
63
  console.log("[Zubbl SDK][Telemetry] Flushing batch:", {
55
64
  url: telemetryUrl,
56
65
  count: batch.length,
57
66
  sampleRatio,
58
67
  payload: batch,
68
+ headers,
59
69
  });
60
70
 
61
71
  try {
62
72
  const resp = await fetch(telemetryUrl, {
63
73
  method: "POST",
64
- headers: {
65
- "Content-Type": "application/json",
66
- "X-Zubbl-SDK-Token": config.apiKey || "missing",
67
- },
74
+ headers,
68
75
  body: JSON.stringify(batch),
69
76
  });
70
77
 
@@ -93,7 +100,7 @@
93
100
  app_id: context.app_id || config.appId,
94
101
  external_user_id: context.external_user_id,
95
102
  method: init.method || "GET",
96
- path: url.pathname, // 🔥 fixed: always "path"
103
+ path: url.pathname, // fixed to "path"
97
104
  status: response?.status ?? 0,
98
105
  latency_ms,
99
106
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zubbl-sdk",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "type": "module",
5
5
  "description": "Zubbl SDK for secure policy enforcement (browser, Node, universal)",
6
6
  "main": "dist/zubbl-sdk.cjs.js",