wisetrack 2.0.2 โ 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 +82 -63
- 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
|
@@ -24,22 +24,16 @@ A lightweight JavaScript SDK for tracking user behavior and events in your web a
|
|
|
24
24
|
|
|
25
25
|
## ๐ฆ Installation
|
|
26
26
|
|
|
27
|
-
### Via npm
|
|
28
|
-
```bash
|
|
29
|
-
npm install wisetrack
|
|
30
|
-
```
|
|
27
|
+
### Via npm, yarn or pnpm
|
|
31
28
|
|
|
32
|
-
### Via yarn
|
|
33
29
|
```bash
|
|
30
|
+
npm install wisetrack
|
|
34
31
|
yarn add wisetrack
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### Via pnpm
|
|
38
|
-
```bash
|
|
39
32
|
pnpm add wisetrack
|
|
40
33
|
```
|
|
41
34
|
|
|
42
35
|
### Via CDN (Direct Browser Usage)
|
|
36
|
+
|
|
43
37
|
```html
|
|
44
38
|
<!-- Latest version -->
|
|
45
39
|
<script src="https://cdn.jsdelivr.net/npm/wisetrack/dist/cdn/sdk.bundle.min.js"></script>
|
|
@@ -49,9 +43,10 @@ pnpm add wisetrack
|
|
|
49
43
|
```
|
|
50
44
|
|
|
51
45
|
### Alternative CDNs
|
|
46
|
+
|
|
52
47
|
```html
|
|
53
48
|
<!-- unpkg -->
|
|
54
|
-
<script src="https://unpkg.com/wisetrack
|
|
49
|
+
<script src="https://unpkg.com/wisetrack/dist/cdn/sdk.bundle.min.js"></script>
|
|
55
50
|
```
|
|
56
51
|
|
|
57
52
|
---
|
|
@@ -61,6 +56,7 @@ pnpm add wisetrack
|
|
|
61
56
|
### For npm/yarn installations (ES6 Modules)
|
|
62
57
|
|
|
63
58
|
#### 1. Initialize the SDK
|
|
59
|
+
|
|
64
60
|
```typescript
|
|
65
61
|
import { WiseTrack, WTUserEnvironment, WTLogLevel } from "wisetrack";
|
|
66
62
|
|
|
@@ -74,26 +70,45 @@ await WiseTrack.instance.init({
|
|
|
74
70
|
```
|
|
75
71
|
|
|
76
72
|
#### 2. Start Tracking (Optional)
|
|
73
|
+
|
|
77
74
|
```typescript
|
|
78
75
|
// Starts automatically if `startTrackerAutomatically` is true.
|
|
79
76
|
// Otherwise, you can start manually:
|
|
80
77
|
await WiseTrack.instance.startTracking();
|
|
81
78
|
```
|
|
82
79
|
|
|
83
|
-
#### 3. Track
|
|
80
|
+
#### 3. Track Event
|
|
81
|
+
|
|
84
82
|
```typescript
|
|
85
83
|
import { WTEvent } from "wisetrack";
|
|
86
84
|
|
|
85
|
+
// Default Event
|
|
87
86
|
const signupEvent = new WTEvent.Default("signup");
|
|
88
87
|
signupEvent.addParam("method", "Google");
|
|
89
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);
|
|
90
98
|
```
|
|
91
99
|
|
|
100
|
+
**Note:** Event parameter keys and values have a maximum limit of 50 characters.
|
|
101
|
+
|
|
92
102
|
#### 4. Track a Revenue Event
|
|
103
|
+
|
|
93
104
|
```typescript
|
|
94
105
|
import { WTEvent, RevenueCurrency } from "wisetrack";
|
|
95
106
|
|
|
96
|
-
const purchase = new WTEvent.Revenue(
|
|
107
|
+
const purchase = new WTEvent.Revenue(
|
|
108
|
+
"order_completed",
|
|
109
|
+
99.99,
|
|
110
|
+
RevenueCurrency.USD
|
|
111
|
+
);
|
|
97
112
|
purchase.addParam("item_id", "SKU-123");
|
|
98
113
|
await WiseTrack.instance.trackEvent(purchase);
|
|
99
114
|
```
|
|
@@ -103,30 +118,31 @@ await WiseTrack.instance.trackEvent(purchase);
|
|
|
103
118
|
```html
|
|
104
119
|
<!DOCTYPE html>
|
|
105
120
|
<html>
|
|
106
|
-
<head>
|
|
107
|
-
|
|
108
|
-
</head>
|
|
109
|
-
<body>
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
</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>
|
|
126
141
|
</html>
|
|
127
142
|
```
|
|
128
143
|
|
|
129
144
|
### For CommonJS (Node.js)
|
|
145
|
+
|
|
130
146
|
```javascript
|
|
131
147
|
const { WiseTrack, WTUserEnvironment, WTLogLevel } = require("wisetrack");
|
|
132
148
|
|
|
@@ -137,17 +153,17 @@ const { WiseTrack, WTUserEnvironment, WTLogLevel } = require("wisetrack");
|
|
|
137
153
|
|
|
138
154
|
## โ๏ธ Configuration Options
|
|
139
155
|
|
|
140
|
-
| Key
|
|
141
|
-
| --------------------------- | -------- |
|
|
142
|
-
| `appToken`
|
|
143
|
-
| `appVersion`
|
|
144
|
-
| `appFrameWork`
|
|
145
|
-
| `userEnvironment`
|
|
146
|
-
| `trackingWaitingTime`
|
|
147
|
-
| `startTrackerAutomatically` | โ
|
|
148
|
-
| `customDeviceId`
|
|
149
|
-
| `defaultTracker`
|
|
150
|
-
| `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`) |
|
|
151
167
|
|
|
152
168
|
---
|
|
153
169
|
|
|
@@ -173,9 +189,10 @@ WiseTrack.instance.setLogLevel(WTLogLevel.DEBUG);
|
|
|
173
189
|
## ๐๏ธ Framework Examples
|
|
174
190
|
|
|
175
191
|
### React/Next.js
|
|
192
|
+
|
|
176
193
|
```tsx
|
|
177
|
-
import { useEffect } from
|
|
178
|
-
import { WiseTrack, WTUserEnvironment } from
|
|
194
|
+
import { useEffect } from "react";
|
|
195
|
+
import { WiseTrack, WTUserEnvironment } from "wisetrack";
|
|
179
196
|
|
|
180
197
|
export default function App() {
|
|
181
198
|
useEffect(() => {
|
|
@@ -192,10 +209,11 @@ export default function App() {
|
|
|
192
209
|
```
|
|
193
210
|
|
|
194
211
|
### Vue.js
|
|
212
|
+
|
|
195
213
|
```vue
|
|
196
214
|
<script setup>
|
|
197
|
-
import { onMounted } from
|
|
198
|
-
import { WiseTrack, WTUserEnvironment } from
|
|
215
|
+
import { onMounted } from "vue";
|
|
216
|
+
import { WiseTrack, WTUserEnvironment } from "wisetrack";
|
|
199
217
|
|
|
200
218
|
onMounted(() => {
|
|
201
219
|
WiseTrack.instance.init({
|
|
@@ -209,13 +227,14 @@ onMounted(() => {
|
|
|
209
227
|
```
|
|
210
228
|
|
|
211
229
|
### Angular
|
|
230
|
+
|
|
212
231
|
```typescript
|
|
213
|
-
import { Component, OnInit } from
|
|
214
|
-
import { WiseTrack, WTUserEnvironment } from
|
|
232
|
+
import { Component, OnInit } from "@angular/core";
|
|
233
|
+
import { WiseTrack, WTUserEnvironment } from "wisetrack";
|
|
215
234
|
|
|
216
235
|
@Component({
|
|
217
|
-
selector:
|
|
218
|
-
templateUrl:
|
|
236
|
+
selector: "app-root",
|
|
237
|
+
templateUrl: "./app.component.html",
|
|
219
238
|
})
|
|
220
239
|
export class AppComponent implements OnInit {
|
|
221
240
|
async ngOnInit() {
|
|
@@ -233,11 +252,11 @@ export class AppComponent implements OnInit {
|
|
|
233
252
|
|
|
234
253
|
## ๐ Bundle Size & Performance
|
|
235
254
|
|
|
236
|
-
| Build Type | Size (Minified) | Size (Gzipped) | Use Case
|
|
237
|
-
|
|
238
|
-
| ESM
|
|
239
|
-
| CommonJS
|
|
240
|
-
| 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 |
|
|
241
260
|
|
|
242
261
|
---
|
|
243
262
|
|
|
@@ -246,7 +265,7 @@ export class AppComponent implements OnInit {
|
|
|
246
265
|
This package includes TypeScript definitions out of the box. No need to install additional `@types` packages.
|
|
247
266
|
|
|
248
267
|
```typescript
|
|
249
|
-
import type { WTConfig, WTEventData } from
|
|
268
|
+
import type { WTConfig, WTEventData } from "wisetrack";
|
|
250
269
|
|
|
251
270
|
const config: WTConfig = {
|
|
252
271
|
appToken: "YOUR_APP_TOKEN",
|
|
@@ -260,11 +279,11 @@ const config: WTConfig = {
|
|
|
260
279
|
## ๐งช Browser Compatibility
|
|
261
280
|
|
|
262
281
|
| Browser | Version |
|
|
263
|
-
|
|
264
|
-
| Chrome
|
|
265
|
-
| Firefox | โฅ 60
|
|
266
|
-
| Safari
|
|
267
|
-
| Edge
|
|
282
|
+
| ------- | ------- |
|
|
283
|
+
| Chrome | โฅ 60 |
|
|
284
|
+
| Firefox | โฅ 60 |
|
|
285
|
+
| Safari | โฅ 12 |
|
|
286
|
+
| Edge | โฅ 79 |
|
|
268
287
|
|
|
269
288
|
---
|
|
270
289
|
|
|
@@ -285,4 +304,4 @@ See [CHANGELOG.md](CHANGELOG.md) for a list of changes.
|
|
|
285
304
|
|
|
286
305
|
## ๐ License
|
|
287
306
|
|
|
288
|
-
MIT ยฉ [WiseTrack](https://wisetrack.io)
|
|
307
|
+
MIT ยฉ [WiseTrack](https://wisetrack.io)
|