@hellyeah/x-ray 0.1.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,140 @@
1
+ ![X-Ray Analytics](https://github.com/finalroundai/xray-sdk/blob/main/.github/banner.png)
2
+
3
+ <div align="center">
4
+ <strong>X-Ray Analytics SDK</strong>
5
+ <br />
6
+ <p>Privacy-friendly analytics for web and server applications</p>
7
+ <a href="https://www.npmjs.com/package/@hellyeah/x-ray"><img src="https://img.shields.io/npm/v/@hellyeah/x-ray.svg" alt="npm version" /></a>
8
+ <a href="https://www.npmjs.com/package/@hellyeah/x-ray"><img src="https://img.shields.io/npm/dm/@hellyeah/x-ray.svg" alt="npm downloads" /></a>
9
+ <a href="https://github.com/finalroundai/xray-sdk/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@hellyeah/x-ray.svg" alt="license" /></a>
10
+ </div>
11
+
12
+ ## Overview
13
+
14
+ `@hellyeah/x-ray` allows you to track page views, custom events, and user identity across any JavaScript framework or server environment.
15
+
16
+ All page views are automatically tracked by default. Custom events and user identification are available via a simple API.
17
+
18
+ ## Quickstart
19
+
20
+ 1. Install the package
21
+
22
+ ```bash
23
+ npm install @hellyeah/x-ray@beta
24
+ ```
25
+
26
+ 2. Add analytics to your app
27
+
28
+ **Next.js**
29
+
30
+ ```tsx
31
+ import { Analytics } from "@hellyeah/x-ray/next";
32
+
33
+ export default function RootLayout({ children }) {
34
+ return (
35
+ <html>
36
+ <body>
37
+ {children}
38
+ <Analytics websiteId="your-website-id" />
39
+ </body>
40
+ </html>
41
+ );
42
+ }
43
+ ```
44
+
45
+ **React**
46
+
47
+ ```tsx
48
+ import { Analytics } from "@hellyeah/x-ray/react";
49
+
50
+ function App() {
51
+ return (
52
+ <>
53
+ <Analytics websiteId="your-website-id" />
54
+ {/* your app */}
55
+ </>
56
+ );
57
+ }
58
+ ```
59
+
60
+ **Vue / Nuxt / Svelte / Remix / Astro** — see [Framework Guides](#frameworks) below.
61
+
62
+ **Vanilla JS**
63
+
64
+ ```ts
65
+ import { inject } from "@hellyeah/x-ray";
66
+
67
+ inject({ websiteId: "your-website-id" });
68
+ ```
69
+
70
+ **Server (Node.js / Bun)**
71
+
72
+ ```ts
73
+ import { XRay } from "@hellyeah/x-ray/server";
74
+
75
+ const xray = new XRay("your-website-id");
76
+ xray.track("signup", { distinctId: "user_42" });
77
+
78
+ // Before process exit, flush remaining events
79
+ await xray.shutdown();
80
+ ```
81
+
82
+ **Serverless / Edge (Vercel, AWS Lambda, Cloudflare Workers)**
83
+
84
+ In short-lived environments, set `flushAt: 1` and `flushInterval: 0` so events are sent immediately rather than batched:
85
+
86
+ ```ts
87
+ import { XRay } from "@hellyeah/x-ray/server";
88
+
89
+ const xray = new XRay("your-website-id", {
90
+ flushAt: 1,
91
+ flushInterval: 0,
92
+ });
93
+
94
+ xray.track("signup", { distinctId: "user_42" });
95
+ ```
96
+
97
+ Or use `trackImmediate` to bypass the queue entirely and await delivery:
98
+
99
+ ```ts
100
+ await xray.trackImmediate("signup", { distinctId: "user_42" });
101
+ ```
102
+
103
+ 3. Deploy your app and see data flowing in.
104
+
105
+ ## Frameworks
106
+
107
+ | Framework | Import path | Usage |
108
+ | --------- | ------------------------ | ----------------------------------------------------- |
109
+ | Next.js | `@hellyeah/x-ray/next` | `<Analytics />` component with Suspense boundary |
110
+ | React | `@hellyeah/x-ray/react` | `<Analytics />` component |
111
+ | Remix | `@hellyeah/x-ray/remix` | `<Analytics />` component |
112
+ | Vue | `@hellyeah/x-ray/vue` | `<Analytics />` component |
113
+ | Svelte | `@hellyeah/x-ray/svelte` | `injectAnalytics()` helper |
114
+ | Nuxt | `@hellyeah/x-ray/nuxt` | `injectAnalytics()` + `<Analytics />` |
115
+ | Astro | `@hellyeah/x-ray/astro` | Re-exports `inject` and `track` |
116
+ | Server | `@hellyeah/x-ray/server` | `XRay` class with batching, retry, and immediate send |
117
+ | Vanilla | `@hellyeah/x-ray` | `inject()`, `track()`, `identify()`, `pageview()` |
118
+
119
+ ## Custom Events
120
+
121
+ ```ts
122
+ import { track } from "@hellyeah/x-ray";
123
+
124
+ track("signup", { plan: "pro" });
125
+ ```
126
+
127
+ For the full list of predefined conversion events and ad platform mappings, see the [Event Catalog](../../skills/references/event-catalog.md).
128
+
129
+ ## User Identification
130
+
131
+ ```ts
132
+ import { identify } from "@hellyeah/x-ray";
133
+
134
+ identify("user_42", { name: "Jane" });
135
+ ```
136
+
137
+ ## License
138
+
139
+ [MIT](LICENSE)
140
+
@@ -0,0 +1,48 @@
1
+ var import_node_module = require("node:module");
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ function __accessProp(key) {
7
+ return this[key];
8
+ }
9
+ var __toCommonJS = (from) => {
10
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
11
+ if (entry)
12
+ return entry;
13
+ entry = __defProp({}, "__esModule", { value: true });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (var key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(entry, key))
17
+ __defProp(entry, key, {
18
+ get: __accessProp.bind(from, key),
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ __moduleCache.set(from, entry);
23
+ return entry;
24
+ };
25
+ var __moduleCache;
26
+ var __returnValue = (v) => v;
27
+ function __exportSetter(name, newValue) {
28
+ this[name] = __returnValue.bind(null, newValue);
29
+ }
30
+ var __export = (target, all) => {
31
+ for (var name in all)
32
+ __defProp(target, name, {
33
+ get: all[name],
34
+ enumerable: true,
35
+ configurable: true,
36
+ set: __exportSetter.bind(all, name)
37
+ });
38
+ };
39
+
40
+ // src/astro/index.ts
41
+ var exports_astro = {};
42
+ __export(exports_astro, {
43
+ track: () => import_generic.track,
44
+ pageview: () => import_generic.pageview,
45
+ inject: () => import_generic.inject,
46
+ identify: () => import_generic.identify
47
+ });
48
+ module.exports = __toCommonJS(exports_astro);
@@ -0,0 +1,36 @@
1
+ /** Props accepted by the `<Analytics />` component and `inject()`. */
2
+ type AnalyticsProps = {
3
+ /** Your x-ray website ID. */
4
+ websiteId: string;
5
+ /** Base URL of your x-ray server. @defaultValue `"https://xray-staging.hellyeahai.com"` */
6
+ hostUrl?: string;
7
+ /** Restrict tracking to this domain only. */
8
+ domains?: string;
9
+ /** Auto-track events on `data-hy-event` elements. @defaultValue true */
10
+ autoTrack?: boolean;
11
+ /** Custom `src` for the tracker script (overrides the default `/script.js`). */
12
+ src?: string;
13
+ };
14
+ /** Arbitrary event data passed to `track()`. */
15
+ type EventData = Record<string, string | number | boolean | null>;
16
+ /**
17
+ * Inject the remote x-ray tracker `<script>` tag into `<head>`.
18
+ *
19
+ * Deduplicates — calling `inject()` twice with the same `websiteId` is a no-op.
20
+ */
21
+ declare const inject: (props: AnalyticsProps) => void;
22
+ /**
23
+ * Track a custom event. If the tracker script hasn't loaded yet, the call is
24
+ * buffered in `window._hy` and replayed once it initialises.
25
+ */
26
+ declare const track: (name?: string, data?: EventData) => void;
27
+ /**
28
+ * Identify the current user. Buffered if the tracker script hasn't loaded yet.
29
+ */
30
+ declare const identify: (id: string, data?: EventData) => void;
31
+ /**
32
+ * Record a pageview. Equivalent to calling `track()` with no arguments — the
33
+ * remote tracker interprets this as a pageview event.
34
+ */
35
+ declare const pageview: () => void;
36
+ export { track, pageview, inject, identify, AnalyticsProps };
@@ -0,0 +1,36 @@
1
+ /** Props accepted by the `<Analytics />` component and `inject()`. */
2
+ type AnalyticsProps = {
3
+ /** Your x-ray website ID. */
4
+ websiteId: string;
5
+ /** Base URL of your x-ray server. @defaultValue `"https://xray-staging.hellyeahai.com"` */
6
+ hostUrl?: string;
7
+ /** Restrict tracking to this domain only. */
8
+ domains?: string;
9
+ /** Auto-track events on `data-hy-event` elements. @defaultValue true */
10
+ autoTrack?: boolean;
11
+ /** Custom `src` for the tracker script (overrides the default `/script.js`). */
12
+ src?: string;
13
+ };
14
+ /** Arbitrary event data passed to `track()`. */
15
+ type EventData = Record<string, string | number | boolean | null>;
16
+ /**
17
+ * Inject the remote x-ray tracker `<script>` tag into `<head>`.
18
+ *
19
+ * Deduplicates — calling `inject()` twice with the same `websiteId` is a no-op.
20
+ */
21
+ declare const inject: (props: AnalyticsProps) => void;
22
+ /**
23
+ * Track a custom event. If the tracker script hasn't loaded yet, the call is
24
+ * buffered in `window._hy` and replayed once it initialises.
25
+ */
26
+ declare const track: (name?: string, data?: EventData) => void;
27
+ /**
28
+ * Identify the current user. Buffered if the tracker script hasn't loaded yet.
29
+ */
30
+ declare const identify: (id: string, data?: EventData) => void;
31
+ /**
32
+ * Record a pageview. Equivalent to calling `track()` with no arguments — the
33
+ * remote tracker interprets this as a pageview event.
34
+ */
35
+ declare const pageview: () => void;
36
+ export { track, pageview, inject, identify, AnalyticsProps };
@@ -0,0 +1,6 @@
1
+ export {
2
+ track,
3
+ pageview,
4
+ inject,
5
+ identify
6
+ };
package/dist/index.cjs ADDED
@@ -0,0 +1,49 @@
1
+ var import_node_module = require("node:module");
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ function __accessProp(key) {
7
+ return this[key];
8
+ }
9
+ var __toCommonJS = (from) => {
10
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
11
+ if (entry)
12
+ return entry;
13
+ entry = __defProp({}, "__esModule", { value: true });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (var key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(entry, key))
17
+ __defProp(entry, key, {
18
+ get: __accessProp.bind(from, key),
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ __moduleCache.set(from, entry);
23
+ return entry;
24
+ };
25
+ var __moduleCache;
26
+ var __returnValue = (v) => v;
27
+ function __exportSetter(name, newValue) {
28
+ this[name] = __returnValue.bind(null, newValue);
29
+ }
30
+ var __export = (target, all) => {
31
+ for (var name in all)
32
+ __defProp(target, name, {
33
+ get: all[name],
34
+ enumerable: true,
35
+ configurable: true,
36
+ set: __exportSetter.bind(all, name)
37
+ });
38
+ };
39
+
40
+ // src/index.ts
41
+ var exports_src = {};
42
+ __export(exports_src, {
43
+ track: () => import_generic.track,
44
+ pageview: () => import_generic.pageview,
45
+ inject: () => import_generic.inject,
46
+ identify: () => import_generic.identify,
47
+ cv: () => import_constants.cv
48
+ });
49
+ module.exports = __toCommonJS(exports_src);
@@ -0,0 +1,52 @@
1
+ /** Props accepted by the `<Analytics />` component and `inject()`. */
2
+ type AnalyticsProps = {
3
+ /** Your x-ray website ID. */
4
+ websiteId: string;
5
+ /** Base URL of your x-ray server. @defaultValue `"https://xray-staging.hellyeahai.com"` */
6
+ hostUrl?: string;
7
+ /** Restrict tracking to this domain only. */
8
+ domains?: string;
9
+ /** Auto-track events on `data-hy-event` elements. @defaultValue true */
10
+ autoTrack?: boolean;
11
+ /** Custom `src` for the tracker script (overrides the default `/script.js`). */
12
+ src?: string;
13
+ };
14
+ /** Arbitrary event data passed to `track()`. */
15
+ type EventData = Record<string, string | number | boolean | null>;
16
+ /**
17
+ * Inject the remote x-ray tracker `<script>` tag into `<head>`.
18
+ *
19
+ * Deduplicates — calling `inject()` twice with the same `websiteId` is a no-op.
20
+ */
21
+ declare const inject: (props: AnalyticsProps) => void;
22
+ /**
23
+ * Track a custom event. If the tracker script hasn't loaded yet, the call is
24
+ * buffered in `window._hy` and replayed once it initialises.
25
+ */
26
+ declare const track: (name?: string, data?: EventData) => void;
27
+ /**
28
+ * Identify the current user. Buffered if the tracker script hasn't loaded yet.
29
+ */
30
+ declare const identify: (id: string, data?: EventData) => void;
31
+ /**
32
+ * Record a pageview. Equivalent to calling `track()` with no arguments — the
33
+ * remote tracker interprets this as a pageview event.
34
+ */
35
+ declare const pageview: () => void;
36
+ declare const cv: {
37
+ readonly purchase: "cv_purchase";
38
+ readonly subscribe: "cv_subscribe";
39
+ readonly startTrial: "cv_start_trial";
40
+ readonly leadSubmit: "cv_lead_submit";
41
+ readonly registrationComplete: "cv_registration_complete";
42
+ readonly bookAppointment: "cv_book_appointment";
43
+ readonly contact: "cv_contact";
44
+ readonly submitApplication: "cv_submit_application";
45
+ readonly addToCart: "cv_add_to_cart";
46
+ readonly beginCheckout: "cv_begin_checkout";
47
+ readonly addPaymentInfo: "cv_add_payment_info";
48
+ readonly viewContent: "cv_view_content";
49
+ readonly search: "cv_search";
50
+ };
51
+ type ConversionEvent = (typeof cv)[keyof typeof cv];
52
+ export { track, pageview, inject, identify, cv, EventData, ConversionEvent, AnalyticsProps };
@@ -0,0 +1,52 @@
1
+ /** Props accepted by the `<Analytics />` component and `inject()`. */
2
+ type AnalyticsProps = {
3
+ /** Your x-ray website ID. */
4
+ websiteId: string;
5
+ /** Base URL of your x-ray server. @defaultValue `"https://xray-staging.hellyeahai.com"` */
6
+ hostUrl?: string;
7
+ /** Restrict tracking to this domain only. */
8
+ domains?: string;
9
+ /** Auto-track events on `data-hy-event` elements. @defaultValue true */
10
+ autoTrack?: boolean;
11
+ /** Custom `src` for the tracker script (overrides the default `/script.js`). */
12
+ src?: string;
13
+ };
14
+ /** Arbitrary event data passed to `track()`. */
15
+ type EventData = Record<string, string | number | boolean | null>;
16
+ /**
17
+ * Inject the remote x-ray tracker `<script>` tag into `<head>`.
18
+ *
19
+ * Deduplicates — calling `inject()` twice with the same `websiteId` is a no-op.
20
+ */
21
+ declare const inject: (props: AnalyticsProps) => void;
22
+ /**
23
+ * Track a custom event. If the tracker script hasn't loaded yet, the call is
24
+ * buffered in `window._hy` and replayed once it initialises.
25
+ */
26
+ declare const track: (name?: string, data?: EventData) => void;
27
+ /**
28
+ * Identify the current user. Buffered if the tracker script hasn't loaded yet.
29
+ */
30
+ declare const identify: (id: string, data?: EventData) => void;
31
+ /**
32
+ * Record a pageview. Equivalent to calling `track()` with no arguments — the
33
+ * remote tracker interprets this as a pageview event.
34
+ */
35
+ declare const pageview: () => void;
36
+ declare const cv: {
37
+ readonly purchase: "cv_purchase";
38
+ readonly subscribe: "cv_subscribe";
39
+ readonly startTrial: "cv_start_trial";
40
+ readonly leadSubmit: "cv_lead_submit";
41
+ readonly registrationComplete: "cv_registration_complete";
42
+ readonly bookAppointment: "cv_book_appointment";
43
+ readonly contact: "cv_contact";
44
+ readonly submitApplication: "cv_submit_application";
45
+ readonly addToCart: "cv_add_to_cart";
46
+ readonly beginCheckout: "cv_begin_checkout";
47
+ readonly addPaymentInfo: "cv_add_payment_info";
48
+ readonly viewContent: "cv_view_content";
49
+ readonly search: "cv_search";
50
+ };
51
+ type ConversionEvent = (typeof cv)[keyof typeof cv];
52
+ export { track, pageview, inject, identify, cv, EventData, ConversionEvent, AnalyticsProps };
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export {
2
+ track,
3
+ pageview,
4
+ inject,
5
+ identify,
6
+ cv
7
+ };
@@ -0,0 +1,145 @@
1
+ "use client";
2
+ 'use client';
3
+ var import_node_module = require("node:module");
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ function __accessProp(key) {
9
+ return this[key];
10
+ }
11
+ var __toCommonJS = (from) => {
12
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
13
+ if (entry)
14
+ return entry;
15
+ entry = __defProp({}, "__esModule", { value: true });
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (var key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(entry, key))
19
+ __defProp(entry, key, {
20
+ get: __accessProp.bind(from, key),
21
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
22
+ });
23
+ }
24
+ __moduleCache.set(from, entry);
25
+ return entry;
26
+ };
27
+ var __moduleCache;
28
+ var __returnValue = (v) => v;
29
+ function __exportSetter(name, newValue) {
30
+ this[name] = __returnValue.bind(null, newValue);
31
+ }
32
+ var __export = (target, all) => {
33
+ for (var name in all)
34
+ __defProp(target, name, {
35
+ get: all[name],
36
+ enumerable: true,
37
+ configurable: true,
38
+ set: __exportSetter.bind(all, name)
39
+ });
40
+ };
41
+
42
+ // src/next/index.tsx
43
+ var exports_next = {};
44
+ __export(exports_next, {
45
+ track: () => track,
46
+ pageview: () => pageview,
47
+ identify: () => identify,
48
+ Analytics: () => Analytics2
49
+ });
50
+ module.exports = __toCommonJS(exports_next);
51
+ var import_react2 = require("react");
52
+
53
+ // src/react/index.tsx
54
+ var import_react = require("react");
55
+
56
+ // src/client/queue.ts
57
+ var initQueue = () => {
58
+ if (typeof window !== "undefined") {
59
+ window._hy = window._hy || [];
60
+ }
61
+ };
62
+
63
+ // src/client/utils.ts
64
+ var DEFAULT_HOST = "https://xray-staging.hellyeahai.com";
65
+ var isBrowser = () => typeof window !== "undefined" && typeof document !== "undefined";
66
+ var isDevelopment = () => typeof process !== "undefined" && process.env?.NODE_ENV === "development";
67
+ var getDefaultHost = () => DEFAULT_HOST;
68
+
69
+ // src/client/generic.ts
70
+ var inject = (props) => {
71
+ if (!isBrowser())
72
+ return;
73
+ const { websiteId, domains, autoTrack = true, src } = props;
74
+ const hostUrl = props.hostUrl || getDefaultHost();
75
+ const scriptSrc = src || `${hostUrl}/script.js`;
76
+ if (document.head.querySelector(`script[src*="${scriptSrc}"]`))
77
+ return;
78
+ initQueue();
79
+ const dataset = {
80
+ websiteId,
81
+ hostUrl
82
+ };
83
+ if (domains)
84
+ dataset.domains = domains;
85
+ if (!autoTrack)
86
+ dataset.autoTrack = "false";
87
+ const script = document.createElement("script");
88
+ script.src = scriptSrc;
89
+ script.defer = true;
90
+ for (const [key, value] of Object.entries(dataset)) {
91
+ script.dataset[key] = value;
92
+ }
93
+ script.onerror = () => {
94
+ const msg = isDevelopment() ? "Please check if any ad blockers are enabled and try again." : "Check that the hostUrl is correct and the script is accessible.";
95
+ console.log(`[x-ray] Failed to load script from ${scriptSrc}. ${msg}`);
96
+ };
97
+ document.head.appendChild(script);
98
+ };
99
+ var track = (name, data) => {
100
+ if (!isBrowser())
101
+ return;
102
+ if (window.hy) {
103
+ window.hy.track(name, data);
104
+ } else {
105
+ initQueue();
106
+ window._hy = window._hy || [];
107
+ window._hy.push(["track", name, data]);
108
+ }
109
+ };
110
+ var identify = (id, data) => {
111
+ if (!isBrowser())
112
+ return;
113
+ if (window.hy) {
114
+ window.hy.identify(id, data);
115
+ } else {
116
+ initQueue();
117
+ window._hy = window._hy || [];
118
+ window._hy.push(["identify", id, data]);
119
+ }
120
+ };
121
+ var pageview = () => {
122
+ track();
123
+ };
124
+
125
+ // src/react/index.tsx
126
+
127
+ var Analytics = (props) => {
128
+ import_react.useEffect(() => {
129
+ inject(props);
130
+ }, []);
131
+ return null;
132
+ };
133
+
134
+ // src/next/index.tsx
135
+ var jsx_runtime = require("react/jsx-runtime");
136
+
137
+ var AnalyticsInner = (props) => /* @__PURE__ */ jsx_runtime.jsx(Analytics, {
138
+ ...props
139
+ });
140
+ var Analytics2 = (props) => /* @__PURE__ */ jsx_runtime.jsx(import_react2.Suspense, {
141
+ fallback: null,
142
+ children: /* @__PURE__ */ jsx_runtime.jsx(AnalyticsInner, {
143
+ ...props
144
+ })
145
+ });
@@ -0,0 +1,32 @@
1
+ import { ReactNode } from "react";
2
+ /** Props accepted by the `<Analytics />` component and `inject()`. */
3
+ type AnalyticsProps = {
4
+ /** Your x-ray website ID. */
5
+ websiteId: string;
6
+ /** Base URL of your x-ray server. @defaultValue `"https://xray-staging.hellyeahai.com"` */
7
+ hostUrl?: string;
8
+ /** Restrict tracking to this domain only. */
9
+ domains?: string;
10
+ /** Auto-track events on `data-hy-event` elements. @defaultValue true */
11
+ autoTrack?: boolean;
12
+ /** Custom `src` for the tracker script (overrides the default `/script.js`). */
13
+ src?: string;
14
+ };
15
+ /** Arbitrary event data passed to `track()`. */
16
+ type EventData = Record<string, string | number | boolean | null>;
17
+ /**
18
+ * Track a custom event. If the tracker script hasn't loaded yet, the call is
19
+ * buffered in `window._hy` and replayed once it initialises.
20
+ */
21
+ declare const track: (name?: string, data?: EventData) => void;
22
+ /**
23
+ * Identify the current user. Buffered if the tracker script hasn't loaded yet.
24
+ */
25
+ declare const identify: (id: string, data?: EventData) => void;
26
+ /**
27
+ * Record a pageview. Equivalent to calling `track()` with no arguments — the
28
+ * remote tracker interprets this as a pageview event.
29
+ */
30
+ declare const pageview: () => void;
31
+ declare const Analytics: (props: AnalyticsProps) => ReactNode;
32
+ export { track, pageview, identify, AnalyticsProps, Analytics };
@@ -0,0 +1,32 @@
1
+ import { ReactNode } from "react";
2
+ /** Props accepted by the `<Analytics />` component and `inject()`. */
3
+ type AnalyticsProps = {
4
+ /** Your x-ray website ID. */
5
+ websiteId: string;
6
+ /** Base URL of your x-ray server. @defaultValue `"https://xray-staging.hellyeahai.com"` */
7
+ hostUrl?: string;
8
+ /** Restrict tracking to this domain only. */
9
+ domains?: string;
10
+ /** Auto-track events on `data-hy-event` elements. @defaultValue true */
11
+ autoTrack?: boolean;
12
+ /** Custom `src` for the tracker script (overrides the default `/script.js`). */
13
+ src?: string;
14
+ };
15
+ /** Arbitrary event data passed to `track()`. */
16
+ type EventData = Record<string, string | number | boolean | null>;
17
+ /**
18
+ * Track a custom event. If the tracker script hasn't loaded yet, the call is
19
+ * buffered in `window._hy` and replayed once it initialises.
20
+ */
21
+ declare const track: (name?: string, data?: EventData) => void;
22
+ /**
23
+ * Identify the current user. Buffered if the tracker script hasn't loaded yet.
24
+ */
25
+ declare const identify: (id: string, data?: EventData) => void;
26
+ /**
27
+ * Record a pageview. Equivalent to calling `track()` with no arguments — the
28
+ * remote tracker interprets this as a pageview event.
29
+ */
30
+ declare const pageview: () => void;
31
+ declare const Analytics: (props: AnalyticsProps) => ReactNode;
32
+ export { track, pageview, identify, AnalyticsProps, Analytics };