@blux.ai/web-sdk 1.0.0 → 1.1.1
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/package.json +1 -1
- package/dist/src/BluxClient.d.ts +7 -1
- package/dist/src/BluxClient.js +79 -18
- package/dist/src/BluxClient.js.map +1 -1
- package/dist/src/apis/APIs.d.ts +21 -18
- package/dist/src/apis/APIs.js +3 -2
- package/dist/src/apis/APIs.js.map +1 -1
- package/dist/src/constants/BLUX_ATTRIBUTES.d.ts +4 -0
- package/dist/src/constants/BLUX_ATTRIBUTES.js +5 -0
- package/dist/src/constants/BLUX_ATTRIBUTES.js.map +1 -0
- package/dist/src/events/types.d.ts +2 -4
- package/dist/src/events/types.js.map +1 -1
- package/dist/src/utils/SessionStorage.d.ts +4 -0
- package/dist/src/utils/SessionStorage.js +12 -0
- package/dist/src/utils/SessionStorage.js.map +1 -0
- package/package.json +1 -1
package/dist/package.json
CHANGED
package/dist/src/BluxClient.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ type BluxUser = {
|
|
|
12
12
|
id: string;
|
|
13
13
|
bluxApiKey: string;
|
|
14
14
|
applicationId: string;
|
|
15
|
-
deviceId
|
|
15
|
+
deviceId?: string;
|
|
16
16
|
userId?: string;
|
|
17
17
|
};
|
|
18
18
|
export declare class BluxClient {
|
|
@@ -20,6 +20,9 @@ export declare class BluxClient {
|
|
|
20
20
|
private readonly sdkInfo;
|
|
21
21
|
readonly bluxUser$: BehaviorSubject<BluxUser | undefined>;
|
|
22
22
|
readonly requestQueue$: BehaviorSubject<EventRequest[]>;
|
|
23
|
+
private sectionViewCollectedSections;
|
|
24
|
+
private observingTargetElements;
|
|
25
|
+
private sectionViewObservers;
|
|
23
26
|
constructor();
|
|
24
27
|
private generateApiHeader;
|
|
25
28
|
static init({ applicationId, bluxApiKey, }: {
|
|
@@ -37,5 +40,8 @@ export declare class BluxClient {
|
|
|
37
40
|
setCustomUserProperties(customUserProperties: Record<string, string | boolean | number | null>): Promise<void>;
|
|
38
41
|
sendEvent(event: Event | Event[]): void;
|
|
39
42
|
getItemRecommendation(recommendation: Recommendation): Promise<APIs.bluxUsersGetItemRecommendations.ResponseData>;
|
|
43
|
+
private handlePageTransition;
|
|
44
|
+
private registerSectionViewObserver;
|
|
45
|
+
private handleIntersection;
|
|
40
46
|
}
|
|
41
47
|
export {};
|
package/dist/src/BluxClient.js
CHANGED
|
@@ -14,6 +14,9 @@ import { VisitEvent } from "./events/VisitEvent";
|
|
|
14
14
|
import { getItemRecommendation } from "./apis/getItemRecommendation";
|
|
15
15
|
import { DevicePlatform } from "./apis/APIs";
|
|
16
16
|
import { AddPageVisitEvent } from "./events/AddPageVisitEvent";
|
|
17
|
+
import { SessionStorage } from "./utils/SessionStorage";
|
|
18
|
+
import { AddSectionViewEvent } from "./events";
|
|
19
|
+
import { BLUX_ATTRIBUTES } from "./constants/BLUX_ATTRIBUTES";
|
|
17
20
|
export class BluxClient {
|
|
18
21
|
api;
|
|
19
22
|
sdkInfo = {
|
|
@@ -22,6 +25,9 @@ export class BluxClient {
|
|
|
22
25
|
};
|
|
23
26
|
bluxUser$ = new BehaviorSubject(undefined);
|
|
24
27
|
requestQueue$ = new BehaviorSubject([]);
|
|
28
|
+
sectionViewCollectedSections = [];
|
|
29
|
+
observingTargetElements = {};
|
|
30
|
+
sectionViewObservers = [];
|
|
25
31
|
constructor() {
|
|
26
32
|
this.api = axios.create({
|
|
27
33
|
baseURL: "https://api.blux.ai/prod",
|
|
@@ -35,7 +41,6 @@ export class BluxClient {
|
|
|
35
41
|
}, {
|
|
36
42
|
events: requests.map((request) => ({
|
|
37
43
|
...request,
|
|
38
|
-
user_id: bluxUser.userId,
|
|
39
44
|
blux_id: bluxUser.id,
|
|
40
45
|
device_id: bluxUser.deviceId,
|
|
41
46
|
})),
|
|
@@ -48,6 +53,10 @@ export class BluxClient {
|
|
|
48
53
|
return requests.map((r) => r.id); // todo: return successed requests only
|
|
49
54
|
}), map((requestIdsSucceeded) => this.requestQueue$.value.filter((request) => !requestIdsSucceeded.includes(request.id))), observeOn(asyncScheduler))
|
|
50
55
|
.subscribe(this.requestQueue$);
|
|
56
|
+
this.bluxUser$.subscribe((bluxUser) => {
|
|
57
|
+
if (bluxUser)
|
|
58
|
+
SessionStorage.setBluxUserId(bluxUser.id);
|
|
59
|
+
});
|
|
51
60
|
}
|
|
52
61
|
generateApiHeader({ bluxApiKey }) {
|
|
53
62
|
return {
|
|
@@ -56,14 +65,17 @@ export class BluxClient {
|
|
|
56
65
|
}
|
|
57
66
|
static async init({ applicationId, bluxApiKey, }) {
|
|
58
67
|
const client = new BluxClient();
|
|
59
|
-
|
|
68
|
+
const blux_user_id = new URLSearchParams(window.location.search).get("blux_user_id");
|
|
69
|
+
const isBluxUserIdExistInSessionStorage = SessionStorage.getBluxUserId();
|
|
70
|
+
if (!isBluxUserIdExistInSessionStorage)
|
|
71
|
+
client.sendEvent(new VisitEvent({}));
|
|
60
72
|
try {
|
|
61
73
|
Logger.debug(`Init with application id: ${applicationId}`);
|
|
62
74
|
const deviceId = LocalStorage.getDeviceId();
|
|
63
75
|
if (!deviceId) {
|
|
64
76
|
Logger.debug("No saved Device ID, register a new one.");
|
|
65
77
|
}
|
|
66
|
-
const { data
|
|
78
|
+
const { data } = await initialize(client.api, { application_id: applicationId }, {
|
|
67
79
|
isVisitHandlingInSdk: true,
|
|
68
80
|
device_id: deviceId ?? undefined,
|
|
69
81
|
country_code: navigator.language.split("-")[1],
|
|
@@ -74,28 +86,26 @@ export class BluxClient {
|
|
|
74
86
|
sdk_version: client.sdkInfo.version,
|
|
75
87
|
sdk_type: client.sdkInfo.type,
|
|
76
88
|
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
89
|
+
blux_user_id: blux_user_id ?? undefined,
|
|
77
90
|
}, client.generateApiHeader({
|
|
78
91
|
bluxApiKey,
|
|
79
92
|
}));
|
|
80
|
-
|
|
93
|
+
if (data.device_id)
|
|
94
|
+
LocalStorage.setDeviceId(data.device_id);
|
|
81
95
|
client.bluxUser$.next({
|
|
82
|
-
id: blux_user_id,
|
|
96
|
+
id: data.blux_user_id,
|
|
83
97
|
bluxApiKey,
|
|
84
98
|
applicationId,
|
|
85
|
-
deviceId: device_id,
|
|
99
|
+
deviceId: data.device_id,
|
|
100
|
+
});
|
|
101
|
+
// [페이지 이동 처리]
|
|
102
|
+
client.handlePageTransition();
|
|
103
|
+
// [Section View 자동 수집 관련 처리]
|
|
104
|
+
client.registerSectionViewObserver(); // init 시마다 특정 section을 observe하는 intersection observer 등록
|
|
105
|
+
// (SPA 처리) init이 최초 1회만 호출되더라도 페이지 이동 및 intersection observer를 처리할 수 있도록 MutationObserver 등록
|
|
106
|
+
const mutationObserver = new MutationObserver(() => {
|
|
107
|
+
client.registerSectionViewObserver();
|
|
86
108
|
});
|
|
87
|
-
function updateUrlAndRef() {
|
|
88
|
-
const url = LocalStorage.getUrl();
|
|
89
|
-
if (window.location.href !== url) {
|
|
90
|
-
// 페이지 이동 시 url, ref 업데이트
|
|
91
|
-
LocalStorage.setRef(`${url}`);
|
|
92
|
-
LocalStorage.setUrl(window.location.href);
|
|
93
|
-
// 페이지 이동 시 page_visit event 자동 수집
|
|
94
|
-
client.sendEvent(new AddPageVisitEvent({}));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
updateUrlAndRef();
|
|
98
|
-
const mutationObserver = new MutationObserver(updateUrlAndRef);
|
|
99
109
|
const mutationObserverConfig = { subtree: true, childList: true };
|
|
100
110
|
mutationObserver.observe(document.body, mutationObserverConfig);
|
|
101
111
|
return client;
|
|
@@ -206,5 +216,56 @@ export class BluxClient {
|
|
|
206
216
|
};
|
|
207
217
|
}
|
|
208
218
|
}
|
|
219
|
+
handlePageTransition() {
|
|
220
|
+
const url = LocalStorage.getUrl();
|
|
221
|
+
if (window.location.href !== url) {
|
|
222
|
+
// 페이지 이동 시 url, ref 업데이트
|
|
223
|
+
LocalStorage.setRef(`${url}`);
|
|
224
|
+
LocalStorage.setUrl(window.location.href);
|
|
225
|
+
// 페이지 이동 시 page_visit event 자동 수집
|
|
226
|
+
this.sendEvent(new AddPageVisitEvent({}));
|
|
227
|
+
// 페이지 이동 시 section view 관련 변수 초기화
|
|
228
|
+
this.sectionViewCollectedSections = [];
|
|
229
|
+
this.observingTargetElements = {};
|
|
230
|
+
this.sectionViewObservers.forEach((observer) => {
|
|
231
|
+
observer.disconnect();
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
registerSectionViewObserver() {
|
|
236
|
+
const targetElements = Array.from(document.querySelectorAll(`[${BLUX_ATTRIBUTES.section}]`));
|
|
237
|
+
targetElements.forEach((targetElement) => {
|
|
238
|
+
const section = targetElement.getAttribute(BLUX_ATTRIBUTES.section);
|
|
239
|
+
if (!section)
|
|
240
|
+
return;
|
|
241
|
+
// 이미 observe 중인 section은 skip
|
|
242
|
+
if (this.observingTargetElements[section]) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
this.observingTargetElements[section] = targetElement;
|
|
246
|
+
const observer = new IntersectionObserver(this.handleIntersection.bind(this), { threshold: 0 });
|
|
247
|
+
observer.observe(targetElement);
|
|
248
|
+
this.sectionViewObservers.push(observer);
|
|
249
|
+
Logger.debug(`SectionView observer is registered for section: "${section}".`);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
handleIntersection(entries) {
|
|
253
|
+
entries.forEach((entry) => {
|
|
254
|
+
if (entry.isIntersecting) {
|
|
255
|
+
const section = entry.target.getAttribute(BLUX_ATTRIBUTES.section);
|
|
256
|
+
const recommendationId = entry.target.getAttribute(BLUX_ATTRIBUTES.recommendation_id);
|
|
257
|
+
if (!section) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
if (!this.sectionViewCollectedSections.includes(section)) {
|
|
261
|
+
this.sendEvent(new AddSectionViewEvent({
|
|
262
|
+
section,
|
|
263
|
+
recommendation_id: recommendationId ?? undefined,
|
|
264
|
+
}));
|
|
265
|
+
this.sectionViewCollectedSections.push(section);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
209
270
|
}
|
|
210
271
|
//# sourceMappingURL=BluxClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BluxClient.js","sourceRoot":"/","sources":["src/BluxClient.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EACL,cAAc,EACd,eAAe,EACf,UAAU,EACV,UAAU,EACV,MAAM,EACN,cAAc,EACd,GAAG,EACH,SAAS,EACT,UAAU,EACV,OAAO,EACP,cAAc,GACf,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAa,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAe/D,MAAM,OAAO,UAAU;IACJ,GAAG,CAAgB;IAEnB,OAAO,GAAY;QAClC,IAAI,EAAE,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from \"../package.json\";\nimport {\n asyncScheduler,\n BehaviorSubject,\n catchError,\n exhaustMap,\n filter,\n firstValueFrom,\n map,\n observeOn,\n throwError,\n timeout,\n withLatestFrom,\n} from \"rxjs\";\nimport { LocalStorage } from \"./utils/LocalStorage\";\nimport type { LogLevel } from \"./utils/Logger\";\nimport { Logger } from \"./utils/Logger\";\nimport type { AxiosInstance } from \"axios\";\nimport axios from \"axios\";\nimport { filterNullable } from \"./utils/operators\";\nimport type { EventRequest } from \"./events/types\";\nimport type { Event } from \"./events/Event\";\nimport { initialize } from \"./apis/initialize\";\nimport { signIn } from \"./apis/signIn\";\nimport { signOut } from \"./apis/signOut\";\nimport { updateUserProperties } from \"./apis/updateUserProperties\";\nimport { updateCustomUserProperties } from \"./apis/updateCustomUserProperties\";\nimport { collectEvent } from \"./apis/createEvent\";\nimport { VisitEvent } from \"./events/VisitEvent\";\nimport type { Recommendation } from \"./recommendations/Recommendation\";\nimport { getItemRecommendation } from \"./apis/getItemRecommendation\";\nimport { DevicePlatform, type APIs } from \"./apis/APIs\";\nimport { AddPageVisitEvent } from \"./events/AddPageVisitEvent\";\n\nexport type SdkInfo = {\n type: string;\n version: string;\n};\n\ntype BluxUser = {\n id: string;\n bluxApiKey: string;\n applicationId: string;\n deviceId: string;\n userId?: string;\n};\n\nexport class BluxClient {\n private readonly api: AxiosInstance;\n\n private readonly sdkInfo: SdkInfo = {\n type: \"browser\",\n version: packageJson.version,\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 this.api = axios.create({\n baseURL: \"https://api.blux.ai/prod\",\n });\n this.requestQueue$\n .pipe(\n filter((queue) => queue.length > 0),\n withLatestFrom(this.bluxUser$.pipe(filterNullable())),\n exhaustMap(async ([requests, bluxUser]) => {\n try {\n await collectEvent(\n this.api,\n {\n blux_user_id: bluxUser.id,\n application_id: bluxUser.applicationId,\n },\n {\n events: requests.map((request) => ({\n ...request,\n user_id: bluxUser.userId,\n blux_id: bluxUser.id,\n device_id: bluxUser.deviceId,\n })),\n },\n this.generateApiHeader(bluxUser),\n );\n } catch (error) {\n // todo : retry\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 map((requestIdsSucceeded) =>\n this.requestQueue$.value.filter(\n (request) => !requestIdsSucceeded.includes(request.id),\n ),\n ),\n observeOn(asyncScheduler),\n )\n .subscribe(this.requestQueue$);\n }\n\n private generateApiHeader({ bluxApiKey }: { bluxApiKey: string }) {\n return {\n Authorization: bluxApiKey,\n };\n }\n\n public static async init({\n applicationId,\n bluxApiKey,\n }: {\n applicationId: string;\n bluxApiKey: string;\n }): Promise<BluxClient | null> {\n const client = new BluxClient();\n client.sendEvent(new VisitEvent({}));\n try {\n Logger.debug(`Init with application id: ${applicationId}`);\n\n const deviceId = LocalStorage.getDeviceId();\n\n if (!deviceId) {\n Logger.debug(\"No saved Device ID, register a new one.\");\n }\n\n const {\n data: { blux_user_id, device_id },\n } = await initialize(\n client.api,\n { application_id: applicationId },\n {\n isVisitHandlingInSdk: true,\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: DevicePlatform.browser,\n os_version: navigator.userAgent,\n sdk_version: client.sdkInfo.version,\n sdk_type: client.sdkInfo.type,\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n },\n client.generateApiHeader({\n bluxApiKey,\n }),\n );\n\n LocalStorage.setDeviceId(device_id);\n\n client.bluxUser$.next({\n id: blux_user_id,\n bluxApiKey,\n applicationId,\n deviceId: device_id,\n });\n\n function updateUrlAndRef() {\n const url = LocalStorage.getUrl();\n\n if (window.location.href !== url) {\n // 페이지 이동 시 url, ref 업데이트\n LocalStorage.setRef(`${url}`);\n LocalStorage.setUrl(window.location.href);\n\n // 페이지 이동 시 page_visit event 자동 수집\n client.sendEvent(new AddPageVisitEvent({}));\n }\n }\n updateUrlAndRef();\n const mutationObserver = new MutationObserver(updateUrlAndRef);\n const mutationObserverConfig = { subtree: true, childList: true };\n mutationObserver.observe(document.body, mutationObserverConfig);\n\n return client;\n } catch (error) {\n Logger.error(error, { tags: { from: \"init\" } });\n return null;\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 \"Application ID is not initialized. 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 signIn(\n this.api,\n { application_id: bluxUser.applicationId, blux_user_id: bluxUser.id },\n { user_id: userId, device_id: bluxUser.deviceId },\n this.generateApiHeader(bluxUser),\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 signOut(\n this.api,\n { application_id: bluxUser.applicationId, blux_user_id: bluxUser.id },\n { device_id: bluxUser.deviceId },\n this.generateApiHeader(bluxUser),\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 updateUserProperties(\n this.api,\n { application_id: bluxUser.applicationId, blux_user_id: bluxUser.id },\n { properties: userProperties },\n this.generateApiHeader(bluxUser),\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 updateCustomUserProperties(\n this.api,\n { application_id: bluxUser.applicationId, blux_user_id: bluxUser.id },\n { properties: customUserProperties },\n this.generateApiHeader(bluxUser),\n );\n } catch (error) {\n Logger.error(error, { tags: { from: \"setCustomUserProperties\" } });\n }\n }\n\n public sendEvent(event: Event | Event[]) {\n const requests = (Array.isArray(event) ? event : [event]).map((event) => {\n // 모든 행동 데이터에 url, ref 추가\n event.request.internal_event_properties = {\n url: `${LocalStorage.getUrl()}`,\n ref: `${LocalStorage.getRef()}`,\n };\n\n return 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 public async getItemRecommendation(\n recommendation: Recommendation,\n ): Promise<APIs.bluxUsersGetItemRecommendations.ResponseData> {\n try {\n const bluxUser = await this.getBluxUserWithTimeout();\n const recommendationRequest = recommendation.request;\n\n const recommendationResponse = await getItemRecommendation(\n this.api,\n {\n application_id: bluxUser.applicationId,\n blux_user_id: bluxUser.id,\n },\n {\n call_type: recommendationRequest.call_type,\n limit: recommendationRequest.limit,\n offset: recommendationRequest.offset,\n item_ids: recommendationRequest.item_ids,\n },\n this.generateApiHeader(bluxUser),\n );\n\n return recommendationResponse.data;\n } catch (error) {\n Logger.error(error, { tags: { from: \"getItemRecommendation\" } });\n return {\n items: [],\n metadata: {},\n status: {\n is_success: false,\n code: 400,\n message: error.message,\n },\n };\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BluxClient.js","sourceRoot":"/","sources":["src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B,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC;YACtD,MAAM,QAAQ,GAAG,IAAI,oBAAoB,CACvC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,EAClC,EAAE,SAAS,EAAE,CAAC,EAAE,CACjB,CAAC;YACF,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;YAChC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAEzC,MAAM,CAAC,KAAK,CACV,oDAAoD,OAAO,IAAI,CAChE,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,kBAAkB,CAAC,OAAoC;QAC7D,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YACxB,IAAI,KAAK,CAAC,cAAc,EAAE;gBACxB,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;gBACnE,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,CAAC,YAAY,CAChD,eAAe,CAAC,iBAAiB,CAClC,CAAC;gBACF,IAAI,CAAC,OAAO,EAAE;oBACZ,OAAO;iBACR;gBAED,IAAI,CAAC,IAAI,CAAC,4BAA4B,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;oBACxD,IAAI,CAAC,SAAS,CACZ,IAAI,mBAAmB,CAAC;wBACtB,OAAO;wBACP,iBAAiB,EAAE,gBAAgB,IAAI,SAAS;qBACjD,CAAC,CACH,CAAC;oBACF,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;iBACjD;aACF;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import packageJson from \"../package.json\";\nimport {\n asyncScheduler,\n BehaviorSubject,\n catchError,\n exhaustMap,\n filter,\n firstValueFrom,\n map,\n observeOn,\n throwError,\n timeout,\n withLatestFrom,\n} from \"rxjs\";\nimport { LocalStorage } from \"./utils/LocalStorage\";\nimport type { LogLevel } from \"./utils/Logger\";\nimport { Logger } from \"./utils/Logger\";\nimport type { AxiosInstance } from \"axios\";\nimport axios from \"axios\";\nimport { filterNullable } from \"./utils/operators\";\nimport type { EventRequest } from \"./events/types\";\nimport type { Event } from \"./events/Event\";\nimport { initialize } from \"./apis/initialize\";\nimport { signIn } from \"./apis/signIn\";\nimport { signOut } from \"./apis/signOut\";\nimport { updateUserProperties } from \"./apis/updateUserProperties\";\nimport { updateCustomUserProperties } from \"./apis/updateCustomUserProperties\";\nimport { collectEvent } from \"./apis/createEvent\";\nimport { VisitEvent } from \"./events/VisitEvent\";\nimport type { Recommendation } from \"./recommendations/Recommendation\";\nimport { getItemRecommendation } from \"./apis/getItemRecommendation\";\nimport { DevicePlatform, type APIs } from \"./apis/APIs\";\nimport { AddPageVisitEvent } from \"./events/AddPageVisitEvent\";\nimport { SessionStorage } from \"./utils/SessionStorage\";\nimport { AddSectionViewEvent } from \"./events\";\nimport { BLUX_ATTRIBUTES } from \"./constants/BLUX_ATTRIBUTES\";\n\nexport type SdkInfo = {\n type: string;\n version: string;\n};\n\ntype BluxUser = {\n id: string;\n bluxApiKey: string;\n applicationId: string;\n deviceId?: string;\n userId?: string;\n};\n\nexport class BluxClient {\n private readonly api: AxiosInstance;\n\n private readonly sdkInfo: SdkInfo = {\n type: \"browser\",\n version: packageJson.version,\n };\n\n public readonly bluxUser$ = new BehaviorSubject<BluxUser | undefined>(\n undefined,\n );\n\n public readonly requestQueue$ = new BehaviorSubject<EventRequest[]>([]);\n\n private sectionViewCollectedSections: string[] = [];\n private observingTargetElements: { [call_type: string]: Element } = {};\n private sectionViewObservers: IntersectionObserver[] = [];\n\n constructor() {\n this.api = axios.create({\n baseURL: \"https://api.blux.ai/prod\",\n });\n this.requestQueue$\n .pipe(\n filter((queue) => queue.length > 0),\n withLatestFrom(this.bluxUser$.pipe(filterNullable())),\n exhaustMap(async ([requests, bluxUser]) => {\n try {\n await collectEvent(\n this.api,\n {\n blux_user_id: bluxUser.id,\n application_id: bluxUser.applicationId,\n },\n {\n events: requests.map((request) => ({\n ...request,\n blux_id: bluxUser.id,\n device_id: bluxUser.deviceId,\n })),\n },\n this.generateApiHeader(bluxUser),\n );\n } catch (error) {\n // todo : retry\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 map((requestIdsSucceeded) =>\n this.requestQueue$.value.filter(\n (request) => !requestIdsSucceeded.includes(request.id),\n ),\n ),\n observeOn(asyncScheduler),\n )\n .subscribe(this.requestQueue$);\n this.bluxUser$.subscribe((bluxUser) => {\n if (bluxUser) SessionStorage.setBluxUserId(bluxUser.id);\n });\n }\n\n private generateApiHeader({ bluxApiKey }: { bluxApiKey: string }) {\n return {\n Authorization: bluxApiKey,\n };\n }\n\n public static async init({\n applicationId,\n bluxApiKey,\n }: {\n applicationId: string;\n bluxApiKey: string;\n }): Promise<BluxClient | null> {\n const client = new BluxClient();\n const blux_user_id = new URLSearchParams(window.location.search).get(\n \"blux_user_id\",\n );\n\n const isBluxUserIdExistInSessionStorage = SessionStorage.getBluxUserId();\n if (!isBluxUserIdExistInSessionStorage)\n client.sendEvent(new VisitEvent({}));\n\n try {\n Logger.debug(`Init with application id: ${applicationId}`);\n\n const deviceId = LocalStorage.getDeviceId();\n\n if (!deviceId) {\n Logger.debug(\"No saved Device ID, register a new one.\");\n }\n\n const { data } = await initialize(\n client.api,\n { application_id: applicationId },\n {\n isVisitHandlingInSdk: true,\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: DevicePlatform.browser,\n os_version: navigator.userAgent,\n sdk_version: client.sdkInfo.version,\n sdk_type: client.sdkInfo.type,\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n blux_user_id: blux_user_id ?? undefined,\n },\n client.generateApiHeader({\n bluxApiKey,\n }),\n );\n\n if (data.device_id) LocalStorage.setDeviceId(data.device_id);\n\n client.bluxUser$.next({\n id: data.blux_user_id,\n bluxApiKey,\n applicationId,\n deviceId: data.device_id,\n });\n\n // [페이지 이동 처리]\n client.handlePageTransition();\n\n // [Section View 자동 수집 관련 처리]\n client.registerSectionViewObserver(); // init 시마다 특정 section을 observe하는 intersection observer 등록\n\n // (SPA 처리) init이 최초 1회만 호출되더라도 페이지 이동 및 intersection observer를 처리할 수 있도록 MutationObserver 등록\n const mutationObserver = new MutationObserver(() => {\n client.registerSectionViewObserver();\n });\n const mutationObserverConfig = { subtree: true, childList: true };\n mutationObserver.observe(document.body, mutationObserverConfig);\n\n return client;\n } catch (error) {\n Logger.error(error, { tags: { from: \"init\" } });\n return null;\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 \"Application ID is not initialized. 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 signIn(\n this.api,\n { application_id: bluxUser.applicationId, blux_user_id: bluxUser.id },\n { user_id: userId, device_id: bluxUser.deviceId },\n this.generateApiHeader(bluxUser),\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 signOut(\n this.api,\n { application_id: bluxUser.applicationId, blux_user_id: bluxUser.id },\n { device_id: bluxUser.deviceId },\n this.generateApiHeader(bluxUser),\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 updateUserProperties(\n this.api,\n { application_id: bluxUser.applicationId, blux_user_id: bluxUser.id },\n { properties: userProperties },\n this.generateApiHeader(bluxUser),\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 updateCustomUserProperties(\n this.api,\n { application_id: bluxUser.applicationId, blux_user_id: bluxUser.id },\n { properties: customUserProperties },\n this.generateApiHeader(bluxUser),\n );\n } catch (error) {\n Logger.error(error, { tags: { from: \"setCustomUserProperties\" } });\n }\n }\n\n public sendEvent(event: Event | Event[]) {\n const requests = (Array.isArray(event) ? event : [event]).map((event) => {\n // 모든 행동 데이터에 url, ref 추가\n event.request.internal_event_properties = {\n url: `${LocalStorage.getUrl()}`,\n ref: `${LocalStorage.getRef()}`,\n };\n\n return 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 public async getItemRecommendation(\n recommendation: Recommendation,\n ): Promise<APIs.bluxUsersGetItemRecommendations.ResponseData> {\n try {\n const bluxUser = await this.getBluxUserWithTimeout();\n const recommendationRequest = recommendation.request;\n\n const recommendationResponse = await getItemRecommendation(\n this.api,\n {\n application_id: bluxUser.applicationId,\n blux_user_id: bluxUser.id,\n },\n {\n call_type: recommendationRequest.call_type,\n limit: recommendationRequest.limit,\n offset: recommendationRequest.offset,\n item_ids: recommendationRequest.item_ids,\n },\n this.generateApiHeader(bluxUser),\n );\n\n return recommendationResponse.data;\n } catch (error) {\n Logger.error(error, { tags: { from: \"getItemRecommendation\" } });\n return {\n items: [],\n metadata: {},\n status: {\n is_success: false,\n code: 400,\n message: error.message,\n },\n };\n }\n }\n\n private handlePageTransition() {\n const url = LocalStorage.getUrl();\n\n if (window.location.href !== url) {\n // 페이지 이동 시 url, ref 업데이트\n LocalStorage.setRef(`${url}`);\n LocalStorage.setUrl(window.location.href);\n\n // 페이지 이동 시 page_visit event 자동 수집\n this.sendEvent(new AddPageVisitEvent({}));\n\n // 페이지 이동 시 section view 관련 변수 초기화\n this.sectionViewCollectedSections = [];\n this.observingTargetElements = {};\n this.sectionViewObservers.forEach((observer) => {\n observer.disconnect();\n });\n }\n }\n\n private registerSectionViewObserver() {\n const targetElements = Array.from(\n document.querySelectorAll(`[${BLUX_ATTRIBUTES.section}]`),\n );\n\n targetElements.forEach((targetElement) => {\n const section = targetElement.getAttribute(BLUX_ATTRIBUTES.section);\n if (!section) return;\n // 이미 observe 중인 section은 skip\n if (this.observingTargetElements[section]) {\n return;\n }\n\n this.observingTargetElements[section] = targetElement;\n const observer = new IntersectionObserver(\n this.handleIntersection.bind(this),\n { threshold: 0 },\n );\n observer.observe(targetElement);\n this.sectionViewObservers.push(observer);\n\n Logger.debug(\n `SectionView observer is registered for section: \"${section}\".`,\n );\n });\n }\n\n private handleIntersection(entries: IntersectionObserverEntry[]) {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n const section = entry.target.getAttribute(BLUX_ATTRIBUTES.section);\n const recommendationId = entry.target.getAttribute(\n BLUX_ATTRIBUTES.recommendation_id,\n );\n if (!section) {\n return;\n }\n\n if (!this.sectionViewCollectedSections.includes(section)) {\n this.sendEvent(\n new AddSectionViewEvent({\n section,\n recommendation_id: recommendationId ?? undefined,\n }),\n );\n this.sectionViewCollectedSections.push(section);\n }\n }\n });\n }\n}\n"]}
|
package/dist/src/apis/APIs.d.ts
CHANGED
|
@@ -27,28 +27,31 @@ export declare namespace APIs {
|
|
|
27
27
|
sdk_version: z.ZodString;
|
|
28
28
|
timezone: z.ZodString;
|
|
29
29
|
isVisitHandlingInSdk: z.ZodDefault<z.ZodBoolean>;
|
|
30
|
+
blux_user_id: z.ZodOptional<z.ZodString>;
|
|
30
31
|
}, "strip", z.ZodTypeAny, {
|
|
31
|
-
platform: DevicePlatform;
|
|
32
|
-
timezone: string;
|
|
33
32
|
device_model: string;
|
|
34
33
|
language_code: string;
|
|
35
34
|
os_version: string;
|
|
35
|
+
platform: DevicePlatform;
|
|
36
36
|
sdk_type: string;
|
|
37
37
|
sdk_version: string;
|
|
38
|
+
timezone: string;
|
|
38
39
|
isVisitHandlingInSdk: boolean;
|
|
39
40
|
device_id?: import("bson-objectid").default | undefined;
|
|
40
41
|
country_code?: "AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AI" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BM" | "BT" | "BO" | "BA" | "BW" | "BR" | "IO" | "BN" | "BG" | "BF" | "BI" | "KH" | "CM" | "CV" | "KY" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CG" | "CD" | "CK" | "CR" | "CI" | "HR" | "CU" | "CY" | "CZ" | "DK" | "DJ" | "DM" | "DO" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FK" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GI" | "GR" | "GL" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "HT" | "VA" | "HN" | "HK" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IL" | "IT" | "JM" | "JP" | "JO" | "KE" | "KI" | "KP" | "KR" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LY" | "LI" | "LT" | "LU" | "MO" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MH" | "MQ" | "MR" | "MU" | "YT" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "MM" | "NA" | "NR" | "NP" | "NL" | "NC" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "MP" | "NO" | "OM" | "PK" | "PW" | "PS" | "PA" | "PG" | "PY" | "GY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "RO" | "RU" | "KZ" | "RW" | "RE" | "BL" | "SH" | "KN" | "LC" | "MF" | "PM" | "VC" | "WS" | "SM" | "ST" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SK" | "SI" | "SB" | "SO" | "ZA" | "SS" | "ES" | "LK" | "SD" | "SR" | "SZ" | "SE" | "CH" | "SY" | "TW" | "TJ" | "TZ" | "TH" | "TL" | "TG" | "TK" | "TO" | "TT" | "TN" | "TR" | "TM" | "TC" | "TV" | "UG" | "UA" | "AE" | "GB" | "US" | "CA" | "UY" | "UZ" | "VU" | "VE" | "VN" | "VG" | "VI" | "WF" | "YE" | "ZM" | "ZW" | undefined;
|
|
42
|
+
blux_user_id?: string | undefined;
|
|
41
43
|
}, {
|
|
42
|
-
platform: DevicePlatform;
|
|
43
|
-
timezone: string;
|
|
44
44
|
device_model: string;
|
|
45
45
|
language_code: string;
|
|
46
46
|
os_version: string;
|
|
47
|
+
platform: DevicePlatform;
|
|
47
48
|
sdk_type: string;
|
|
48
49
|
sdk_version: string;
|
|
50
|
+
timezone: string;
|
|
49
51
|
device_id?: string | undefined;
|
|
50
52
|
country_code?: unknown;
|
|
51
53
|
isVisitHandlingInSdk?: boolean | undefined;
|
|
54
|
+
blux_user_id?: string | undefined;
|
|
52
55
|
}>;
|
|
53
56
|
type Body = Serialize<z.input<typeof bodySchema>>;
|
|
54
57
|
const pathSchema: z.ZodObject<{
|
|
@@ -61,7 +64,7 @@ export declare namespace APIs {
|
|
|
61
64
|
type PathParam = Serialize<z.input<typeof pathSchema>>;
|
|
62
65
|
type ResponseData = {
|
|
63
66
|
blux_user_id: string;
|
|
64
|
-
device_id
|
|
67
|
+
device_id?: string;
|
|
65
68
|
};
|
|
66
69
|
}
|
|
67
70
|
namespace bluxUsersSignIn {
|
|
@@ -99,11 +102,11 @@ export declare namespace APIs {
|
|
|
99
102
|
const path: string;
|
|
100
103
|
const method = HttpMethod.PUT;
|
|
101
104
|
const bodySchema: z.ZodObject<{
|
|
102
|
-
device_id: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("bson-objectid").default, string
|
|
105
|
+
device_id: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("bson-objectid").default, string>>;
|
|
103
106
|
}, "strip", z.ZodTypeAny, {
|
|
104
|
-
device_id
|
|
107
|
+
device_id?: import("bson-objectid").default | undefined;
|
|
105
108
|
}, {
|
|
106
|
-
device_id
|
|
109
|
+
device_id?: string | undefined;
|
|
107
110
|
}>;
|
|
108
111
|
type Body = Serialize<z.input<typeof bodySchema>>;
|
|
109
112
|
const pathSchema: z.ZodObject<{
|
|
@@ -129,11 +132,11 @@ export declare namespace APIs {
|
|
|
129
132
|
application_id: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("bson-objectid").default, string>;
|
|
130
133
|
blux_user_id: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("bson-objectid").default, string>;
|
|
131
134
|
}, "strip", z.ZodTypeAny, {
|
|
132
|
-
application_id: import("bson-objectid").default;
|
|
133
135
|
blux_user_id: import("bson-objectid").default;
|
|
136
|
+
application_id: import("bson-objectid").default;
|
|
134
137
|
}, {
|
|
135
|
-
application_id: string;
|
|
136
138
|
blux_user_id: string;
|
|
139
|
+
application_id: string;
|
|
137
140
|
}>;
|
|
138
141
|
type PathParam = Serialize<z.input<typeof pathSchema>>;
|
|
139
142
|
const bodySchema: z.ZodObject<{
|
|
@@ -162,8 +165,8 @@ export declare namespace APIs {
|
|
|
162
165
|
url?: string | undefined;
|
|
163
166
|
ref?: string | undefined;
|
|
164
167
|
} | undefined;
|
|
165
|
-
event_properties?: Record<string, string | number | boolean | string[]
|
|
166
|
-
custom_event_properties?: Record<string, string | number | boolean | string[]
|
|
168
|
+
event_properties?: Record<string, string | number | boolean | Date | string[]> | undefined;
|
|
169
|
+
custom_event_properties?: Record<string, string | number | boolean | Date | string[]> | undefined;
|
|
167
170
|
item_id?: string | undefined;
|
|
168
171
|
device_id?: import("bson-objectid").default | undefined;
|
|
169
172
|
event_value?: string | undefined;
|
|
@@ -188,8 +191,8 @@ export declare namespace APIs {
|
|
|
188
191
|
url?: string | undefined;
|
|
189
192
|
ref?: string | undefined;
|
|
190
193
|
} | undefined;
|
|
191
|
-
event_properties?: Record<string, string | number | boolean | string[]
|
|
192
|
-
custom_event_properties?: Record<string, string | number | boolean | string[]
|
|
194
|
+
event_properties?: Record<string, string | number | boolean | Date | string[]> | undefined;
|
|
195
|
+
custom_event_properties?: Record<string, string | number | boolean | Date | string[]> | undefined;
|
|
193
196
|
item_id?: string | undefined;
|
|
194
197
|
device_id?: import("bson-objectid").default | undefined;
|
|
195
198
|
event_value?: string | undefined;
|
|
@@ -222,9 +225,9 @@ export declare namespace APIs {
|
|
|
222
225
|
offset: z.ZodDefault<z.ZodNumber>;
|
|
223
226
|
item_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
224
227
|
}, "strip", z.ZodTypeAny, {
|
|
225
|
-
offset: number;
|
|
226
228
|
call_type: string;
|
|
227
229
|
limit: number;
|
|
230
|
+
offset: number;
|
|
228
231
|
item_ids?: string[] | undefined;
|
|
229
232
|
}, {
|
|
230
233
|
call_type: string;
|
|
@@ -237,11 +240,11 @@ export declare namespace APIs {
|
|
|
237
240
|
application_id: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("bson-objectid").default, string>;
|
|
238
241
|
blux_user_id: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("bson-objectid").default, string>;
|
|
239
242
|
}, "strip", z.ZodTypeAny, {
|
|
240
|
-
application_id: import("bson-objectid").default;
|
|
241
243
|
blux_user_id: import("bson-objectid").default;
|
|
244
|
+
application_id: import("bson-objectid").default;
|
|
242
245
|
}, {
|
|
243
|
-
application_id: string;
|
|
244
246
|
blux_user_id: string;
|
|
247
|
+
application_id: string;
|
|
245
248
|
}>;
|
|
246
249
|
type PathParam = Serialize<z.input<typeof pathSchema>>;
|
|
247
250
|
type ResponseData = {
|
|
@@ -324,7 +327,7 @@ export declare namespace APIs {
|
|
|
324
327
|
const bodySchema: z.ZodObject<{
|
|
325
328
|
properties: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString, "many">, z.ZodNull]>>;
|
|
326
329
|
}, "strip", z.ZodTypeAny, {
|
|
327
|
-
properties: Record<string, string | number | boolean | string[] |
|
|
330
|
+
properties: Record<string, string | number | boolean | Date | string[] | null>;
|
|
328
331
|
}, {
|
|
329
332
|
properties: Record<string, string | number | boolean | string[] | null>;
|
|
330
333
|
}>;
|
package/dist/src/apis/APIs.js
CHANGED
|
@@ -32,7 +32,8 @@ export var APIs;
|
|
|
32
32
|
sdk_type: z.string(),
|
|
33
33
|
sdk_version: z.string(),
|
|
34
34
|
timezone: z.string(),
|
|
35
|
-
isVisitHandlingInSdk: z.boolean().default(false),
|
|
35
|
+
isVisitHandlingInSdk: z.boolean().default(false),
|
|
36
|
+
blux_user_id: z.string().optional(),
|
|
36
37
|
});
|
|
37
38
|
bluxUsersInitialize.pathSchema = z.object({
|
|
38
39
|
application_id: z.string().optional(),
|
|
@@ -58,7 +59,7 @@ export var APIs;
|
|
|
58
59
|
bluxUsersSignOut.path = `${applicationsRoot}/blux-users/{blux_user_id}/sign-out`;
|
|
59
60
|
bluxUsersSignOut.method = HttpMethod.PUT;
|
|
60
61
|
bluxUsersSignOut.bodySchema = z.object({
|
|
61
|
-
device_id: objectIdSchema,
|
|
62
|
+
device_id: objectIdSchema.optional(),
|
|
62
63
|
});
|
|
63
64
|
bluxUsersSignOut.pathSchema = z.object({
|
|
64
65
|
application_id: z.string().optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"APIs.js","sourceRoot":"/","sources":["src/apis/APIs.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC7B,sBAAsB,EACtB,UAAU,EACV,cAAc,GACf,MAAM,qBAAqB,CAAC;AAG7B,IAAK,UAKJ;AALD,WAAK,UAAU;IACb,yBAAW,CAAA;IACX,2BAAa,CAAA;IACb,yBAAW,CAAA;IACX,+BAAiB,CAAA;AACnB,CAAC,EALI,UAAU,KAAV,UAAU,QAKd;AAED,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,6BAAW,CAAA;IACX,qCAAmB,CAAA;IACnB,qCAAmB,CAAA;AACrB,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB;AAED,MAAM,gBAAgB,GAAG,gCAAgC,CAAC;AAE1D,MAAM,KAAW,IAAI,CA4LpB;AA5LD,WAAiB,IAAI;IACnB,IAAiB,mBAAmB,CA4BnC;IA5BD,WAAiB,mBAAmB;QACrB,wBAAI,GAAG,qBAAqB,CAAC;QAC7B,wBAAI,GAAG,GAAG,gBAAgB,wBAAwB,CAAC;QACnD,0BAAM,GAAG,UAAU,CAAC,IAAI,CAAC;QAEzB,8BAAU,GAAG,CAAC,CAAC,MAAM,CAAC;YACjC,SAAS,EAAE,cAAc,CAAC,QAAQ,EAAE;YACpC,YAAY,EAAE,8BAA8B,CAAC,QAAQ,EAAE;YACvD,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;YACxB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;YACzB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;YACtB,QA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,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;gBACjE,8BAA8B,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;gBACjE,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;gBAC9C,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;aACjD,CAAC;SACH,CAAC,CAAC;QAGU,wCAAU,GAAG,CAAC,CAAC,MAAM,CAAC;YACjC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YACrC,YAAY,EAAE,cAAc;SAC7B,CAAC,CAAC;IAML,CAAC,EA1BgB,6BAA6B,GAA7B,kCAA6B,KAA7B,kCAA6B,QA0B7C;IAED,IAAiB,mCAAmC,CAmBnD;IAnBD,WAAiB,mCAAmC;QACrC,wCAAI,GAAG,qCAAqC,CAAC;QAC7C,wCAAI,GAAG,GAAG,gBAAgB,0DAA0D,CAAC;QACrF,0CAAM,GAAG,UAAU,CAAC,GAAG,CAAC;QAExB,8CAAU,GAAG,CAAC,CAAC,MAAM,CAAC;YACjC,UAAU,EAAE,6BAA6B;SAC1C,CAAC,CAAC;QAGU,8CAAU,GAAG,CAAC,CAAC,MAAM,CAAC;YACjC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YACrC,YAAY,EAAE,cAAc;SAC7B,CAAC,CAAC;IAML,CAAC,EAnBgB,mCAAmC,GAAnC,wCAAmC,KAAnC,wCAAmC,QAmBnD;AACH,CAAC,EA5LgB,IAAI,KAAJ,IAAI,QA4LpB","sourcesContent":["/* eslint-disable @typescript-eslint/no-namespace */\nimport { z } from \"zod\";\nimport {\n countryCodeWithLowerCaseSchema,\n customPropertiesRequestSchema,\n customPropertiesSchema,\n dateSchema,\n objectIdSchema,\n} from \"../utils/zodSchemas\";\nimport type { Serialize } from \"../utils/Base\";\n\nenum HttpMethod {\n GET = \"get\",\n POST = \"post\",\n PUT = \"put\",\n DELETE = \"delete\",\n}\n\nexport enum DevicePlatform {\n ios = \"ios\",\n android = \"android\",\n browser = \"browser\",\n}\n\nconst applicationsRoot = \"/applications/{application_id}\";\n\nexport namespace APIs {\n export namespace bluxUsersInitialize {\n export const name = \"bluxUsersInitialize\";\n export const path = `${applicationsRoot}/blux-users/initialize`;\n export const method = HttpMethod.POST;\n\n export const bodySchema = z.object({\n device_id: objectIdSchema.optional(),\n country_code: countryCodeWithLowerCaseSchema.optional(),\n device_model: z.string(),\n language_code: z.string(),\n os_version: z.string(),\n platform: z.nativeEnum(DevicePlatform),\n sdk_type: z.string(),\n sdk_version: z.string(),\n timezone: z.string(),\n isVisitHandlingInSdk: z.boolean().default(false), // sdk 업데이트 후 삭제\n });\n export type Body = Serialize<z.input<typeof bodySchema>>;\n\n export const pathSchema = z.object({\n application_id: z.string().optional(),\n });\n export type PathParam = Serialize<z.input<typeof pathSchema>>;\n\n export type ResponseData = {\n blux_user_id: string;\n device_id: string;\n };\n }\n\n export namespace bluxUsersSignIn {\n export const name = \"bluxUsersSignIn\";\n export const path = `${applicationsRoot}/blux-users/{blux_user_id}/sign-in`;\n export const method = HttpMethod.PUT;\n\n export const bodySchema = z.object({\n user_id: z.string(),\n device_id: z.string().optional(), // todo: sdk update 후 필수로 변경\n });\n export type Body = Serialize<z.input<typeof bodySchema>>;\n\n export const pathSchema = z.object({\n application_id: z.string().optional(),\n blux_user_id: objectIdSchema,\n });\n export type PathParam = Serialize<z.input<typeof pathSchema>>;\n\n export type ResponseData = {\n blux_user_id: string;\n };\n }\n\n export namespace bluxUsersSignOut {\n export const name = \"bluxUsersSignOut\";\n export const path = `${applicationsRoot}/blux-users/{blux_user_id}/sign-out`;\n export const method = HttpMethod.PUT;\n\n export const bodySchema = z.object({\n device_id: objectIdSchema,\n });\n export type Body = Serialize<z.input<typeof bodySchema>>;\n\n export const pathSchema = z.object({\n application_id: z.string().optional(), // todo: objectIdSchema 로 변경\n blux_user_id: objectIdSchema,\n });\n export type PathParam = Serialize<z.input<typeof pathSchema>>;\n\n export type ResponseData = {\n blux_user_id: string;\n };\n }\n\n export namespace bluxUsersCollectEvents {\n export const name = \"bluxUsersCollectEvents\";\n export const path = `${applicationsRoot}/blux-users/{blux_user_id}/collect-events`;\n export const method = HttpMethod.POST;\n export const pathSchema = z.object({\n application_id: objectIdSchema,\n blux_user_id: objectIdSchema,\n });\n export type PathParam = Serialize<z.input<typeof pathSchema>>;\n\n export const bodySchema = z.object({\n events: z.array(\n z.object({\n device_id: objectIdSchema.optional(),\n event_type: z.string(),\n event_value: z.string().optional(),\n item_id: z.string().optional(),\n event_properties: customPropertiesSchema.optional(), // todo : remove this\n custom_event_properties: customPropertiesSchema.optional(),\n internal_event_properties: z\n .object({\n url: z.string().optional(),\n ref: z.string().optional(),\n })\n .optional(),\n captured_at: dateSchema,\n }),\n ),\n });\n export type Body = Serialize<z.input<typeof bodySchema>>;\n\n export type ResponseData = boolean;\n }\n\n export namespace bluxUsersGetItemRecommendations {\n export const name = \"bluxUsersGetItemRecommendations\";\n export const path = `${applicationsRoot}/blux-users/{blux_user_id}/item-recommendations`;\n export const method = HttpMethod.POST;\n\n export const bodySchema = z.object({\n call_type: z.string(),\n limit: z.number(),\n offset: z.number().default(0),\n item_ids: z.array(z.string()).optional(),\n });\n export type Body = Serialize<z.input<typeof bodySchema>>;\n\n export const pathSchema = z.object({\n application_id: objectIdSchema,\n blux_user_id: objectIdSchema,\n });\n export type PathParam = Serialize<z.input<typeof pathSchema>>;\n\n export type ResponseData = {\n recommendation_id?: string;\n items: string[];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata: Record<string, any>;\n status: {\n is_success: boolean;\n code: number;\n message?: string;\n };\n };\n }\n\n export namespace bluxUsersUpdateUserProperties {\n export const name = \"bluxUsersUpdateUserProperties\";\n export const path = `${applicationsRoot}/blux-users/{blux_user_id}/update-user-properties`;\n export const method = HttpMethod.PUT;\n\n export const bodySchema = z.object({\n properties: z.object({\n phone_number: z.string().nullable().optional(),\n email_address: z.string().nullable().optional(),\n nighttime_notification_consent: z.boolean().nullable().optional(),\n marketing_notification_consent: z.boolean().nullable().optional(),\n sms_consent: z.boolean().nullable().optional(),\n email_consent: z.boolean().nullable().optional(),\n }),\n });\n export type Body = Serialize<z.input<typeof bodySchema>>;\n\n export const pathSchema = z.object({\n application_id: z.string().optional(),\n blux_user_id: objectIdSchema,\n });\n export type PathParam = Serialize<z.input<typeof pathSchema>>;\n\n export type ResponseData = {\n blux_user_id: string;\n };\n }\n\n export namespace bluxUsersUpdateCustomUserProperties {\n export const name = \"bluxUsersUpdateCustomUserProperties\";\n export const path = `${applicationsRoot}/blux-users/{blux_user_id}/update-custom-user-properties`;\n export const method = HttpMethod.PUT;\n\n export const bodySchema = z.object({\n properties: customPropertiesRequestSchema,\n });\n export type Body = Serialize<z.input<typeof bodySchema>>;\n\n export const pathSchema = z.object({\n application_id: z.string().optional(),\n blux_user_id: objectIdSchema,\n });\n export type PathParam = Serialize<z.input<typeof pathSchema>>;\n\n export type ResponseData = {\n blux_user_id: string;\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"APIs.js","sourceRoot":"/","sources":["src/apis/APIs.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC7B,sBAAsB,EACtB,UAAU,EACV,cAAc,GACf,MAAM,qBAAqB,CAAC;AAG7B,IAAK,UAKJ;AALD,WAAK,UAAU;IACb,yBAAW,CAAA;IACX,2BAAa,CAAA;IACb,yBAAW,CAAA;IACX,+BAAiB,CAAA;AACnB,CAAC,EALI,UAAU,KAAV,UAAU,QAKd;AAED,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,6BAAW,CAAA;IACX,qCAAmB,CAAA;IACn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D;IAnBD,WAAiB,mCAAmC;QACrC,wCAAI,GAAG,qCAAqC,CAAC;QAC7C,wCAAI,GAAG,GAAG,gBAAgB,0DAA0D,CAAC;QACrF,0CAAM,GAAG,UAAU,CAAC,GAAG,CAAC;QAExB,8CAAU,GAAG,CAAC,CAAC,MAAM,CAAC;YACjC,UAAU,EAAE,6BAA6B;SAC1C,CAAC,CAAC;QAGU,8CAAU,GAAG,CAAC,CAAC,MAAM,CAAC;YACjC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YACrC,YAAY,EAAE,cAAc;SAC7B,CAAC,CAAC;IAML,CAAC,EAnBgB,mCAAmC,GAAnC,wCAAmC,KAAnC,wCAAmC,QAmBnD;AACH,CAAC,EA7LgB,IAAI,KAAJ,IAAI,QA6LpB","sourcesContent":["/* eslint-disable @typescript-eslint/no-namespace */\nimport { z } from \"zod\";\nimport {\n countryCodeWithLowerCaseSchema,\n customPropertiesRequestSchema,\n customPropertiesSchema,\n dateSchema,\n objectIdSchema,\n} from \"../utils/zodSchemas\";\nimport type { Serialize } from \"../utils/Base\";\n\nenum HttpMethod {\n GET = \"get\",\n POST = \"post\",\n PUT = \"put\",\n DELETE = \"delete\",\n}\n\nexport enum DevicePlatform {\n ios = \"ios\",\n android = \"android\",\n browser = \"browser\",\n}\n\nconst applicationsRoot = \"/applications/{application_id}\";\n\nexport namespace APIs {\n export namespace bluxUsersInitialize {\n export const name = \"bluxUsersInitialize\";\n export const path = `${applicationsRoot}/blux-users/initialize`;\n export const method = HttpMethod.POST;\n\n export const bodySchema = z.object({\n device_id: objectIdSchema.optional(),\n country_code: countryCodeWithLowerCaseSchema.optional(),\n device_model: z.string(),\n language_code: z.string(),\n os_version: z.string(),\n platform: z.nativeEnum(DevicePlatform),\n sdk_type: z.string(),\n sdk_version: z.string(),\n timezone: z.string(),\n isVisitHandlingInSdk: z.boolean().default(false), // sdk 업데이트 후 삭제\n blux_user_id: z.string().optional(),\n });\n export type Body = Serialize<z.input<typeof bodySchema>>;\n\n export const pathSchema = z.object({\n application_id: z.string().optional(),\n });\n export type PathParam = Serialize<z.input<typeof pathSchema>>;\n\n export type ResponseData = {\n blux_user_id: string;\n device_id?: string;\n };\n }\n\n export namespace bluxUsersSignIn {\n export const name = \"bluxUsersSignIn\";\n export const path = `${applicationsRoot}/blux-users/{blux_user_id}/sign-in`;\n export const method = HttpMethod.PUT;\n\n export const bodySchema = z.object({\n user_id: z.string(),\n device_id: z.string().optional(), // todo: sdk update 후 필수로 변경\n });\n export type Body = Serialize<z.input<typeof bodySchema>>;\n\n export const pathSchema = z.object({\n application_id: z.string().optional(),\n blux_user_id: objectIdSchema,\n });\n export type PathParam = Serialize<z.input<typeof pathSchema>>;\n\n export type ResponseData = {\n blux_user_id: string;\n };\n }\n\n export namespace bluxUsersSignOut {\n export const name = \"bluxUsersSignOut\";\n export const path = `${applicationsRoot}/blux-users/{blux_user_id}/sign-out`;\n export const method = HttpMethod.PUT;\n\n export const bodySchema = z.object({\n device_id: objectIdSchema.optional(),\n });\n export type Body = Serialize<z.input<typeof bodySchema>>;\n\n export const pathSchema = z.object({\n application_id: z.string().optional(), // todo: objectIdSchema 로 변경\n blux_user_id: objectIdSchema,\n });\n export type PathParam = Serialize<z.input<typeof pathSchema>>;\n\n export type ResponseData = {\n blux_user_id: string;\n };\n }\n\n export namespace bluxUsersCollectEvents {\n export const name = \"bluxUsersCollectEvents\";\n export const path = `${applicationsRoot}/blux-users/{blux_user_id}/collect-events`;\n export const method = HttpMethod.POST;\n export const pathSchema = z.object({\n application_id: objectIdSchema,\n blux_user_id: objectIdSchema,\n });\n export type PathParam = Serialize<z.input<typeof pathSchema>>;\n\n export const bodySchema = z.object({\n events: z.array(\n z.object({\n device_id: objectIdSchema.optional(),\n event_type: z.string(),\n event_value: z.string().optional(),\n item_id: z.string().optional(),\n event_properties: customPropertiesSchema.optional(), // todo : remove this\n custom_event_properties: customPropertiesSchema.optional(),\n internal_event_properties: z\n .object({\n url: z.string().optional(),\n ref: z.string().optional(),\n })\n .optional(),\n captured_at: dateSchema,\n }),\n ),\n });\n export type Body = Serialize<z.input<typeof bodySchema>>;\n\n export type ResponseData = boolean;\n }\n\n export namespace bluxUsersGetItemRecommendations {\n export const name = \"bluxUsersGetItemRecommendations\";\n export const path = `${applicationsRoot}/blux-users/{blux_user_id}/item-recommendations`;\n export const method = HttpMethod.POST;\n\n export const bodySchema = z.object({\n call_type: z.string(),\n limit: z.number(),\n offset: z.number().default(0),\n item_ids: z.array(z.string()).optional(),\n });\n export type Body = Serialize<z.input<typeof bodySchema>>;\n\n export const pathSchema = z.object({\n application_id: objectIdSchema,\n blux_user_id: objectIdSchema,\n });\n export type PathParam = Serialize<z.input<typeof pathSchema>>;\n\n export type ResponseData = {\n recommendation_id?: string;\n items: string[];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata: Record<string, any>;\n status: {\n is_success: boolean;\n code: number;\n message?: string;\n };\n };\n }\n\n export namespace bluxUsersUpdateUserProperties {\n export const name = \"bluxUsersUpdateUserProperties\";\n export const path = `${applicationsRoot}/blux-users/{blux_user_id}/update-user-properties`;\n export const method = HttpMethod.PUT;\n\n export const bodySchema = z.object({\n properties: z.object({\n phone_number: z.string().nullable().optional(),\n email_address: z.string().nullable().optional(),\n nighttime_notification_consent: z.boolean().nullable().optional(),\n marketing_notification_consent: z.boolean().nullable().optional(),\n sms_consent: z.boolean().nullable().optional(),\n email_consent: z.boolean().nullable().optional(),\n }),\n });\n export type Body = Serialize<z.input<typeof bodySchema>>;\n\n export const pathSchema = z.object({\n application_id: z.string().optional(),\n blux_user_id: objectIdSchema,\n });\n export type PathParam = Serialize<z.input<typeof pathSchema>>;\n\n export type ResponseData = {\n blux_user_id: string;\n };\n }\n\n export namespace bluxUsersUpdateCustomUserProperties {\n export const name = \"bluxUsersUpdateCustomUserProperties\";\n export const path = `${applicationsRoot}/blux-users/{blux_user_id}/update-custom-user-properties`;\n export const method = HttpMethod.PUT;\n\n export const bodySchema = z.object({\n properties: customPropertiesRequestSchema,\n });\n export type Body = Serialize<z.input<typeof bodySchema>>;\n\n export const pathSchema = z.object({\n application_id: z.string().optional(),\n blux_user_id: objectIdSchema,\n });\n export type PathParam = Serialize<z.input<typeof pathSchema>>;\n\n export type ResponseData = {\n blux_user_id: string;\n };\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BLUX_ATTRIBUTES.js","sourceRoot":"/","sources":["src/constants/BLUX_ATTRIBUTES.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,cAAc;IACvB,iBAAiB,EAAE,aAAa;CACjC,CAAC","sourcesContent":["export const BLUX_ATTRIBUTES = {\n section: \"blux-section\",\n recommendation_id: \"blux-rec-id\",\n};\n"]}
|
|
@@ -47,10 +47,8 @@ export interface IAddCustomEvent extends BaseEvent {
|
|
|
47
47
|
event_type: string;
|
|
48
48
|
event_properties?: EventProperties;
|
|
49
49
|
}
|
|
50
|
-
export
|
|
51
|
-
|
|
52
|
-
export interface IAddPageVisitEvent extends Omit<BaseEvent, "item_id"> {
|
|
53
|
-
}
|
|
50
|
+
export type IVisitEvent = BaseEvent;
|
|
51
|
+
export type IAddPageVisitEvent = BaseEvent;
|
|
54
52
|
export interface IAddPageViewEvent extends Omit<BaseEvent, "item_id"> {
|
|
55
53
|
page: string;
|
|
56
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["src/events/types.ts"],"names":[],"mappings":"AAAA,uDAAuD","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype EventProperties = {\n item_id?: string;\n section?: string;\n prev_section?: string;\n recommendation_id?: string;\n price?: number;\n order_id?: string;\n rating?: number;\n prev_page?: string;\n page?: string;\n position?: number;\n};\nexport interface EventRequest {\n id: string;\n event_type: string;\n event_properties?: EventProperties;\n custom_event_properties?: Record<string, any>;\n internal_event_properties?: { url?: string; ref?: string };\n captured_at: string;\n}\n\ntype BaseEvent = Omit<\n EventRequest,\n | \"event_type\"\n | \"id\"\n | \"captured_at\"\n | \"internal_event_properties\"\n | \"event_properties\"\n>;\n\nexport interface IAddProductDetailViewEvent extends BaseEvent {\n item_id: string;\n recommendation_id?: string;\n prev_page?: string;\n prev_section?: string;\n}\n\nexport interface IAddLikeEvent extends BaseEvent {\n item_id: string;\n}\n\nexport interface IAddCartaddEvent extends BaseEvent {\n item_id: string;\n}\n\nexport interface IAddRateEvent extends BaseEvent {\n item_id: string;\n rating: number;\n}\n\nexport interface IAddPurchaseEvent extends BaseEvent {\n item_id: string;\n price: number;\n order_id?: string;\n}\n\nexport interface IAddCustomEvent extends BaseEvent {\n event_type: string;\n event_properties?: EventProperties;\n}\n\nexport
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["src/events/types.ts"],"names":[],"mappings":"AAAA,uDAAuD","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype EventProperties = {\n item_id?: string;\n section?: string;\n prev_section?: string;\n recommendation_id?: string;\n price?: number;\n order_id?: string;\n rating?: number;\n prev_page?: string;\n page?: string;\n position?: number;\n};\nexport interface EventRequest {\n id: string;\n event_type: string;\n event_properties?: EventProperties;\n custom_event_properties?: Record<string, any>;\n internal_event_properties?: { url?: string; ref?: string };\n captured_at: string;\n}\n\ntype BaseEvent = Omit<\n EventRequest,\n | \"event_type\"\n | \"id\"\n | \"captured_at\"\n | \"internal_event_properties\"\n | \"event_properties\"\n>;\n\nexport interface IAddProductDetailViewEvent extends BaseEvent {\n item_id: string;\n recommendation_id?: string;\n prev_page?: string;\n prev_section?: string;\n}\n\nexport interface IAddLikeEvent extends BaseEvent {\n item_id: string;\n}\n\nexport interface IAddCartaddEvent extends BaseEvent {\n item_id: string;\n}\n\nexport interface IAddRateEvent extends BaseEvent {\n item_id: string;\n rating: number;\n}\n\nexport interface IAddPurchaseEvent extends BaseEvent {\n item_id: string;\n price: number;\n order_id?: string;\n}\n\nexport interface IAddCustomEvent extends BaseEvent {\n event_type: string;\n event_properties?: EventProperties;\n}\n\nexport type IVisitEvent = BaseEvent;\n\nexport type IAddPageVisitEvent = BaseEvent;\n\nexport interface IAddPageViewEvent extends Omit<BaseEvent, \"item_id\"> {\n page: string;\n}\n\nexport interface IAddSectionViewEvent extends Omit<BaseEvent, \"item_id\"> {\n section: string;\n recommendation_id?: string;\n}\n\nexport interface IAddInstantImpression extends BaseEvent {\n item_id: string;\n page: string;\n section: string;\n position: number;\n recommendation_id?: string;\n}\n\nexport interface IAddPersistentImpression extends BaseEvent {\n item_id: string;\n page: string;\n section: string;\n position: number;\n recommendation_id?: string;\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const BLUX_USER_ID = "blux_userId";
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
3
|
+
export class SessionStorage {
|
|
4
|
+
static getBluxUserId() {
|
|
5
|
+
const userId = sessionStorage.getItem(BLUX_USER_ID);
|
|
6
|
+
return userId === "undefined" || userId?.trim() === "" ? null : userId;
|
|
7
|
+
}
|
|
8
|
+
static setBluxUserId(userId) {
|
|
9
|
+
sessionStorage.setItem(BLUX_USER_ID, userId);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=SessionStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionStorage.js","sourceRoot":"/","sources":["src/utils/SessionStorage.ts"],"names":[],"mappings":"AAAA,MAAM,YAAY,GAAG,aAAa,CAAC;AAEnC,kEAAkE;AAClE,MAAM,OAAO,cAAc;IACzB,MAAM,CAAC,aAAa;QAClB,MAAM,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACpD,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;IACzE,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,MAAc;QACjC,cAAc,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["const BLUX_USER_ID = \"blux_userId\";\n\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport class SessionStorage {\n static getBluxUserId(): string | null {\n const userId = sessionStorage.getItem(BLUX_USER_ID);\n return userId === \"undefined\" || userId?.trim() === \"\" ? null : userId;\n }\n\n static setBluxUserId(userId: string) {\n sessionStorage.setItem(BLUX_USER_ID, userId);\n }\n}\n"]}
|