@unisights/analytics 0.0.2 โ†’ 0.0.4

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unisights/analytics",
3
3
  "description": "Unisights browser event tracking script",
4
- "version": "0.0.2",
4
+ "version": "0.0.4",
5
5
  "main": "dist/unisights.min.js",
6
6
  "module": "dist/unisights.min.js",
7
7
  "types": "dist/unisights.d.ts",
package/dist/pkg/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,103 +0,0 @@
1
- # ๐Ÿ“Š wasm-analytics (Rust WebAssembly SDK)
2
-
3
- This project implements a lightweight, privacy-focused WebAssembly analytics SDK written in Rust. It tracks user interactions on the web (like clicks, scrolls, and page views) and securely exports analytics data with optional AES-GCM encryption.
4
-
5
- ---
6
-
7
- ## ๐Ÿš€ Features
8
-
9
- - ๐Ÿ” Click tracking
10
- - ๐Ÿ–ฑ๏ธ Scroll depth monitoring
11
- - ๐Ÿ“„ Page view + entry/exit logging
12
- - โฑ๏ธ Time-on-page tracking
13
- - ๐Ÿ“ˆ Web Vitals support (LCP, CLS, INP, etc.)
14
- - ๐Ÿ” AES-256-GCM encrypted payload export
15
- - ๐ŸŒ UTM and device info capture
16
- - ๐Ÿ“ฆ WASM target for frontend JS integration
17
-
18
- ---
19
-
20
- ## ๐Ÿงฑ Project Structure
21
-
22
- ```
23
- wasm-analytics/
24
- โ”œโ”€โ”€ src/
25
- โ”‚ โ””โ”€โ”€ lib.rs # Rust source code (Tracker)
26
- โ”œโ”€โ”€ Cargo.toml # Rust project config and deps
27
- โ”œโ”€โ”€ pkg/ # Output of wasm-pack build
28
- โ””โ”€โ”€ README.md # You are here
29
- ```
30
-
31
- ---
32
-
33
- ## ๐Ÿ›  Prerequisites
34
-
35
- - [Rust](https://rust-lang.org)
36
- - [wasm-pack](https://rustwasm.github.io/wasm-pack/)
37
-
38
- Install wasm-pack:
39
-
40
- ```bash
41
- cargo install wasm-pack
42
- ```
43
-
44
- ---
45
-
46
- ## โš™๏ธ Build Setup
47
-
48
- Build the WebAssembly package (for frontend JS usage):
49
-
50
- ```bash
51
- wasm-pack build --target web --release
52
- ```
53
-
54
- This generates:
55
-
56
- - `pkg/wasm_analytics.js`
57
- - `pkg/wasm_analytics_bg.wasm`
58
-
59
- ---
60
-
61
- ## ๐Ÿ” Encryption
62
-
63
- - Key derivation: PBKDF2-HMAC-SHA256 (100,000 iterations)
64
- - AES-GCM (256-bit key, 96-bit nonce)
65
- - Use `.set_encryption_key(passphrase, salt)` to configure
66
-
67
- To export an encrypted payload:
68
-
69
- ```rust
70
- tracker.export_encrypted_payload()
71
- ```
72
-
73
- ---
74
-
75
- ## ๐Ÿงช Quick Test in JS
76
-
77
- ```js
78
- import init, { Tracker } from "./pkg/wasm_analytics.js";
79
-
80
- await init("./pkg/wasm_analytics_bg.wasm");
81
- const tracker = new Tracker();
82
- tracker.set_session_info("asset", "session", location.href, {}, {});
83
- tracker.log_click(100, 200);
84
- const encrypted = tracker.export_encrypted_payload();
85
- console.log(encrypted);
86
- ```
87
-
88
- ---
89
-
90
- ## ๐Ÿ“‰ Optional Optimization
91
-
92
- ```bash
93
- wasm-strip pkg/wasm_analytics_bg.wasm
94
- wasm-opt -Oz -o pkg/wasm_analytics_bg_opt.wasm pkg/wasm_analytics_bg.wasm
95
- ```
96
-
97
- ---
98
-
99
- ## ๐Ÿ“œ License
100
-
101
- Licensed under the [MIT License](https://github.com/<your-username>/unisights/blob/main/LICENSE)โ€”see the root `LICENSE` file for details.
102
-
103
- ---
@@ -1,68 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- export class Tracker {
4
- free(): void;
5
- clearEvents(): void;
6
- setPageUrl(page_url: string): void;
7
- logExitPage(url: string): void;
8
- logPageView(url: string): void;
9
- logWebVital(name: string, value: number, id: string, rating: string, delta: number, entries: number, navigation_type: string): void;
10
- updateScroll(percent: number): void;
11
- logEntryPage(url: string): void;
12
- logCustomEvent(name: string, data: string): void;
13
- setSessionInfo(asset_id: string, session_id: string, page_url: string, utm_params: any, device_info: any): void;
14
- setEncryptionKey(passphrase: string, salt: string): void;
15
- exportEncryptedPayload(): any;
16
- constructor();
17
- tick(seconds: number): void;
18
- logClick(x: number, y: number): void;
19
- }
20
-
21
- export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
22
-
23
- export interface InitOutput {
24
- readonly memory: WebAssembly.Memory;
25
- readonly __wbg_tracker_free: (a: number, b: number) => void;
26
- readonly tracker_clearEvents: (a: number) => void;
27
- readonly tracker_exportEncryptedPayload: (a: number) => [number, number, number];
28
- readonly tracker_logClick: (a: number, b: number, c: number) => void;
29
- readonly tracker_logCustomEvent: (a: number, b: number, c: number, d: number, e: number) => void;
30
- readonly tracker_logEntryPage: (a: number, b: number, c: number) => void;
31
- readonly tracker_logExitPage: (a: number, b: number, c: number) => void;
32
- readonly tracker_logPageView: (a: number, b: number, c: number) => void;
33
- readonly tracker_logWebVital: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
34
- readonly tracker_new: () => number;
35
- readonly tracker_setEncryptionKey: (a: number, b: number, c: number, d: number, e: number) => void;
36
- readonly tracker_setPageUrl: (a: number, b: number, c: number) => void;
37
- readonly tracker_setSessionInfo: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any, i: any) => void;
38
- readonly tracker_tick: (a: number, b: number) => void;
39
- readonly tracker_updateScroll: (a: number, b: number) => void;
40
- readonly __wbindgen_malloc: (a: number, b: number) => number;
41
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
42
- readonly __wbindgen_exn_store: (a: number) => void;
43
- readonly __externref_table_alloc: () => number;
44
- readonly __wbindgen_export_4: WebAssembly.Table;
45
- readonly __externref_table_dealloc: (a: number) => void;
46
- readonly __wbindgen_start: () => void;
47
- }
48
-
49
- export type SyncInitInput = BufferSource | WebAssembly.Module;
50
- /**
51
- * Instantiates the given `module`, which can either be bytes or
52
- * a precompiled `WebAssembly.Module`.
53
- *
54
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
55
- *
56
- * @returns {InitOutput}
57
- */
58
- export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
59
-
60
- /**
61
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
62
- * for everything else, calls `WebAssembly.instantiate` directly.
63
- *
64
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
65
- *
66
- * @returns {Promise<InitOutput>}
67
- */
68
- export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;