@outlit/browser 0.1.0
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/LICENSE +201 -0
- package/dist/index.d.mts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +435 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +409 -0
- package/dist/index.mjs.map +1 -0
- package/dist/outlit.global.js +2 -0
- package/dist/outlit.global.js.map +1 -0
- package/dist/react/index.d.mts +170 -0
- package/dist/react/index.d.ts +170 -0
- package/dist/react/index.js +511 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/index.mjs +487 -0
- package/dist/react/index.mjs.map +1 -0
- package/dist/tracker-CocH64L9.d.mts +107 -0
- package/dist/tracker-CocH64L9.d.ts +107 -0
- package/package.json +83 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { TrackerConfig, BrowserTrackOptions, BrowserIdentifyOptions } from '@outlit/core';
|
|
2
|
+
|
|
3
|
+
interface TrackerOptions extends TrackerConfig {
|
|
4
|
+
/**
|
|
5
|
+
* Automatically start tracking on init.
|
|
6
|
+
* Set to false if you need to wait for user consent before tracking.
|
|
7
|
+
* Call enableTracking() to start tracking after consent is obtained.
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
autoTrack?: boolean;
|
|
11
|
+
trackPageviews?: boolean;
|
|
12
|
+
trackForms?: boolean;
|
|
13
|
+
formFieldDenylist?: string[];
|
|
14
|
+
flushInterval?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Automatically identify users when they submit forms with email fields.
|
|
17
|
+
* Extracts email and name (first/last) from form fields using heuristics.
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
autoIdentify?: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare class Tracker {
|
|
23
|
+
private publicKey;
|
|
24
|
+
private apiHost;
|
|
25
|
+
private visitorId;
|
|
26
|
+
private eventQueue;
|
|
27
|
+
private flushTimer;
|
|
28
|
+
private flushInterval;
|
|
29
|
+
private isInitialized;
|
|
30
|
+
private isTrackingEnabled;
|
|
31
|
+
private options;
|
|
32
|
+
constructor(options: TrackerOptions);
|
|
33
|
+
/**
|
|
34
|
+
* Enable tracking. Call this after obtaining user consent.
|
|
35
|
+
* This will:
|
|
36
|
+
* - Generate/retrieve the visitor ID
|
|
37
|
+
* - Start automatic pageview and form tracking (if configured)
|
|
38
|
+
* - Begin sending events to the server
|
|
39
|
+
*
|
|
40
|
+
* If autoTrack is true (default), this is called automatically on init.
|
|
41
|
+
*/
|
|
42
|
+
enableTracking(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Check if tracking is currently enabled.
|
|
45
|
+
*/
|
|
46
|
+
isEnabled(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Track a custom event.
|
|
49
|
+
*/
|
|
50
|
+
track(eventName: string, properties?: BrowserTrackOptions["properties"]): void;
|
|
51
|
+
/**
|
|
52
|
+
* Identify the current visitor.
|
|
53
|
+
* Links the anonymous visitor to a known user.
|
|
54
|
+
*/
|
|
55
|
+
identify(options: BrowserIdentifyOptions): void;
|
|
56
|
+
/**
|
|
57
|
+
* Get the current visitor ID.
|
|
58
|
+
* Returns null if tracking is not enabled.
|
|
59
|
+
*/
|
|
60
|
+
getVisitorId(): string | null;
|
|
61
|
+
/**
|
|
62
|
+
* Manually flush the event queue.
|
|
63
|
+
*/
|
|
64
|
+
flush(): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Shutdown the tracker.
|
|
67
|
+
*/
|
|
68
|
+
shutdown(): Promise<void>;
|
|
69
|
+
private initPageviewTracking;
|
|
70
|
+
private initFormTracking;
|
|
71
|
+
private enqueue;
|
|
72
|
+
private startFlushTimer;
|
|
73
|
+
private sendEvents;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Initialize the Outlit tracker.
|
|
77
|
+
* Should be called once at app startup.
|
|
78
|
+
*/
|
|
79
|
+
declare function init(options: TrackerOptions): Tracker;
|
|
80
|
+
/**
|
|
81
|
+
* Get the tracker instance.
|
|
82
|
+
* Throws if not initialized.
|
|
83
|
+
*/
|
|
84
|
+
declare function getInstance(): Tracker;
|
|
85
|
+
/**
|
|
86
|
+
* Track a custom event.
|
|
87
|
+
* Convenience method that uses the singleton instance.
|
|
88
|
+
*/
|
|
89
|
+
declare function track(eventName: string, properties?: BrowserTrackOptions["properties"]): void;
|
|
90
|
+
/**
|
|
91
|
+
* Identify the current visitor.
|
|
92
|
+
* Convenience method that uses the singleton instance.
|
|
93
|
+
*/
|
|
94
|
+
declare function identify(options: BrowserIdentifyOptions): void;
|
|
95
|
+
/**
|
|
96
|
+
* Enable tracking after consent is obtained.
|
|
97
|
+
* Call this in your consent management tool's callback.
|
|
98
|
+
* Convenience method that uses the singleton instance.
|
|
99
|
+
*/
|
|
100
|
+
declare function enableTracking(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Check if tracking is currently enabled.
|
|
103
|
+
* Convenience method that uses the singleton instance.
|
|
104
|
+
*/
|
|
105
|
+
declare function isTrackingEnabled(): boolean;
|
|
106
|
+
|
|
107
|
+
export { Tracker as T, identify as a, isTrackingEnabled as b, type TrackerOptions as c, enableTracking as e, getInstance as g, init as i, track as t };
|
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@outlit/browser",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Outlit browser tracking SDK with React bindings",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Outlit AI",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/OutlitAI/outlit-sdk.git",
|
|
10
|
+
"directory": "packages/browser"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/OutlitAI/outlit-sdk/issues"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/OutlitAI/outlit-sdk#readme",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"outlit",
|
|
18
|
+
"analytics",
|
|
19
|
+
"tracking",
|
|
20
|
+
"sdk",
|
|
21
|
+
"browser",
|
|
22
|
+
"react"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"module": "./dist/index.mjs",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.mjs",
|
|
34
|
+
"require": "./dist/index.js",
|
|
35
|
+
"default": "./dist/index.mjs"
|
|
36
|
+
},
|
|
37
|
+
"./react": {
|
|
38
|
+
"types": "./dist/react/index.d.ts",
|
|
39
|
+
"import": "./dist/react/index.mjs",
|
|
40
|
+
"require": "./dist/react/index.js",
|
|
41
|
+
"default": "./dist/react/index.mjs"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"dist"
|
|
46
|
+
],
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@outlit/core": "0.1.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@playwright/test": "^1.48.0",
|
|
52
|
+
"@types/node": "^20.0.0",
|
|
53
|
+
"@types/react": "^18.2.0",
|
|
54
|
+
"react": "^18.2.0",
|
|
55
|
+
"tsup": "^8.0.1",
|
|
56
|
+
"tsx": "^4.0.0",
|
|
57
|
+
"typescript": "^5.3.3",
|
|
58
|
+
"@outlit/typescript-config": "0.0.0"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"react": ">=17.0.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"react": {
|
|
65
|
+
"optional": true
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"build": "tsup",
|
|
70
|
+
"dev": "tsup --watch",
|
|
71
|
+
"clean": "rm -rf dist .turbo node_modules",
|
|
72
|
+
"lint": "biome check . --write",
|
|
73
|
+
"format": "biome format --write .",
|
|
74
|
+
"typecheck": "tsc --noEmit",
|
|
75
|
+
"test": "playwright test",
|
|
76
|
+
"test:ui": "playwright test --ui",
|
|
77
|
+
"test:headed": "playwright test --headed",
|
|
78
|
+
"serve:test": "tsx ./__tests__/e2e/serve.ts",
|
|
79
|
+
"deploy:canary": "pnpm build && tsx ./scripts/deploy.ts canary",
|
|
80
|
+
"deploy:stable": "pnpm build && tsx ./scripts/deploy.ts stable",
|
|
81
|
+
"deploy:version": "pnpm build && tsx ./scripts/deploy.ts version"
|
|
82
|
+
}
|
|
83
|
+
}
|