@athena-tracker/tracker 1.0.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/README.md +317 -0
- package/dist/events/capture-react-native.d.ts +77 -0
- package/dist/events/capture-react-native.d.ts.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +2860 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +2872 -0
- package/dist/index.js.map +1 -0
- package/dist/inference/auto-detect.d.ts +21 -0
- package/dist/inference/auto-detect.d.ts.map +1 -0
- package/dist/inference/on-device.d.ts +36 -0
- package/dist/inference/on-device.d.ts.map +1 -0
- package/dist/inference/server.d.ts +30 -0
- package/dist/inference/server.d.ts.map +1 -0
- package/dist/react-native/ForcedReloadWrapper.d.ts +26 -0
- package/dist/react-native/ForcedReloadWrapper.d.ts.map +1 -0
- package/dist/tracker.d.ts +82 -0
- package/dist/tracker.d.ts.map +1 -0
- package/dist/types/index.d.ts +96 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @athena/tracker Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
export type InferenceMode = 'auto' | 'on-device' | 'server';
|
|
5
|
+
export type UserArchetype = 'fast_mover' | 'on_track' | 'slow_adopter' | 'at_risk' | 'different_path';
|
|
6
|
+
export interface AthenaConfig {
|
|
7
|
+
/** App token from ATHENA provisioning API */
|
|
8
|
+
appToken: string;
|
|
9
|
+
/** API base URL (default: https://tracker.pascal.cx) */
|
|
10
|
+
apiUrl?: string;
|
|
11
|
+
/** Inference mode: auto-detect, force on-device, or force server */
|
|
12
|
+
inferenceMode?: InferenceMode;
|
|
13
|
+
/** Path to ONNX model file (for on-device inference) */
|
|
14
|
+
modelPath?: string;
|
|
15
|
+
/** Server-side inference endpoint (default: /v1/predict) */
|
|
16
|
+
serverInferenceUrl?: string;
|
|
17
|
+
/** Webhook configuration */
|
|
18
|
+
webhook?: WebhookConfig;
|
|
19
|
+
/** Event batching configuration */
|
|
20
|
+
batching?: BatchingConfig;
|
|
21
|
+
/** Debug mode */
|
|
22
|
+
debug?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface WebhookConfig {
|
|
25
|
+
/** Webhook URL to receive predictions */
|
|
26
|
+
url: string;
|
|
27
|
+
/** Enable webhook delivery */
|
|
28
|
+
enabled?: boolean;
|
|
29
|
+
/** Retry configuration */
|
|
30
|
+
retry?: {
|
|
31
|
+
maxAttempts?: number;
|
|
32
|
+
backoffMs?: number;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface BatchingConfig {
|
|
36
|
+
/** Batch size (number of events) */
|
|
37
|
+
size?: number;
|
|
38
|
+
/** Batch interval (milliseconds) */
|
|
39
|
+
intervalMs?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface Event {
|
|
42
|
+
event_type: string;
|
|
43
|
+
timestamp: number;
|
|
44
|
+
properties?: Record<string, any>;
|
|
45
|
+
url?: string;
|
|
46
|
+
selector?: string;
|
|
47
|
+
session_id?: string;
|
|
48
|
+
user_id?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface PredictionResult {
|
|
51
|
+
/** Predicted class label */
|
|
52
|
+
predicted_class: string;
|
|
53
|
+
/** Confidence score (0-1) */
|
|
54
|
+
confidence: number;
|
|
55
|
+
/** User archetype classification */
|
|
56
|
+
archetype: UserArchetype;
|
|
57
|
+
/** Purchase intent score (0-1) */
|
|
58
|
+
purchase_intent: number;
|
|
59
|
+
/** Cart abandonment risk (0-1) */
|
|
60
|
+
cart_abandonment_risk?: number;
|
|
61
|
+
/** Checkout abandonment risk (0-1) */
|
|
62
|
+
checkout_abandonment_risk?: number;
|
|
63
|
+
/** Recommended action for external systems */
|
|
64
|
+
recommended_action?: string;
|
|
65
|
+
/** Urgency level */
|
|
66
|
+
urgency?: 'low' | 'medium' | 'high' | 'critical';
|
|
67
|
+
/** Trigger reason (human-readable) */
|
|
68
|
+
trigger_reason?: string;
|
|
69
|
+
/** Inference latency (milliseconds) */
|
|
70
|
+
inference_time_ms: number;
|
|
71
|
+
/** Where inference occurred */
|
|
72
|
+
inference_location: 'on-device' | 'server';
|
|
73
|
+
/** Timestamp */
|
|
74
|
+
timestamp?: string;
|
|
75
|
+
}
|
|
76
|
+
export interface ServerInferenceRequest {
|
|
77
|
+
app_token: string;
|
|
78
|
+
events: Event[];
|
|
79
|
+
session_id?: string;
|
|
80
|
+
user_id?: string;
|
|
81
|
+
}
|
|
82
|
+
export interface ServerInferenceResponse extends PredictionResult {
|
|
83
|
+
}
|
|
84
|
+
export interface FeatureVector {
|
|
85
|
+
temporal: number[];
|
|
86
|
+
session: number[];
|
|
87
|
+
to_vector(): Float32Array;
|
|
88
|
+
}
|
|
89
|
+
export interface TrackerState {
|
|
90
|
+
initialized: boolean;
|
|
91
|
+
inferenceMode: 'on-device' | 'server' | null;
|
|
92
|
+
sessionId: string | null;
|
|
93
|
+
userId: string | null;
|
|
94
|
+
events: Event[];
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE5D,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,UAAU,GACV,cAAc,GACd,SAAS,GACT,gBAAgB,CAAC;AAErB,MAAM,WAAW,YAAY;IAC3B,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;IAEjB,wDAAwD;IACxD,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,oEAAoE;IACpE,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,4DAA4D;IAC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EAAE,MAAM,CAAC;IAE5B,oBAAoB;IACpB,OAAO,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IAEjD,sCAAsC;IACtC,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,uCAAuC;IACvC,iBAAiB,EAAE,MAAM,CAAC;IAE1B,+BAA+B;IAC/B,kBAAkB,EAAE,WAAW,GAAG,QAAQ,CAAC;IAE3C,gBAAgB;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;CAAG;AAEpE,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,IAAI,YAAY,CAAC;CAC3B;AAED,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,WAAW,GAAG,QAAQ,GAAG,IAAI,CAAC;IAC7C,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@athena-tracker/tracker",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Behavioral analytics tracker with edge AI for React Native and Web",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"react-native": "dist/index.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "rollup -c",
|
|
16
|
+
"build:types": "tsc --declaration --emitDeclarationOnly --outDir dist",
|
|
17
|
+
"test": "jest --passWithNoTests",
|
|
18
|
+
"test:watch": "jest --watch",
|
|
19
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
20
|
+
"prepublishOnly": "npm run build && npm test"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"analytics",
|
|
24
|
+
"behavioral",
|
|
25
|
+
"ai",
|
|
26
|
+
"ml",
|
|
27
|
+
"react-native",
|
|
28
|
+
"web",
|
|
29
|
+
"onnx",
|
|
30
|
+
"edge-ai",
|
|
31
|
+
"athena"
|
|
32
|
+
],
|
|
33
|
+
"author": "Pascal Team",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/RubaiyatF/Pascal.git",
|
|
38
|
+
"directory": "tracker/packages/athena-tracker"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"react-native": ">=0.70.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependenciesMeta": {
|
|
44
|
+
"react-native": {
|
|
45
|
+
"optional": true
|
|
46
|
+
},
|
|
47
|
+
"onnxruntime-react-native": {
|
|
48
|
+
"optional": true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@types/react-native": "^0.72.0",
|
|
53
|
+
"tslib": "^2.8.1"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@babel/core": "^7.23.0",
|
|
57
|
+
"@babel/preset-env": "^7.23.0",
|
|
58
|
+
"@babel/preset-typescript": "^7.23.0",
|
|
59
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
60
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
61
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
62
|
+
"@rollup/plugin-typescript": "^11.1.5",
|
|
63
|
+
"@types/jest": "^29.5.8",
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "^6.11.0",
|
|
65
|
+
"@typescript-eslint/parser": "^6.11.0",
|
|
66
|
+
"eslint": "^8.54.0",
|
|
67
|
+
"jest": "^29.7.0",
|
|
68
|
+
"rollup": "^4.5.0",
|
|
69
|
+
"ts-jest": "^29.1.1",
|
|
70
|
+
"typescript": "^5.3.2"
|
|
71
|
+
},
|
|
72
|
+
"engines": {
|
|
73
|
+
"node": ">=16.0.0"
|
|
74
|
+
}
|
|
75
|
+
}
|