@orbithunt/tracker 1.0.0-beta.2

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 ADDED
@@ -0,0 +1,9 @@
1
+ Copyright (c) 2024 OrbitHunt. All rights reserved.
2
+
3
+ This software is proprietary and confidential. You may use the published
4
+ npm packages (@orbithunt/tracker, @orbithunt/react) in your own projects,
5
+ but you may not copy, modify, distribute, reverse-engineer, or create
6
+ derivative works of the source code without prior written permission
7
+ from OrbitHunt.
8
+
9
+ For licensing inquiries, contact: support@orbithunt.com
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # @orbithunt/tracker
2
+
3
+ Lightweight CDN loader for [OrbitHunt](https://orbithunt.com) session recording. Injects the tracker script tag — same behavior as the manual `<script>` tag, but installable via npm.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @orbithunt/tracker
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```javascript
14
+ import { load } from '@orbithunt/tracker';
15
+
16
+ load('your-tracker-id');
17
+ ```
18
+
19
+ That's it. The CDN script handles everything: visitor IDs, session management, recording, batching, retry logic, and flushing on page unload.
20
+
21
+ ## React / Next.js
22
+
23
+ Use the companion package for a React component:
24
+
25
+ ```bash
26
+ npm install @orbithunt/tracker @orbithunt/react
27
+ ```
28
+
29
+ See [@orbithunt/react](https://www.npmjs.com/package/@orbithunt/react) for details.
30
+
31
+ ## Vue / Svelte / Angular
32
+
33
+ ```javascript
34
+ // main.js or equivalent entry point
35
+ import { load } from '@orbithunt/tracker';
36
+
37
+ load('your-tracker-id');
38
+ ```
39
+
40
+ ## Manual Script Tag
41
+
42
+ If you prefer not to use npm, add this to your HTML:
43
+
44
+ ```html
45
+ <script
46
+ src="https://script.orbithunt.com/js/tracker.js"
47
+ data-tracker-id="your-tracker-id"
48
+ async
49
+ ></script>
50
+ ```
51
+
52
+ The npm package does exactly this under the hood.
53
+
54
+ ## Configuration
55
+
56
+ | Option | Type | Required | Default | Description |
57
+ |--------|------|----------|---------|-------------|
58
+ | `trackerId` | `string` | Yes | — | First argument to `load()` |
59
+ | `ingestUrl` | `string` | No | Built-in default | Override the ingest endpoint URL |
60
+ | `rrwebCdn` | `string` | No | Built-in default | Override the rrweb CDN URL |
61
+
62
+ ```javascript
63
+ load('your-tracker-id', {
64
+ ingestUrl: 'https://your-custom-endpoint.com/v1/ingest',
65
+ });
66
+ ```
67
+
68
+ ## API Reference
69
+
70
+ ### `load(trackerId, options?): void`
71
+
72
+ Inject the OrbitHunt tracker script tag. Safe to call on the server (no-op). Prevents double-loading automatically.
73
+
74
+ ### `unload(): void`
75
+
76
+ Remove the tracker script tag from the DOM. Safe to call on the server (no-op).
77
+
78
+ ## SSR
79
+
80
+ Safe to import and call on the server. `load()` and `unload()` are no-ops when `window` is undefined.
81
+
82
+ ## Privacy
83
+
84
+ - All input fields are masked at the browser level — sensitive data never leaves the page
85
+ - No cookies or cross-site tracking
86
+ - IP addresses are anonymized server-side
87
+ - Built-in consent banner (configurable per tracker)
88
+
89
+ ## License
90
+
91
+ Proprietary. See [LICENSE](./LICENSE) for details.
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ var CDN_URL = "https://script.orbithunt.com/js/tracker.js";
4
+
5
+ /**
6
+ * Load the OrbitHunt tracker by injecting the CDN script tag.
7
+ * Safe to call in SSR — does nothing on the server.
8
+ *
9
+ * @param {string} trackerId - Your OrbitHunt tracker ID
10
+ * @param {Object} [options]
11
+ * @param {string} [options.ingestUrl] - Custom ingest endpoint
12
+ * @param {string} [options.rrwebCdn] - Custom rrweb CDN URL
13
+ */
14
+ function load(trackerId, options) {
15
+ if (typeof window === "undefined") return;
16
+
17
+ if (!trackerId) {
18
+ console.error("[OrbitHunt] trackerId is required");
19
+ return;
20
+ }
21
+
22
+ // Prevent double-loading
23
+ if (document.querySelector("script[data-orbithunt-loader]")) {
24
+ console.warn("[OrbitHunt] Tracker already loaded");
25
+ return;
26
+ }
27
+
28
+ var opts = options || {};
29
+ var script = document.createElement("script");
30
+ script.src = CDN_URL;
31
+ script.async = true;
32
+ script.setAttribute("data-tracker-id", trackerId);
33
+ script.setAttribute("data-orbithunt-loader", "true");
34
+
35
+ if (opts.ingestUrl) script.setAttribute("data-ingest-url", opts.ingestUrl);
36
+ if (opts.rrwebCdn) script.setAttribute("data-rrweb-cdn", opts.rrwebCdn);
37
+
38
+ document.head.appendChild(script);
39
+ }
40
+
41
+ /**
42
+ * Remove the OrbitHunt tracker script tag.
43
+ * Safe to call in SSR — does nothing on the server.
44
+ */
45
+ function unload() {
46
+ if (typeof window === "undefined") return;
47
+
48
+ var script = document.querySelector("script[data-orbithunt-loader]");
49
+ if (script) {
50
+ script.remove();
51
+ }
52
+ }
53
+
54
+ exports.load = load;
55
+ exports.unload = unload;
@@ -0,0 +1,52 @@
1
+ var CDN_URL = "https://script.orbithunt.com/js/tracker.js";
2
+
3
+ /**
4
+ * Load the OrbitHunt tracker by injecting the CDN script tag.
5
+ * Safe to call in SSR — does nothing on the server.
6
+ *
7
+ * @param {string} trackerId - Your OrbitHunt tracker ID
8
+ * @param {Object} [options]
9
+ * @param {string} [options.ingestUrl] - Custom ingest endpoint
10
+ * @param {string} [options.rrwebCdn] - Custom rrweb CDN URL
11
+ */
12
+ function load(trackerId, options) {
13
+ if (typeof window === "undefined") return;
14
+
15
+ if (!trackerId) {
16
+ console.error("[OrbitHunt] trackerId is required");
17
+ return;
18
+ }
19
+
20
+ // Prevent double-loading
21
+ if (document.querySelector("script[data-orbithunt-loader]")) {
22
+ console.warn("[OrbitHunt] Tracker already loaded");
23
+ return;
24
+ }
25
+
26
+ var opts = options || {};
27
+ var script = document.createElement("script");
28
+ script.src = CDN_URL;
29
+ script.async = true;
30
+ script.setAttribute("data-tracker-id", trackerId);
31
+ script.setAttribute("data-orbithunt-loader", "true");
32
+
33
+ if (opts.ingestUrl) script.setAttribute("data-ingest-url", opts.ingestUrl);
34
+ if (opts.rrwebCdn) script.setAttribute("data-rrweb-cdn", opts.rrwebCdn);
35
+
36
+ document.head.appendChild(script);
37
+ }
38
+
39
+ /**
40
+ * Remove the OrbitHunt tracker script tag.
41
+ * Safe to call in SSR — does nothing on the server.
42
+ */
43
+ function unload() {
44
+ if (typeof window === "undefined") return;
45
+
46
+ var script = document.querySelector("script[data-orbithunt-loader]");
47
+ if (script) {
48
+ script.remove();
49
+ }
50
+ }
51
+
52
+ export { load, unload };
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@orbithunt/tracker",
3
+ "version": "1.0.0-beta.2",
4
+ "description": "OrbitHunt session recording tracker — lightweight CDN loader for any framework",
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "main": "./dist/index.cjs.js",
7
+ "module": "./dist/index.esm.js",
8
+ "types": "./src/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./src/index.d.ts",
12
+ "import": "./dist/index.esm.js",
13
+ "require": "./dist/index.cjs.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "src/index.d.ts",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "scripts": {
23
+ "build": "rollup -c ../../rollup.config.mjs --environment PACKAGE:tracker"
24
+ },
25
+ "keywords": [
26
+ "analytics",
27
+ "session-recording",
28
+ "session-replay",
29
+ "rrweb",
30
+ "web-analytics",
31
+ "orbithunt",
32
+ "heatmap",
33
+ "user-tracking"
34
+ ],
35
+ "homepage": "https://orbithunt.com"
36
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ export interface LoadOptions {
2
+ /** Custom ingest endpoint URL */
3
+ ingestUrl?: string;
4
+ /** Custom rrweb CDN URL */
5
+ rrwebCdn?: string;
6
+ }
7
+
8
+ /**
9
+ * Load the OrbitHunt tracker by injecting the CDN script tag.
10
+ * Safe to call in SSR — does nothing on the server.
11
+ */
12
+ export function load(trackerId: string, options?: LoadOptions): void;
13
+
14
+ /**
15
+ * Remove the OrbitHunt tracker script tag.
16
+ * Safe to call in SSR — does nothing on the server.
17
+ */
18
+ export function unload(): void;