@blux.ai/web-sdk 0.0.3 → 0.0.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/.prettierrc +0 -1
- package/.sentryclirc +3 -0
- package/README.md +147 -11
- package/demo/README.md +46 -0
- package/demo/craco.config.js +27 -0
- package/demo/package.json +48 -0
- package/demo/public/favicon.ico +0 -0
- package/demo/public/index.html +43 -0
- package/demo/public/logo192.png +0 -0
- package/demo/public/logo512.png +0 -0
- package/demo/public/manifest.json +25 -0
- package/demo/public/robots.txt +3 -0
- package/demo/src/App.test.tsx +9 -0
- package/demo/src/App.tsx +158 -0
- package/demo/src/index.css +16 -0
- package/demo/src/index.tsx +19 -0
- package/demo/src/react-app-env.d.ts +1 -0
- package/demo/src/reportWebVitals.ts +15 -0
- package/demo/src/setupTests.ts +5 -0
- package/demo/tailwind.config.js +8 -0
- package/demo/yarn.lock +10120 -0
- package/dist/BluxClient.d.ts +40 -15
- package/dist/BluxClient.js +317 -87
- package/dist/BluxClient.js.map +1 -0
- package/dist/constants/URLS.d.ts +12 -0
- package/dist/constants/URLS.js +19 -0
- package/dist/constants/URLS.js.map +1 -0
- package/dist/core/LocalStorage.d.ts +0 -9
- package/dist/core/LocalStorage.js +4 -26
- package/dist/core/LocalStorage.js.map +1 -0
- package/dist/core/Logger.d.ts +11 -12
- package/dist/core/Logger.js +61 -63
- package/dist/core/Logger.js.map +1 -0
- package/dist/events/AddCartaddEvent.d.ts +5 -0
- package/dist/{requests/Events → events}/AddCartaddEvent.js +13 -10
- package/dist/events/AddCartaddEvent.js.map +1 -0
- package/dist/events/AddCustomEvent.d.ts +5 -0
- package/dist/{requests/Events → events}/AddCustomEvent.js +14 -11
- package/dist/events/AddCustomEvent.js.map +1 -0
- package/dist/events/AddLikeEvent.d.ts +5 -0
- package/dist/{requests/Events → events}/AddLikeEvent.js +13 -10
- package/dist/events/AddLikeEvent.js.map +1 -0
- package/dist/events/AddPageViewEvent.d.ts +5 -0
- package/dist/{requests/Events → events}/AddPageViewEvent.js +11 -8
- package/dist/events/AddPageViewEvent.js.map +1 -0
- package/dist/events/AddProductDetailViewEvent.d.ts +5 -0
- package/dist/{requests/Events → events}/AddProductDetailViewEvent.js +13 -10
- package/dist/events/AddProductDetailViewEvent.js.map +1 -0
- package/dist/events/AddPurchaseEvent.d.ts +5 -0
- package/dist/{requests/Events → events}/AddPurchaseEvent.js +13 -10
- package/dist/events/AddPurchaseEvent.js.map +1 -0
- package/dist/events/AddRateEvent.d.ts +5 -0
- package/dist/{requests/Events → events}/AddRateEvent.js +14 -11
- package/dist/events/AddRateEvent.js.map +1 -0
- package/dist/events/AddRecommendationViewEvent.d.ts +5 -0
- package/dist/{requests/Events → events}/AddRecommendationViewEvent.js +12 -9
- package/dist/events/AddRecommendationViewEvent.js.map +1 -0
- package/dist/events/Event.d.ts +5 -0
- package/dist/events/Event.js +26 -0
- package/dist/events/Event.js.map +1 -0
- package/dist/{requests/Events → events}/index.js +4 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/types.d.ts +42 -0
- package/dist/events/types.js +6 -0
- package/dist/events/types.js.map +1 -0
- package/dist/index.d.ts +3 -4
- package/dist/index.js +20 -15
- package/dist/index.js.map +1 -0
- package/dist/utils/helper.js +4 -0
- package/dist/utils/helper.js.map +1 -0
- package/dist/utils/operators.d.ts +2 -0
- package/dist/utils/operators.js +12 -0
- package/dist/utils/operators.js.map +1 -0
- package/dist/utils/sentry.d.ts +2 -0
- package/dist/utils/sentry.js +50 -0
- package/dist/utils/sentry.js.map +1 -0
- package/package.json +13 -3
- package/.vscode/settings.json +0 -7
- package/dist/core/BaseErrorHandler.d.ts +0 -3
- package/dist/core/BaseErrorHandler.js +0 -13
- package/dist/core/HTTPClient.d.ts +0 -10
- package/dist/core/HTTPClient.js +0 -122
- package/dist/requests/Devices/ActivateDevice.d.ts +0 -8
- package/dist/requests/Devices/ActivateDevice.js +0 -39
- package/dist/requests/Devices/CreateDevice.d.ts +0 -14
- package/dist/requests/Devices/CreateDevice.js +0 -54
- package/dist/requests/Devices/UpdateDevice.d.ts +0 -17
- package/dist/requests/Devices/UpdateDevice.js +0 -61
- package/dist/requests/Devices/index.d.ts +0 -3
- package/dist/requests/Devices/index.js +0 -19
- package/dist/requests/Events/AddCartaddEvent.d.ts +0 -5
- package/dist/requests/Events/AddCustomEvent.d.ts +0 -5
- package/dist/requests/Events/AddLikeEvent.d.ts +0 -5
- package/dist/requests/Events/AddPageViewEvent.d.ts +0 -5
- package/dist/requests/Events/AddProductDetailViewEvent.d.ts +0 -5
- package/dist/requests/Events/AddPurchaseEvent.d.ts +0 -5
- package/dist/requests/Events/AddRateEvent.d.ts +0 -5
- package/dist/requests/Events/AddRecommendationViewEvent.d.ts +0 -5
- package/dist/requests/Events/EventRequest.d.ts +0 -17
- package/dist/requests/Events/EventRequest.js +0 -56
- package/dist/requests/Events/types.d.ts +0 -42
- package/dist/requests/Events/types.js +0 -2
- package/dist/requests/Request.d.ts +0 -12
- package/dist/requests/Request.js +0 -22
- package/dist/requests/Users/UpdateUserProperties.d.ts +0 -17
- package/dist/requests/Users/UpdateUserProperties.js +0 -54
- package/dist/requests/Users/index.d.ts +0 -1
- package/dist/requests/Users/index.js +0 -17
- package/dist/requests/Users/types.d.ts +0 -12
- package/dist/requests/Users/types.js +0 -2
- package/dist/requests/index.d.ts +0 -3
- package/dist/requests/index.js +0 -19
- package/dist/utils/types.d.ts +0 -2
- package/dist/utils/types.js +0 -11
- /package/dist/{requests/Events → events}/index.d.ts +0 -0
package/dist/BluxClient.d.ts
CHANGED
|
@@ -1,17 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import "./utils/sentry";
|
|
2
|
+
import { BehaviorSubject } from "rxjs";
|
|
3
|
+
import { LogLevel } from "./core/Logger";
|
|
4
|
+
import { EventRequest } from "./events/types";
|
|
5
|
+
import { Event } from "./events/Event";
|
|
6
|
+
export type SdkInfo = {
|
|
7
|
+
type: string;
|
|
8
|
+
version: string;
|
|
9
|
+
};
|
|
10
|
+
type BluxUser = {
|
|
11
|
+
id: string;
|
|
12
|
+
bluxApiKey: string;
|
|
13
|
+
organizationId: string;
|
|
14
|
+
deviceId: string;
|
|
15
|
+
userId?: string;
|
|
16
|
+
};
|
|
17
|
+
declare class BluxClient {
|
|
18
|
+
private readonly STAGE;
|
|
19
|
+
private readonly identifierApi;
|
|
20
|
+
private readonly collectorApi;
|
|
21
|
+
private readonly sdkInfo;
|
|
22
|
+
readonly bluxUser$: BehaviorSubject<BluxUser | undefined>;
|
|
23
|
+
readonly requestQueue$: BehaviorSubject<EventRequest[]>;
|
|
24
|
+
constructor(STAGE?: "local" | "dev" | "stg" | "prod");
|
|
25
|
+
private generateIdentifierHeader;
|
|
26
|
+
init({ bluxClientId: organizationId, bluxApiKey, }: {
|
|
10
27
|
bluxClientId: string;
|
|
11
|
-
|
|
12
|
-
}): void
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
28
|
+
bluxApiKey: string;
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
setLogLevel(logLevel: LogLevel): void;
|
|
31
|
+
private getBluxUserWithTimeout;
|
|
32
|
+
signIn(userId: string): Promise<void>;
|
|
33
|
+
signOut(): Promise<void>;
|
|
34
|
+
setUserProperties(userProperties: {
|
|
35
|
+
phone_number?: string;
|
|
36
|
+
email_address?: string;
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
setCustomUserProperties(customUserProperties: Record<string, string | boolean | number | null>): Promise<void>;
|
|
39
|
+
sendEvent(event: Event | Event[]): Promise<void>;
|
|
17
40
|
}
|
|
41
|
+
export declare const bluxClient: BluxClient;
|
|
42
|
+
export {};
|
package/dist/BluxClient.js
CHANGED
|
@@ -1,104 +1,334 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a3d74585-c9aa-5c56-8a6b-1bf7035d4bc4")}catch(e){}}();
|
|
3
|
+
|
|
4
|
+
var __assign = (this && this.__assign) || function () {
|
|
5
|
+
__assign = Object.assign || function(t) {
|
|
6
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
7
|
+
s = arguments[i];
|
|
8
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
9
|
+
t[p] = s[p];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
return __assign.apply(this, arguments);
|
|
14
|
+
};
|
|
15
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
25
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
26
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
27
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
28
|
+
function step(op) {
|
|
29
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
30
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
31
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
32
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
33
|
+
switch (op[0]) {
|
|
34
|
+
case 0: case 1: t = op; break;
|
|
35
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
36
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
37
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
38
|
+
default:
|
|
39
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
40
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
41
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
42
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
43
|
+
if (t[2]) _.ops.pop();
|
|
44
|
+
_.trys.pop(); continue;
|
|
45
|
+
}
|
|
46
|
+
op = body.call(thisArg, _);
|
|
47
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
48
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
52
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
53
|
+
if (ar || !(i in from)) {
|
|
54
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
55
|
+
ar[i] = from[i];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
59
|
+
};
|
|
60
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
61
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
62
|
+
};
|
|
2
63
|
exports.__esModule = true;
|
|
3
|
-
|
|
4
|
-
|
|
64
|
+
exports.bluxClient = void 0;
|
|
65
|
+
require("./utils/sentry");
|
|
66
|
+
var rxjs_1 = require("rxjs");
|
|
5
67
|
var LocalStorage_1 = require("./core/LocalStorage");
|
|
6
68
|
var Logger_1 = require("./core/Logger");
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
69
|
+
var axios_1 = __importDefault(require("axios"));
|
|
70
|
+
var operators_1 = require("./utils/operators");
|
|
71
|
+
var URLS_1 = require("./constants/URLS");
|
|
72
|
+
var sentry_1 = require("./utils/sentry");
|
|
11
73
|
var BluxClient = /** @class */ (function () {
|
|
12
|
-
function BluxClient() {
|
|
74
|
+
function BluxClient(STAGE) {
|
|
75
|
+
if (STAGE === void 0) { STAGE = "prod"; }
|
|
76
|
+
var _this = this;
|
|
77
|
+
this.STAGE = STAGE;
|
|
78
|
+
this.identifierApi = axios_1["default"].create({
|
|
79
|
+
baseURL: URLS_1.IDENTIFIER_API_URL_BY_STAGE[this.STAGE]
|
|
80
|
+
});
|
|
81
|
+
this.collectorApi = axios_1["default"].create({
|
|
82
|
+
baseURL: URLS_1.COLLECTOR_API_URL_BY_STAGE[this.STAGE],
|
|
83
|
+
headers: {
|
|
84
|
+
"Content-Type": "application/json;charset=UTF-8",
|
|
85
|
+
Accept: "application/json"
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
this.sdkInfo = {
|
|
89
|
+
type: "browser",
|
|
90
|
+
version: "0.0.3"
|
|
91
|
+
};
|
|
92
|
+
this.bluxUser$ = new rxjs_1.BehaviorSubject(undefined);
|
|
93
|
+
this.requestQueue$ = new rxjs_1.BehaviorSubject([]);
|
|
94
|
+
this.requestQueue$
|
|
95
|
+
.pipe((0, rxjs_1.filter)(function (queue) { return queue.length > 0; }), (0, rxjs_1.concatMap)(function (requests) {
|
|
96
|
+
return (0, rxjs_1.from)(requests.map(function (request, idx) { return ({ request: request, idx: idx }); })).pipe((0, rxjs_1.withLatestFrom)(_this.bluxUser$.pipe((0, operators_1.filterNullable)())), (0, rxjs_1.concatMap)(function (_a) {
|
|
97
|
+
var _b = _a[0], request = _b.request, idx = _b.idx, bluxUser = _a[1];
|
|
98
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
99
|
+
var body, error_1;
|
|
100
|
+
return __generator(this, function (_c) {
|
|
101
|
+
switch (_c.label) {
|
|
102
|
+
case 0:
|
|
103
|
+
body = JSON.stringify(__assign(__assign({}, request), { user_id: bluxUser.userId, blux_id: bluxUser.id, device_id: bluxUser.deviceId, timetsamp: request.timestamp + 1e-6 * idx }));
|
|
104
|
+
_c.label = 1;
|
|
105
|
+
case 1:
|
|
106
|
+
_c.trys.push([1, 3, , 4]);
|
|
107
|
+
return [4 /*yield*/, this.collectorApi.post("/events", body, {
|
|
108
|
+
headers: {
|
|
109
|
+
"X-BLUX-SDK-INFO": "".concat(this.sdkInfo.type, "-").concat(this.sdkInfo.version),
|
|
110
|
+
"X-BLUX-CLIENT-ID": bluxUser.organizationId,
|
|
111
|
+
"X-BLUX-API-KEY": bluxUser.bluxApiKey,
|
|
112
|
+
"X-BLUX-TIMESTAMP": Math.floor(Date.now() / 1000).toString()
|
|
113
|
+
}
|
|
114
|
+
})];
|
|
115
|
+
case 2:
|
|
116
|
+
_c.sent(); // todo : retry & send with batch
|
|
117
|
+
return [3 /*break*/, 4];
|
|
118
|
+
case 3:
|
|
119
|
+
error_1 = _c.sent();
|
|
120
|
+
Logger_1.Logger.error(error_1, { tags: { from: "request-events-api" } });
|
|
121
|
+
return [3 /*break*/, 4];
|
|
122
|
+
case 4: return [2 /*return*/, requests.map(function (r) { return r.id; })]; // todo: return successed requests only
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
}));
|
|
127
|
+
}), (0, rxjs_1.map)(function (requestIdsSucceeded) {
|
|
128
|
+
return _this.requestQueue$.value.filter(function (request) { return !requestIdsSucceeded.includes(request.id); });
|
|
129
|
+
}))
|
|
130
|
+
.subscribe(this.requestQueue$);
|
|
13
131
|
}
|
|
14
|
-
BluxClient.
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
BluxClient.bluxAPIKey = bluxAPIKey;
|
|
20
|
-
BluxClient.deviceRegisterOrActivate();
|
|
21
|
-
}
|
|
22
|
-
catch (e) {
|
|
23
|
-
BaseErrorHandler_1.BaseErrorHandler.handle(e);
|
|
24
|
-
}
|
|
132
|
+
BluxClient.prototype.generateIdentifierHeader = function (_a) {
|
|
133
|
+
var bluxApiKey = _a.bluxApiKey;
|
|
134
|
+
return {
|
|
135
|
+
Authorization: bluxApiKey
|
|
136
|
+
};
|
|
25
137
|
};
|
|
26
|
-
BluxClient.
|
|
138
|
+
BluxClient.prototype.init = function (_a) {
|
|
139
|
+
var organizationId = _a.bluxClientId, bluxApiKey = _a.bluxApiKey;
|
|
140
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
141
|
+
var deviceId, _b, blux_user_id, device_id, error_2;
|
|
142
|
+
return __generator(this, function (_c) {
|
|
143
|
+
switch (_c.label) {
|
|
144
|
+
case 0:
|
|
145
|
+
sentry_1.Sentry.setTag("bluxClientId", organizationId);
|
|
146
|
+
_c.label = 1;
|
|
147
|
+
case 1:
|
|
148
|
+
_c.trys.push([1, 3, , 4]);
|
|
149
|
+
Logger_1.Logger.debug("Init with client id: " + organizationId);
|
|
150
|
+
deviceId = LocalStorage_1.LocalStorage.getDeviceId();
|
|
151
|
+
if (!deviceId) {
|
|
152
|
+
Logger_1.Logger.debug("Saved Device ID is not exists, newly registered.");
|
|
153
|
+
}
|
|
154
|
+
return [4 /*yield*/, this.identifierApi.post("/organizations/".concat(organizationId, "/blux-users/initialize"), {
|
|
155
|
+
device_id: deviceId !== null && deviceId !== void 0 ? deviceId : undefined,
|
|
156
|
+
country_code: navigator.language.split("-")[1],
|
|
157
|
+
device_model: navigator.userAgent,
|
|
158
|
+
language_code: navigator.language.split("-")[0],
|
|
159
|
+
platform: "browser",
|
|
160
|
+
os_version: navigator.userAgent,
|
|
161
|
+
sdk_version: this.sdkInfo.version,
|
|
162
|
+
sdk_type: this.sdkInfo.type,
|
|
163
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
164
|
+
}, {
|
|
165
|
+
headers: this.generateIdentifierHeader({
|
|
166
|
+
bluxApiKey: bluxApiKey
|
|
167
|
+
})
|
|
168
|
+
})];
|
|
169
|
+
case 2:
|
|
170
|
+
_b = (_c.sent()).data, blux_user_id = _b.blux_user_id, device_id = _b.device_id;
|
|
171
|
+
console.log({ device_id: device_id });
|
|
172
|
+
LocalStorage_1.LocalStorage.setDeviceId(device_id);
|
|
173
|
+
this.bluxUser$.next({
|
|
174
|
+
id: blux_user_id,
|
|
175
|
+
bluxApiKey: bluxApiKey,
|
|
176
|
+
organizationId: organizationId,
|
|
177
|
+
deviceId: device_id
|
|
178
|
+
});
|
|
179
|
+
return [3 /*break*/, 4];
|
|
180
|
+
case 3:
|
|
181
|
+
error_2 = _c.sent();
|
|
182
|
+
Logger_1.Logger.error(error_2, { tags: { from: "init" } });
|
|
183
|
+
return [3 /*break*/, 4];
|
|
184
|
+
case 4: return [2 /*return*/];
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
BluxClient.prototype.setLogLevel = function (logLevel) {
|
|
27
190
|
Logger_1.Logger.setLevel(logLevel);
|
|
28
191
|
};
|
|
29
|
-
BluxClient.
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
Logger_1.Logger.debug("Saved Device ID and Blux ID are exists : " + deviceId + " | " + bluxId);
|
|
50
|
-
// Activate Device 호출
|
|
51
|
-
var activateDeviceRequest = new ActivateDevice_1.ActivateDevice(bluxId, deviceId);
|
|
52
|
-
HTTPClient_1.HTTPClient.sendRequestWithBody(activateDeviceRequest);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
BaseErrorHandler_1.BaseErrorHandler.handle(e);
|
|
57
|
-
}
|
|
192
|
+
BluxClient.prototype.getBluxUserWithTimeout = function () {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
194
|
+
var bluxUser;
|
|
195
|
+
return __generator(this, function (_a) {
|
|
196
|
+
switch (_a.label) {
|
|
197
|
+
case 0: return [4 /*yield*/, (0, rxjs_1.firstValueFrom)(this.bluxUser$.pipe((0, operators_1.filterNullable)(), (0, rxjs_1.timeout)(5000), (0, rxjs_1.catchError)(function (error) {
|
|
198
|
+
return (0, rxjs_1.throwError)(function () {
|
|
199
|
+
return error.name === "TimeoutError"
|
|
200
|
+
? new Error("Client ID is not intialized. Please initialize BluxClient.")
|
|
201
|
+
: error;
|
|
202
|
+
});
|
|
203
|
+
})))];
|
|
204
|
+
case 1:
|
|
205
|
+
bluxUser = _a.sent();
|
|
206
|
+
return [2 /*return*/, bluxUser];
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
});
|
|
58
210
|
};
|
|
59
|
-
BluxClient.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
211
|
+
BluxClient.prototype.signIn = function (userId) {
|
|
212
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
213
|
+
var bluxUser, bluxIdInResponse, error_3;
|
|
214
|
+
return __generator(this, function (_a) {
|
|
215
|
+
switch (_a.label) {
|
|
216
|
+
case 0:
|
|
217
|
+
_a.trys.push([0, 3, , 4]);
|
|
218
|
+
return [4 /*yield*/, this.getBluxUserWithTimeout()];
|
|
219
|
+
case 1:
|
|
220
|
+
bluxUser = _a.sent();
|
|
221
|
+
return [4 /*yield*/, this.identifierApi.put("/organizations/".concat(bluxUser.organizationId, "/blux-users/").concat(bluxUser.id, "/sign-in"), { user_id: userId }, {
|
|
222
|
+
headers: this.generateIdentifierHeader(bluxUser)
|
|
223
|
+
})];
|
|
224
|
+
case 2:
|
|
225
|
+
bluxIdInResponse = (_a.sent()).data.blux_user_id;
|
|
226
|
+
if (bluxIdInResponse !== bluxUser.id) {
|
|
227
|
+
Logger_1.Logger.debug("Blux id is changed in signIn.");
|
|
228
|
+
this.bluxUser$.next(__assign(__assign({}, bluxUser), { id: bluxIdInResponse }));
|
|
229
|
+
}
|
|
230
|
+
return [3 /*break*/, 4];
|
|
231
|
+
case 3:
|
|
232
|
+
error_3 = _a.sent();
|
|
233
|
+
Logger_1.Logger.error(error_3, { tags: { from: "signIn" } });
|
|
234
|
+
return [3 /*break*/, 4];
|
|
235
|
+
case 4: return [2 /*return*/];
|
|
74
236
|
}
|
|
75
237
|
});
|
|
76
|
-
}
|
|
77
|
-
catch (e) {
|
|
78
|
-
BaseErrorHandler_1.BaseErrorHandler.handle(e);
|
|
79
|
-
}
|
|
238
|
+
});
|
|
80
239
|
};
|
|
81
|
-
BluxClient.
|
|
82
|
-
|
|
83
|
-
var
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
240
|
+
BluxClient.prototype.signOut = function () {
|
|
241
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
242
|
+
var bluxUser, bluxIdInResponse, error_4;
|
|
243
|
+
return __generator(this, function (_a) {
|
|
244
|
+
switch (_a.label) {
|
|
245
|
+
case 0:
|
|
246
|
+
_a.trys.push([0, 3, , 4]);
|
|
247
|
+
return [4 /*yield*/, this.getBluxUserWithTimeout()];
|
|
248
|
+
case 1:
|
|
249
|
+
bluxUser = _a.sent();
|
|
250
|
+
return [4 /*yield*/, this.identifierApi.put("/organizations/".concat(bluxUser.organizationId, "/blux-users/").concat(bluxUser.id, "/sign-out"), { device_id: bluxUser.deviceId }, {
|
|
251
|
+
headers: this.generateIdentifierHeader(bluxUser)
|
|
252
|
+
})];
|
|
253
|
+
case 2:
|
|
254
|
+
bluxIdInResponse = (_a.sent()).data.blux_user_id;
|
|
255
|
+
Logger_1.Logger.debug("Blux id is changed in signOut.");
|
|
256
|
+
this.bluxUser$.next(__assign(__assign({}, bluxUser), { id: bluxIdInResponse }));
|
|
257
|
+
return [3 /*break*/, 4];
|
|
258
|
+
case 3:
|
|
259
|
+
error_4 = _a.sent();
|
|
260
|
+
Logger_1.Logger.error(error_4, { tags: { from: "signOut" } });
|
|
261
|
+
return [3 /*break*/, 4];
|
|
262
|
+
case 4: return [2 /*return*/];
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
BluxClient.prototype.setUserProperties = function (userProperties) {
|
|
268
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
269
|
+
var bluxUser, error_5;
|
|
270
|
+
return __generator(this, function (_a) {
|
|
271
|
+
switch (_a.label) {
|
|
272
|
+
case 0:
|
|
273
|
+
_a.trys.push([0, 3, , 4]);
|
|
274
|
+
return [4 /*yield*/, this.getBluxUserWithTimeout()];
|
|
275
|
+
case 1:
|
|
276
|
+
bluxUser = _a.sent();
|
|
277
|
+
return [4 /*yield*/, this.identifierApi.put("/organizations/".concat(bluxUser.organizationId, "/blux-users/").concat(bluxUser.id, "/update-user-properties"), { properties: userProperties }, {
|
|
278
|
+
headers: this.generateIdentifierHeader(bluxUser)
|
|
279
|
+
})];
|
|
280
|
+
case 2:
|
|
281
|
+
_a.sent();
|
|
282
|
+
return [3 /*break*/, 4];
|
|
283
|
+
case 3:
|
|
284
|
+
error_5 = _a.sent();
|
|
285
|
+
Logger_1.Logger.error(error_5, { tags: { from: "setUserProperties" } });
|
|
286
|
+
return [3 /*break*/, 4];
|
|
287
|
+
case 4: return [2 /*return*/];
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
});
|
|
95
291
|
};
|
|
96
|
-
BluxClient.
|
|
97
|
-
|
|
98
|
-
|
|
292
|
+
BluxClient.prototype.setCustomUserProperties = function (customUserProperties) {
|
|
293
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
294
|
+
var bluxUser, error_6;
|
|
295
|
+
return __generator(this, function (_a) {
|
|
296
|
+
switch (_a.label) {
|
|
297
|
+
case 0:
|
|
298
|
+
_a.trys.push([0, 3, , 4]);
|
|
299
|
+
return [4 /*yield*/, this.getBluxUserWithTimeout()];
|
|
300
|
+
case 1:
|
|
301
|
+
bluxUser = _a.sent();
|
|
302
|
+
return [4 /*yield*/, this.identifierApi.put("/organizations/".concat(bluxUser.organizationId, "/blux-users/").concat(bluxUser.id, "/update-custom-user-properties"), { properties: customUserProperties }, {
|
|
303
|
+
headers: this.generateIdentifierHeader(bluxUser)
|
|
304
|
+
})];
|
|
305
|
+
case 2:
|
|
306
|
+
_a.sent();
|
|
307
|
+
return [3 /*break*/, 4];
|
|
308
|
+
case 3:
|
|
309
|
+
error_6 = _a.sent();
|
|
310
|
+
Logger_1.Logger.error(error_6, { tags: { from: "setCustomUserProperties" } });
|
|
311
|
+
return [3 /*break*/, 4];
|
|
312
|
+
case 4: return [2 /*return*/];
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
};
|
|
317
|
+
BluxClient.prototype.sendEvent = function (event) {
|
|
318
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
319
|
+
var requests;
|
|
320
|
+
var _this = this;
|
|
321
|
+
return __generator(this, function (_a) {
|
|
322
|
+
requests = (Array.isArray(event) ? event : [event]).map(function (event) { return event.request; });
|
|
323
|
+
this.requestQueue$.next(__spreadArray(__spreadArray([], this.requestQueue$.value, true), requests.filter(function (request) {
|
|
324
|
+
return !_this.requestQueue$.value.map(function (r) { return r.id; }).includes(request.id);
|
|
325
|
+
}), true));
|
|
326
|
+
return [2 /*return*/];
|
|
327
|
+
});
|
|
328
|
+
});
|
|
99
329
|
};
|
|
100
|
-
BluxClient.bluxClientID = null;
|
|
101
|
-
BluxClient.bluxAPIKey = null;
|
|
102
330
|
return BluxClient;
|
|
103
331
|
}());
|
|
104
|
-
exports
|
|
332
|
+
exports.bluxClient = new BluxClient("prod");
|
|
333
|
+
//# sourceMappingURL=BluxClient.js.map
|
|
334
|
+
//# debugId=a3d74585-c9aa-5c56-8a6b-1bf7035d4bc4
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BluxClient.js","sources":["BluxClient.ts"],"sourceRoot":"/","sourcesContent":["import \"./utils/sentry\";\nimport {\n BehaviorSubject,\n catchError,\n concatMap,\n filter,\n firstValueFrom,\n from,\n map,\n throwError,\n timeout,\n withLatestFrom,\n} from \"rxjs\";\nimport { LocalStorage } from \"./core/LocalStorage\";\nimport { Logger, LogLevel } from \"./core/Logger\";\nimport axios from \"axios\";\nimport { filterNullable } from \"./utils/operators\";\nimport { EventRequest } from \"./events/types\";\nimport {\n COLLECTOR_API_URL_BY_STAGE,\n IDENTIFIER_API_URL_BY_STAGE,\n} from \"./constants/URLS\";\nimport { Event } from \"./events/Event\";\nimport { Sentry } from \"./utils/sentry\";\n\nexport type SdkInfo = {\n type: string;\n version: string;\n};\n\ntype BluxUser = {\n id: string;\n bluxApiKey: string;\n organizationId: string;\n deviceId: string;\n userId?: string;\n};\n\nclass BluxClient {\n private readonly identifierApi = axios.create({\n baseURL: IDENTIFIER_API_URL_BY_STAGE[this.STAGE],\n });\n private readonly collectorApi = axios.create({\n baseURL: COLLECTOR_API_URL_BY_STAGE[this.STAGE],\n headers: {\n \"Content-Type\": \"application/json;charset=UTF-8\",\n Accept: \"application/json\",\n },\n });\n\n private readonly sdkInfo: SdkInfo = {\n type: \"browser\",\n version: \"0.0.3\",\n };\n\n public readonly bluxUser$ = new BehaviorSubject<BluxUser | undefined>(\n undefined\n );\n\n public readonly requestQueue$ = new BehaviorSubject<EventRequest[]>([]);\n\n constructor(\n private readonly STAGE: \"local\" | \"dev\" | \"stg\" | \"prod\" = \"prod\"\n ) {\n this.requestQueue$\n .pipe(\n filter((queue) => queue.length > 0),\n concatMap((requests) => {\n return from(requests.map((request, idx) => ({ request, idx }))).pipe(\n withLatestFrom(this.bluxUser$.pipe(filterNullable())),\n concatMap(async ([{ request, idx }, bluxUser]) => {\n const body = JSON.stringify({\n ...request,\n user_id: bluxUser.userId,\n blux_id: bluxUser.id,\n device_id: bluxUser.deviceId,\n timetsamp: request.timestamp + 1e-6 * idx,\n });\n try {\n await this.collectorApi.post(\"/events\", body, {\n headers: {\n \"X-BLUX-SDK-INFO\": `${this.sdkInfo.type}-${this.sdkInfo.version}`,\n \"X-BLUX-CLIENT-ID\": bluxUser.organizationId,\n \"X-BLUX-API-KEY\": bluxUser.bluxApiKey,\n \"X-BLUX-TIMESTAMP\": Math.floor(\n Date.now() / 1000\n ).toString(),\n },\n }); // todo : retry & send with batch\n } catch (error) {\n Logger.error(error, { tags: { from: \"request-events-api\" } });\n }\n\n return requests.map((r) => r.id); // todo: return successed requests only\n })\n );\n }),\n map((requestIdsSucceeded) =>\n this.requestQueue$.value.filter(\n (request) => !requestIdsSucceeded.includes(request.id)\n )\n )\n )\n .subscribe(this.requestQueue$);\n }\n\n private generateIdentifierHeader({ bluxApiKey }: { bluxApiKey: string }) {\n return {\n Authorization: bluxApiKey,\n };\n }\n\n public async init({\n bluxClientId: organizationId,\n bluxApiKey,\n }: {\n bluxClientId: string;\n bluxApiKey: string;\n }) {\n Sentry.setTag(\"bluxClientId\", organizationId);\n try {\n Logger.debug(\"Init with client id: \" + organizationId);\n\n const deviceId = LocalStorage.getDeviceId();\n\n if (!deviceId) {\n Logger.debug(\"Saved Device ID is not exists, newly registered.\");\n }\n\n const {\n data: { blux_user_id, device_id },\n } = await this.identifierApi.post<{\n blux_user_id: string;\n device_id: string;\n }>(\n `/organizations/${organizationId}/blux-users/initialize`,\n {\n device_id: deviceId ?? undefined,\n country_code: navigator.language.split(\"-\")[1],\n device_model: navigator.userAgent,\n language_code: navigator.language.split(\"-\")[0],\n platform: \"browser\",\n os_version: navigator.userAgent,\n sdk_version: this.sdkInfo.version,\n sdk_type: this.sdkInfo.type,\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n },\n {\n headers: this.generateIdentifierHeader({\n bluxApiKey,\n }),\n }\n );\n\n console.log({ device_id });\n\n LocalStorage.setDeviceId(device_id);\n\n this.bluxUser$.next({\n id: blux_user_id,\n bluxApiKey,\n organizationId,\n deviceId: device_id,\n });\n } catch (error) {\n Logger.error(error, { tags: { from: \"init\" } });\n }\n }\n\n public setLogLevel(logLevel: LogLevel) {\n Logger.setLevel(logLevel);\n }\n\n private async getBluxUserWithTimeout() {\n const bluxUser = await firstValueFrom(\n this.bluxUser$.pipe(\n filterNullable(),\n timeout(5000),\n catchError((error) => {\n return throwError(() =>\n error.name === \"TimeoutError\"\n ? new Error(\n \"Client ID is not intialized. Please initialize BluxClient.\"\n )\n : error\n );\n })\n )\n );\n\n return bluxUser;\n }\n\n public async signIn(userId: string) {\n try {\n const bluxUser = await this.getBluxUserWithTimeout();\n\n const {\n data: { blux_user_id: bluxIdInResponse },\n } = await this.identifierApi.put<{ blux_user_id: string }>(\n `/organizations/${bluxUser.organizationId}/blux-users/${bluxUser.id}/sign-in`,\n { user_id: userId },\n {\n headers: this.generateIdentifierHeader(bluxUser),\n }\n );\n\n if (bluxIdInResponse !== bluxUser.id) {\n Logger.debug(\"Blux id is changed in signIn.\");\n this.bluxUser$.next({\n ...bluxUser,\n id: bluxIdInResponse,\n });\n }\n } catch (error) {\n Logger.error(error, { tags: { from: \"signIn\" } });\n }\n }\n\n public async signOut() {\n try {\n const bluxUser = await this.getBluxUserWithTimeout();\n\n const {\n data: { blux_user_id: bluxIdInResponse },\n } = await this.identifierApi.put<{ blux_user_id: string }>(\n `/organizations/${bluxUser.organizationId}/blux-users/${bluxUser.id}/sign-out`,\n { device_id: bluxUser.deviceId },\n {\n headers: this.generateIdentifierHeader(bluxUser),\n }\n );\n\n Logger.debug(\"Blux id is changed in signOut.\");\n this.bluxUser$.next({\n ...bluxUser,\n id: bluxIdInResponse,\n });\n } catch (error) {\n Logger.error(error, { tags: { from: \"signOut\" } });\n }\n }\n\n public async setUserProperties(userProperties: {\n phone_number?: string;\n email_address?: string;\n }) {\n try {\n const bluxUser = await this.getBluxUserWithTimeout();\n\n await this.identifierApi.put<{ blux_user_id: string }>(\n `/organizations/${bluxUser.organizationId}/blux-users/${bluxUser.id}/update-user-properties`,\n { properties: userProperties },\n {\n headers: this.generateIdentifierHeader(bluxUser),\n }\n );\n } catch (error) {\n Logger.error(error, { tags: { from: \"setUserProperties\" } });\n }\n }\n\n public async setCustomUserProperties(\n customUserProperties: Record<string, string | boolean | number | null>\n ) {\n try {\n const bluxUser = await this.getBluxUserWithTimeout();\n\n await this.identifierApi.put<{ blux_user_id: string }>(\n `/organizations/${bluxUser.organizationId}/blux-users/${bluxUser.id}/update-custom-user-properties`,\n { properties: customUserProperties },\n {\n headers: this.generateIdentifierHeader(bluxUser),\n }\n );\n } catch (error) {\n Logger.error(error, { tags: { from: \"setCustomUserProperties\" } });\n }\n }\n\n public async sendEvent(event: Event | Event[]) {\n const requests = (Array.isArray(event) ? event : [event]).map(\n (event) => event.request\n );\n\n this.requestQueue$.next([\n ...this.requestQueue$.value,\n ...requests.filter(\n (request) =>\n !this.requestQueue$.value.map((r) => r.id).includes(request.id)\n ),\n ]);\n }\n}\n\nexport const bluxClient = new BluxClient(\"prod\");\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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K,IAAK,OAAA,KAAK,CAAC,OAAO,EAAb,CAAa,CACzB,CAAC;gBAEF,IAAI,CAAC,aAAa,CAAC,IAAI,iCAClB,IAAI,CAAC,aAAa,CAAC,KAAK,SACxB,QAAQ,CAAC,MAAM,CAChB,UAAC,OAAO;oBACN,OAAA,CAAC,KAAI,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,EAAE,EAAJ,CAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBAA/D,CAA+D,CAClE,QACD,CAAC;;;;KACJ;IACH,iBAAC;AAAD,CAAC,AA/PD,IA+PC;AAEY,QAAA,UAAU,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC","debug_id":"a3d74585-c9aa-5c56-8a6b-1bf7035d4bc4"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const IDENTIFIER_API_URL_BY_STAGE: {
|
|
2
|
+
readonly local: "http://localhost:9000/local";
|
|
3
|
+
readonly dev: "https://api.blux.ai/dev";
|
|
4
|
+
readonly stg: "https://api.blux.ai/stg";
|
|
5
|
+
readonly prod: "https://api.blux.ai/prod";
|
|
6
|
+
};
|
|
7
|
+
export declare const COLLECTOR_API_URL_BY_STAGE: {
|
|
8
|
+
readonly local: "https://collector-api-web.blux.ai";
|
|
9
|
+
readonly dev: "https://collector-api-web.blux.ai";
|
|
10
|
+
readonly stg: "https://collector-api-web.blux.ai";
|
|
11
|
+
readonly prod: "https://collector-api-web.blux.ai";
|
|
12
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1c75b390-3f74-5ded-a474-48fab05f8d88")}catch(e){}}();
|
|
3
|
+
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.COLLECTOR_API_URL_BY_STAGE = exports.IDENTIFIER_API_URL_BY_STAGE = void 0;
|
|
6
|
+
exports.IDENTIFIER_API_URL_BY_STAGE = {
|
|
7
|
+
local: "http://localhost:9000/local",
|
|
8
|
+
dev: "https://api.blux.ai/dev",
|
|
9
|
+
stg: "https://api.blux.ai/stg",
|
|
10
|
+
prod: "https://api.blux.ai/prod"
|
|
11
|
+
};
|
|
12
|
+
exports.COLLECTOR_API_URL_BY_STAGE = {
|
|
13
|
+
local: "https://collector-api-web.blux.ai",
|
|
14
|
+
dev: "https://collector-api-web.blux.ai",
|
|
15
|
+
stg: "https://collector-api-web.blux.ai",
|
|
16
|
+
prod: "https://collector-api-web.blux.ai"
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=URLS.js.map
|
|
19
|
+
//# debugId=1c75b390-3f74-5ded-a474-48fab05f8d88
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"URLS.js","sources":["constants/URLS.ts"],"sourceRoot":"/","sourcesContent":["export const IDENTIFIER_API_URL_BY_STAGE = {\n local: \"http://localhost:9000/local\",\n dev: \"https://api.blux.ai/dev\",\n stg: \"https://api.blux.ai/stg\",\n prod: \"https://api.blux.ai/prod\",\n} as const;\n\nexport const COLLECTOR_API_URL_BY_STAGE = {\n local: \"https://collector-api-web.blux.ai\", // todo\n dev: \"https://collector-api-web.blux.ai\", // todo\n stg: \"https://collector-api-web.blux.ai\", // todo\n prod: \"https://collector-api-web.blux.ai\", // todo\n} as const;\n"],"names":[],"mappings":";;;;;AAAa,QAAA,2BAA2B,GAAG;IACzC,KAAK,EAAE,6BAA6B;IACpC,GAAG,EAAE,yBAAyB;IAC9B,GAAG,EAAE,yBAAyB;IAC9B,IAAI,EAAE,0BAA0B;CACxB,CAAC;AAEE,QAAA,0BAA0B,GAAG;IACxC,KAAK,EAAE,mCAAmC;IAC1C,GAAG,EAAE,mCAAmC;IACxC,GAAG,EAAE,mCAAmC;IACxC,IAAI,EAAE,mCAAmC;CACjC,CAAC","debug_id":"1c75b390-3f74-5ded-a474-48fab05f8d88"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
export declare class LocalStorage {
|
|
2
|
-
/**
|
|
3
|
-
* Used in BluxClient initialization to dedupe local storage.
|
|
4
|
-
*/
|
|
5
|
-
static getLogLevel(): string | null;
|
|
6
|
-
static setLogLevel(loglevel: string): void;
|
|
7
|
-
static getBluxId(): string | null;
|
|
8
|
-
static setBluxId(bluxId: string): void;
|
|
9
2
|
static getDeviceId(): string | null;
|
|
10
3
|
static setDeviceId(deviceId: string): void;
|
|
11
|
-
static getUserId(): string | null;
|
|
12
|
-
static setUserId(userId: string): void;
|
|
13
4
|
}
|
|
@@ -1,29 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="984c1bce-2a88-501a-9964-b1e8f8423f11")}catch(e){}}();
|
|
3
|
+
|
|
2
4
|
exports.__esModule = true;
|
|
3
5
|
exports.LocalStorage = void 0;
|
|
4
|
-
var BlUX_LOGLEVEL = "blux_loglevel";
|
|
5
|
-
var BLUX_ID = "blux_id";
|
|
6
6
|
var BLUX_DEVICE_ID = "blux_deviceId";
|
|
7
|
-
var BLUX_USER_ID = "blux_userId";
|
|
8
7
|
var LocalStorage = /** @class */ (function () {
|
|
9
8
|
function LocalStorage() {
|
|
10
9
|
}
|
|
11
|
-
/**
|
|
12
|
-
* Used in BluxClient initialization to dedupe local storage.
|
|
13
|
-
*/
|
|
14
|
-
LocalStorage.getLogLevel = function () {
|
|
15
|
-
return localStorage.getItem(BlUX_LOGLEVEL);
|
|
16
|
-
};
|
|
17
|
-
LocalStorage.setLogLevel = function (loglevel) {
|
|
18
|
-
localStorage.setItem(BlUX_LOGLEVEL, loglevel);
|
|
19
|
-
};
|
|
20
|
-
LocalStorage.getBluxId = function () {
|
|
21
|
-
var bluxId = localStorage.getItem(BLUX_ID);
|
|
22
|
-
return bluxId === "undefined" || (bluxId === null || bluxId === void 0 ? void 0 : bluxId.trim()) == "" ? null : bluxId;
|
|
23
|
-
};
|
|
24
|
-
LocalStorage.setBluxId = function (bluxId) {
|
|
25
|
-
localStorage.setItem(BLUX_ID, bluxId);
|
|
26
|
-
};
|
|
27
10
|
LocalStorage.getDeviceId = function () {
|
|
28
11
|
var deviceId = localStorage.getItem(BLUX_DEVICE_ID);
|
|
29
12
|
return deviceId === "undefined" || (deviceId === null || deviceId === void 0 ? void 0 : deviceId.trim()) == "" ? null : deviceId;
|
|
@@ -31,13 +14,8 @@ var LocalStorage = /** @class */ (function () {
|
|
|
31
14
|
LocalStorage.setDeviceId = function (deviceId) {
|
|
32
15
|
localStorage.setItem(BLUX_DEVICE_ID, deviceId);
|
|
33
16
|
};
|
|
34
|
-
LocalStorage.getUserId = function () {
|
|
35
|
-
var userId = localStorage.getItem(BLUX_USER_ID);
|
|
36
|
-
return userId === "undefined" || (userId === null || userId === void 0 ? void 0 : userId.trim()) == "" ? null : userId;
|
|
37
|
-
};
|
|
38
|
-
LocalStorage.setUserId = function (userId) {
|
|
39
|
-
localStorage.setItem(BLUX_USER_ID, userId);
|
|
40
|
-
};
|
|
41
17
|
return LocalStorage;
|
|
42
18
|
}());
|
|
43
19
|
exports.LocalStorage = LocalStorage;
|
|
20
|
+
//# sourceMappingURL=LocalStorage.js.map
|
|
21
|
+
//# debugId=984c1bce-2a88-501a-9964-b1e8f8423f11
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalStorage.js","sources":["core/LocalStorage.ts"],"sourceRoot":"/","sourcesContent":["const BLUX_DEVICE_ID = \"blux_deviceId\";\n\nexport class LocalStorage {\n static getDeviceId(): string | null {\n const deviceId = localStorage.getItem(BLUX_DEVICE_ID);\n return deviceId === \"undefined\" || deviceId?.trim() == \"\" ? null : deviceId;\n }\n\n static setDeviceId(deviceId: string) {\n localStorage.setItem(BLUX_DEVICE_ID, deviceId);\n }\n}\n"],"names":[],"mappings":";;;;;AAAA,IAAM,cAAc,GAAG,eAAe,CAAC;AAEvC;IAAA;IASA,CAAC;IARQ,wBAAW,GAAlB;QACE,IAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QACtD,OAAO,QAAQ,KAAK,WAAW,IAAI,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,EAAE,KAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC9E,CAAC;IAEM,wBAAW,GAAlB,UAAmB,QAAgB;QACjC,YAAY,CAAC,OAAO,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC;IACH,mBAAC;AAAD,CAAC,AATD,IASC;AATY,oCAAY","debug_id":"984c1bce-2a88-501a-9964-b1e8f8423f11"}
|