wisetrack 2.0.3 โ 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -53
- package/dist/cdn/sdk.bundle.min.js +1 -1
- package/dist/cjs/constants/constants.d.ts +3 -4
- package/dist/cjs/constants/environments.d.ts +2 -2
- package/dist/cjs/core/network/api-client.d.ts +0 -2
- package/dist/cjs/core/network/network-manager.d.ts +0 -1
- package/dist/cjs/core/storage/storage-manager.d.ts +0 -3
- package/dist/cjs/core/wisetrack.d.ts +0 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/types/config/secure-config.d.ts +8 -0
- package/dist/cjs/types/config/wt-config.d.ts +6 -9
- package/dist/cjs/types/event/event-validation.d.ts +32 -0
- package/dist/cjs/types/event/wt-event.d.ts +20 -5
- package/dist/esm/constants/constants.d.ts +3 -4
- package/dist/esm/constants/environments.d.ts +2 -2
- package/dist/esm/core/network/api-client.d.ts +0 -2
- package/dist/esm/core/network/network-manager.d.ts +0 -1
- package/dist/esm/core/storage/storage-manager.d.ts +0 -3
- package/dist/esm/core/wisetrack.d.ts +0 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/types/config/secure-config.d.ts +8 -0
- package/dist/esm/types/config/wt-config.d.ts +6 -9
- package/dist/esm/types/event/event-validation.d.ts +32 -0
- package/dist/esm/types/event/wt-event.d.ts +20 -5
- package/package.json +1 -1
- package/dist/cjs/types/config/wt-app-settings.d.ts +0 -15
- package/dist/esm/types/config/wt-app-settings.d.ts +0 -15
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@ A lightweight JavaScript SDK for tracking user behavior and events in your web a
|
|
|
25
25
|
## ๐ฆ Installation
|
|
26
26
|
|
|
27
27
|
### Via npm, yarn or pnpm
|
|
28
|
+
|
|
28
29
|
```bash
|
|
29
30
|
npm install wisetrack
|
|
30
31
|
yarn add wisetrack
|
|
@@ -32,6 +33,7 @@ pnpm add wisetrack
|
|
|
32
33
|
```
|
|
33
34
|
|
|
34
35
|
### Via CDN (Direct Browser Usage)
|
|
36
|
+
|
|
35
37
|
```html
|
|
36
38
|
<!-- Latest version -->
|
|
37
39
|
<script src="https://cdn.jsdelivr.net/npm/wisetrack/dist/cdn/sdk.bundle.min.js"></script>
|
|
@@ -41,6 +43,7 @@ pnpm add wisetrack
|
|
|
41
43
|
```
|
|
42
44
|
|
|
43
45
|
### Alternative CDNs
|
|
46
|
+
|
|
44
47
|
```html
|
|
45
48
|
<!-- unpkg -->
|
|
46
49
|
<script src="https://unpkg.com/wisetrack/dist/cdn/sdk.bundle.min.js"></script>
|
|
@@ -53,6 +56,7 @@ pnpm add wisetrack
|
|
|
53
56
|
### For npm/yarn installations (ES6 Modules)
|
|
54
57
|
|
|
55
58
|
#### 1. Initialize the SDK
|
|
59
|
+
|
|
56
60
|
```typescript
|
|
57
61
|
import { WiseTrack, WTUserEnvironment, WTLogLevel } from "wisetrack";
|
|
58
62
|
|
|
@@ -66,26 +70,45 @@ await WiseTrack.instance.init({
|
|
|
66
70
|
```
|
|
67
71
|
|
|
68
72
|
#### 2. Start Tracking (Optional)
|
|
73
|
+
|
|
69
74
|
```typescript
|
|
70
75
|
// Starts automatically if `startTrackerAutomatically` is true.
|
|
71
76
|
// Otherwise, you can start manually:
|
|
72
77
|
await WiseTrack.instance.startTracking();
|
|
73
78
|
```
|
|
74
79
|
|
|
75
|
-
#### 3. Track
|
|
80
|
+
#### 3. Track Event
|
|
81
|
+
|
|
76
82
|
```typescript
|
|
77
83
|
import { WTEvent } from "wisetrack";
|
|
78
84
|
|
|
85
|
+
// Default Event
|
|
79
86
|
const signupEvent = new WTEvent.Default("signup");
|
|
80
87
|
signupEvent.addParam("method", "Google");
|
|
81
88
|
await WiseTrack.instance.trackEvent(signupEvent);
|
|
89
|
+
|
|
90
|
+
// Revenue Event
|
|
91
|
+
const purchase = new WTEvent.Revenue(
|
|
92
|
+
"order_completed",
|
|
93
|
+
99.99,
|
|
94
|
+
RevenueCurrency.USD
|
|
95
|
+
);
|
|
96
|
+
purchase.addParam("item_id", "SKU-123");
|
|
97
|
+
await WiseTrack.instance.trackEvent(purchase);
|
|
82
98
|
```
|
|
83
99
|
|
|
100
|
+
**Note:** Event parameter keys and values have a maximum limit of 50 characters.
|
|
101
|
+
|
|
84
102
|
#### 4. Track a Revenue Event
|
|
103
|
+
|
|
85
104
|
```typescript
|
|
86
105
|
import { WTEvent, RevenueCurrency } from "wisetrack";
|
|
87
106
|
|
|
88
|
-
const purchase = new WTEvent.Revenue(
|
|
107
|
+
const purchase = new WTEvent.Revenue(
|
|
108
|
+
"order_completed",
|
|
109
|
+
99.99,
|
|
110
|
+
RevenueCurrency.USD
|
|
111
|
+
);
|
|
89
112
|
purchase.addParam("item_id", "SKU-123");
|
|
90
113
|
await WiseTrack.instance.trackEvent(purchase);
|
|
91
114
|
```
|
|
@@ -95,30 +118,31 @@ await WiseTrack.instance.trackEvent(purchase);
|
|
|
95
118
|
```html
|
|
96
119
|
<!DOCTYPE html>
|
|
97
120
|
<html>
|
|
98
|
-
<head>
|
|
99
|
-
|
|
100
|
-
</head>
|
|
101
|
-
<body>
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
</body>
|
|
121
|
+
<head>
|
|
122
|
+
<script src="https://cdn.jsdelivr.net/npm/wisetrack/dist/cdn/sdk.bundle.min.js"></script>
|
|
123
|
+
</head>
|
|
124
|
+
<body>
|
|
125
|
+
<script>
|
|
126
|
+
// Initialize
|
|
127
|
+
WiseTrackSDK.WiseTrack.instance.init({
|
|
128
|
+
appToken: "YOUR_APP_TOKEN",
|
|
129
|
+
appVersion: "1.0.0",
|
|
130
|
+
appFrameWork: "Vanilla JS",
|
|
131
|
+
userEnvironment: WiseTrackSDK.WTUserEnvironment.SANDBOX,
|
|
132
|
+
logLevel: WiseTrackSDK.WTLogLevel.DEBUG,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Track event
|
|
136
|
+
const signupEvent = new WiseTrackSDK.WTEvent.Default("signup");
|
|
137
|
+
signupEvent.addParam("method", "Google");
|
|
138
|
+
WiseTrackSDK.WiseTrack.instance.trackEvent(signupEvent);
|
|
139
|
+
</script>
|
|
140
|
+
</body>
|
|
118
141
|
</html>
|
|
119
142
|
```
|
|
120
143
|
|
|
121
144
|
### For CommonJS (Node.js)
|
|
145
|
+
|
|
122
146
|
```javascript
|
|
123
147
|
const { WiseTrack, WTUserEnvironment, WTLogLevel } = require("wisetrack");
|
|
124
148
|
|
|
@@ -129,17 +153,17 @@ const { WiseTrack, WTUserEnvironment, WTLogLevel } = require("wisetrack");
|
|
|
129
153
|
|
|
130
154
|
## โ๏ธ Configuration Options
|
|
131
155
|
|
|
132
|
-
| Key
|
|
133
|
-
| --------------------------- | -------- |
|
|
134
|
-
| `appToken`
|
|
135
|
-
| `appVersion`
|
|
136
|
-
| `appFrameWork`
|
|
137
|
-
| `userEnvironment`
|
|
138
|
-
| `trackingWaitingTime`
|
|
139
|
-
| `startTrackerAutomatically` | โ
|
|
140
|
-
| `customDeviceId`
|
|
141
|
-
| `defaultTracker`
|
|
142
|
-
| `logLevel`
|
|
156
|
+
| Key | Required | Default | Description |
|
|
157
|
+
| --------------------------- | -------- | --------- | -------------------------------------------------------------- |
|
|
158
|
+
| `appToken` | โ
| - | Your unique WiseTrack app token |
|
|
159
|
+
| `appVersion` | โ
| - | Your app version |
|
|
160
|
+
| `appFrameWork` | โ
| - | The framework/platform name |
|
|
161
|
+
| `userEnvironment` | โ | `SANDBOX` | `WTUserEnvironment.SANDBOX` or `WTUserEnvironment.PRODUCTION` |
|
|
162
|
+
| `trackingWaitingTime` | โ | `0` | Time in seconds to wait before tracking starts automatically |
|
|
163
|
+
| `startTrackerAutomatically` | โ | `true` | Whether to start tracking automatically |
|
|
164
|
+
| `customDeviceId` | โ | `auto` | Provide your own device ID |
|
|
165
|
+
| `defaultTracker` | โ | - | Optional tracker name |
|
|
166
|
+
| `logLevel` | โ | `ERROR` | Logging level (`WTLogLevel.DEBUG` / `INFO` / `WARN` / `ERROR`) |
|
|
143
167
|
|
|
144
168
|
---
|
|
145
169
|
|
|
@@ -165,9 +189,10 @@ WiseTrack.instance.setLogLevel(WTLogLevel.DEBUG);
|
|
|
165
189
|
## ๐๏ธ Framework Examples
|
|
166
190
|
|
|
167
191
|
### React/Next.js
|
|
192
|
+
|
|
168
193
|
```tsx
|
|
169
|
-
import { useEffect } from
|
|
170
|
-
import { WiseTrack, WTUserEnvironment } from
|
|
194
|
+
import { useEffect } from "react";
|
|
195
|
+
import { WiseTrack, WTUserEnvironment } from "wisetrack";
|
|
171
196
|
|
|
172
197
|
export default function App() {
|
|
173
198
|
useEffect(() => {
|
|
@@ -184,10 +209,11 @@ export default function App() {
|
|
|
184
209
|
```
|
|
185
210
|
|
|
186
211
|
### Vue.js
|
|
212
|
+
|
|
187
213
|
```vue
|
|
188
214
|
<script setup>
|
|
189
|
-
import { onMounted } from
|
|
190
|
-
import { WiseTrack, WTUserEnvironment } from
|
|
215
|
+
import { onMounted } from "vue";
|
|
216
|
+
import { WiseTrack, WTUserEnvironment } from "wisetrack";
|
|
191
217
|
|
|
192
218
|
onMounted(() => {
|
|
193
219
|
WiseTrack.instance.init({
|
|
@@ -201,13 +227,14 @@ onMounted(() => {
|
|
|
201
227
|
```
|
|
202
228
|
|
|
203
229
|
### Angular
|
|
230
|
+
|
|
204
231
|
```typescript
|
|
205
|
-
import { Component, OnInit } from
|
|
206
|
-
import { WiseTrack, WTUserEnvironment } from
|
|
232
|
+
import { Component, OnInit } from "@angular/core";
|
|
233
|
+
import { WiseTrack, WTUserEnvironment } from "wisetrack";
|
|
207
234
|
|
|
208
235
|
@Component({
|
|
209
|
-
selector:
|
|
210
|
-
templateUrl:
|
|
236
|
+
selector: "app-root",
|
|
237
|
+
templateUrl: "./app.component.html",
|
|
211
238
|
})
|
|
212
239
|
export class AppComponent implements OnInit {
|
|
213
240
|
async ngOnInit() {
|
|
@@ -225,11 +252,11 @@ export class AppComponent implements OnInit {
|
|
|
225
252
|
|
|
226
253
|
## ๐ Bundle Size & Performance
|
|
227
254
|
|
|
228
|
-
| Build Type | Size (Minified) | Size (Gzipped) | Use Case
|
|
229
|
-
|
|
230
|
-
| ESM
|
|
231
|
-
| CommonJS
|
|
232
|
-
| CDN Bundle | ~25KB
|
|
255
|
+
| Build Type | Size (Minified) | Size (Gzipped) | Use Case |
|
|
256
|
+
| ---------- | --------------- | -------------- | ------------------------------- |
|
|
257
|
+
| ESM | ~45KB | ~12KB | Modern bundlers (Webpack, Vite) |
|
|
258
|
+
| CommonJS | ~45KB | ~12KB | Node.js, older bundlers |
|
|
259
|
+
| CDN Bundle | ~25KB | ~8KB | Direct browser usage |
|
|
233
260
|
|
|
234
261
|
---
|
|
235
262
|
|
|
@@ -238,7 +265,7 @@ export class AppComponent implements OnInit {
|
|
|
238
265
|
This package includes TypeScript definitions out of the box. No need to install additional `@types` packages.
|
|
239
266
|
|
|
240
267
|
```typescript
|
|
241
|
-
import type { WTConfig, WTEventData } from
|
|
268
|
+
import type { WTConfig, WTEventData } from "wisetrack";
|
|
242
269
|
|
|
243
270
|
const config: WTConfig = {
|
|
244
271
|
appToken: "YOUR_APP_TOKEN",
|
|
@@ -252,11 +279,11 @@ const config: WTConfig = {
|
|
|
252
279
|
## ๐งช Browser Compatibility
|
|
253
280
|
|
|
254
281
|
| Browser | Version |
|
|
255
|
-
|
|
256
|
-
| Chrome
|
|
257
|
-
| Firefox | โฅ 60
|
|
258
|
-
| Safari
|
|
259
|
-
| Edge
|
|
282
|
+
| ------- | ------- |
|
|
283
|
+
| Chrome | โฅ 60 |
|
|
284
|
+
| Firefox | โฅ 60 |
|
|
285
|
+
| Safari | โฅ 12 |
|
|
286
|
+
| Edge | โฅ 79 |
|
|
260
287
|
|
|
261
288
|
---
|
|
262
289
|
|
|
@@ -277,4 +304,4 @@ See [CHANGELOG.md](CHANGELOG.md) for a list of changes.
|
|
|
277
304
|
|
|
278
305
|
## ๐ License
|
|
279
306
|
|
|
280
|
-
MIT ยฉ [WiseTrack](https://wisetrack.io)
|
|
307
|
+
MIT ยฉ [WiseTrack](https://wisetrack.io)
|