wisetrack 2.0.3 โ 2.0.6
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 +71 -58
- 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.d.ts +3 -1
- 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.d.ts +3 -1
- 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 +2 -2
- 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,59 +70,65 @@ 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);
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
#### 4. Track a Revenue Event
|
|
85
|
-
```typescript
|
|
86
|
-
import { WTEvent, RevenueCurrency } from "wisetrack";
|
|
87
89
|
|
|
88
|
-
|
|
90
|
+
// Revenue Event
|
|
91
|
+
const purchase = new WTEvent.Revenue(
|
|
92
|
+
"order_completed",
|
|
93
|
+
99.99,
|
|
94
|
+
RevenueCurrency.USD
|
|
95
|
+
);
|
|
89
96
|
purchase.addParam("item_id", "SKU-123");
|
|
90
97
|
await WiseTrack.instance.trackEvent(purchase);
|
|
91
98
|
```
|
|
92
99
|
|
|
100
|
+
**Note:** Event parameter keys and values have a maximum limit of 50 characters.
|
|
101
|
+
|
|
93
102
|
### For CDN usage (Direct Browser)
|
|
94
103
|
|
|
95
104
|
```html
|
|
96
105
|
<!DOCTYPE html>
|
|
97
106
|
<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>
|
|
107
|
+
<head>
|
|
108
|
+
<script src="https://cdn.jsdelivr.net/npm/wisetrack/dist/cdn/sdk.bundle.min.js"></script>
|
|
109
|
+
</head>
|
|
110
|
+
<body>
|
|
111
|
+
<script>
|
|
112
|
+
// Initialize
|
|
113
|
+
WiseTrackSDK.WiseTrack.instance.init({
|
|
114
|
+
appToken: "YOUR_APP_TOKEN",
|
|
115
|
+
appVersion: "1.0.0",
|
|
116
|
+
appFrameWork: "Vanilla JS",
|
|
117
|
+
userEnvironment: WiseTrackSDK.WTUserEnvironment.SANDBOX,
|
|
118
|
+
logLevel: WiseTrackSDK.WTLogLevel.DEBUG,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Track event
|
|
122
|
+
const signupEvent = new WiseTrackSDK.WTEvent.Default("signup");
|
|
123
|
+
signupEvent.addParam("method", "Google");
|
|
124
|
+
WiseTrackSDK.WiseTrack.instance.trackEvent(signupEvent);
|
|
125
|
+
</script>
|
|
126
|
+
</body>
|
|
118
127
|
</html>
|
|
119
128
|
```
|
|
120
129
|
|
|
121
130
|
### For CommonJS (Node.js)
|
|
131
|
+
|
|
122
132
|
```javascript
|
|
123
133
|
const { WiseTrack, WTUserEnvironment, WTLogLevel } = require("wisetrack");
|
|
124
134
|
|
|
@@ -129,17 +139,17 @@ const { WiseTrack, WTUserEnvironment, WTLogLevel } = require("wisetrack");
|
|
|
129
139
|
|
|
130
140
|
## โ๏ธ Configuration Options
|
|
131
141
|
|
|
132
|
-
| Key
|
|
133
|
-
| --------------------------- | -------- |
|
|
134
|
-
| `appToken`
|
|
135
|
-
| `appVersion`
|
|
136
|
-
| `appFrameWork`
|
|
137
|
-
| `userEnvironment`
|
|
138
|
-
| `trackingWaitingTime`
|
|
139
|
-
| `startTrackerAutomatically` | โ
|
|
140
|
-
| `customDeviceId`
|
|
141
|
-
| `defaultTracker`
|
|
142
|
-
| `logLevel`
|
|
142
|
+
| Key | Required | Default | Description |
|
|
143
|
+
| --------------------------- | -------- | --------- | -------------------------------------------------------------- |
|
|
144
|
+
| `appToken` | โ
| - | Your unique WiseTrack app token |
|
|
145
|
+
| `appVersion` | โ
| - | Your app version |
|
|
146
|
+
| `appFrameWork` | โ
| - | The framework/platform name |
|
|
147
|
+
| `userEnvironment` | โ | `SANDBOX` | `WTUserEnvironment.SANDBOX` or `WTUserEnvironment.PRODUCTION` |
|
|
148
|
+
| `trackingWaitingTime` | โ | `0` | Time in seconds to wait before tracking starts automatically |
|
|
149
|
+
| `startTrackerAutomatically` | โ | `true` | Whether to start tracking automatically |
|
|
150
|
+
| `customDeviceId` | โ | `auto` | Provide your own device ID |
|
|
151
|
+
| `defaultTracker` | โ | - | Optional tracker name |
|
|
152
|
+
| `logLevel` | โ | `ERROR` | Logging level (`WTLogLevel.DEBUG` / `INFO` / `WARN` / `ERROR`) |
|
|
143
153
|
|
|
144
154
|
---
|
|
145
155
|
|
|
@@ -165,9 +175,10 @@ WiseTrack.instance.setLogLevel(WTLogLevel.DEBUG);
|
|
|
165
175
|
## ๐๏ธ Framework Examples
|
|
166
176
|
|
|
167
177
|
### React/Next.js
|
|
178
|
+
|
|
168
179
|
```tsx
|
|
169
|
-
import { useEffect } from
|
|
170
|
-
import { WiseTrack, WTUserEnvironment } from
|
|
180
|
+
import { useEffect } from "react";
|
|
181
|
+
import { WiseTrack, WTUserEnvironment } from "wisetrack";
|
|
171
182
|
|
|
172
183
|
export default function App() {
|
|
173
184
|
useEffect(() => {
|
|
@@ -184,10 +195,11 @@ export default function App() {
|
|
|
184
195
|
```
|
|
185
196
|
|
|
186
197
|
### Vue.js
|
|
198
|
+
|
|
187
199
|
```vue
|
|
188
200
|
<script setup>
|
|
189
|
-
import { onMounted } from
|
|
190
|
-
import { WiseTrack, WTUserEnvironment } from
|
|
201
|
+
import { onMounted } from "vue";
|
|
202
|
+
import { WiseTrack, WTUserEnvironment } from "wisetrack";
|
|
191
203
|
|
|
192
204
|
onMounted(() => {
|
|
193
205
|
WiseTrack.instance.init({
|
|
@@ -201,13 +213,14 @@ onMounted(() => {
|
|
|
201
213
|
```
|
|
202
214
|
|
|
203
215
|
### Angular
|
|
216
|
+
|
|
204
217
|
```typescript
|
|
205
|
-
import { Component, OnInit } from
|
|
206
|
-
import { WiseTrack, WTUserEnvironment } from
|
|
218
|
+
import { Component, OnInit } from "@angular/core";
|
|
219
|
+
import { WiseTrack, WTUserEnvironment } from "wisetrack";
|
|
207
220
|
|
|
208
221
|
@Component({
|
|
209
|
-
selector:
|
|
210
|
-
templateUrl:
|
|
222
|
+
selector: "app-root",
|
|
223
|
+
templateUrl: "./app.component.html",
|
|
211
224
|
})
|
|
212
225
|
export class AppComponent implements OnInit {
|
|
213
226
|
async ngOnInit() {
|
|
@@ -225,11 +238,11 @@ export class AppComponent implements OnInit {
|
|
|
225
238
|
|
|
226
239
|
## ๐ Bundle Size & Performance
|
|
227
240
|
|
|
228
|
-
| Build Type | Size (Minified) | Size (Gzipped) | Use Case
|
|
229
|
-
|
|
230
|
-
| ESM
|
|
231
|
-
| CommonJS
|
|
232
|
-
| CDN Bundle | ~25KB
|
|
241
|
+
| Build Type | Size (Minified) | Size (Gzipped) | Use Case |
|
|
242
|
+
| ---------- | --------------- | -------------- | ------------------------------- |
|
|
243
|
+
| ESM | ~45KB | ~12KB | Modern bundlers (Webpack, Vite) |
|
|
244
|
+
| CommonJS | ~45KB | ~12KB | Node.js, older bundlers |
|
|
245
|
+
| CDN Bundle | ~25KB | ~8KB | Direct browser usage |
|
|
233
246
|
|
|
234
247
|
---
|
|
235
248
|
|
|
@@ -238,7 +251,7 @@ export class AppComponent implements OnInit {
|
|
|
238
251
|
This package includes TypeScript definitions out of the box. No need to install additional `@types` packages.
|
|
239
252
|
|
|
240
253
|
```typescript
|
|
241
|
-
import type { WTConfig, WTEventData } from
|
|
254
|
+
import type { WTConfig, WTEventData } from "wisetrack";
|
|
242
255
|
|
|
243
256
|
const config: WTConfig = {
|
|
244
257
|
appToken: "YOUR_APP_TOKEN",
|
|
@@ -252,11 +265,11 @@ const config: WTConfig = {
|
|
|
252
265
|
## ๐งช Browser Compatibility
|
|
253
266
|
|
|
254
267
|
| Browser | Version |
|
|
255
|
-
|
|
256
|
-
| Chrome
|
|
257
|
-
| Firefox | โฅ 60
|
|
258
|
-
| Safari
|
|
259
|
-
| Edge
|
|
268
|
+
| ------- | ------- |
|
|
269
|
+
| Chrome | โฅ 60 |
|
|
270
|
+
| Firefox | โฅ 60 |
|
|
271
|
+
| Safari | โฅ 12 |
|
|
272
|
+
| Edge | โฅ 79 |
|
|
260
273
|
|
|
261
274
|
---
|
|
262
275
|
|
|
@@ -277,4 +290,4 @@ See [CHANGELOG.md](CHANGELOG.md) for a list of changes.
|
|
|
277
290
|
|
|
278
291
|
## ๐ License
|
|
279
292
|
|
|
280
|
-
MIT ยฉ [WiseTrack](https://wisetrack.io)
|
|
293
|
+
MIT ยฉ [WiseTrack](https://wisetrack.io)
|