@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/dist/unisights.min.js +2 -2
- package/package.json +1 -1
- package/dist/pkg/LICENSE +0 -21
- package/dist/pkg/README.md +0 -103
- package/dist/pkg/unisights_core.d.ts +0 -68
- package/dist/pkg/unisights_core.js +0 -714
- package/dist/pkg/unisights_core_bg.wasm +0 -0
- package/dist/pkg/unisights_core_bg.wasm.d.ts +0 -25
package/package.json
CHANGED
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.
|
package/dist/pkg/README.md
DELETED
|
@@ -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>;
|