zubbl-sdk 1.1.1 → 1.1.3
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 +23 -4
- package/dist/zubbl-sdk.esm.js +23 -4
- package/dist/zubbl-sdk.umd.js +23 -4
- package/package.json +1 -1
package/dist/zubbl-sdk.cjs.js
CHANGED
|
@@ -8,6 +8,9 @@ let config = {
|
|
|
8
8
|
appId: null
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Initialize SDK with API credentials.
|
|
13
|
+
*/
|
|
11
14
|
function init({ apiKey, tenantId, appId }) {
|
|
12
15
|
if (!apiKey || !tenantId || !appId) {
|
|
13
16
|
throw new Error("apiKey, tenantId, and appId are required");
|
|
@@ -15,6 +18,10 @@ function init({ apiKey, tenantId, appId }) {
|
|
|
15
18
|
config = { apiKey, tenantId, appId };
|
|
16
19
|
}
|
|
17
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Identify a user by email (and optional name).
|
|
23
|
+
* Returns user info including external_user_id.
|
|
24
|
+
*/
|
|
18
25
|
async function identifyUser({ email, name }) {
|
|
19
26
|
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
20
27
|
throw new Error("Zubbl SDK not initialized");
|
|
@@ -22,11 +29,11 @@ async function identifyUser({ email, name }) {
|
|
|
22
29
|
if (!email) throw new Error("email is required");
|
|
23
30
|
|
|
24
31
|
try {
|
|
25
|
-
// Correct: send Authorization header as Bearer
|
|
26
32
|
const headers = {
|
|
27
33
|
Authorization: `Bearer ${config.apiKey}`,
|
|
28
34
|
"X-Tenant-Id": config.tenantId,
|
|
29
|
-
"X-App-Id": config.appId
|
|
35
|
+
"X-App-Id": config.appId,
|
|
36
|
+
"Content-Type": "application/json"
|
|
30
37
|
};
|
|
31
38
|
|
|
32
39
|
const response = await axios.post(
|
|
@@ -38,11 +45,19 @@ async function identifyUser({ email, name }) {
|
|
|
38
45
|
console.log("[ZUBBL SDK] identifyUser response:", response.data);
|
|
39
46
|
return response.data;
|
|
40
47
|
} catch (err) {
|
|
41
|
-
|
|
48
|
+
// Forward server message for easier debugging
|
|
49
|
+
if (err.response && err.response.data) {
|
|
50
|
+
console.error("[ZUBBL SDK] identifyUser error:", err.response.data);
|
|
51
|
+
throw err.response.data;
|
|
52
|
+
}
|
|
53
|
+
console.error("[ZUBBL SDK] identifyUser error:", err);
|
|
42
54
|
throw err;
|
|
43
55
|
}
|
|
44
56
|
}
|
|
45
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Get tiles for a user using their external_user_id.
|
|
60
|
+
*/
|
|
46
61
|
async function getTiles({ external_user_id }) {
|
|
47
62
|
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
48
63
|
throw new Error("Zubbl SDK not initialized");
|
|
@@ -64,7 +79,11 @@ async function getTiles({ external_user_id }) {
|
|
|
64
79
|
console.log("[ZUBBL SDK] getTiles response:", response.data);
|
|
65
80
|
return response.data;
|
|
66
81
|
} catch (err) {
|
|
67
|
-
|
|
82
|
+
if (err.response && err.response.data) {
|
|
83
|
+
console.error("[ZUBBL SDK] getTiles error:", err.response.data);
|
|
84
|
+
throw err.response.data;
|
|
85
|
+
}
|
|
86
|
+
console.error("[ZUBBL SDK] getTiles error:", err);
|
|
68
87
|
throw err;
|
|
69
88
|
}
|
|
70
89
|
}
|
package/dist/zubbl-sdk.esm.js
CHANGED
|
@@ -6,6 +6,9 @@ let config = {
|
|
|
6
6
|
appId: null
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Initialize SDK with API credentials.
|
|
11
|
+
*/
|
|
9
12
|
function init({ apiKey, tenantId, appId }) {
|
|
10
13
|
if (!apiKey || !tenantId || !appId) {
|
|
11
14
|
throw new Error("apiKey, tenantId, and appId are required");
|
|
@@ -13,6 +16,10 @@ function init({ apiKey, tenantId, appId }) {
|
|
|
13
16
|
config = { apiKey, tenantId, appId };
|
|
14
17
|
}
|
|
15
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Identify a user by email (and optional name).
|
|
21
|
+
* Returns user info including external_user_id.
|
|
22
|
+
*/
|
|
16
23
|
async function identifyUser({ email, name }) {
|
|
17
24
|
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
18
25
|
throw new Error("Zubbl SDK not initialized");
|
|
@@ -20,11 +27,11 @@ async function identifyUser({ email, name }) {
|
|
|
20
27
|
if (!email) throw new Error("email is required");
|
|
21
28
|
|
|
22
29
|
try {
|
|
23
|
-
// Correct: send Authorization header as Bearer
|
|
24
30
|
const headers = {
|
|
25
31
|
Authorization: `Bearer ${config.apiKey}`,
|
|
26
32
|
"X-Tenant-Id": config.tenantId,
|
|
27
|
-
"X-App-Id": config.appId
|
|
33
|
+
"X-App-Id": config.appId,
|
|
34
|
+
"Content-Type": "application/json"
|
|
28
35
|
};
|
|
29
36
|
|
|
30
37
|
const response = await axios.post(
|
|
@@ -36,11 +43,19 @@ async function identifyUser({ email, name }) {
|
|
|
36
43
|
console.log("[ZUBBL SDK] identifyUser response:", response.data);
|
|
37
44
|
return response.data;
|
|
38
45
|
} catch (err) {
|
|
39
|
-
|
|
46
|
+
// Forward server message for easier debugging
|
|
47
|
+
if (err.response && err.response.data) {
|
|
48
|
+
console.error("[ZUBBL SDK] identifyUser error:", err.response.data);
|
|
49
|
+
throw err.response.data;
|
|
50
|
+
}
|
|
51
|
+
console.error("[ZUBBL SDK] identifyUser error:", err);
|
|
40
52
|
throw err;
|
|
41
53
|
}
|
|
42
54
|
}
|
|
43
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Get tiles for a user using their external_user_id.
|
|
58
|
+
*/
|
|
44
59
|
async function getTiles({ external_user_id }) {
|
|
45
60
|
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
46
61
|
throw new Error("Zubbl SDK not initialized");
|
|
@@ -62,7 +77,11 @@ async function getTiles({ external_user_id }) {
|
|
|
62
77
|
console.log("[ZUBBL SDK] getTiles response:", response.data);
|
|
63
78
|
return response.data;
|
|
64
79
|
} catch (err) {
|
|
65
|
-
|
|
80
|
+
if (err.response && err.response.data) {
|
|
81
|
+
console.error("[ZUBBL SDK] getTiles error:", err.response.data);
|
|
82
|
+
throw err.response.data;
|
|
83
|
+
}
|
|
84
|
+
console.error("[ZUBBL SDK] getTiles error:", err);
|
|
66
85
|
throw err;
|
|
67
86
|
}
|
|
68
87
|
}
|
package/dist/zubbl-sdk.umd.js
CHANGED
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
appId: null
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Initialize SDK with API credentials.
|
|
15
|
+
*/
|
|
13
16
|
function init({ apiKey, tenantId, appId }) {
|
|
14
17
|
if (!apiKey || !tenantId || !appId) {
|
|
15
18
|
throw new Error("apiKey, tenantId, and appId are required");
|
|
@@ -17,6 +20,10 @@
|
|
|
17
20
|
config = { apiKey, tenantId, appId };
|
|
18
21
|
}
|
|
19
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Identify a user by email (and optional name).
|
|
25
|
+
* Returns user info including external_user_id.
|
|
26
|
+
*/
|
|
20
27
|
async function identifyUser({ email, name }) {
|
|
21
28
|
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
22
29
|
throw new Error("Zubbl SDK not initialized");
|
|
@@ -24,11 +31,11 @@
|
|
|
24
31
|
if (!email) throw new Error("email is required");
|
|
25
32
|
|
|
26
33
|
try {
|
|
27
|
-
// Correct: send Authorization header as Bearer
|
|
28
34
|
const headers = {
|
|
29
35
|
Authorization: `Bearer ${config.apiKey}`,
|
|
30
36
|
"X-Tenant-Id": config.tenantId,
|
|
31
|
-
"X-App-Id": config.appId
|
|
37
|
+
"X-App-Id": config.appId,
|
|
38
|
+
"Content-Type": "application/json"
|
|
32
39
|
};
|
|
33
40
|
|
|
34
41
|
const response = await axios.post(
|
|
@@ -40,11 +47,19 @@
|
|
|
40
47
|
console.log("[ZUBBL SDK] identifyUser response:", response.data);
|
|
41
48
|
return response.data;
|
|
42
49
|
} catch (err) {
|
|
43
|
-
|
|
50
|
+
// Forward server message for easier debugging
|
|
51
|
+
if (err.response && err.response.data) {
|
|
52
|
+
console.error("[ZUBBL SDK] identifyUser error:", err.response.data);
|
|
53
|
+
throw err.response.data;
|
|
54
|
+
}
|
|
55
|
+
console.error("[ZUBBL SDK] identifyUser error:", err);
|
|
44
56
|
throw err;
|
|
45
57
|
}
|
|
46
58
|
}
|
|
47
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Get tiles for a user using their external_user_id.
|
|
62
|
+
*/
|
|
48
63
|
async function getTiles({ external_user_id }) {
|
|
49
64
|
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
50
65
|
throw new Error("Zubbl SDK not initialized");
|
|
@@ -66,7 +81,11 @@
|
|
|
66
81
|
console.log("[ZUBBL SDK] getTiles response:", response.data);
|
|
67
82
|
return response.data;
|
|
68
83
|
} catch (err) {
|
|
69
|
-
|
|
84
|
+
if (err.response && err.response.data) {
|
|
85
|
+
console.error("[ZUBBL SDK] getTiles error:", err.response.data);
|
|
86
|
+
throw err.response.data;
|
|
87
|
+
}
|
|
88
|
+
console.error("[ZUBBL SDK] getTiles error:", err);
|
|
70
89
|
throw err;
|
|
71
90
|
}
|
|
72
91
|
}
|