@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.
Files changed (115) hide show
  1. package/.prettierrc +0 -1
  2. package/.sentryclirc +3 -0
  3. package/README.md +147 -11
  4. package/demo/README.md +46 -0
  5. package/demo/craco.config.js +27 -0
  6. package/demo/package.json +48 -0
  7. package/demo/public/favicon.ico +0 -0
  8. package/demo/public/index.html +43 -0
  9. package/demo/public/logo192.png +0 -0
  10. package/demo/public/logo512.png +0 -0
  11. package/demo/public/manifest.json +25 -0
  12. package/demo/public/robots.txt +3 -0
  13. package/demo/src/App.test.tsx +9 -0
  14. package/demo/src/App.tsx +158 -0
  15. package/demo/src/index.css +16 -0
  16. package/demo/src/index.tsx +19 -0
  17. package/demo/src/react-app-env.d.ts +1 -0
  18. package/demo/src/reportWebVitals.ts +15 -0
  19. package/demo/src/setupTests.ts +5 -0
  20. package/demo/tailwind.config.js +8 -0
  21. package/demo/yarn.lock +10120 -0
  22. package/dist/BluxClient.d.ts +40 -15
  23. package/dist/BluxClient.js +317 -87
  24. package/dist/BluxClient.js.map +1 -0
  25. package/dist/constants/URLS.d.ts +12 -0
  26. package/dist/constants/URLS.js +19 -0
  27. package/dist/constants/URLS.js.map +1 -0
  28. package/dist/core/LocalStorage.d.ts +0 -9
  29. package/dist/core/LocalStorage.js +4 -26
  30. package/dist/core/LocalStorage.js.map +1 -0
  31. package/dist/core/Logger.d.ts +11 -12
  32. package/dist/core/Logger.js +61 -63
  33. package/dist/core/Logger.js.map +1 -0
  34. package/dist/events/AddCartaddEvent.d.ts +5 -0
  35. package/dist/{requests/Events → events}/AddCartaddEvent.js +13 -10
  36. package/dist/events/AddCartaddEvent.js.map +1 -0
  37. package/dist/events/AddCustomEvent.d.ts +5 -0
  38. package/dist/{requests/Events → events}/AddCustomEvent.js +14 -11
  39. package/dist/events/AddCustomEvent.js.map +1 -0
  40. package/dist/events/AddLikeEvent.d.ts +5 -0
  41. package/dist/{requests/Events → events}/AddLikeEvent.js +13 -10
  42. package/dist/events/AddLikeEvent.js.map +1 -0
  43. package/dist/events/AddPageViewEvent.d.ts +5 -0
  44. package/dist/{requests/Events → events}/AddPageViewEvent.js +11 -8
  45. package/dist/events/AddPageViewEvent.js.map +1 -0
  46. package/dist/events/AddProductDetailViewEvent.d.ts +5 -0
  47. package/dist/{requests/Events → events}/AddProductDetailViewEvent.js +13 -10
  48. package/dist/events/AddProductDetailViewEvent.js.map +1 -0
  49. package/dist/events/AddPurchaseEvent.d.ts +5 -0
  50. package/dist/{requests/Events → events}/AddPurchaseEvent.js +13 -10
  51. package/dist/events/AddPurchaseEvent.js.map +1 -0
  52. package/dist/events/AddRateEvent.d.ts +5 -0
  53. package/dist/{requests/Events → events}/AddRateEvent.js +14 -11
  54. package/dist/events/AddRateEvent.js.map +1 -0
  55. package/dist/events/AddRecommendationViewEvent.d.ts +5 -0
  56. package/dist/{requests/Events → events}/AddRecommendationViewEvent.js +12 -9
  57. package/dist/events/AddRecommendationViewEvent.js.map +1 -0
  58. package/dist/events/Event.d.ts +5 -0
  59. package/dist/events/Event.js +26 -0
  60. package/dist/events/Event.js.map +1 -0
  61. package/dist/{requests/Events → events}/index.js +4 -0
  62. package/dist/events/index.js.map +1 -0
  63. package/dist/events/types.d.ts +42 -0
  64. package/dist/events/types.js +6 -0
  65. package/dist/events/types.js.map +1 -0
  66. package/dist/index.d.ts +3 -4
  67. package/dist/index.js +20 -15
  68. package/dist/index.js.map +1 -0
  69. package/dist/utils/helper.js +4 -0
  70. package/dist/utils/helper.js.map +1 -0
  71. package/dist/utils/operators.d.ts +2 -0
  72. package/dist/utils/operators.js +12 -0
  73. package/dist/utils/operators.js.map +1 -0
  74. package/dist/utils/sentry.d.ts +2 -0
  75. package/dist/utils/sentry.js +50 -0
  76. package/dist/utils/sentry.js.map +1 -0
  77. package/package.json +13 -3
  78. package/.vscode/settings.json +0 -7
  79. package/dist/core/BaseErrorHandler.d.ts +0 -3
  80. package/dist/core/BaseErrorHandler.js +0 -13
  81. package/dist/core/HTTPClient.d.ts +0 -10
  82. package/dist/core/HTTPClient.js +0 -122
  83. package/dist/requests/Devices/ActivateDevice.d.ts +0 -8
  84. package/dist/requests/Devices/ActivateDevice.js +0 -39
  85. package/dist/requests/Devices/CreateDevice.d.ts +0 -14
  86. package/dist/requests/Devices/CreateDevice.js +0 -54
  87. package/dist/requests/Devices/UpdateDevice.d.ts +0 -17
  88. package/dist/requests/Devices/UpdateDevice.js +0 -61
  89. package/dist/requests/Devices/index.d.ts +0 -3
  90. package/dist/requests/Devices/index.js +0 -19
  91. package/dist/requests/Events/AddCartaddEvent.d.ts +0 -5
  92. package/dist/requests/Events/AddCustomEvent.d.ts +0 -5
  93. package/dist/requests/Events/AddLikeEvent.d.ts +0 -5
  94. package/dist/requests/Events/AddPageViewEvent.d.ts +0 -5
  95. package/dist/requests/Events/AddProductDetailViewEvent.d.ts +0 -5
  96. package/dist/requests/Events/AddPurchaseEvent.d.ts +0 -5
  97. package/dist/requests/Events/AddRateEvent.d.ts +0 -5
  98. package/dist/requests/Events/AddRecommendationViewEvent.d.ts +0 -5
  99. package/dist/requests/Events/EventRequest.d.ts +0 -17
  100. package/dist/requests/Events/EventRequest.js +0 -56
  101. package/dist/requests/Events/types.d.ts +0 -42
  102. package/dist/requests/Events/types.js +0 -2
  103. package/dist/requests/Request.d.ts +0 -12
  104. package/dist/requests/Request.js +0 -22
  105. package/dist/requests/Users/UpdateUserProperties.d.ts +0 -17
  106. package/dist/requests/Users/UpdateUserProperties.js +0 -54
  107. package/dist/requests/Users/index.d.ts +0 -1
  108. package/dist/requests/Users/index.js +0 -17
  109. package/dist/requests/Users/types.d.ts +0 -12
  110. package/dist/requests/Users/types.js +0 -2
  111. package/dist/requests/index.d.ts +0 -3
  112. package/dist/requests/index.js +0 -19
  113. package/dist/utils/types.d.ts +0 -2
  114. package/dist/utils/types.js +0 -11
  115. /package/dist/{requests/Events → events}/index.d.ts +0 -0
package/.prettierrc CHANGED
@@ -1,5 +1,4 @@
1
1
  {
2
- "printWidth": 120,
3
2
  "tabWidth": 2,
4
3
  "singleQuote": false
5
4
  }
package/.sentryclirc ADDED
@@ -0,0 +1,3 @@
1
+
2
+ [auth]
3
+ token=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
package/README.md CHANGED
@@ -1,21 +1,157 @@
1
- # @blux.ai/web-sdk
2
-
3
- The BluxClient Web SDK Library is a set of methods attached to a global bluxclient object intended to be used by websites wishing to send data to Blux collector api.
4
-
5
- ### Requirements
6
-
7
- ---
8
-
9
- - [Node.js](https://github.com/nodejs/node) >= 10.24.1 (ES6 2015 지원)
10
- - TypeScript (권장)
1
+ # Blux Web sdk 행동데이터 연동 안내 문서
11
2
 
12
3
  ### Installation
13
4
 
14
- ---
5
+ - Supported Node.js Version `>= 10.24.1`
6
+ - npm/yarn을 이용하여 설치하실 수 있습니다.
15
7
 
16
8
  ```shell
17
9
  // NPM 이용
18
10
  npm install @blux.ai/web-sdk
11
+
19
12
  // Yarn 이용
20
13
  yarn add @blux.ai/web-sdk
21
14
  ```
15
+
16
+ ### **Initialize**
17
+
18
+ ---
19
+
20
+ - 필요 변수 : `클라이언트 ID`, `API 키`
21
+
22
+ ```typescript
23
+ BluxClient.setLogLevel("debug");
24
+ BluxClient.init({
25
+ bluxClientId: "{blux_client_id}",
26
+ bluxApiKey: "{blux_api_key}",
27
+ });
28
+ ```
29
+
30
+ - **setLogLevel** : 연동 관련하여 디버깅을 하기 위해서 로깅을 활성화할 수 있습니다. 해당 설정은 정적이므로 BluxClient를 초기화하기 전에 호출하실 수 있습니다.
31
+ - `'debug'`
32
+ - `'log'`
33
+ - `'warning'`
34
+ - `'error'`
35
+ - `'fatal'`
36
+
37
+ ### signIn
38
+
39
+ - 회원 유저에 대해서 부여하고 계시는 유저 ID를 넘겨주시면 됩니다.
40
+ - Blux 서비스에서 같은 `UserId`를 가지는 유저는 같은 유저로 식별됩니다.
41
+ - 비회원 유저에서 회원 유저로 식별되는 시점에 아래 함수를 호출해주세요.
42
+ - 회원 유저가 앱을 실행하는 시점에도 `initialize` 메소드 호출 이후에 실행되어야 합니다.
43
+
44
+ ```typescript
45
+ BluxClient.signIn("USER ID");
46
+ ```
47
+
48
+ ### setUserProperties
49
+
50
+ - 유저에게 지정된 속성들을 부여합니다. 전화번호, 이메일 번호를 등록할 수 있습니다.
51
+
52
+ ```typescript
53
+ BluxClient.setUserProperties({
54
+ phone_number: "+821011112222",
55
+ email_address: "test@example.com",
56
+ });
57
+ ```
58
+
59
+ ### setCustomUserProperties
60
+
61
+ - `setUserProperties`에서 설정할 수 있는 지정된 속성 외 임의의 속성을 부여할 수 있습니다.
62
+
63
+ ```typescript
64
+ BluxClient.setCustomUserProperties({
65
+ custom_key1: "any_value",
66
+ custom_key2: true,
67
+ custom_key3: null,
68
+ custom_key4: 3,
69
+ });
70
+ ```
71
+
72
+ ### signOut
73
+
74
+ - 유저가 서비스에서 로그아웃 한 경우 호출해주시면 됩니다.
75
+ - 유저들을 더 잘 식별하기위해 사용됩니다.
76
+
77
+ ```typescript
78
+ BluxClient.signOut();
79
+ ```
80
+
81
+ ### sendEvent
82
+
83
+ #### 상품 상세 페이지 진입
84
+
85
+ : 유저가 제품 상세보기 페이지에 들어가거나, 영상을 시청하는 등 클릭을 통해 어떠한 아이템에 대해 관심을 보이는 행동을 보일 때 사용 가능한 이벤트입니다.
86
+
87
+ ---
88
+
89
+ ```typescript
90
+ BluxClient.sendEvent(
91
+ new AddProductDetailViewEvent({
92
+ itemId: "ITEM_ID",
93
+ })
94
+ );
95
+ ```
96
+
97
+ #### 상품 좋아요
98
+
99
+ : 유저가 제품이나 영상 등에 좋아요를 누르거나, 찜을 해두는 등 적극적인 관심을 보이는 행동을 할 때 사용 가능한 이벤트입니다.
100
+
101
+ ---
102
+
103
+ ```typescript
104
+ BluxClient.sendEvent(
105
+ new AddLikeEvent({
106
+ itemId: "ITEM_ID",
107
+ })
108
+ );
109
+ ```
110
+
111
+ #### 상품 장바구니 담기
112
+
113
+ : 이커머스에서 유저가 제품을 장바구니에 담는 행동을 할 때 사용 가능한 이벤트입니다.
114
+
115
+ ---
116
+
117
+ ```typescript
118
+ BluxClient.sendEvent(
119
+ new AddCartaddEvent({
120
+ itemId: "ITEM_ID",
121
+ })
122
+ );
123
+ ```
124
+
125
+ #### 상품 구매
126
+
127
+ : 유저가 제품을 구매했을 때 사용 가능한 이벤트입니다. 추가 인풋으로 `price`가 요구되며, 제품의 구매 당시 가격을 기록하면 됩니다.
128
+
129
+ ---
130
+
131
+ - **_동일 상품 복수 구매_**
132
+ - price 파라미터의 경우, 해당 상품 판매를 통한 총 매출을 계산할 때 활용됩니다. 추천에 의한 매출 기여액 지표를 보여드릴 때 사용되는 값으로 만약 5,000원짜리 상품을 5개 구매하였다면, 25,000 을 입력하시면 됩니다.
133
+ - **_복수 상품 구매_**
134
+ - `AddPurchaseEvent` 객체를 각 상품 구매건에 맞춰서 생성한 후 list 형태로 넘겨주시면 됩니다.
135
+
136
+ ```typescript
137
+ BluxClient.sendEvent(
138
+ new AddPurchaseEvent({
139
+ itemId: "ITEM_ID",
140
+ price: 1000,
141
+ })
142
+ );
143
+ ```
144
+
145
+ ```typescript
146
+ // 복수 상품을 구매한 경우
147
+ BluxClient.sendEvent([
148
+ new AddPurchaseEvent({
149
+ itemId: "ITEM_ID_1",
150
+ price: 1000,
151
+ }),
152
+ new AddPurchaseEvent({
153
+ itemId: "ITEM_ID_2",
154
+ price: 2000,
155
+ }),
156
+ ]);
157
+ ```
package/demo/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # Getting Started with Create React App
2
+
3
+ This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4
+
5
+ ## Available Scripts
6
+
7
+ In the project directory, you can run:
8
+
9
+ ### `yarn start`
10
+
11
+ Runs the app in the development mode.\
12
+ Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13
+
14
+ The page will reload if you make edits.\
15
+ You will also see any lint errors in the console.
16
+
17
+ ### `yarn test`
18
+
19
+ Launches the test runner in the interactive watch mode.\
20
+ See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21
+
22
+ ### `yarn build`
23
+
24
+ Builds the app for production to the `build` folder.\
25
+ It correctly bundles React in production mode and optimizes the build for the best performance.
26
+
27
+ The build is minified and the filenames include the hashes.\
28
+ Your app is ready to be deployed!
29
+
30
+ See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31
+
32
+ ### `yarn eject`
33
+
34
+ **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35
+
36
+ If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37
+
38
+ Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39
+
40
+ You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41
+
42
+ ## Learn More
43
+
44
+ You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45
+
46
+ To learn React, check out the [React documentation](https://reactjs.org/).
@@ -0,0 +1,27 @@
1
+ module.exports = {
2
+ webpack: {
3
+ configure: (config) => {
4
+ // ...
5
+ const fileLoaderRule = getFileLoaderRule(config.module.rules);
6
+ if (!fileLoaderRule) {
7
+ throw new Error("File loader not found");
8
+ }
9
+ fileLoaderRule.exclude.push(/\.cjs$/);
10
+ // ...
11
+ return config;
12
+ },
13
+ },
14
+ };
15
+
16
+ function getFileLoaderRule(rules) {
17
+ for (const rule of rules) {
18
+ if ("oneOf" in rule) {
19
+ const found = getFileLoaderRule(rule.oneOf);
20
+ if (found) {
21
+ return found;
22
+ }
23
+ } else if (rule.test === undefined && rule.type === "asset/resource") {
24
+ return rule;
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "demo",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "dependencies": {
6
+ "@blux.ai/web-sdk": "../",
7
+ "@testing-library/jest-dom": "^5.14.1",
8
+ "@testing-library/react": "^13.0.0",
9
+ "@testing-library/user-event": "^13.2.1",
10
+ "@types/jest": "^27.0.1",
11
+ "@types/node": "^16.7.13",
12
+ "@types/react": "^18.0.0",
13
+ "@types/react-dom": "^18.0.0",
14
+ "react": "^18.3.1",
15
+ "react-dom": "^18.3.1",
16
+ "react-scripts": "5.0.1",
17
+ "typescript": "^4.4.2",
18
+ "web-vitals": "^2.1.0"
19
+ },
20
+ "scripts": {
21
+ "start": "craco start",
22
+ "build": "craco build",
23
+ "test": "craco test",
24
+ "eject": "react-scripts eject"
25
+ },
26
+ "eslintConfig": {
27
+ "extends": [
28
+ "react-app",
29
+ "react-app/jest"
30
+ ]
31
+ },
32
+ "browserslist": {
33
+ "production": [
34
+ ">0.2%",
35
+ "not dead",
36
+ "not op_mini all"
37
+ ],
38
+ "development": [
39
+ "last 1 chrome version",
40
+ "last 1 firefox version",
41
+ "last 1 safari version"
42
+ ]
43
+ },
44
+ "devDependencies": {
45
+ "@craco/craco": "^7.1.0",
46
+ "tailwindcss": "^3.4.4"
47
+ }
48
+ }
Binary file
@@ -0,0 +1,43 @@
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>
Binary file
Binary file
@@ -0,0 +1,25 @@
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
+ }
@@ -0,0 +1,3 @@
1
+ # https://www.robotstxt.org/robotstxt.html
2
+ User-agent: *
3
+ Disallow:
@@ -0,0 +1,9 @@
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
+ });
@@ -0,0 +1,158 @@
1
+ import React, { useState } from "react";
2
+ import BluxClient, { AddLikeEvent } from "@blux.ai/web-sdk";
3
+ function App() {
4
+ const [bluxClientId, setBluxClientId] = useState<string>(
5
+ "cc392627-0c7a-40a0-b472-fbd0842eb125"
6
+ );
7
+ const [bluxApiKey, setBluxApiKey] = useState<string>(
8
+ "yvU_CEMtZxqWXKFpkv2FsN2ICoKb6G8BrmiD5urZzYg"
9
+ );
10
+
11
+ const [userId, signIn] = useState<string>(
12
+ `test_user_id_${Math.floor(Math.random() * 100)}`
13
+ );
14
+
15
+ const [telNumber, setTelNumber] = useState<string>("+821012345678");
16
+ const [email, setEmail] = useState<string>("qa@blux.ai");
17
+ const [customKey, setCustomKey] = useState<string>("custom_key");
18
+ const [customValue, setCustomValue] = useState<string>("custom_value");
19
+
20
+ const [isInitialized, setIsInitialized] = useState<boolean>(false);
21
+
22
+ return (
23
+ <div className="p-10">
24
+ <div className="input-container flex flex-col">
25
+ <div>BluxUser</div>
26
+ <div>
27
+ {BluxClient.bluxUser$.value
28
+ ? JSON.stringify(BluxClient.bluxUser$.value)
29
+ : "not initialized"}
30
+ </div>
31
+ <div>BluxClientId</div>
32
+ <input
33
+ className="w-[500px] rounded-md border-black border-2"
34
+ type="text"
35
+ placeholder="Enter Blux Client ID"
36
+ value={bluxClientId}
37
+ onChange={(e) => setBluxClientId(e.target.value)}
38
+ />
39
+ <div className="mt-3">BluxApiKey</div>
40
+ <input
41
+ className="w-[500px] rounded-md border-black border-2"
42
+ type="text"
43
+ placeholder="Enter Blux API Key"
44
+ value={bluxApiKey}
45
+ onChange={(e) => setBluxApiKey(e.target.value)}
46
+ />
47
+ <div className="mt-3">User Id</div>
48
+ <input
49
+ className="w-[500px] rounded-md border-black border-2"
50
+ type="text"
51
+ placeholder="Enter User Id"
52
+ value={userId}
53
+ onChange={(e) => signIn(e.target.value)}
54
+ />
55
+ <div className="mt-3">Phone Number</div>
56
+ <input
57
+ className="w-[500px] rounded-md border-black border-2"
58
+ type="text"
59
+ placeholder="Enter phone number"
60
+ value={telNumber}
61
+ onChange={(e) => setTelNumber(e.target.value)}
62
+ />
63
+ <div className="mt-3">Email</div>
64
+ <input
65
+ className="w-[500px] rounded-md border-black border-2"
66
+ type="text"
67
+ placeholder="Enter email"
68
+ value={email}
69
+ onChange={(e) => setEmail(e.target.value)}
70
+ />
71
+ <div className="mt-3">CustomKey</div>
72
+ <input
73
+ className="w-[500px] rounded-md border-black border-2"
74
+ type="text"
75
+ placeholder="Enter custom key"
76
+ value={customKey}
77
+ onChange={(e) => setCustomKey(e.target.value)}
78
+ />
79
+ <div className="mt-3">CustomValue</div>
80
+ <input
81
+ className="w-[500px] rounded-md border-black border-2"
82
+ type="text"
83
+ placeholder="Enter custom value"
84
+ value={customValue}
85
+ onChange={(e) => setCustomValue(e.target.value)}
86
+ />
87
+ </div>
88
+ <div className="mt-10 flex gap-4">
89
+ <button
90
+ className="bg-blue-500 rounded-md p-4 disabled:bg-gray-300"
91
+ onClick={() =>
92
+ BluxClient.init({ bluxClientId, bluxApiKey }).then(() =>
93
+ setIsInitialized(true)
94
+ )
95
+ }
96
+ disabled={bluxClientId === "" || bluxApiKey === ""}
97
+ >
98
+ init
99
+ </button>
100
+ <button
101
+ className="bg-blue-500 rounded-md p-4 disabled:bg-gray-300"
102
+ onClick={() => BluxClient.signIn(userId)}
103
+ disabled={!isInitialized}
104
+ >
105
+ signIn
106
+ </button>
107
+ <button
108
+ className="bg-blue-500 rounded-md p-4 disabled:bg-gray-300"
109
+ onClick={() => BluxClient.signOut()}
110
+ disabled={!isInitialized}
111
+ >
112
+ signOut
113
+ </button>
114
+ <button
115
+ className="bg-blue-500 rounded-md p-4 disabled:bg-gray-300"
116
+ onClick={() =>
117
+ BluxClient.setUserProperties({ phone_number: telNumber })
118
+ }
119
+ disabled={!isInitialized}
120
+ >
121
+ setUserProperties (phone number)
122
+ </button>
123
+ <button
124
+ className="bg-blue-500 rounded-md p-4 disabled:bg-gray-300"
125
+ onClick={() => BluxClient.setUserProperties({ email_address: email })}
126
+ disabled={!isInitialized}
127
+ >
128
+ setUserProperties (email)
129
+ </button>
130
+ <button
131
+ className="bg-blue-500 rounded-md p-4 disabled:bg-gray-300"
132
+ onClick={() =>
133
+ BluxClient.setCustomUserProperties({ [customKey]: customValue })
134
+ }
135
+ disabled={!isInitialized}
136
+ >
137
+ setCustomProperties
138
+ </button>
139
+ <button
140
+ className="bg-blue-500 rounded-md p-4 disabled:bg-gray-300"
141
+ onClick={() =>
142
+ BluxClient.sendEvent(
143
+ new AddLikeEvent({
144
+ item_id: "test-neo",
145
+ url: "test-url",
146
+ })
147
+ )
148
+ }
149
+ disabled={!isInitialized}
150
+ >
151
+ sendEvent
152
+ </button>
153
+ </div>
154
+ </div>
155
+ );
156
+ }
157
+
158
+ export default App;
@@ -0,0 +1,16 @@
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
+ }
@@ -0,0 +1,19 @@
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();
@@ -0,0 +1 @@
1
+ /// <reference types="react-scripts" />
@@ -0,0 +1,15 @@
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;
@@ -0,0 +1,5 @@
1
+ // jest-dom adds custom jest matchers for asserting on DOM nodes.
2
+ // allows you to do things like:
3
+ // expect(element).toHaveTextContent(/react/i)
4
+ // learn more: https://github.com/testing-library/jest-dom
5
+ import "@testing-library/jest-dom";
@@ -0,0 +1,8 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+ content: ["./src/**/*.{js,jsx,ts,tsx}"],
4
+ theme: {
5
+ extend: {},
6
+ },
7
+ plugins: [],
8
+ };