Skip to content

Commit 16d32ac

Browse files
zhu-xiaoweixiaoweii
andauthored
chore: update readme to add source code integration method (#5)
Co-authored-by: xiaoweii <xiaoweii@amazom.com>
1 parent 4fe6272 commit 16d32ac

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

README.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,34 @@ The SDK relies on the Amplify for JS SDK Core Library and is developed according
88

99
## Integrate SDK
1010

11-
**1.Include SDK**
11+
### Include SDK
1212

13-
For NPM repository:
13+
**1. Using NPM repository** (The package is pending release)
1414

1515
```bash
1616
npm install @awslabs/clickstream-web
1717
```
1818

19-
For GitHub repository:
19+
**2. Using source code**
2020

21+
Clone this repository locally.
2122
```bash
22-
npm install github:awslabs/clickstream-web#0.1.0
23+
git clone https://github.com/awslabs/clickstream-web.git
2324
```
2425

25-
Note: for beta version we use GitHub repository to distribute our SDK.
26+
Execute the following script to Generate `clickstream-web-x.x.x.tgz` zip package, which will be located in the project root folder.
27+
```bash
28+
cd clickstream-web && npm run build && npm run pack
29+
```
30+
31+
Copy the `clickstream-web-x.x.x.tgz` into your project, then execute the following script in your project root folder to install the SDK.
32+
```bash
33+
npm install ./clickstream-web-x.x.x.tgz
34+
```
35+
Note: Please correct the SDK version and change the path to where the `clickstream-web-x.x.x.tgz` file is located.
2636

27-
**2.Initialize the SDK**
28-
You need to configure the SDK with default information before using it. Copy your configuration code from your clickstream solution control plane, the configuration code will as follows:
37+
### Initialize the SDK
38+
You need to configure the SDK with default information before using it. Copy your configuration code from your clickstream solution control plane, the configuration code should look like as follows. You can also manually add this code snippet and replace the values of appId and endpoint after you registered app to a data pipeline in the Clickstream Analytics solution console.
2939

3040
```typescript
3141
import { ClickstreamAnalytics, EventMode, PageType } from 'clickstream-web';
@@ -40,7 +50,7 @@ Your `appId` and `endpoint` are already set up in it.
4050
4151
### Start using
4252
43-
#### Record event.
53+
#### Record event
4454
4555
Add the following code where you need to record event.
4656
@@ -69,15 +79,15 @@ ClickstreamAnalytics.setUserId(null);
6979
#### Add user attribute
7080
7181
```typescript
72-
ClickstreamAnalytics.setUserAttribute({
82+
ClickstreamAnalytics.setUserAttributes({
7383
userName:"carl",
7484
userAge: 22
7585
});
7686
```
7787
78-
Current login users attributes will be cached in localStorage, so the next time browser open you don't need to set all user's attribute again, of course you can update the current user's attribute when it changes.
88+
Current login user's attributes will be cached in localStorage, so the next time browser open you don't need to set all user's attribute again, of course you can use the same api `ClickstreamAnalytics.setUserAttributes()` to update the current user's attribute when it changes.
7989
80-
#### Other configuration
90+
#### Other configurations
8191
In addition to the required `appId` and `endpoint`, you can configure other information to get more customized usage:
8292
8393
```typescript
@@ -110,12 +120,12 @@ Here is an explanation of each property:
110120
- **isTrackSearchEvents**: whether auto record search result page events in browser, default is `true`
111121
- **isTrackScrollEvents**: whether auto record page scroll events in browser, default is `true`
112122
- **pageType**: the website type, `SPA` for single page application, `multiPageApp` for multiple page application, default is `SPA`. This attribute works only when the attribute `isTrackPageViewEvents`'s value is `true`.
113-
- **isLogEvents**: whether log events json, default is false.
123+
- **isLogEvents**: whether to print out event json for debugging, default is false.
114124
- **authCookie**: your auth cookie for AWS application load balancer auth cookie.
115125
- **sessionTimeoutDuration**: the duration for session timeout millisecond, default is 1800000
116126
117127
#### Configuration update
118-
You can update the default configuration after initializing the SDK. We now support updating the following parameters:
128+
You can update the default configuration after initializing the SDK, below are the additional configuration options you can customize.
119129
120130
```typescript
121131
import { ClickstreamAnalytics } from 'clickstream-web';

0 commit comments

Comments
 (0)