zubbl-sdk 1.1.3 → 1.1.5
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 +14 -7
- package/dist/zubbl-sdk.esm.js +14 -7
- package/dist/zubbl-sdk.umd.js +14 -7
- package/package.json +1 -1
package/dist/zubbl-sdk.cjs.js
CHANGED
|
@@ -5,17 +5,23 @@ var axios = require('axios');
|
|
|
5
5
|
let config = {
|
|
6
6
|
apiKey: null,
|
|
7
7
|
tenantId: null,
|
|
8
|
-
appId: null
|
|
8
|
+
appId: null,
|
|
9
|
+
baseUrl: "https://api.zubbl.com/api" // ✅ Default to Worker-routed path
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Initialize SDK with API credentials.
|
|
13
14
|
*/
|
|
14
|
-
function init({ apiKey, tenantId, appId }) {
|
|
15
|
+
function init({ apiKey, tenantId, appId, baseUrl }) {
|
|
15
16
|
if (!apiKey || !tenantId || !appId) {
|
|
16
17
|
throw new Error("apiKey, tenantId, and appId are required");
|
|
17
18
|
}
|
|
18
|
-
config = {
|
|
19
|
+
config = {
|
|
20
|
+
apiKey,
|
|
21
|
+
tenantId,
|
|
22
|
+
appId,
|
|
23
|
+
baseUrl: baseUrl || "https://api.zubbl.com/api" // ✅ Override if provided
|
|
24
|
+
};
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
/**
|
|
@@ -37,7 +43,7 @@ async function identifyUser({ email, name }) {
|
|
|
37
43
|
};
|
|
38
44
|
|
|
39
45
|
const response = await axios.post(
|
|
40
|
-
|
|
46
|
+
`${config.baseUrl}/sdk/identify`, // ✅ Now dynamic
|
|
41
47
|
{ email, name },
|
|
42
48
|
{ headers }
|
|
43
49
|
);
|
|
@@ -45,7 +51,6 @@ async function identifyUser({ email, name }) {
|
|
|
45
51
|
console.log("[ZUBBL SDK] identifyUser response:", response.data);
|
|
46
52
|
return response.data;
|
|
47
53
|
} catch (err) {
|
|
48
|
-
// Forward server message for easier debugging
|
|
49
54
|
if (err.response && err.response.data) {
|
|
50
55
|
console.error("[ZUBBL SDK] identifyUser error:", err.response.data);
|
|
51
56
|
throw err.response.data;
|
|
@@ -57,6 +62,7 @@ async function identifyUser({ email, name }) {
|
|
|
57
62
|
|
|
58
63
|
/**
|
|
59
64
|
* Get tiles for a user using their external_user_id.
|
|
65
|
+
* Sends all required headers for Worker + backend.
|
|
60
66
|
*/
|
|
61
67
|
async function getTiles({ external_user_id }) {
|
|
62
68
|
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
@@ -68,11 +74,12 @@ async function getTiles({ external_user_id }) {
|
|
|
68
74
|
const headers = {
|
|
69
75
|
Authorization: `Bearer ${config.apiKey}`,
|
|
70
76
|
"X-Tenant-Id": config.tenantId,
|
|
71
|
-
"X-App-Id": config.appId
|
|
77
|
+
"X-App-Id": config.appId,
|
|
78
|
+
"X-External-User-Id": external_user_id // <<<< CRITICAL for Worker
|
|
72
79
|
};
|
|
73
80
|
|
|
74
81
|
const response = await axios.get(
|
|
75
|
-
|
|
82
|
+
`${config.baseUrl}/sdk/external-users/${external_user_id}/tiles`, // ✅ Now dynamic
|
|
76
83
|
{ headers }
|
|
77
84
|
);
|
|
78
85
|
|
package/dist/zubbl-sdk.esm.js
CHANGED
|
@@ -3,17 +3,23 @@ import axios from 'axios';
|
|
|
3
3
|
let config = {
|
|
4
4
|
apiKey: null,
|
|
5
5
|
tenantId: null,
|
|
6
|
-
appId: null
|
|
6
|
+
appId: null,
|
|
7
|
+
baseUrl: "https://api.zubbl.com/api" // ✅ Default to Worker-routed path
|
|
7
8
|
};
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Initialize SDK with API credentials.
|
|
11
12
|
*/
|
|
12
|
-
function init({ apiKey, tenantId, appId }) {
|
|
13
|
+
function init({ apiKey, tenantId, appId, baseUrl }) {
|
|
13
14
|
if (!apiKey || !tenantId || !appId) {
|
|
14
15
|
throw new Error("apiKey, tenantId, and appId are required");
|
|
15
16
|
}
|
|
16
|
-
config = {
|
|
17
|
+
config = {
|
|
18
|
+
apiKey,
|
|
19
|
+
tenantId,
|
|
20
|
+
appId,
|
|
21
|
+
baseUrl: baseUrl || "https://api.zubbl.com/api" // ✅ Override if provided
|
|
22
|
+
};
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
/**
|
|
@@ -35,7 +41,7 @@ async function identifyUser({ email, name }) {
|
|
|
35
41
|
};
|
|
36
42
|
|
|
37
43
|
const response = await axios.post(
|
|
38
|
-
|
|
44
|
+
`${config.baseUrl}/sdk/identify`, // ✅ Now dynamic
|
|
39
45
|
{ email, name },
|
|
40
46
|
{ headers }
|
|
41
47
|
);
|
|
@@ -43,7 +49,6 @@ async function identifyUser({ email, name }) {
|
|
|
43
49
|
console.log("[ZUBBL SDK] identifyUser response:", response.data);
|
|
44
50
|
return response.data;
|
|
45
51
|
} catch (err) {
|
|
46
|
-
// Forward server message for easier debugging
|
|
47
52
|
if (err.response && err.response.data) {
|
|
48
53
|
console.error("[ZUBBL SDK] identifyUser error:", err.response.data);
|
|
49
54
|
throw err.response.data;
|
|
@@ -55,6 +60,7 @@ async function identifyUser({ email, name }) {
|
|
|
55
60
|
|
|
56
61
|
/**
|
|
57
62
|
* Get tiles for a user using their external_user_id.
|
|
63
|
+
* Sends all required headers for Worker + backend.
|
|
58
64
|
*/
|
|
59
65
|
async function getTiles({ external_user_id }) {
|
|
60
66
|
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
@@ -66,11 +72,12 @@ async function getTiles({ external_user_id }) {
|
|
|
66
72
|
const headers = {
|
|
67
73
|
Authorization: `Bearer ${config.apiKey}`,
|
|
68
74
|
"X-Tenant-Id": config.tenantId,
|
|
69
|
-
"X-App-Id": config.appId
|
|
75
|
+
"X-App-Id": config.appId,
|
|
76
|
+
"X-External-User-Id": external_user_id // <<<< CRITICAL for Worker
|
|
70
77
|
};
|
|
71
78
|
|
|
72
79
|
const response = await axios.get(
|
|
73
|
-
|
|
80
|
+
`${config.baseUrl}/sdk/external-users/${external_user_id}/tiles`, // ✅ Now dynamic
|
|
74
81
|
{ headers }
|
|
75
82
|
);
|
|
76
83
|
|
package/dist/zubbl-sdk.umd.js
CHANGED
|
@@ -7,17 +7,23 @@
|
|
|
7
7
|
let config = {
|
|
8
8
|
apiKey: null,
|
|
9
9
|
tenantId: null,
|
|
10
|
-
appId: null
|
|
10
|
+
appId: null,
|
|
11
|
+
baseUrl: "https://api.zubbl.com/api" // ✅ Default to Worker-routed path
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Initialize SDK with API credentials.
|
|
15
16
|
*/
|
|
16
|
-
function init({ apiKey, tenantId, appId }) {
|
|
17
|
+
function init({ apiKey, tenantId, appId, baseUrl }) {
|
|
17
18
|
if (!apiKey || !tenantId || !appId) {
|
|
18
19
|
throw new Error("apiKey, tenantId, and appId are required");
|
|
19
20
|
}
|
|
20
|
-
config = {
|
|
21
|
+
config = {
|
|
22
|
+
apiKey,
|
|
23
|
+
tenantId,
|
|
24
|
+
appId,
|
|
25
|
+
baseUrl: baseUrl || "https://api.zubbl.com/api" // ✅ Override if provided
|
|
26
|
+
};
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
/**
|
|
@@ -39,7 +45,7 @@
|
|
|
39
45
|
};
|
|
40
46
|
|
|
41
47
|
const response = await axios.post(
|
|
42
|
-
|
|
48
|
+
`${config.baseUrl}/sdk/identify`, // ✅ Now dynamic
|
|
43
49
|
{ email, name },
|
|
44
50
|
{ headers }
|
|
45
51
|
);
|
|
@@ -47,7 +53,6 @@
|
|
|
47
53
|
console.log("[ZUBBL SDK] identifyUser response:", response.data);
|
|
48
54
|
return response.data;
|
|
49
55
|
} catch (err) {
|
|
50
|
-
// Forward server message for easier debugging
|
|
51
56
|
if (err.response && err.response.data) {
|
|
52
57
|
console.error("[ZUBBL SDK] identifyUser error:", err.response.data);
|
|
53
58
|
throw err.response.data;
|
|
@@ -59,6 +64,7 @@
|
|
|
59
64
|
|
|
60
65
|
/**
|
|
61
66
|
* Get tiles for a user using their external_user_id.
|
|
67
|
+
* Sends all required headers for Worker + backend.
|
|
62
68
|
*/
|
|
63
69
|
async function getTiles({ external_user_id }) {
|
|
64
70
|
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
@@ -70,11 +76,12 @@
|
|
|
70
76
|
const headers = {
|
|
71
77
|
Authorization: `Bearer ${config.apiKey}`,
|
|
72
78
|
"X-Tenant-Id": config.tenantId,
|
|
73
|
-
"X-App-Id": config.appId
|
|
79
|
+
"X-App-Id": config.appId,
|
|
80
|
+
"X-External-User-Id": external_user_id // <<<< CRITICAL for Worker
|
|
74
81
|
};
|
|
75
82
|
|
|
76
83
|
const response = await axios.get(
|
|
77
|
-
|
|
84
|
+
`${config.baseUrl}/sdk/external-users/${external_user_id}/tiles`, // ✅ Now dynamic
|
|
78
85
|
{ headers }
|
|
79
86
|
);
|
|
80
87
|
|