@unisights/analytics 0.0.1
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 +21 -0
- package/README.md +121 -0
- package/dist/pkg/LICENSE +21 -0
- package/dist/pkg/README.md +103 -0
- package/dist/pkg/unisights_core.d.ts +68 -0
- package/dist/pkg/unisights_core.js +714 -0
- package/dist/pkg/unisights_core_bg.wasm +0 -0
- package/dist/pkg/unisights_core_bg.wasm.d.ts +25 -0
- package/dist/unisights.d.ts +24 -0
- package/dist/unisights.min.js +2 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Unisights Client SDK
|
|
2
|
+
|
|
3
|
+
Welcome to the **Unisights Client SDK**, the heart of the Unisights real-time analytics platform! This folder contains the WebAssembly (WASM)-powered tracking SDK, built with Rust and TypeScript, designed to efficiently and securely capture user interactions on your website or application. The SDK is lightweight, privacy-focused, and easy to integrate, enabling real-time event tracking with minimal performance impact.
|
|
4
|
+
|
|
5
|
+
## 🌟 Purpose
|
|
6
|
+
|
|
7
|
+
The Unisights Client SDK collects events (e.g., page views, clicks, custom actions) directly in the browser using WASM for speed and efficiency. It encrypts data in-browser before sending it to your Unisights ingestion service, ensuring privacy and compliance with regulations like GDPR. This SDK powers the client-side tracking for the Unisights platform, feeding data into Apache Kafka and Druid for real-time analytics.
|
|
8
|
+
|
|
9
|
+
## 📦 Folder Structure
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
client-sdk/
|
|
13
|
+
├── core/ # Rust WASM core logic (compiled to analytics-bundle.min.js)
|
|
14
|
+
├── src/ # TypeScript wrapper and utilities
|
|
15
|
+
├── package.json # Node.js configuration for building
|
|
16
|
+
├── tsconfig.json # TypeScript configuration
|
|
17
|
+
└── README.md # You are here
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
- **`core/`**: Contains the Rust source code compiled to WASM, providing the high-performance event collection logic.
|
|
21
|
+
- **`src/`**: Includes TypeScript files that wrap the WASM module and expose a simple JavaScript API for developers.
|
|
22
|
+
|
|
23
|
+
## 🚀 Getting Started
|
|
24
|
+
|
|
25
|
+
### 1️⃣ Prerequisites
|
|
26
|
+
|
|
27
|
+
- **Node.js** (>= 16.x) with npm
|
|
28
|
+
- **Rust** (for building or modifying the WASM core)
|
|
29
|
+
- **WasmPack** (install with `cargo install wasm-pack` for development)
|
|
30
|
+
|
|
31
|
+
### 2️⃣ Install Dependencies
|
|
32
|
+
|
|
33
|
+
Navigate to the `client-sdk` folder and install dependencies:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 3️⃣ Build the SDK
|
|
40
|
+
|
|
41
|
+
Compile the Rust WASM code and bundle it with TypeScript:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm run build
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
This generates `analytics-bundle.min.js` in the `dist/` folder (or configure the output path as needed), ready for deployment.
|
|
48
|
+
|
|
49
|
+
### 4️⃣ Integrate into Your HTML
|
|
50
|
+
|
|
51
|
+
Inject the SDK into your website by adding the following `<script>` tag to your HTML file. Replace `your-insights-id` with your unique Unisights API key and adjust the `src` URL to point to your hosted SDK file (e.g., a CDN or local server):
|
|
52
|
+
|
|
53
|
+
```html
|
|
54
|
+
<script
|
|
55
|
+
type="module"
|
|
56
|
+
id="unisights-script"
|
|
57
|
+
defer
|
|
58
|
+
data-insights-id="your-insights-id"
|
|
59
|
+
data-secret="..."
|
|
60
|
+
data-salt="..."
|
|
61
|
+
src="http://localhost:9005/analytics-bundle.min.js"
|
|
62
|
+
></script>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
- **`type="module"`**: Ensures the SDK loads as an ES module.
|
|
66
|
+
- **`id="unisights-script"`**: A unique identifier for the script tag.
|
|
67
|
+
- **`defer`**: Loads the script asynchronously without blocking HTML parsing.
|
|
68
|
+
- **`data-insights-id`**: Your Unisights API key for identifying the data source.
|
|
69
|
+
- **`src`**: Path to the compiled `analytics-bundle.min.js` file.
|
|
70
|
+
|
|
71
|
+
### 5️⃣ Usage
|
|
72
|
+
|
|
73
|
+
Once loaded, the SDK is available globally as `unisights`. You can track events like this:
|
|
74
|
+
|
|
75
|
+
```html
|
|
76
|
+
<script>
|
|
77
|
+
// Initialize the SDK (optional, auto-runs with data-insights-id)
|
|
78
|
+
unisights.init({ apiKey: "your-insights-id" });
|
|
79
|
+
|
|
80
|
+
// Track a custom event
|
|
81
|
+
unisights.track("page_view", {
|
|
82
|
+
path: window.location.pathname,
|
|
83
|
+
timestamp: new Date().toISOString(),
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Track a click event
|
|
87
|
+
document.querySelector("button").addEventListener("click", () => {
|
|
88
|
+
unisights.track("button_click", { element: "submit-btn" });
|
|
89
|
+
});
|
|
90
|
+
</script>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- **`init()`**: Configures the SDK with your API key (optional if set in `data-insights-id`).
|
|
94
|
+
- **`track(eventName, data)`**: Sends an event with a name and optional metadata to the Unisights ingestion service.
|
|
95
|
+
|
|
96
|
+
## 🛠 Development
|
|
97
|
+
|
|
98
|
+
### Modify the WASM Core
|
|
99
|
+
|
|
100
|
+
- Edit Rust files in `core/`.
|
|
101
|
+
- Rebuild with `npm run build` to regenerate `analytics-bundle.min.js`.
|
|
102
|
+
|
|
103
|
+
### Test Locally
|
|
104
|
+
|
|
105
|
+
- Serve the `dist/` folder with a local server (e.g., `npx serve dist` or use `http://localhost:9005`).
|
|
106
|
+
- Open your HTML file in a browser and check the console for errors or use network tools to verify event transmission.
|
|
107
|
+
|
|
108
|
+
## ✨ Why This SDK Stands Out
|
|
109
|
+
|
|
110
|
+
- **WASM Performance**: Rust-compiled WASM offers faster execution and lower overhead than traditional JavaScript trackers.
|
|
111
|
+
- **Privacy-Focused**: In-browser encryption protects user data before it leaves the client.
|
|
112
|
+
- **Lightweight**: Minimal impact on page load times, ideal for high-traffic sites.
|
|
113
|
+
- **Extensible**: Easy to add custom events or integrate with your analytics workflow.
|
|
114
|
+
|
|
115
|
+
## 🌟 Support the Project
|
|
116
|
+
|
|
117
|
+
If you find the Unisights Client SDK useful, give the main Unisights repository a ⭐ on GitHub at [https://github.com/<your-username>/unisights](https://github.com/<your-username>/unisights). Share it with your network or suggest improvements via GitHub Issues. More contributors will help us enhance this SDK!
|
|
118
|
+
|
|
119
|
+
## 📜 License
|
|
120
|
+
|
|
121
|
+
Licensed under the [MIT License](https://github.com/<your-username>/unisights/blob/main/LICENSE)—see the root `LICENSE` file for details.
|
package/dist/pkg/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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.
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
---
|
|
@@ -0,0 +1,68 @@
|
|
|
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>;
|
|
@@ -0,0 +1,714 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
let WASM_VECTOR_LEN = 0;
|
|
4
|
+
|
|
5
|
+
let cachedUint8ArrayMemory0 = null;
|
|
6
|
+
|
|
7
|
+
function getUint8ArrayMemory0() {
|
|
8
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
9
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
10
|
+
}
|
|
11
|
+
return cachedUint8ArrayMemory0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
15
|
+
|
|
16
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
17
|
+
? function (arg, view) {
|
|
18
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
19
|
+
}
|
|
20
|
+
: function (arg, view) {
|
|
21
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
22
|
+
view.set(buf);
|
|
23
|
+
return {
|
|
24
|
+
read: arg.length,
|
|
25
|
+
written: buf.length
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
30
|
+
|
|
31
|
+
if (realloc === undefined) {
|
|
32
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
33
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
34
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
35
|
+
WASM_VECTOR_LEN = buf.length;
|
|
36
|
+
return ptr;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let len = arg.length;
|
|
40
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
41
|
+
|
|
42
|
+
const mem = getUint8ArrayMemory0();
|
|
43
|
+
|
|
44
|
+
let offset = 0;
|
|
45
|
+
|
|
46
|
+
for (; offset < len; offset++) {
|
|
47
|
+
const code = arg.charCodeAt(offset);
|
|
48
|
+
if (code > 0x7F) break;
|
|
49
|
+
mem[ptr + offset] = code;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (offset !== len) {
|
|
53
|
+
if (offset !== 0) {
|
|
54
|
+
arg = arg.slice(offset);
|
|
55
|
+
}
|
|
56
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
57
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
58
|
+
const ret = encodeString(arg, view);
|
|
59
|
+
|
|
60
|
+
offset += ret.written;
|
|
61
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
WASM_VECTOR_LEN = offset;
|
|
65
|
+
return ptr;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let cachedDataViewMemory0 = null;
|
|
69
|
+
|
|
70
|
+
function getDataViewMemory0() {
|
|
71
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
72
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
73
|
+
}
|
|
74
|
+
return cachedDataViewMemory0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function addToExternrefTable0(obj) {
|
|
78
|
+
const idx = wasm.__externref_table_alloc();
|
|
79
|
+
wasm.__wbindgen_export_4.set(idx, obj);
|
|
80
|
+
return idx;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function handleError(f, args) {
|
|
84
|
+
try {
|
|
85
|
+
return f.apply(this, args);
|
|
86
|
+
} catch (e) {
|
|
87
|
+
const idx = addToExternrefTable0(e);
|
|
88
|
+
wasm.__wbindgen_exn_store(idx);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
93
|
+
|
|
94
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
95
|
+
|
|
96
|
+
function getStringFromWasm0(ptr, len) {
|
|
97
|
+
ptr = ptr >>> 0;
|
|
98
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function isLikeNone(x) {
|
|
102
|
+
return x === undefined || x === null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function debugString(val) {
|
|
106
|
+
// primitive types
|
|
107
|
+
const type = typeof val;
|
|
108
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
109
|
+
return `${val}`;
|
|
110
|
+
}
|
|
111
|
+
if (type == 'string') {
|
|
112
|
+
return `"${val}"`;
|
|
113
|
+
}
|
|
114
|
+
if (type == 'symbol') {
|
|
115
|
+
const description = val.description;
|
|
116
|
+
if (description == null) {
|
|
117
|
+
return 'Symbol';
|
|
118
|
+
} else {
|
|
119
|
+
return `Symbol(${description})`;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (type == 'function') {
|
|
123
|
+
const name = val.name;
|
|
124
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
125
|
+
return `Function(${name})`;
|
|
126
|
+
} else {
|
|
127
|
+
return 'Function';
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// objects
|
|
131
|
+
if (Array.isArray(val)) {
|
|
132
|
+
const length = val.length;
|
|
133
|
+
let debug = '[';
|
|
134
|
+
if (length > 0) {
|
|
135
|
+
debug += debugString(val[0]);
|
|
136
|
+
}
|
|
137
|
+
for(let i = 1; i < length; i++) {
|
|
138
|
+
debug += ', ' + debugString(val[i]);
|
|
139
|
+
}
|
|
140
|
+
debug += ']';
|
|
141
|
+
return debug;
|
|
142
|
+
}
|
|
143
|
+
// Test for built-in
|
|
144
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
145
|
+
let className;
|
|
146
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
147
|
+
className = builtInMatches[1];
|
|
148
|
+
} else {
|
|
149
|
+
// Failed to match the standard '[object ClassName]'
|
|
150
|
+
return toString.call(val);
|
|
151
|
+
}
|
|
152
|
+
if (className == 'Object') {
|
|
153
|
+
// we're a user defined class or Object
|
|
154
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
155
|
+
// easier than looping through ownProperties of `val`.
|
|
156
|
+
try {
|
|
157
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
158
|
+
} catch (_) {
|
|
159
|
+
return 'Object';
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// errors
|
|
163
|
+
if (val instanceof Error) {
|
|
164
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
165
|
+
}
|
|
166
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
167
|
+
return className;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function takeFromExternrefTable0(idx) {
|
|
171
|
+
const value = wasm.__wbindgen_export_4.get(idx);
|
|
172
|
+
wasm.__externref_table_dealloc(idx);
|
|
173
|
+
return value;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const TrackerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
177
|
+
? { register: () => {}, unregister: () => {} }
|
|
178
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_tracker_free(ptr >>> 0, 1));
|
|
179
|
+
|
|
180
|
+
export class Tracker {
|
|
181
|
+
|
|
182
|
+
__destroy_into_raw() {
|
|
183
|
+
const ptr = this.__wbg_ptr;
|
|
184
|
+
this.__wbg_ptr = 0;
|
|
185
|
+
TrackerFinalization.unregister(this);
|
|
186
|
+
return ptr;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
free() {
|
|
190
|
+
const ptr = this.__destroy_into_raw();
|
|
191
|
+
wasm.__wbg_tracker_free(ptr, 0);
|
|
192
|
+
}
|
|
193
|
+
clearEvents() {
|
|
194
|
+
wasm.tracker_clearEvents(this.__wbg_ptr);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* @param {string} page_url
|
|
198
|
+
*/
|
|
199
|
+
setPageUrl(page_url) {
|
|
200
|
+
const ptr0 = passStringToWasm0(page_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
201
|
+
const len0 = WASM_VECTOR_LEN;
|
|
202
|
+
wasm.tracker_setPageUrl(this.__wbg_ptr, ptr0, len0);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* @param {string} url
|
|
206
|
+
*/
|
|
207
|
+
logExitPage(url) {
|
|
208
|
+
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
209
|
+
const len0 = WASM_VECTOR_LEN;
|
|
210
|
+
wasm.tracker_logExitPage(this.__wbg_ptr, ptr0, len0);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* @param {string} url
|
|
214
|
+
*/
|
|
215
|
+
logPageView(url) {
|
|
216
|
+
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
217
|
+
const len0 = WASM_VECTOR_LEN;
|
|
218
|
+
wasm.tracker_logPageView(this.__wbg_ptr, ptr0, len0);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* @param {string} name
|
|
222
|
+
* @param {number} value
|
|
223
|
+
* @param {string} id
|
|
224
|
+
* @param {string} rating
|
|
225
|
+
* @param {number} delta
|
|
226
|
+
* @param {number} entries
|
|
227
|
+
* @param {string} navigation_type
|
|
228
|
+
*/
|
|
229
|
+
logWebVital(name, value, id, rating, delta, entries, navigation_type) {
|
|
230
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
231
|
+
const len0 = WASM_VECTOR_LEN;
|
|
232
|
+
const ptr1 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
233
|
+
const len1 = WASM_VECTOR_LEN;
|
|
234
|
+
const ptr2 = passStringToWasm0(rating, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
235
|
+
const len2 = WASM_VECTOR_LEN;
|
|
236
|
+
const ptr3 = passStringToWasm0(navigation_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
237
|
+
const len3 = WASM_VECTOR_LEN;
|
|
238
|
+
wasm.tracker_logWebVital(this.__wbg_ptr, ptr0, len0, value, ptr1, len1, ptr2, len2, delta, entries, ptr3, len3);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* @param {number} percent
|
|
242
|
+
*/
|
|
243
|
+
updateScroll(percent) {
|
|
244
|
+
wasm.tracker_updateScroll(this.__wbg_ptr, percent);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* @param {string} url
|
|
248
|
+
*/
|
|
249
|
+
logEntryPage(url) {
|
|
250
|
+
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
251
|
+
const len0 = WASM_VECTOR_LEN;
|
|
252
|
+
wasm.tracker_logEntryPage(this.__wbg_ptr, ptr0, len0);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* @param {string} name
|
|
256
|
+
* @param {string} data
|
|
257
|
+
*/
|
|
258
|
+
logCustomEvent(name, data) {
|
|
259
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
260
|
+
const len0 = WASM_VECTOR_LEN;
|
|
261
|
+
const ptr1 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
262
|
+
const len1 = WASM_VECTOR_LEN;
|
|
263
|
+
wasm.tracker_logCustomEvent(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* @param {string} asset_id
|
|
267
|
+
* @param {string} session_id
|
|
268
|
+
* @param {string} page_url
|
|
269
|
+
* @param {any} utm_params
|
|
270
|
+
* @param {any} device_info
|
|
271
|
+
*/
|
|
272
|
+
setSessionInfo(asset_id, session_id, page_url, utm_params, device_info) {
|
|
273
|
+
const ptr0 = passStringToWasm0(asset_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
274
|
+
const len0 = WASM_VECTOR_LEN;
|
|
275
|
+
const ptr1 = passStringToWasm0(session_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
276
|
+
const len1 = WASM_VECTOR_LEN;
|
|
277
|
+
const ptr2 = passStringToWasm0(page_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
278
|
+
const len2 = WASM_VECTOR_LEN;
|
|
279
|
+
wasm.tracker_setSessionInfo(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, utm_params, device_info);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* @param {string} passphrase
|
|
283
|
+
* @param {string} salt
|
|
284
|
+
*/
|
|
285
|
+
setEncryptionKey(passphrase, salt) {
|
|
286
|
+
const ptr0 = passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
287
|
+
const len0 = WASM_VECTOR_LEN;
|
|
288
|
+
const ptr1 = passStringToWasm0(salt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
289
|
+
const len1 = WASM_VECTOR_LEN;
|
|
290
|
+
wasm.tracker_setEncryptionKey(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* @returns {any}
|
|
294
|
+
*/
|
|
295
|
+
exportEncryptedPayload() {
|
|
296
|
+
const ret = wasm.tracker_exportEncryptedPayload(this.__wbg_ptr);
|
|
297
|
+
if (ret[2]) {
|
|
298
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
299
|
+
}
|
|
300
|
+
return takeFromExternrefTable0(ret[0]);
|
|
301
|
+
}
|
|
302
|
+
constructor() {
|
|
303
|
+
const ret = wasm.tracker_new();
|
|
304
|
+
this.__wbg_ptr = ret >>> 0;
|
|
305
|
+
TrackerFinalization.register(this, this.__wbg_ptr, this);
|
|
306
|
+
return this;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* @param {number} seconds
|
|
310
|
+
*/
|
|
311
|
+
tick(seconds) {
|
|
312
|
+
wasm.tracker_tick(this.__wbg_ptr, seconds);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* @param {number} x
|
|
316
|
+
* @param {number} y
|
|
317
|
+
*/
|
|
318
|
+
logClick(x, y) {
|
|
319
|
+
wasm.tracker_logClick(this.__wbg_ptr, x, y);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
async function __wbg_load(module, imports) {
|
|
324
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
325
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
326
|
+
try {
|
|
327
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
328
|
+
|
|
329
|
+
} catch (e) {
|
|
330
|
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
331
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
332
|
+
|
|
333
|
+
} else {
|
|
334
|
+
throw e;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const bytes = await module.arrayBuffer();
|
|
340
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
341
|
+
|
|
342
|
+
} else {
|
|
343
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
344
|
+
|
|
345
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
346
|
+
return { instance, module };
|
|
347
|
+
|
|
348
|
+
} else {
|
|
349
|
+
return instance;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function __wbg_get_imports() {
|
|
355
|
+
const imports = {};
|
|
356
|
+
imports.wbg = {};
|
|
357
|
+
imports.wbg.__wbg_String_eecc4a11987127d6 = function(arg0, arg1) {
|
|
358
|
+
const ret = String(arg1);
|
|
359
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
360
|
+
const len1 = WASM_VECTOR_LEN;
|
|
361
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
362
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
363
|
+
};
|
|
364
|
+
imports.wbg.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
|
|
365
|
+
const ret = arg0.buffer;
|
|
366
|
+
return ret;
|
|
367
|
+
};
|
|
368
|
+
imports.wbg.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
|
|
369
|
+
const ret = arg0.call(arg1);
|
|
370
|
+
return ret;
|
|
371
|
+
}, arguments) };
|
|
372
|
+
imports.wbg.__wbg_call_7cccdd69e0791ae2 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
373
|
+
const ret = arg0.call(arg1, arg2);
|
|
374
|
+
return ret;
|
|
375
|
+
}, arguments) };
|
|
376
|
+
imports.wbg.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
|
|
377
|
+
const ret = arg0.crypto;
|
|
378
|
+
return ret;
|
|
379
|
+
};
|
|
380
|
+
imports.wbg.__wbg_done_769e5ede4b31c67b = function(arg0) {
|
|
381
|
+
const ret = arg0.done;
|
|
382
|
+
return ret;
|
|
383
|
+
};
|
|
384
|
+
imports.wbg.__wbg_entries_3265d4158b33e5dc = function(arg0) {
|
|
385
|
+
const ret = Object.entries(arg0);
|
|
386
|
+
return ret;
|
|
387
|
+
};
|
|
388
|
+
imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
|
|
389
|
+
arg0.getRandomValues(arg1);
|
|
390
|
+
}, arguments) };
|
|
391
|
+
imports.wbg.__wbg_get_67b2ba62fc30de12 = function() { return handleError(function (arg0, arg1) {
|
|
392
|
+
const ret = Reflect.get(arg0, arg1);
|
|
393
|
+
return ret;
|
|
394
|
+
}, arguments) };
|
|
395
|
+
imports.wbg.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {
|
|
396
|
+
const ret = arg0[arg1 >>> 0];
|
|
397
|
+
return ret;
|
|
398
|
+
};
|
|
399
|
+
imports.wbg.__wbg_instanceof_ArrayBuffer_e14585432e3737fc = function(arg0) {
|
|
400
|
+
let result;
|
|
401
|
+
try {
|
|
402
|
+
result = arg0 instanceof ArrayBuffer;
|
|
403
|
+
} catch (_) {
|
|
404
|
+
result = false;
|
|
405
|
+
}
|
|
406
|
+
const ret = result;
|
|
407
|
+
return ret;
|
|
408
|
+
};
|
|
409
|
+
imports.wbg.__wbg_instanceof_Uint8Array_17156bcf118086a9 = function(arg0) {
|
|
410
|
+
let result;
|
|
411
|
+
try {
|
|
412
|
+
result = arg0 instanceof Uint8Array;
|
|
413
|
+
} catch (_) {
|
|
414
|
+
result = false;
|
|
415
|
+
}
|
|
416
|
+
const ret = result;
|
|
417
|
+
return ret;
|
|
418
|
+
};
|
|
419
|
+
imports.wbg.__wbg_isArray_a1eab7e0d067391b = function(arg0) {
|
|
420
|
+
const ret = Array.isArray(arg0);
|
|
421
|
+
return ret;
|
|
422
|
+
};
|
|
423
|
+
imports.wbg.__wbg_isSafeInteger_343e2beeeece1bb0 = function(arg0) {
|
|
424
|
+
const ret = Number.isSafeInteger(arg0);
|
|
425
|
+
return ret;
|
|
426
|
+
};
|
|
427
|
+
imports.wbg.__wbg_iterator_9a24c88df860dc65 = function() {
|
|
428
|
+
const ret = Symbol.iterator;
|
|
429
|
+
return ret;
|
|
430
|
+
};
|
|
431
|
+
imports.wbg.__wbg_length_a446193dc22c12f8 = function(arg0) {
|
|
432
|
+
const ret = arg0.length;
|
|
433
|
+
return ret;
|
|
434
|
+
};
|
|
435
|
+
imports.wbg.__wbg_length_e2d2a49132c1b256 = function(arg0) {
|
|
436
|
+
const ret = arg0.length;
|
|
437
|
+
return ret;
|
|
438
|
+
};
|
|
439
|
+
imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
|
|
440
|
+
const ret = arg0.msCrypto;
|
|
441
|
+
return ret;
|
|
442
|
+
};
|
|
443
|
+
imports.wbg.__wbg_new_405e22f390576ce2 = function() {
|
|
444
|
+
const ret = new Object();
|
|
445
|
+
return ret;
|
|
446
|
+
};
|
|
447
|
+
imports.wbg.__wbg_new_5e0be73521bc8c17 = function() {
|
|
448
|
+
const ret = new Map();
|
|
449
|
+
return ret;
|
|
450
|
+
};
|
|
451
|
+
imports.wbg.__wbg_new_78feb108b6472713 = function() {
|
|
452
|
+
const ret = new Array();
|
|
453
|
+
return ret;
|
|
454
|
+
};
|
|
455
|
+
imports.wbg.__wbg_new_a12002a7f91c75be = function(arg0) {
|
|
456
|
+
const ret = new Uint8Array(arg0);
|
|
457
|
+
return ret;
|
|
458
|
+
};
|
|
459
|
+
imports.wbg.__wbg_newnoargs_105ed471475aaf50 = function(arg0, arg1) {
|
|
460
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
461
|
+
return ret;
|
|
462
|
+
};
|
|
463
|
+
imports.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function(arg0, arg1, arg2) {
|
|
464
|
+
const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
|
465
|
+
return ret;
|
|
466
|
+
};
|
|
467
|
+
imports.wbg.__wbg_newwithlength_a381634e90c276d4 = function(arg0) {
|
|
468
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
469
|
+
return ret;
|
|
470
|
+
};
|
|
471
|
+
imports.wbg.__wbg_next_25feadfc0913fea9 = function(arg0) {
|
|
472
|
+
const ret = arg0.next;
|
|
473
|
+
return ret;
|
|
474
|
+
};
|
|
475
|
+
imports.wbg.__wbg_next_6574e1a8a62d1055 = function() { return handleError(function (arg0) {
|
|
476
|
+
const ret = arg0.next();
|
|
477
|
+
return ret;
|
|
478
|
+
}, arguments) };
|
|
479
|
+
imports.wbg.__wbg_node_905d3e251edff8a2 = function(arg0) {
|
|
480
|
+
const ret = arg0.node;
|
|
481
|
+
return ret;
|
|
482
|
+
};
|
|
483
|
+
imports.wbg.__wbg_now_807e54c39636c349 = function() {
|
|
484
|
+
const ret = Date.now();
|
|
485
|
+
return ret;
|
|
486
|
+
};
|
|
487
|
+
imports.wbg.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
|
|
488
|
+
const ret = arg0.process;
|
|
489
|
+
return ret;
|
|
490
|
+
};
|
|
491
|
+
imports.wbg.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
|
|
492
|
+
arg0.randomFillSync(arg1);
|
|
493
|
+
}, arguments) };
|
|
494
|
+
imports.wbg.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
|
|
495
|
+
const ret = module.require;
|
|
496
|
+
return ret;
|
|
497
|
+
}, arguments) };
|
|
498
|
+
imports.wbg.__wbg_set_37837023f3d740e8 = function(arg0, arg1, arg2) {
|
|
499
|
+
arg0[arg1 >>> 0] = arg2;
|
|
500
|
+
};
|
|
501
|
+
imports.wbg.__wbg_set_3807d5f0bfc24aa7 = function(arg0, arg1, arg2) {
|
|
502
|
+
arg0[arg1] = arg2;
|
|
503
|
+
};
|
|
504
|
+
imports.wbg.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
|
|
505
|
+
arg0.set(arg1, arg2 >>> 0);
|
|
506
|
+
};
|
|
507
|
+
imports.wbg.__wbg_set_8fc6bf8a5b1071d1 = function(arg0, arg1, arg2) {
|
|
508
|
+
const ret = arg0.set(arg1, arg2);
|
|
509
|
+
return ret;
|
|
510
|
+
};
|
|
511
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function() {
|
|
512
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
513
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
514
|
+
};
|
|
515
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function() {
|
|
516
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
517
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
518
|
+
};
|
|
519
|
+
imports.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function() {
|
|
520
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
521
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
522
|
+
};
|
|
523
|
+
imports.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function() {
|
|
524
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
525
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
526
|
+
};
|
|
527
|
+
imports.wbg.__wbg_subarray_aa9065fa9dc5df96 = function(arg0, arg1, arg2) {
|
|
528
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
529
|
+
return ret;
|
|
530
|
+
};
|
|
531
|
+
imports.wbg.__wbg_value_cd1ffa7b1ab794f1 = function(arg0) {
|
|
532
|
+
const ret = arg0.value;
|
|
533
|
+
return ret;
|
|
534
|
+
};
|
|
535
|
+
imports.wbg.__wbg_versions_c01dfd4722a88165 = function(arg0) {
|
|
536
|
+
const ret = arg0.versions;
|
|
537
|
+
return ret;
|
|
538
|
+
};
|
|
539
|
+
imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {
|
|
540
|
+
const ret = arg0;
|
|
541
|
+
return ret;
|
|
542
|
+
};
|
|
543
|
+
imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
|
|
544
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
545
|
+
return ret;
|
|
546
|
+
};
|
|
547
|
+
imports.wbg.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
|
|
548
|
+
const v = arg1;
|
|
549
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
550
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
551
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
552
|
+
};
|
|
553
|
+
imports.wbg.__wbindgen_boolean_get = function(arg0) {
|
|
554
|
+
const v = arg0;
|
|
555
|
+
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
|
|
556
|
+
return ret;
|
|
557
|
+
};
|
|
558
|
+
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
|
559
|
+
const ret = debugString(arg1);
|
|
560
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
561
|
+
const len1 = WASM_VECTOR_LEN;
|
|
562
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
563
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
564
|
+
};
|
|
565
|
+
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
566
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
567
|
+
return ret;
|
|
568
|
+
};
|
|
569
|
+
imports.wbg.__wbindgen_in = function(arg0, arg1) {
|
|
570
|
+
const ret = arg0 in arg1;
|
|
571
|
+
return ret;
|
|
572
|
+
};
|
|
573
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
574
|
+
const table = wasm.__wbindgen_export_4;
|
|
575
|
+
const offset = table.grow(4);
|
|
576
|
+
table.set(0, undefined);
|
|
577
|
+
table.set(offset + 0, undefined);
|
|
578
|
+
table.set(offset + 1, null);
|
|
579
|
+
table.set(offset + 2, true);
|
|
580
|
+
table.set(offset + 3, false);
|
|
581
|
+
;
|
|
582
|
+
};
|
|
583
|
+
imports.wbg.__wbindgen_is_bigint = function(arg0) {
|
|
584
|
+
const ret = typeof(arg0) === 'bigint';
|
|
585
|
+
return ret;
|
|
586
|
+
};
|
|
587
|
+
imports.wbg.__wbindgen_is_function = function(arg0) {
|
|
588
|
+
const ret = typeof(arg0) === 'function';
|
|
589
|
+
return ret;
|
|
590
|
+
};
|
|
591
|
+
imports.wbg.__wbindgen_is_object = function(arg0) {
|
|
592
|
+
const val = arg0;
|
|
593
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
594
|
+
return ret;
|
|
595
|
+
};
|
|
596
|
+
imports.wbg.__wbindgen_is_string = function(arg0) {
|
|
597
|
+
const ret = typeof(arg0) === 'string';
|
|
598
|
+
return ret;
|
|
599
|
+
};
|
|
600
|
+
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
|
601
|
+
const ret = arg0 === undefined;
|
|
602
|
+
return ret;
|
|
603
|
+
};
|
|
604
|
+
imports.wbg.__wbindgen_jsval_eq = function(arg0, arg1) {
|
|
605
|
+
const ret = arg0 === arg1;
|
|
606
|
+
return ret;
|
|
607
|
+
};
|
|
608
|
+
imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
|
|
609
|
+
const ret = arg0 == arg1;
|
|
610
|
+
return ret;
|
|
611
|
+
};
|
|
612
|
+
imports.wbg.__wbindgen_memory = function() {
|
|
613
|
+
const ret = wasm.memory;
|
|
614
|
+
return ret;
|
|
615
|
+
};
|
|
616
|
+
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
|
617
|
+
const obj = arg1;
|
|
618
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
619
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
620
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
621
|
+
};
|
|
622
|
+
imports.wbg.__wbindgen_number_new = function(arg0) {
|
|
623
|
+
const ret = arg0;
|
|
624
|
+
return ret;
|
|
625
|
+
};
|
|
626
|
+
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
|
627
|
+
const obj = arg1;
|
|
628
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
629
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
630
|
+
var len1 = WASM_VECTOR_LEN;
|
|
631
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
632
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
633
|
+
};
|
|
634
|
+
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
635
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
636
|
+
return ret;
|
|
637
|
+
};
|
|
638
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
639
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
return imports;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
function __wbg_init_memory(imports, memory) {
|
|
646
|
+
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
function __wbg_finalize_init(instance, module) {
|
|
650
|
+
wasm = instance.exports;
|
|
651
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
652
|
+
cachedDataViewMemory0 = null;
|
|
653
|
+
cachedUint8ArrayMemory0 = null;
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
wasm.__wbindgen_start();
|
|
657
|
+
return wasm;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
function initSync(module) {
|
|
661
|
+
if (wasm !== undefined) return wasm;
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
if (typeof module !== 'undefined') {
|
|
665
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
666
|
+
({module} = module)
|
|
667
|
+
} else {
|
|
668
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
const imports = __wbg_get_imports();
|
|
673
|
+
|
|
674
|
+
__wbg_init_memory(imports);
|
|
675
|
+
|
|
676
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
677
|
+
module = new WebAssembly.Module(module);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
681
|
+
|
|
682
|
+
return __wbg_finalize_init(instance, module);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
async function __wbg_init(module_or_path) {
|
|
686
|
+
if (wasm !== undefined) return wasm;
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
if (typeof module_or_path !== 'undefined') {
|
|
690
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
691
|
+
({module_or_path} = module_or_path)
|
|
692
|
+
} else {
|
|
693
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
if (typeof module_or_path === 'undefined') {
|
|
698
|
+
module_or_path = new URL('unisights_core_bg.wasm', import.meta.url);
|
|
699
|
+
}
|
|
700
|
+
const imports = __wbg_get_imports();
|
|
701
|
+
|
|
702
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
703
|
+
module_or_path = fetch(module_or_path);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
__wbg_init_memory(imports);
|
|
707
|
+
|
|
708
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
709
|
+
|
|
710
|
+
return __wbg_finalize_init(instance, module);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
export { initSync };
|
|
714
|
+
export default __wbg_init;
|
|
Binary file
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_tracker_free: (a: number, b: number) => void;
|
|
5
|
+
export const tracker_clearEvents: (a: number) => void;
|
|
6
|
+
export const tracker_exportEncryptedPayload: (a: number) => [number, number, number];
|
|
7
|
+
export const tracker_logClick: (a: number, b: number, c: number) => void;
|
|
8
|
+
export const tracker_logCustomEvent: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
9
|
+
export const tracker_logEntryPage: (a: number, b: number, c: number) => void;
|
|
10
|
+
export const tracker_logExitPage: (a: number, b: number, c: number) => void;
|
|
11
|
+
export const tracker_logPageView: (a: number, b: number, c: number) => void;
|
|
12
|
+
export const 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;
|
|
13
|
+
export const tracker_new: () => number;
|
|
14
|
+
export const tracker_setEncryptionKey: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
15
|
+
export const tracker_setPageUrl: (a: number, b: number, c: number) => void;
|
|
16
|
+
export const tracker_setSessionInfo: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any, i: any) => void;
|
|
17
|
+
export const tracker_tick: (a: number, b: number) => void;
|
|
18
|
+
export const tracker_updateScroll: (a: number, b: number) => void;
|
|
19
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
20
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
21
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
22
|
+
export const __externref_table_alloc: () => number;
|
|
23
|
+
export const __wbindgen_export_4: WebAssembly.Table;
|
|
24
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
25
|
+
export const __wbindgen_start: () => void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
unisights?: Unisights;
|
|
4
|
+
unisightsq?: Array<() => void>;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
interface Unisights {
|
|
8
|
+
init: (config: Partial<UnisightsConfig>) => Promise<void>;
|
|
9
|
+
registerEvent: (eventType: string, handler: EventHandler) => (name: string, data: any) => void;
|
|
10
|
+
flushNow: () => void;
|
|
11
|
+
log: (name: string, data: any) => void;
|
|
12
|
+
}
|
|
13
|
+
type EventHandler = ((event: Event) => void) | (() => (event: Event) => void);
|
|
14
|
+
interface UnisightsConfig {
|
|
15
|
+
endpoint: string;
|
|
16
|
+
insightsId?: string;
|
|
17
|
+
debug?: boolean;
|
|
18
|
+
flushIntervalMs?: number;
|
|
19
|
+
trackPageViews?: boolean;
|
|
20
|
+
trackClicks?: boolean;
|
|
21
|
+
trackScroll?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function init(userConfig?: Partial<UnisightsConfig>): Promise<void>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var o,u=0,A=null;function O(){return(A===null||A.byteLength===0)&&(A=new Uint8Array(o.memory.buffer)),A}var U=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},ke=typeof U.encodeInto=="function"?function(t,e){return U.encodeInto(t,e)}:function(t,e){let n=U.encode(t);return e.set(n),{read:t.length,written:n.length}};function f(t,e,n){if(n===void 0){let a=U.encode(t),l=e(a.length,1)>>>0;return O().subarray(l,l+a.length).set(a),u=a.length,l}let r=t.length,i=e(r,1)>>>0,c=O(),s=0;for(;s<r;s++){let a=t.charCodeAt(s);if(a>127)break;c[i+s]=a}if(s!==r){s!==0&&(t=t.slice(s)),i=n(i,r,r=s+t.length*3,1)>>>0;let a=O().subarray(i+s,i+r),l=ke(t,a);s+=l.written,i=n(i,r,s,1)>>>0}return u=s,i}var v=null;function b(){return(v===null||v.buffer.detached===!0||v.buffer.detached===void 0&&v.buffer!==o.memory.buffer)&&(v=new DataView(o.memory.buffer)),v}function k(t){let e=o.__externref_table_alloc();return o.__wbindgen_export_4.set(e,t),e}function y(t,e){try{return t.apply(this,e)}catch(n){let r=k(n);o.__wbindgen_exn_store(r)}}var ce=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&ce.decode();function M(t,e){return t=t>>>0,ce.decode(O().subarray(t,t+e))}function h(t){return t==null}function q(t){let e=typeof t;if(e=="number"||e=="boolean"||t==null)return`${t}`;if(e=="string")return`"${t}"`;if(e=="symbol"){let i=t.description;return i==null?"Symbol":`Symbol(${i})`}if(e=="function"){let i=t.name;return typeof i=="string"&&i.length>0?`Function(${i})`:"Function"}if(Array.isArray(t)){let i=t.length,c="[";i>0&&(c+=q(t[0]));for(let s=1;s<i;s++)c+=", "+q(t[s]);return c+="]",c}let n=/\[object ([^\]]+)\]/.exec(toString.call(t)),r;if(n&&n.length>1)r=n[1];else return toString.call(t);if(r=="Object")try{return"Object("+JSON.stringify(t)+")"}catch{return"Object"}return t instanceof Error?`${t.name}: ${t.message}
|
|
2
|
+
${t.stack}`:r}function oe(t){let e=o.__wbindgen_export_4.get(t);return o.__externref_table_dealloc(t),e}var se=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>o.__wbg_tracker_free(t>>>0,1)),N=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,se.unregister(this),e}free(){let e=this.__destroy_into_raw();o.__wbg_tracker_free(e,0)}clearEvents(){o.tracker_clearEvents(this.__wbg_ptr)}setPageUrl(e){let n=f(e,o.__wbindgen_malloc,o.__wbindgen_realloc),r=u;o.tracker_setPageUrl(this.__wbg_ptr,n,r)}logExitPage(e){let n=f(e,o.__wbindgen_malloc,o.__wbindgen_realloc),r=u;o.tracker_logExitPage(this.__wbg_ptr,n,r)}logPageView(e){let n=f(e,o.__wbindgen_malloc,o.__wbindgen_realloc),r=u;o.tracker_logPageView(this.__wbg_ptr,n,r)}logWebVital(e,n,r,i,c,s,a){let l=f(e,o.__wbindgen_malloc,o.__wbindgen_realloc),_=u,g=f(r,o.__wbindgen_malloc,o.__wbindgen_realloc),S=u,P=f(i,o.__wbindgen_malloc,o.__wbindgen_realloc),R=u,V=f(a,o.__wbindgen_malloc,o.__wbindgen_realloc),j=u;o.tracker_logWebVital(this.__wbg_ptr,l,_,n,g,S,P,R,c,s,V,j)}updateScroll(e){o.tracker_updateScroll(this.__wbg_ptr,e)}logEntryPage(e){let n=f(e,o.__wbindgen_malloc,o.__wbindgen_realloc),r=u;o.tracker_logEntryPage(this.__wbg_ptr,n,r)}logCustomEvent(e,n){let r=f(e,o.__wbindgen_malloc,o.__wbindgen_realloc),i=u,c=f(n,o.__wbindgen_malloc,o.__wbindgen_realloc),s=u;o.tracker_logCustomEvent(this.__wbg_ptr,r,i,c,s)}setSessionInfo(e,n,r,i,c){let s=f(e,o.__wbindgen_malloc,o.__wbindgen_realloc),a=u,l=f(n,o.__wbindgen_malloc,o.__wbindgen_realloc),_=u,g=f(r,o.__wbindgen_malloc,o.__wbindgen_realloc),S=u;o.tracker_setSessionInfo(this.__wbg_ptr,s,a,l,_,g,S,i,c)}setEncryptionKey(e,n){let r=f(e,o.__wbindgen_malloc,o.__wbindgen_realloc),i=u,c=f(n,o.__wbindgen_malloc,o.__wbindgen_realloc),s=u;o.tracker_setEncryptionKey(this.__wbg_ptr,r,i,c,s)}exportEncryptedPayload(){let e=o.tracker_exportEncryptedPayload(this.__wbg_ptr);if(e[2])throw oe(e[1]);return oe(e[0])}constructor(){let e=o.tracker_new();return this.__wbg_ptr=e>>>0,se.register(this,this.__wbg_ptr,this),this}tick(e){o.tracker_tick(this.__wbg_ptr,e)}logClick(e,n){o.tracker_logClick(this.__wbg_ptr,e,n)}};async function Ce(t,e){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,e)}catch(r){if(t.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",r);else throw r}let n=await t.arrayBuffer();return await WebAssembly.instantiate(n,e)}else{let n=await WebAssembly.instantiate(t,e);return n instanceof WebAssembly.Instance?{instance:n,module:t}:n}}function Le(){let t={};return t.wbg={},t.wbg.__wbg_String_eecc4a11987127d6=function(e,n){let r=String(n),i=f(r,o.__wbindgen_malloc,o.__wbindgen_realloc),c=u;b().setInt32(e+4*1,c,!0),b().setInt32(e+4*0,i,!0)},t.wbg.__wbg_buffer_609cc3eee51ed158=function(e){return e.buffer},t.wbg.__wbg_call_672a4d21634d4a24=function(){return y(function(e,n){return e.call(n)},arguments)},t.wbg.__wbg_call_7cccdd69e0791ae2=function(){return y(function(e,n,r){return e.call(n,r)},arguments)},t.wbg.__wbg_crypto_574e78ad8b13b65f=function(e){return e.crypto},t.wbg.__wbg_done_769e5ede4b31c67b=function(e){return e.done},t.wbg.__wbg_entries_3265d4158b33e5dc=function(e){return Object.entries(e)},t.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e=function(){return y(function(e,n){e.getRandomValues(n)},arguments)},t.wbg.__wbg_get_67b2ba62fc30de12=function(){return y(function(e,n){return Reflect.get(e,n)},arguments)},t.wbg.__wbg_get_b9b93047fe3cf45b=function(e,n){return e[n>>>0]},t.wbg.__wbg_instanceof_ArrayBuffer_e14585432e3737fc=function(e){let n;try{n=e instanceof ArrayBuffer}catch{n=!1}return n},t.wbg.__wbg_instanceof_Uint8Array_17156bcf118086a9=function(e){let n;try{n=e instanceof Uint8Array}catch{n=!1}return n},t.wbg.__wbg_isArray_a1eab7e0d067391b=function(e){return Array.isArray(e)},t.wbg.__wbg_isSafeInteger_343e2beeeece1bb0=function(e){return Number.isSafeInteger(e)},t.wbg.__wbg_iterator_9a24c88df860dc65=function(){return Symbol.iterator},t.wbg.__wbg_length_a446193dc22c12f8=function(e){return e.length},t.wbg.__wbg_length_e2d2a49132c1b256=function(e){return e.length},t.wbg.__wbg_msCrypto_a61aeb35a24c1329=function(e){return e.msCrypto},t.wbg.__wbg_new_405e22f390576ce2=function(){return new Object},t.wbg.__wbg_new_5e0be73521bc8c17=function(){return new Map},t.wbg.__wbg_new_78feb108b6472713=function(){return new Array},t.wbg.__wbg_new_a12002a7f91c75be=function(e){return new Uint8Array(e)},t.wbg.__wbg_newnoargs_105ed471475aaf50=function(e,n){return new Function(M(e,n))},t.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a=function(e,n,r){return new Uint8Array(e,n>>>0,r>>>0)},t.wbg.__wbg_newwithlength_a381634e90c276d4=function(e){return new Uint8Array(e>>>0)},t.wbg.__wbg_next_25feadfc0913fea9=function(e){return e.next},t.wbg.__wbg_next_6574e1a8a62d1055=function(){return y(function(e){return e.next()},arguments)},t.wbg.__wbg_node_905d3e251edff8a2=function(e){return e.node},t.wbg.__wbg_now_807e54c39636c349=function(){return Date.now()},t.wbg.__wbg_process_dc0fbacc7c1c06f7=function(e){return e.process},t.wbg.__wbg_randomFillSync_ac0988aba3254290=function(){return y(function(e,n){e.randomFillSync(n)},arguments)},t.wbg.__wbg_require_60cc747a6bc5215a=function(){return y(function(){return module.require},arguments)},t.wbg.__wbg_set_37837023f3d740e8=function(e,n,r){e[n>>>0]=r},t.wbg.__wbg_set_3807d5f0bfc24aa7=function(e,n,r){e[n]=r},t.wbg.__wbg_set_65595bdd868b3009=function(e,n,r){e.set(n,r>>>0)},t.wbg.__wbg_set_8fc6bf8a5b1071d1=function(e,n,r){return e.set(n,r)},t.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07=function(){let e=typeof global>"u"?null:global;return h(e)?0:k(e)},t.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0=function(){let e=typeof globalThis>"u"?null:globalThis;return h(e)?0:k(e)},t.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819=function(){let e=typeof self>"u"?null:self;return h(e)?0:k(e)},t.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40=function(){let e=typeof window>"u"?null:window;return h(e)?0:k(e)},t.wbg.__wbg_subarray_aa9065fa9dc5df96=function(e,n,r){return e.subarray(n>>>0,r>>>0)},t.wbg.__wbg_value_cd1ffa7b1ab794f1=function(e){return e.value},t.wbg.__wbg_versions_c01dfd4722a88165=function(e){return e.versions},t.wbg.__wbindgen_bigint_from_i64=function(e){return e},t.wbg.__wbindgen_bigint_from_u64=function(e){return BigInt.asUintN(64,e)},t.wbg.__wbindgen_bigint_get_as_i64=function(e,n){let r=n,i=typeof r=="bigint"?r:void 0;b().setBigInt64(e+8*1,h(i)?BigInt(0):i,!0),b().setInt32(e+4*0,!h(i),!0)},t.wbg.__wbindgen_boolean_get=function(e){let n=e;return typeof n=="boolean"?n?1:0:2},t.wbg.__wbindgen_debug_string=function(e,n){let r=q(n),i=f(r,o.__wbindgen_malloc,o.__wbindgen_realloc),c=u;b().setInt32(e+4*1,c,!0),b().setInt32(e+4*0,i,!0)},t.wbg.__wbindgen_error_new=function(e,n){return new Error(M(e,n))},t.wbg.__wbindgen_in=function(e,n){return e in n},t.wbg.__wbindgen_init_externref_table=function(){let e=o.__wbindgen_export_4,n=e.grow(4);e.set(0,void 0),e.set(n+0,void 0),e.set(n+1,null),e.set(n+2,!0),e.set(n+3,!1)},t.wbg.__wbindgen_is_bigint=function(e){return typeof e=="bigint"},t.wbg.__wbindgen_is_function=function(e){return typeof e=="function"},t.wbg.__wbindgen_is_object=function(e){let n=e;return typeof n=="object"&&n!==null},t.wbg.__wbindgen_is_string=function(e){return typeof e=="string"},t.wbg.__wbindgen_is_undefined=function(e){return e===void 0},t.wbg.__wbindgen_jsval_eq=function(e,n){return e===n},t.wbg.__wbindgen_jsval_loose_eq=function(e,n){return e==n},t.wbg.__wbindgen_memory=function(){return o.memory},t.wbg.__wbindgen_number_get=function(e,n){let r=n,i=typeof r=="number"?r:void 0;b().setFloat64(e+8*1,h(i)?0:i,!0),b().setInt32(e+4*0,!h(i),!0)},t.wbg.__wbindgen_number_new=function(e){return e},t.wbg.__wbindgen_string_get=function(e,n){let r=n,i=typeof r=="string"?r:void 0;var c=h(i)?0:f(i,o.__wbindgen_malloc,o.__wbindgen_realloc),s=u;b().setInt32(e+4*1,s,!0),b().setInt32(e+4*0,c,!0)},t.wbg.__wbindgen_string_new=function(e,n){return M(e,n)},t.wbg.__wbindgen_throw=function(e,n){throw new Error(M(e,n))},t}function xe(t,e){return o=t.exports,ae.__wbindgen_wasm_module=e,v=null,A=null,o.__wbindgen_start(),o}async function ae(t){if(o!==void 0)return o;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module_or_path:t}=t:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof t>"u"&&(t=new URL("unisights_core_bg.wasm",import.meta.url));let e=Le();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:n,module:r}=await Ce(await t,e);return xe(n,r)}var le=ae;var he=-1,T=t=>{addEventListener("pageshow",e=>{e.persisted&&(he=e.timeStamp,t(e))},!0)},w=(t,e,n,r)=>{let i,c;return s=>{e.value>=0&&(s||r)&&(c=e.value-(i??0),(c||i===void 0)&&(i=e.value,e.delta=c,e.rating=((a,l)=>a>l[1]?"poor":a>l[0]?"needs-improvement":"good")(e.value,n),t(e)))}},Z=t=>{requestAnimationFrame(()=>requestAnimationFrame(()=>t()))},ee=()=>{let t=performance.getEntriesByType("navigation")[0];if(t&&t.responseStart>0&&t.responseStart<performance.now())return t},C=()=>ee()?.activationStart??0,p=(t,e=-1)=>{let n=ee(),r="navigate";return he>=0?r="back-forward-cache":n&&(document.prerendering||C()>0?r="prerender":document.wasDiscarded?r="restore":n.type&&(r=n.type.replace(/_/g,"-"))),{name:t,value:e,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:r}},$=new WeakMap;function te(t,e){return $.get(t)||$.set(t,new e),$.get(t)}var J=class{t;i=0;o=[];h(e){if(e.hadRecentInput)return;let n=this.o[0],r=this.o.at(-1);this.i&&n&&r&&e.startTime-r.startTime<1e3&&e.startTime-n.startTime<5e3?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),this.t?.(e)}},L=(t,e,n={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(t)){let r=new PerformanceObserver(i=>{Promise.resolve().then(()=>{e(i.getEntries())})});return r.observe({type:t,buffered:!0,...n}),r}}catch{}},ne=t=>{let e=!1;return()=>{e||(t(),e=!0)}},I=-1,me=new Set,ge=()=>document.visibilityState!=="hidden"||document.prerendering?1/0:0,z=t=>{if(document.visibilityState==="hidden"){if(t.type==="visibilitychange")for(let e of me)e();isFinite(I)||(I=t.type==="visibilitychange"?t.timeStamp:0,removeEventListener("prerenderingchange",z,!0))}},F=()=>{if(I<0){let t=C();I=(document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter(n=>n.name==="hidden"&&n.startTime>t)[0]?.startTime)??ge(),addEventListener("visibilitychange",z,!0),addEventListener("prerenderingchange",z,!0),T(()=>{setTimeout(()=>{I=ge()})})}return{get firstHiddenTime(){return I},onHidden(t){me.add(t)}}},D=t=>{document.prerendering?addEventListener("prerenderingchange",()=>t(),!0):t()},_e=[1800,3e3],re=(t,e={})=>{D(()=>{let n=F(),r,i=p("FCP"),c=L("paint",s=>{for(let a of s)a.name==="first-contentful-paint"&&(c.disconnect(),a.startTime<n.firstHiddenTime&&(i.value=Math.max(a.startTime-C(),0),i.entries.push(a),r(!0)))});c&&(r=w(t,i,_e,e.reportAllChanges),T(s=>{i=p("FCP"),r=w(t,i,_e,e.reportAllChanges),Z(()=>{i.value=performance.now()-s.timeStamp,r(!0)})}))})},ue=[.1,.25],ye=(t,e={})=>{let n=F();re(ne(()=>{let r,i=p("CLS",0),c=te(e,J),s=l=>{for(let _ of l)c.h(_);c.i>i.value&&(i.value=c.i,i.entries=c.o,r())},a=L("layout-shift",s);a&&(r=w(t,i,ue,e.reportAllChanges),n.onHidden(()=>{s(a.takeRecords()),r(!0)}),T(()=>{c.i=0,i=p("CLS",0),r=w(t,i,ue,e.reportAllChanges),Z(()=>r())}),setTimeout(r))}))},ve=0,G=1/0,W=0,Oe=t=>{for(let e of t)e.interactionId&&(G=Math.min(G,e.interactionId),W=Math.max(W,e.interactionId),ve=W?(W-G)/7+1:0)},K,de=()=>K?ve:performance.interactionCount??0,Ue=()=>{"interactionCount"in performance||K||(K=L("event",Oe,{type:"event",buffered:!0,durationThreshold:0}))},fe=0,Y=class{u=[];l=new Map;m;p;v(){fe=de(),this.u.length=0,this.l.clear()}L(){let e=Math.min(this.u.length-1,Math.floor((de()-fe)/50));return this.u[e]}h(e){if(this.m?.(e),!e.interactionId&&e.entryType!=="first-input")return;let n=this.u.at(-1),r=this.l.get(e.interactionId);if(r||this.u.length<10||e.duration>n.P){if(r?e.duration>r.P?(r.entries=[e],r.P=e.duration):e.duration===r.P&&e.startTime===r.entries[0].startTime&&r.entries.push(e):(r={id:e.interactionId,entries:[e],P:e.duration},this.l.set(r.id,r),this.u.push(r)),this.u.sort((i,c)=>c.P-i.P),this.u.length>10){let i=this.u.splice(10);for(let c of i)this.l.delete(c.id)}this.p?.(r)}}},Se=t=>{let e=globalThis.requestIdleCallback||setTimeout;document.visibilityState==="hidden"?t():(t=ne(t),addEventListener("visibilitychange",t,{once:!0,capture:!0}),e(()=>{t(),removeEventListener("visibilitychange",t,{capture:!0})}))},be=[200,500],Ie=(t,e={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;let n=F();D(()=>{Ue();let r,i=p("INP"),c=te(e,Y),s=l=>{Se(()=>{for(let g of l)c.h(g);let _=c.L();_&&_.P!==i.value&&(i.value=_.P,i.entries=_.entries,r())})},a=L("event",s,{durationThreshold:e.durationThreshold??40});r=w(t,i,be,e.reportAllChanges),a&&(a.observe({type:"first-input",buffered:!0}),n.onHidden(()=>{s(a.takeRecords()),r(!0)}),T(()=>{c.v(),i=p("INP"),r=w(t,i,be,e.reportAllChanges)}))})},Q=class{m;h(e){this.m?.(e)}},we=[2500,4e3],Te=(t,e={})=>{D(()=>{let n=F(),r,i=p("LCP"),c=te(e,Q),s=l=>{e.reportAllChanges||(l=l.slice(-1));for(let _ of l)c.h(_),_.startTime<n.firstHiddenTime&&(i.value=Math.max(_.startTime-C(),0),i.entries=[_],r())},a=L("largest-contentful-paint",s);if(a){r=w(t,i,we,e.reportAllChanges);let l=ne(()=>{s(a.takeRecords()),a.disconnect(),r(!0)}),_=g=>{g.isTrusted&&(Se(l),removeEventListener(g.type,_,{capture:!0}))};for(let g of["keydown","click","visibilitychange"])addEventListener(g,_,{capture:!0});T(g=>{i=p("LCP"),r=w(t,i,we,e.reportAllChanges),Z(()=>{i.value=performance.now()-g.timeStamp,r(!0)})})}})},pe=[800,1800],X=t=>{document.prerendering?D(()=>X(t)):document.readyState!=="complete"?addEventListener("load",()=>X(t),!0):setTimeout(t)},Ee=(t,e={})=>{let n=p("TTFB"),r=w(t,n,pe,e.reportAllChanges);X(()=>{let i=ee();i&&(n.value=Math.max(i.responseStart-C(),0),n.entries=[i],r(!0),T(()=>{n=p("TTFB",0),r=w(t,n,pe,e.reportAllChanges),r(!0)}))})};var Ne=()=>{let e=document.getElementById("unisights-script")?.src||"";return e.substring(0,e.lastIndexOf("/"))||""},We={endpoint:"",debug:!1,flushIntervalMs:15e3,trackPageViews:!0,trackClicks:!0,trackScroll:!0};await le(`${Ne()}/pkg/unisights_core_bg.wasm`);function Fe(t,e){let n=r=>{try{t.logWebVital(r.name,r.value,r.id,r.rating,r.delta,r.entries?.length||0,r.navigationType||"navigate"),e.debug&&console.log("[Insights] - Web Vital logged:",r)}catch(i){console.error("[Insights] - Web Vital Error:",i)}};[ye,Ie,Te,re,Ee].forEach(r=>r(n))}function De(){let t=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],e={},n=new URLSearchParams(window.location.search);for(let r of t){let i=n.get(r)||sessionStorage.getItem(`_us_${r}`);i&&(e[r]=i,sessionStorage.setItem(`_us_${r}`,i))}return e}function He(){let t=navigator.userAgent,e=navigator.platform,n=/Win/.test(e)?"Windows":/Mac/.test(e)?"macOS":/Linux/.test(e)?"Linux":/Android/.test(t)?"Android":/iPhone|iPad|iPod/.test(t)?"iOS":"Unknown",r=/Mobi|Android/i.test(t)?"Mobile":"Desktop";return{userAgent:t,platform:e,os:n,screenWidth:screen.width,screenHeight:screen.height,deviceType:r}}var Be=/bot|crawler|spider|crawling/i.test(navigator.userAgent),x="__ua_session",Re=30*60*1e3;function Ve(){let t=Date.now(),e=localStorage.getItem(x);if(e){let r=JSON.parse(e);if(t-r.lastActivity<Re)return r.lastActivity=t,localStorage.setItem(x,JSON.stringify(r)),r.sessionId}let n={sessionId:crypto.randomUUID(),startedAt:t,lastActivity:t};return localStorage.setItem(x,JSON.stringify(n)),n.sessionId}function H(){let t=localStorage.getItem(x);if(!t)return;let e=JSON.parse(t);e.lastActivity=Date.now(),localStorage.setItem(x,JSON.stringify(e))}var Pe=!1,je,E=location.href;async function qe(t={}){if(Pe)return;Pe=!0;let e=document.querySelector("script[data-insights-id]"),n=e?.getAttribute("data-insights-id"),r=e?.getAttribute("data-secret"),i=e?.getAttribute("data-salt");if(!n)throw new Error("Missing data-insights-id");let c={};try{c=JSON.parse(e?.getAttribute("data-analytics-config")||"{}")}catch(d){console.error("[Insights] - Config parse error:",d)}if(Be)return;let s={...We,...c,...t,insightsId:n},a=new N,l=Ve(),_=performance.now(),g=!1;a.setEncryptionKey(r||"",i||""),a.setSessionInfo(s.insightsId,l,location.href,De(),He()),Fe(a,s),s.debug&&console.log("[Insights] - Session ID:",l);let S=new Map;if(s.trackClicks){let d=m=>{a.logClick(m.clientX,m.clientY),H(),g=!0};window.addEventListener("click",d),S.set("click",d)}if(s.trackScroll){let d=-50,m=()=>{let ie=performance.now();if(ie-d<50)return;d=ie;let Ae=(window.scrollY+window.innerHeight)/(document.body.scrollHeight||1)*100;a.updateScroll(Ae),H(),g=!0};window.addEventListener("scroll",m),S.set("scroll",m)}s.trackPageViews&&(a.logEntryPage(location.href),a.logPageView(location.href),s.debug&&console.log("[Insights] - Entry page event:",location.href),g=!0);let P=()=>{let d=location.href;d!==E&&(g&&(B(a,s),g=!1),E=d,s.trackPageViews&&(a.logPageView(E),s.debug&&console.log("[Insights] - Page view event:",E),H(),g=!0))};window.addEventListener("popstate",P);let R=history.pushState,V=history.replaceState;history.pushState=function(...d){R.apply(this,d),P()},history.replaceState=function(...d){V.apply(this,d),P()};let j=()=>{a.logExitPage(E),s.debug&&console.log("[Insights] - Exit page (via pagehide) event:",E),B(a,s,!0),H(),g=!1};window.addEventListener("pagehide",j),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&(B(a,s,!0),g=!1)}),je=window.setInterval(()=>{let d=performance.now();a.tick((d-_)/1e3),_=d,g&&(B(a,s),g=!1)},s.flushIntervalMs),Array.isArray(window.unisightsq)&&window.unisightsq.splice(0).forEach(d=>{try{d()}catch(m){console.error("[Insights] - Queue Error:",m)}})}function B(t,e,n=!1){try{let r=t.exportEncryptedPayload();if(e.debug&&console.log("[Insights] - Payload:",r),!r||r instanceof Error)return;let i=r instanceof Map?Object.fromEntries(r.entries()):r,c=new Blob([JSON.stringify(i)],{type:"application/json"}),s=navigator.sendBeacon(e.endpoint,c);e.debug&&console.log("[Insights] - Encrypted payload sent:",{success:s,length:c.size}),s&&t.clearEvents()}catch(r){e.debug&&console.error("[Insights] - Send Error:",r)}}typeof window<"u"&&(window.unisightsq||=[],window.unisights={init:qe,log:()=>console.warn("[Insights] - Call init() first"),flushNow:()=>{},registerEvent:()=>()=>{}});export{qe as init};
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@unisights/analytics",
|
|
3
|
+
"description": "Unisights browser event tracking script",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"main": "dist/unisights.min.js",
|
|
6
|
+
"module": "dist/unisights.min.js",
|
|
7
|
+
"types": "dist/unisights.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/unisights.min.js",
|
|
11
|
+
"types": "./dist/unisights.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Pradeep Arul",
|
|
16
|
+
"email": "pradeeparul2@gmail.com",
|
|
17
|
+
"url": "https://github.com/Pradeeparul2"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc && node build.mjs && cpx \"core/pkg/**/*\" dist/pkg",
|
|
21
|
+
"dev:build": "tsc && esbuild src/unisights.ts --bundle --outfile=dist/unisights.js --format=esm --sourcemap --loader:.wasm=binary --define:process.env.NODE_ENV='\"development\"' && cpx \"core/pkg/**/*\" dist/pkg",
|
|
22
|
+
"dev:watch": "node build.mjs --watch --define:process.env.NODE_ENV='\"development\"'",
|
|
23
|
+
"serve": "live-server dist --no-browser --port=9005 --watch=dist --cors",
|
|
24
|
+
"dev": "concurrently \"pnpm dev:watch\" \"pnpm serve\""
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"web-vitals": "^5.0.3"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"concurrently": "^9.2.0",
|
|
31
|
+
"cpx": "^1.5.0",
|
|
32
|
+
"dotenv": "^17.0.1",
|
|
33
|
+
"esbuild": "^0.23.0",
|
|
34
|
+
"live-server": "^1.2.2",
|
|
35
|
+
"typescript": "^5.5.0"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist/**/*",
|
|
39
|
+
"LICENSE",
|
|
40
|
+
"README.md"
|
|
41
|
+
],
|
|
42
|
+
"sideEffects": false,
|
|
43
|
+
"engines": {
|
|
44
|
+
"browser": "*"
|
|
45
|
+
},
|
|
46
|
+
"license": "MIT"
|
|
47
|
+
}
|