unshared-clientjs-sdk 1.0.2 → 1.0.4
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/client.d.ts +2 -0
- package/dist/client.js +5 -4
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export interface UnsharedLabsClientConfig {
|
|
2
2
|
apiKey: string;
|
|
3
|
+
clientId: string;
|
|
3
4
|
baseUrl?: string;
|
|
4
5
|
}
|
|
5
6
|
export default class UnsharedLabsClient {
|
|
6
7
|
private _UNSHAREDLABS_DEFAULT_URL;
|
|
7
8
|
private _UNSHAREDLABS_INTERNAL_CLIENT;
|
|
8
9
|
private _apiKey;
|
|
10
|
+
private _clientId;
|
|
9
11
|
constructor(config: UnsharedLabsClientConfig);
|
|
10
12
|
private _getSupabaseClient;
|
|
11
13
|
submitEvent(eventType: string, userId: string, ipAddress: string, deviceId: string, sessionHash: string, userAgent: string, clientTimestamp: string, eventDetails?: Map<string, any> | null): Promise<any>;
|
package/dist/client.js
CHANGED
|
@@ -4,9 +4,10 @@ const supabase_js_1 = require("@supabase/supabase-js");
|
|
|
4
4
|
const util_1 = require("./util");
|
|
5
5
|
class UnsharedLabsClient {
|
|
6
6
|
constructor(config) {
|
|
7
|
-
this._UNSHAREDLABS_DEFAULT_URL = '
|
|
7
|
+
this._UNSHAREDLABS_DEFAULT_URL = atob('aHR0cHM6Ly95c3Vmem5jZXR0d2VyYnlhbXlneC5zdXBhYmFzZS5jbwo=');
|
|
8
8
|
let url = config.baseUrl || this._UNSHAREDLABS_DEFAULT_URL;
|
|
9
9
|
this._apiKey = config.apiKey;
|
|
10
|
+
this._clientId = atob(config.clientId);
|
|
10
11
|
this._UNSHAREDLABS_INTERNAL_CLIENT = this._getSupabaseClient(url, this._apiKey);
|
|
11
12
|
}
|
|
12
13
|
_getSupabaseClient(url, apiKey) {
|
|
@@ -35,13 +36,13 @@ class UnsharedLabsClient {
|
|
|
35
36
|
client_timestamp: clientTimestamp,
|
|
36
37
|
event_details: encryptedEventDetails,
|
|
37
38
|
};
|
|
38
|
-
const { data, error } = await this._UNSHAREDLABS_INTERNAL_CLIENT
|
|
39
|
-
.from(
|
|
39
|
+
const { status, statusText, data, error } = await this._UNSHAREDLABS_INTERNAL_CLIENT
|
|
40
|
+
.from(this._clientId)
|
|
40
41
|
.insert(body);
|
|
41
42
|
if (error) {
|
|
42
43
|
throw error;
|
|
43
44
|
}
|
|
44
|
-
return data;
|
|
45
|
+
return { status, statusText, data };
|
|
45
46
|
}
|
|
46
47
|
catch (error) {
|
|
47
48
|
throw new Error(`Failed to call UnsharedLabs API: ${error instanceof Error ? error.message : JSON.stringify(error)}`);
|