@inslytic/sdk-browser 0.1.1 → 0.1.2
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 +57 -0
- package/package.json +4 -7
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @inslytic/sdk-browser
|
|
2
|
+
|
|
3
|
+
Browser tracking SDK for [Inslytic](https://inslytic.com) — AI-powered product analytics. ~2.5KB gzipped.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @inslytic/sdk-browser
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { init, track, identify, page, setConsent } from "@inslytic/sdk-browser";
|
|
15
|
+
|
|
16
|
+
// Initialize with your project API key
|
|
17
|
+
init({ apiKey: "your-api-key" });
|
|
18
|
+
|
|
19
|
+
// Track events
|
|
20
|
+
track("button_clicked", { properties: { button: "signup" } });
|
|
21
|
+
|
|
22
|
+
// Identify users
|
|
23
|
+
identify("user-123");
|
|
24
|
+
|
|
25
|
+
// Track page views
|
|
26
|
+
page();
|
|
27
|
+
|
|
28
|
+
// Set consent (required before data is stored)
|
|
29
|
+
setConsent(true);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Configuration
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
init({
|
|
36
|
+
apiKey: "your-api-key",
|
|
37
|
+
endpoint: "https://api.inslytic.com", // default
|
|
38
|
+
flushInterval: 2000, // batch flush interval in ms
|
|
39
|
+
maxBatchSize: 20, // max events per batch
|
|
40
|
+
debug: false, // enable debug logging
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## API
|
|
45
|
+
|
|
46
|
+
| Function | Description |
|
|
47
|
+
|---|---|
|
|
48
|
+
| `init(config)` | Initialize the SDK |
|
|
49
|
+
| `track(event, options?)` | Track a custom event |
|
|
50
|
+
| `identify(userId, traits?)` | Associate events with a user |
|
|
51
|
+
| `page(properties?)` | Track a page view |
|
|
52
|
+
| `setConsent(granted)` | Set user consent status |
|
|
53
|
+
| `reset()` | Clear user identity and stop tracking |
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inslytic/sdk-browser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Browser tracking SDK for Inslytic — AI-powered product analytics",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "https://github.com/inslytic/inslytic",
|
|
9
|
-
"directory": "packages/sdk-browser"
|
|
10
|
-
},
|
|
6
|
+
"homepage": "https://www.inslytic.com/docs/browser-sdk",
|
|
11
7
|
"keywords": [
|
|
12
8
|
"analytics",
|
|
13
9
|
"tracking",
|
|
@@ -32,7 +28,8 @@
|
|
|
32
28
|
}
|
|
33
29
|
},
|
|
34
30
|
"files": [
|
|
35
|
-
"dist"
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md"
|
|
36
33
|
],
|
|
37
34
|
"publishConfig": {
|
|
38
35
|
"access": "public"
|