@blux.ai/web-sdk 0.0.7 → 1.0.0-rc1
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/README.md +19 -19
- package/dist/package.json +35 -0
- package/package.json +2 -2
- package/demo/craco.config.js +0 -29
- package/demo/package.json +0 -50
- package/demo/public/favicon.ico +0 -0
- package/demo/public/index.html +0 -43
- package/demo/public/logo192.png +0 -0
- package/demo/public/logo512.png +0 -0
- package/demo/public/manifest.json +0 -25
- package/demo/public/robots.txt +0 -3
- package/demo/src/App.test.tsx +0 -9
- package/demo/src/App.tsx +0 -252
- package/demo/src/index.css +0 -16
- package/demo/src/index.tsx +0 -19
- package/demo/src/react-app-env.d.ts +0 -1
- package/demo/src/reportWebVitals.ts +0 -15
- package/demo/src/setupTests.ts +0 -5
- package/demo/tailwind.config.js +0 -10
- package/dist/BluxClient.d.ts +0 -43
- package/dist/BluxClient.js +0 -190
- package/dist/BluxClient.js.map +0 -1
- package/dist/apis/APIs.d.ts +0 -317
- package/dist/apis/APIs.js +0 -138
- package/dist/apis/APIs.js.map +0 -1
- package/dist/apis/createEvent.d.ts +0 -4
- package/dist/apis/createEvent.js +0 -7
- package/dist/apis/createEvent.js.map +0 -1
- package/dist/apis/getItemRecommendation.d.ts +0 -4
- package/dist/apis/getItemRecommendation.js +0 -7
- package/dist/apis/getItemRecommendation.js.map +0 -1
- package/dist/apis/initialize.d.ts +0 -4
- package/dist/apis/initialize.js +0 -7
- package/dist/apis/initialize.js.map +0 -1
- package/dist/apis/signIn.d.ts +0 -4
- package/dist/apis/signIn.js +0 -7
- package/dist/apis/signIn.js.map +0 -1
- package/dist/apis/signOut.d.ts +0 -4
- package/dist/apis/signOut.js +0 -7
- package/dist/apis/signOut.js.map +0 -1
- package/dist/apis/updateCustomUserProperties.d.ts +0 -4
- package/dist/apis/updateCustomUserProperties.js +0 -7
- package/dist/apis/updateCustomUserProperties.js.map +0 -1
- package/dist/apis/updateUserProperties.d.ts +0 -4
- package/dist/apis/updateUserProperties.js +0 -7
- package/dist/apis/updateUserProperties.js.map +0 -1
- package/dist/constants/COUNTRIES.d.ts +0 -928
- package/dist/constants/COUNTRIES.js +0 -1159
- package/dist/constants/COUNTRIES.js.map +0 -1
- package/dist/constants/ISO8601_REGEX.d.ts +0 -1
- package/dist/constants/ISO8601_REGEX.js +0 -4
- package/dist/constants/ISO8601_REGEX.js.map +0 -1
- package/dist/constants/URLS.d.ts +0 -6
- package/dist/constants/URLS.js +0 -7
- package/dist/constants/URLS.js.map +0 -1
- package/dist/events/AddCartaddEvent.d.ts +0 -5
- package/dist/events/AddCartaddEvent.js +0 -11
- package/dist/events/AddCartaddEvent.js.map +0 -1
- package/dist/events/AddCustomEvent.d.ts +0 -5
- package/dist/events/AddCustomEvent.js +0 -12
- package/dist/events/AddCustomEvent.js.map +0 -1
- package/dist/events/AddLikeEvent.d.ts +0 -5
- package/dist/events/AddLikeEvent.js +0 -11
- package/dist/events/AddLikeEvent.js.map +0 -1
- package/dist/events/AddPageViewEvent.d.ts +0 -5
- package/dist/events/AddPageViewEvent.js +0 -11
- package/dist/events/AddPageViewEvent.js.map +0 -1
- package/dist/events/AddProductDetailViewEvent.d.ts +0 -5
- package/dist/events/AddProductDetailViewEvent.js +0 -11
- package/dist/events/AddProductDetailViewEvent.js.map +0 -1
- package/dist/events/AddPurchaseEvent.d.ts +0 -5
- package/dist/events/AddPurchaseEvent.js +0 -12
- package/dist/events/AddPurchaseEvent.js.map +0 -1
- package/dist/events/AddRateEvent.d.ts +0 -5
- package/dist/events/AddRateEvent.js +0 -12
- package/dist/events/AddRateEvent.js.map +0 -1
- package/dist/events/AddRecommendationViewEvent.d.ts +0 -5
- package/dist/events/AddRecommendationViewEvent.js +0 -10
- package/dist/events/AddRecommendationViewEvent.js.map +0 -1
- package/dist/events/Event.d.ts +0 -16
- package/dist/events/Event.js +0 -24
- package/dist/events/Event.js.map +0 -1
- package/dist/events/VisitEvent.d.ts +0 -5
- package/dist/events/VisitEvent.js +0 -10
- package/dist/events/VisitEvent.js.map +0 -1
- package/dist/events/index.d.ts +0 -8
- package/dist/events/index.js +0 -9
- package/dist/events/index.js.map +0 -1
- package/dist/events/types.d.ts +0 -38
- package/dist/events/types.js +0 -2
- package/dist/events/types.js.map +0 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -6
- package/dist/index.js.map +0 -1
- package/dist/recommendations/ItemRecommendation.d.ts +0 -5
- package/dist/recommendations/ItemRecommendation.js +0 -12
- package/dist/recommendations/ItemRecommendation.js.map +0 -1
- package/dist/recommendations/Recommendation.d.ts +0 -5
- package/dist/recommendations/Recommendation.js +0 -9
- package/dist/recommendations/Recommendation.js.map +0 -1
- package/dist/recommendations/index.d.ts +0 -1
- package/dist/recommendations/index.js +0 -2
- package/dist/recommendations/index.js.map +0 -1
- package/dist/recommendations/types.d.ts +0 -11
- package/dist/recommendations/types.js +0 -2
- package/dist/recommendations/types.js.map +0 -1
- package/dist/utils/Base.d.ts +0 -13
- package/dist/utils/Base.js +0 -2
- package/dist/utils/Base.js.map +0 -1
- package/dist/utils/LocalStorage.d.ts +0 -4
- package/dist/utils/LocalStorage.js +0 -14
- package/dist/utils/LocalStorage.js.map +0 -1
- package/dist/utils/Logger.d.ts +0 -13
- package/dist/utils/Logger.js +0 -49
- package/dist/utils/Logger.js.map +0 -1
- package/dist/utils/assertEqualTypes.d.ts +0 -3
- package/dist/utils/assertEqualTypes.js +0 -5
- package/dist/utils/assertEqualTypes.js.map +0 -1
- package/dist/utils/getPath.d.ts +0 -1
- package/dist/utils/getPath.js +0 -9
- package/dist/utils/getPath.js.map +0 -1
- package/dist/utils/helper.d.ts +0 -1
- package/dist/utils/helper.js +0 -4
- package/dist/utils/helper.js.map +0 -1
- package/dist/utils/operators.d.ts +0 -2
- package/dist/utils/operators.js +0 -6
- package/dist/utils/operators.js.map +0 -1
- package/dist/utils/zodSchemas.d.ts +0 -19
- package/dist/utils/zodSchemas.js +0 -105
- package/dist/utils/zodSchemas.js.map +0 -1
package/README.md
CHANGED
|
@@ -20,11 +20,11 @@ yarn add @blux.ai/web-sdk
|
|
|
20
20
|
- 필요 변수 : `클라이언트 ID`, `API 키`
|
|
21
21
|
|
|
22
22
|
```typescript
|
|
23
|
-
BluxClient.
|
|
24
|
-
|
|
25
|
-
bluxClientId: "{blux_client_id}",
|
|
23
|
+
const bluxClient = await BluxClient.init({
|
|
24
|
+
applicationId: "{blux_client_id}",
|
|
26
25
|
bluxApiKey: "{blux_api_key}",
|
|
27
26
|
});
|
|
27
|
+
bluxClient.setLogLevel("debug");
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
- **setLogLevel** : 연동 관련하여 디버깅을 하기 위해서 로깅을 활성화할 수 있습니다. 해당 설정은 정적이므로 BluxClient를 초기화하기 전에 호출하실 수 있습니다.
|
|
@@ -42,7 +42,7 @@ BluxClient.init({
|
|
|
42
42
|
- 회원 유저가 앱을 실행하는 시점에도 `initialize` 메소드 호출 이후에 실행되어야 합니다.
|
|
43
43
|
|
|
44
44
|
```typescript
|
|
45
|
-
|
|
45
|
+
bluxClient.signIn("USER ID");
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
### setUserProperties
|
|
@@ -50,8 +50,8 @@ BluxClient.signIn("USER ID");
|
|
|
50
50
|
- 유저에게 지정된 속성들을 부여합니다. 전화번호, 이메일 번호를 등록할 수 있습니다.
|
|
51
51
|
|
|
52
52
|
```typescript
|
|
53
|
-
|
|
54
|
-
phone_number: "
|
|
53
|
+
bluxClient.setUserProperties({
|
|
54
|
+
phone_number: "01011112222",
|
|
55
55
|
email_address: "test@example.com",
|
|
56
56
|
});
|
|
57
57
|
```
|
|
@@ -61,7 +61,7 @@ BluxClient.setUserProperties({
|
|
|
61
61
|
- `setUserProperties`에서 설정할 수 있는 지정된 속성 외 임의의 속성을 부여할 수 있습니다.
|
|
62
62
|
|
|
63
63
|
```typescript
|
|
64
|
-
|
|
64
|
+
bluxClient.setCustomUserProperties({
|
|
65
65
|
custom_key1: "any_value",
|
|
66
66
|
custom_key2: true,
|
|
67
67
|
custom_key3: null,
|
|
@@ -75,7 +75,7 @@ BluxClient.setCustomUserProperties({
|
|
|
75
75
|
- 유저들을 더 잘 식별하기위해 사용됩니다.
|
|
76
76
|
|
|
77
77
|
```typescript
|
|
78
|
-
|
|
78
|
+
bluxClient.signOut();
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
### sendEvent
|
|
@@ -87,9 +87,9 @@ BluxClient.signOut();
|
|
|
87
87
|
---
|
|
88
88
|
|
|
89
89
|
```typescript
|
|
90
|
-
|
|
90
|
+
bluxClient.sendEvent(
|
|
91
91
|
new AddProductDetailViewEvent({
|
|
92
|
-
|
|
92
|
+
item_id: "ITEM_ID",
|
|
93
93
|
}),
|
|
94
94
|
);
|
|
95
95
|
```
|
|
@@ -101,9 +101,9 @@ BluxClient.sendEvent(
|
|
|
101
101
|
---
|
|
102
102
|
|
|
103
103
|
```typescript
|
|
104
|
-
|
|
104
|
+
bluxClient.sendEvent(
|
|
105
105
|
new AddLikeEvent({
|
|
106
|
-
|
|
106
|
+
item_id: "ITEM_ID",
|
|
107
107
|
}),
|
|
108
108
|
);
|
|
109
109
|
```
|
|
@@ -115,9 +115,9 @@ BluxClient.sendEvent(
|
|
|
115
115
|
---
|
|
116
116
|
|
|
117
117
|
```typescript
|
|
118
|
-
|
|
118
|
+
bluxClient.sendEvent(
|
|
119
119
|
new AddCartaddEvent({
|
|
120
|
-
|
|
120
|
+
item_id: "ITEM_ID",
|
|
121
121
|
}),
|
|
122
122
|
);
|
|
123
123
|
```
|
|
@@ -134,9 +134,9 @@ BluxClient.sendEvent(
|
|
|
134
134
|
- `AddPurchaseEvent` 객체를 각 상품 구매건에 맞춰서 생성한 후 list 형태로 넘겨주시면 됩니다.
|
|
135
135
|
|
|
136
136
|
```typescript
|
|
137
|
-
|
|
137
|
+
bluxClient.sendEvent(
|
|
138
138
|
new AddPurchaseEvent({
|
|
139
|
-
|
|
139
|
+
item_id: "ITEM_ID",
|
|
140
140
|
price: 1000,
|
|
141
141
|
}),
|
|
142
142
|
);
|
|
@@ -144,13 +144,13 @@ BluxClient.sendEvent(
|
|
|
144
144
|
|
|
145
145
|
```typescript
|
|
146
146
|
// 복수 상품을 구매한 경우
|
|
147
|
-
|
|
147
|
+
bluxClient.sendEvent([
|
|
148
148
|
new AddPurchaseEvent({
|
|
149
|
-
|
|
149
|
+
item_id: "ITEM_ID_1",
|
|
150
150
|
price: 1000,
|
|
151
151
|
}),
|
|
152
152
|
new AddPurchaseEvent({
|
|
153
|
-
|
|
153
|
+
item_id: "ITEM_ID_2",
|
|
154
154
|
price: 2000,
|
|
155
155
|
}),
|
|
156
156
|
]);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@blux.ai/web-sdk",
|
|
3
|
+
"version": "1.0.0-rc1",
|
|
4
|
+
"description": "The official Blux JavaScript browser client library",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"license": "UNLICENSED",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "jest",
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"dev": "yarn build -w",
|
|
13
|
+
"prepack": "rm -rf dist && yarn build",
|
|
14
|
+
"deploy": "npm publish --access public"
|
|
15
|
+
},
|
|
16
|
+
"author": "Z.Ai Inc.",
|
|
17
|
+
"homepage": "https://www.blux.ai/",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@sentry/types": "^8.35.0",
|
|
20
|
+
"@types/uuid": "^10.0.0",
|
|
21
|
+
"typescript": "^4.6.3"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"axios": "1.7.7",
|
|
25
|
+
"bson-objectid": "^2.0.4",
|
|
26
|
+
"dayjs": "1.11.13",
|
|
27
|
+
"lodash": "4.17.21",
|
|
28
|
+
"rxjs": "^7.8.1",
|
|
29
|
+
"uuid": "^10.0.0",
|
|
30
|
+
"zod": "3.23.8"
|
|
31
|
+
},
|
|
32
|
+
"installConfig": {
|
|
33
|
+
"hoistingLimits": "workspaces"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blux.ai/web-sdk",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0-rc1",
|
|
4
4
|
"description": "The official Blux JavaScript browser client library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"typescript": "^4.6.3"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"axios": "
|
|
24
|
+
"axios": "1.7.7",
|
|
25
25
|
"bson-objectid": "^2.0.4",
|
|
26
26
|
"dayjs": "1.11.13",
|
|
27
27
|
"lodash": "4.17.21",
|
package/demo/craco.config.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
webpack: {
|
|
5
|
-
configure: (config) => {
|
|
6
|
-
// ...
|
|
7
|
-
const fileLoaderRule = getFileLoaderRule(config.module.rules);
|
|
8
|
-
if (!fileLoaderRule) {
|
|
9
|
-
throw new Error("File loader not found");
|
|
10
|
-
}
|
|
11
|
-
fileLoaderRule.exclude.push(/\.cjs$/);
|
|
12
|
-
// ...
|
|
13
|
-
return config;
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
function getFileLoaderRule(rules) {
|
|
19
|
-
for (const rule of rules) {
|
|
20
|
-
if ("oneOf" in rule) {
|
|
21
|
-
const found = getFileLoaderRule(rule.oneOf);
|
|
22
|
-
if (found) {
|
|
23
|
-
return found;
|
|
24
|
-
}
|
|
25
|
-
} else if (rule.test === undefined && rule.type === "asset/resource") {
|
|
26
|
-
return rule;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
package/demo/package.json
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "demo",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"dependencies": {
|
|
6
|
-
"@blux.ai/web-sdk": "workspace:*",
|
|
7
|
-
"@testing-library/jest-dom": "^5.14.1",
|
|
8
|
-
"@testing-library/react": "^13.0.0",
|
|
9
|
-
"@types/jest": "^27.0.1",
|
|
10
|
-
"@types/node": "^16.7.13",
|
|
11
|
-
"@types/react": "^18.0.0",
|
|
12
|
-
"@types/react-dom": "^18.0.0",
|
|
13
|
-
"react": "^18.3.1",
|
|
14
|
-
"react-dom": "^18.3.1",
|
|
15
|
-
"react-scripts": "5.0.1",
|
|
16
|
-
"typescript": "^4.4.2",
|
|
17
|
-
"web-vitals": "^2.1.0"
|
|
18
|
-
},
|
|
19
|
-
"scripts": {
|
|
20
|
-
"start": "craco start",
|
|
21
|
-
"build": "craco build",
|
|
22
|
-
"test": "craco test",
|
|
23
|
-
"eject": "react-scripts eject"
|
|
24
|
-
},
|
|
25
|
-
"eslintConfig": {
|
|
26
|
-
"extends": [
|
|
27
|
-
"react-app",
|
|
28
|
-
"react-app/jest"
|
|
29
|
-
]
|
|
30
|
-
},
|
|
31
|
-
"browserslist": {
|
|
32
|
-
"production": [
|
|
33
|
-
">0.2%",
|
|
34
|
-
"not dead",
|
|
35
|
-
"not op_mini all"
|
|
36
|
-
],
|
|
37
|
-
"development": [
|
|
38
|
-
"last 1 chrome version",
|
|
39
|
-
"last 1 firefox version",
|
|
40
|
-
"last 1 safari version"
|
|
41
|
-
]
|
|
42
|
-
},
|
|
43
|
-
"devDependencies": {
|
|
44
|
-
"@craco/craco": "^7.1.0",
|
|
45
|
-
"tailwindcss": "^3.4.4"
|
|
46
|
-
},
|
|
47
|
-
"installConfig": {
|
|
48
|
-
"hoistingLimits": "workspaces"
|
|
49
|
-
}
|
|
50
|
-
}
|
package/demo/public/favicon.ico
DELETED
|
Binary file
|
package/demo/public/index.html
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
-
<meta name="theme-color" content="#000000" />
|
|
8
|
-
<meta
|
|
9
|
-
name="description"
|
|
10
|
-
content="Web site created using create-react-app"
|
|
11
|
-
/>
|
|
12
|
-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
|
13
|
-
<!--
|
|
14
|
-
manifest.json provides metadata used when your web app is installed on a
|
|
15
|
-
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
|
16
|
-
-->
|
|
17
|
-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
|
18
|
-
<!--
|
|
19
|
-
Notice the use of %PUBLIC_URL% in the tags above.
|
|
20
|
-
It will be replaced with the URL of the `public` folder during the build.
|
|
21
|
-
Only files inside the `public` folder can be referenced from the HTML.
|
|
22
|
-
|
|
23
|
-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
24
|
-
work correctly both with client-side routing and a non-root public URL.
|
|
25
|
-
Learn how to configure a non-root public URL by running `npm run build`.
|
|
26
|
-
-->
|
|
27
|
-
<title>React App</title>
|
|
28
|
-
</head>
|
|
29
|
-
<body>
|
|
30
|
-
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
31
|
-
<div id="root"></div>
|
|
32
|
-
<!--
|
|
33
|
-
This HTML file is a template.
|
|
34
|
-
If you open it directly in the browser, you will see an empty page.
|
|
35
|
-
|
|
36
|
-
You can add webfonts, meta tags, or analytics to this file.
|
|
37
|
-
The build step will place the bundled scripts into the <body> tag.
|
|
38
|
-
|
|
39
|
-
To begin the development, run `npm start` or `yarn start`.
|
|
40
|
-
To create a production bundle, use `npm run build` or `yarn build`.
|
|
41
|
-
-->
|
|
42
|
-
</body>
|
|
43
|
-
</html>
|
package/demo/public/logo192.png
DELETED
|
Binary file
|
package/demo/public/logo512.png
DELETED
|
Binary file
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"short_name": "React App",
|
|
3
|
-
"name": "Create React App Sample",
|
|
4
|
-
"icons": [
|
|
5
|
-
{
|
|
6
|
-
"src": "favicon.ico",
|
|
7
|
-
"sizes": "64x64 32x32 24x24 16x16",
|
|
8
|
-
"type": "image/x-icon"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"src": "logo192.png",
|
|
12
|
-
"type": "image/png",
|
|
13
|
-
"sizes": "192x192"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"src": "logo512.png",
|
|
17
|
-
"type": "image/png",
|
|
18
|
-
"sizes": "512x512"
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
"start_url": ".",
|
|
22
|
-
"display": "standalone",
|
|
23
|
-
"theme_color": "#000000",
|
|
24
|
-
"background_color": "#ffffff"
|
|
25
|
-
}
|
package/demo/public/robots.txt
DELETED
package/demo/src/App.test.tsx
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render, screen } from "@testing-library/react";
|
|
3
|
-
import App from "./App";
|
|
4
|
-
|
|
5
|
-
test("renders learn react link", () => {
|
|
6
|
-
render(<App />);
|
|
7
|
-
const linkElement = screen.getByText(/learn react/i);
|
|
8
|
-
expect(linkElement).toBeInTheDocument();
|
|
9
|
-
});
|
package/demo/src/App.tsx
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import { AddCustomEvent, ItemRecommendation, BluxClient } from "@blux.ai/web-sdk";
|
|
3
|
-
|
|
4
|
-
const bluxClient = new BluxClient("stg");
|
|
5
|
-
bluxClient.setLogLevel("debug");
|
|
6
|
-
|
|
7
|
-
const searchParams = new URL(window.location.href).searchParams;
|
|
8
|
-
const APPLICATION_ID_FROM_QUERY_PARAMS = searchParams.get("application_id");
|
|
9
|
-
const API_KEY_FROM_QUERY_PARAMS = searchParams.get("api_key");
|
|
10
|
-
const PHONE_NUMBER_FROM_QUERY_PARAMS = searchParams.get("phone_number");
|
|
11
|
-
const EMAIL_FROM_QUERY_PARAMS = searchParams.get("email");
|
|
12
|
-
|
|
13
|
-
function App() {
|
|
14
|
-
const [applicationId, setApplicationId] = useState<string>(
|
|
15
|
-
APPLICATION_ID_FROM_QUERY_PARAMS ?? "",
|
|
16
|
-
);
|
|
17
|
-
const [bluxApiKey, setBluxApiKey] = useState<string>(
|
|
18
|
-
API_KEY_FROM_QUERY_PARAMS ?? "",
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const [userId, signIn] = useState<string>(
|
|
22
|
-
`test_user_id_${Math.floor(Math.random() * 100)}`,
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const [telNumber, setTelNumber] = useState<string>(
|
|
26
|
-
PHONE_NUMBER_FROM_QUERY_PARAMS ?? "",
|
|
27
|
-
);
|
|
28
|
-
const [email, setEmail] = useState<string>(EMAIL_FROM_QUERY_PARAMS ?? "");
|
|
29
|
-
const [customKey, setCustomKey] = useState<string>("custom_key");
|
|
30
|
-
const [customValue, setCustomValue] = useState<string>("custom_value");
|
|
31
|
-
const [eventType, setEventType] = useState<string>("custom_event_type");
|
|
32
|
-
const [itemId, setItemId] = useState<string>("item_id_3");
|
|
33
|
-
|
|
34
|
-
// Recommendation Related States
|
|
35
|
-
const [callType, setCallType] = useState<string>("");
|
|
36
|
-
const [limit, setLimit] = useState<number>(10);
|
|
37
|
-
const [offset, setOffset] = useState<number>(0);
|
|
38
|
-
const [recommendationItemIds, setRecommendationItemIds] = useState<string>("ITEM_ID_1, ITEM_ID_2, ITEM_ID_3");
|
|
39
|
-
|
|
40
|
-
const [isInitialized, setIsInitialized] = useState<boolean>(false);
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<div className="p-10">
|
|
44
|
-
<div className="input-container flex flex-col">
|
|
45
|
-
<div>BluxUser</div>
|
|
46
|
-
<div>
|
|
47
|
-
{bluxClient.bluxUser$.value
|
|
48
|
-
? JSON.stringify(bluxClient.bluxUser$.value, null, 2)
|
|
49
|
-
: "not initialized"}
|
|
50
|
-
</div>
|
|
51
|
-
<div className="flex">
|
|
52
|
-
<div>
|
|
53
|
-
<div>ApplicationId</div>
|
|
54
|
-
<input
|
|
55
|
-
className="w-[500px] rounded-md border-black border-2"
|
|
56
|
-
type="text"
|
|
57
|
-
placeholder="Enter Application Id"
|
|
58
|
-
value={applicationId}
|
|
59
|
-
onChange={(e) => setApplicationId(e.target.value)}
|
|
60
|
-
/>
|
|
61
|
-
<div className="mt-3">BluxApiKey</div>
|
|
62
|
-
<input
|
|
63
|
-
className="w-[500px] rounded-md border-black border-2"
|
|
64
|
-
type="text"
|
|
65
|
-
placeholder="Enter Blux API Key"
|
|
66
|
-
value={bluxApiKey}
|
|
67
|
-
onChange={(e) => setBluxApiKey(e.target.value)}
|
|
68
|
-
/>
|
|
69
|
-
<div className="mt-3">User Id</div>
|
|
70
|
-
<input
|
|
71
|
-
className="w-[500px] rounded-md border-black border-2"
|
|
72
|
-
type="text"
|
|
73
|
-
placeholder="Enter User Id"
|
|
74
|
-
value={userId}
|
|
75
|
-
onChange={(e) => signIn(e.target.value)}
|
|
76
|
-
/>
|
|
77
|
-
<div className="mt-3">Phone Number</div>
|
|
78
|
-
<input
|
|
79
|
-
className="w-[500px] rounded-md border-black border-2"
|
|
80
|
-
type="text"
|
|
81
|
-
placeholder="Enter phone number"
|
|
82
|
-
value={telNumber}
|
|
83
|
-
onChange={(e) => setTelNumber(e.target.value)}
|
|
84
|
-
/>
|
|
85
|
-
<div className="mt-3">Email</div>
|
|
86
|
-
<input
|
|
87
|
-
className="w-[500px] rounded-md border-black border-2"
|
|
88
|
-
type="text"
|
|
89
|
-
placeholder="Enter email"
|
|
90
|
-
value={email}
|
|
91
|
-
onChange={(e) => setEmail(e.target.value)}
|
|
92
|
-
/>
|
|
93
|
-
<div className="mt-3">CustomKey</div>
|
|
94
|
-
<input
|
|
95
|
-
className="w-[500px] rounded-md border-black border-2"
|
|
96
|
-
type="text"
|
|
97
|
-
placeholder="Enter custom key"
|
|
98
|
-
value={customKey}
|
|
99
|
-
onChange={(e) => setCustomKey(e.target.value)}
|
|
100
|
-
/>
|
|
101
|
-
<div className="mt-3">CustomValue</div>
|
|
102
|
-
<input
|
|
103
|
-
className="w-[500px] rounded-md border-black border-2"
|
|
104
|
-
type="text"
|
|
105
|
-
placeholder="Enter custom value"
|
|
106
|
-
value={customValue}
|
|
107
|
-
onChange={(e) => setCustomValue(e.target.value)}
|
|
108
|
-
/>
|
|
109
|
-
<div className="mt-3">CustomEventType</div>
|
|
110
|
-
<input
|
|
111
|
-
className="w-[500px] rounded-md border-black border-2"
|
|
112
|
-
type="text"
|
|
113
|
-
placeholder="Enter custom event type"
|
|
114
|
-
value={eventType}
|
|
115
|
-
onChange={(e) => setEventType(e.target.value)}
|
|
116
|
-
/>
|
|
117
|
-
<div className="mt-3">CustomEvent ItemId</div>
|
|
118
|
-
<input
|
|
119
|
-
className="w-[500px] rounded-md border-black border-2"
|
|
120
|
-
type="text"
|
|
121
|
-
placeholder="Enter custom event item id"
|
|
122
|
-
value={itemId}
|
|
123
|
-
onChange={(e) => setItemId(e.target.value)}
|
|
124
|
-
/>
|
|
125
|
-
</div>
|
|
126
|
-
<div>
|
|
127
|
-
<div className="mt-3 ml-10">RecommendationCallType</div>
|
|
128
|
-
<input
|
|
129
|
-
className="w-[500px] rounded-md border-black border-2 ml-10"
|
|
130
|
-
type="text"
|
|
131
|
-
placeholder="Enter call type for item recommendation"
|
|
132
|
-
value={callType}
|
|
133
|
-
onChange={(e) => setCallType(e.target.value)}
|
|
134
|
-
/>
|
|
135
|
-
<div className="ml-10">RecommendationLimit</div>
|
|
136
|
-
<input
|
|
137
|
-
className="w-[500px] rounded-md border-black border-2 ml-10"
|
|
138
|
-
type="text"
|
|
139
|
-
placeholder="Enter recommendation limit"
|
|
140
|
-
value={limit}
|
|
141
|
-
onChange={(e) => setLimit(Number(e.target.value))}
|
|
142
|
-
/>
|
|
143
|
-
<div className="mt-3 ml-10">RecommendationOffset</div>
|
|
144
|
-
<input
|
|
145
|
-
className="w-[500px] rounded-md border-black border-2 ml-10"
|
|
146
|
-
type="text"
|
|
147
|
-
placeholder="Enter recommendation offset"
|
|
148
|
-
value={offset}
|
|
149
|
-
onChange={(e) => setOffset(Number(e.target.value))}
|
|
150
|
-
/>
|
|
151
|
-
<div className="mt-3 ml-10">RecommendationItemIds</div>
|
|
152
|
-
<input
|
|
153
|
-
className="w-[500px] rounded-md border-black border-2 ml-10"
|
|
154
|
-
type="text"
|
|
155
|
-
placeholder="Enter recommendation item ids (comma separated)"
|
|
156
|
-
value={recommendationItemIds}
|
|
157
|
-
onChange={(e) => setRecommendationItemIds(e.target.value)}
|
|
158
|
-
/>
|
|
159
|
-
</div>
|
|
160
|
-
</div>
|
|
161
|
-
</div>
|
|
162
|
-
<div className="mt-10 flex gap-4 w-[1000px] flex-wrap">
|
|
163
|
-
<button
|
|
164
|
-
className="bg-blue-500 rounded-md p-4 disabled:bg-gray-300"
|
|
165
|
-
onClick={() =>
|
|
166
|
-
bluxClient
|
|
167
|
-
.init({ applicationId, bluxApiKey })
|
|
168
|
-
.then((isSuccess) => setIsInitialized(isSuccess))
|
|
169
|
-
}
|
|
170
|
-
disabled={applicationId === "" || bluxApiKey === ""}
|
|
171
|
-
>
|
|
172
|
-
init
|
|
173
|
-
</button>
|
|
174
|
-
<button
|
|
175
|
-
className="bg-blue-500 rounded-md p-4 disabled:bg-gray-300"
|
|
176
|
-
onClick={() => bluxClient.signIn(userId)}
|
|
177
|
-
disabled={!isInitialized}
|
|
178
|
-
>
|
|
179
|
-
signIn
|
|
180
|
-
</button>
|
|
181
|
-
<button
|
|
182
|
-
className="bg-blue-500 rounded-md p-4 disabled:bg-gray-300"
|
|
183
|
-
onClick={() => bluxClient.signOut()}
|
|
184
|
-
disabled={!isInitialized}
|
|
185
|
-
>
|
|
186
|
-
signOut
|
|
187
|
-
</button>
|
|
188
|
-
<button
|
|
189
|
-
className="bg-blue-500 rounded-md p-4 disabled:bg-gray-300"
|
|
190
|
-
onClick={() =>
|
|
191
|
-
bluxClient.setUserProperties({ phone_number: telNumber })
|
|
192
|
-
}
|
|
193
|
-
disabled={!isInitialized}
|
|
194
|
-
>
|
|
195
|
-
setUserProperties (phone number)
|
|
196
|
-
</button>
|
|
197
|
-
<button
|
|
198
|
-
className="bg-blue-500 rounded-md p-4 disabled:bg-gray-300"
|
|
199
|
-
onClick={() => bluxClient.setUserProperties({ email_address: email })}
|
|
200
|
-
disabled={!isInitialized}
|
|
201
|
-
>
|
|
202
|
-
setUserProperties (email)
|
|
203
|
-
</button>
|
|
204
|
-
<button
|
|
205
|
-
className="bg-blue-500 rounded-md p-4 disabled:bg-gray-300"
|
|
206
|
-
onClick={() =>
|
|
207
|
-
bluxClient.setCustomUserProperties({ [customKey]: customValue })
|
|
208
|
-
}
|
|
209
|
-
disabled={!isInitialized}
|
|
210
|
-
>
|
|
211
|
-
setCustomProperties
|
|
212
|
-
</button>
|
|
213
|
-
<button
|
|
214
|
-
className="bg-blue-500 rounded-md p-4 disabled:bg-gray-300"
|
|
215
|
-
onClick={() =>
|
|
216
|
-
bluxClient.sendEvent(
|
|
217
|
-
new AddCustomEvent({
|
|
218
|
-
item_id: itemId,
|
|
219
|
-
event_properties: { [customKey]: customValue },
|
|
220
|
-
event_type: eventType,
|
|
221
|
-
}),
|
|
222
|
-
)
|
|
223
|
-
}
|
|
224
|
-
disabled={!isInitialized}
|
|
225
|
-
>
|
|
226
|
-
sendCustomEvent
|
|
227
|
-
</button>
|
|
228
|
-
<button
|
|
229
|
-
className="bg-blue-500 rounded-md p-4 disabled:bg-gray-300"
|
|
230
|
-
onClick={async () =>
|
|
231
|
-
{
|
|
232
|
-
const recommendationResponse = await bluxClient.getItemRecommendation(
|
|
233
|
-
new ItemRecommendation({
|
|
234
|
-
call_type: callType,
|
|
235
|
-
limit,
|
|
236
|
-
offset,
|
|
237
|
-
item_ids: recommendationItemIds ? recommendationItemIds.split(","): undefined,
|
|
238
|
-
}),
|
|
239
|
-
)
|
|
240
|
-
console.log(recommendationResponse);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
disabled={!isInitialized || callType === ""}
|
|
244
|
-
>
|
|
245
|
-
getItemRecommendation
|
|
246
|
-
</button>
|
|
247
|
-
</div>
|
|
248
|
-
</div>
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
export default App;
|
package/demo/src/index.css
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
@tailwind base;
|
|
2
|
-
@tailwind components;
|
|
3
|
-
@tailwind utilities;
|
|
4
|
-
body {
|
|
5
|
-
margin: 0;
|
|
6
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
|
|
7
|
-
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
|
|
8
|
-
sans-serif;
|
|
9
|
-
-webkit-font-smoothing: antialiased;
|
|
10
|
-
-moz-osx-font-smoothing: grayscale;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
code {
|
|
14
|
-
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
|
|
15
|
-
monospace;
|
|
16
|
-
}
|
package/demo/src/index.tsx
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import ReactDOM from "react-dom/client";
|
|
3
|
-
import "./index.css";
|
|
4
|
-
import App from "./App";
|
|
5
|
-
import reportWebVitals from "./reportWebVitals";
|
|
6
|
-
|
|
7
|
-
const root = ReactDOM.createRoot(
|
|
8
|
-
document.getElementById("root") as HTMLElement,
|
|
9
|
-
);
|
|
10
|
-
root.render(
|
|
11
|
-
<React.StrictMode>
|
|
12
|
-
<App />
|
|
13
|
-
</React.StrictMode>,
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
// If you want to start measuring performance in your app, pass a function
|
|
17
|
-
// to log results (for example: reportWebVitals(console.log))
|
|
18
|
-
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
|
19
|
-
reportWebVitals();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="react-scripts" />
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ReportHandler } from "web-vitals";
|
|
2
|
-
|
|
3
|
-
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
|
|
4
|
-
if (onPerfEntry && onPerfEntry instanceof Function) {
|
|
5
|
-
import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
|
6
|
-
getCLS(onPerfEntry);
|
|
7
|
-
getFID(onPerfEntry);
|
|
8
|
-
getFCP(onPerfEntry);
|
|
9
|
-
getLCP(onPerfEntry);
|
|
10
|
-
getTTFB(onPerfEntry);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default reportWebVitals;
|
package/demo/src/setupTests.ts
DELETED