@appxiom/web 0.1.8

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,5 @@
1
+ Copyright (c) 2026 BasilGregory Software Labs Private Limited
2
+
3
+ All rights reserved.
4
+
5
+ This software is licensed, not sold. No part of this software may be copied, modified, distributed, reverse engineered, or used except as expressly permitted by BasilGregory Software Labs Private Limited.
package/README.md ADDED
@@ -0,0 +1,313 @@
1
+ # Appxiom Web SDK (`@appxiom/web`)
2
+
3
+ The official client-side JavaScript SDK for Appxiom. Use this package to initialize monitoring, track goals, report issues, and attach custom activity data from your web app.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Installation](#installation)
8
+ - [Quick Start](#quick-start)
9
+ - [Vite](#vite)
10
+ - [Frameworks and SSR](#frameworks-and-ssr)
11
+ - [Production Deployment](#production-deployment)
12
+ - [Public API](#public-api)
13
+ - [Error Types](#error-types)
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @appxiom/web
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ### JavaScript
24
+
25
+ ```javascript
26
+ import init from '@appxiom/web';
27
+
28
+ const ax = await init(
29
+ 'YOUR_APP_KEY',
30
+ 'YOUR_PLATFORM_KEY',
31
+ 'YOUR_APP_VERSION',
32
+ 'YOUR_BUILD_IDENTIFIER'
33
+ );
34
+ ```
35
+
36
+ ### TypeScript
37
+
38
+ `@appxiom/web` ships first-party TypeScript declarations. No separate `@types` package is needed.
39
+
40
+ ```typescript
41
+ import init, { type AX } from '@appxiom/web';
42
+
43
+ const ax: AX = await init(
44
+ 'YOUR_APP_KEY',
45
+ 'YOUR_PLATFORM_KEY',
46
+ 'YOUR_APP_VERSION',
47
+ 'YOUR_BUILD_IDENTIFIER',
48
+ );
49
+ ```
50
+
51
+ `init(...)` returns `Promise<AX>`. The SDK actions available on `AX` are documented below.
52
+
53
+ ## Vite
54
+
55
+ `@appxiom/web` includes a WebAssembly binary. During local development, exclude the package from Vite dependency optimization so Vite preserves the binary's source-relative URL:
56
+
57
+ ```javascript
58
+ import { defineConfig } from 'vite';
59
+
60
+ export default defineConfig({
61
+ optimizeDeps: {
62
+ exclude: ['@appxiom/web'],
63
+ },
64
+ });
65
+ ```
66
+
67
+ After adding this setting, clear Vite's optimized-dependency cache and restart the development server:
68
+
69
+ ```bash
70
+ rm -rf node_modules/.vite
71
+ npm run dev -- --force
72
+ ```
73
+
74
+ This setting affects Vite's development server only. It is safe to retain for production builds; Vite does not use dependency optimization when running `vite build`.
75
+
76
+ ## Frameworks and SSR
77
+
78
+ The SDK is framework-neutral and runs in the browser. Initialize it from your application's browser entry point or client-side lifecycle code.
79
+
80
+ - React: initialize in a client-side application entry point, or use `@appxiom/4react` for React-specific integrations.
81
+ - Vue: initialize from `main.ts` or another browser-only application entry point.
82
+ - Angular: initialize from a browser-only service or application lifecycle path.
83
+ - Svelte: initialize from browser code such as `onMount`.
84
+ - Next.js, Nuxt, SvelteKit, and other SSR frameworks: initialize only on the client. Do not import or initialize the SDK from server-rendered code, route handlers, or server components.
85
+
86
+ Vite-powered frameworks, including Vite React, Vue, SvelteKit, and Nuxt applications, need the Vite configuration above during local development.
87
+
88
+ For an SSR application, load and initialize the SDK only after the browser is available:
89
+
90
+ ```typescript
91
+ const { default: init } = await import('@appxiom/web');
92
+
93
+ const ax = await init(
94
+ 'YOUR_APP_KEY',
95
+ 'YOUR_PLATFORM_KEY',
96
+ 'YOUR_APP_VERSION',
97
+ 'YOUR_BUILD_IDENTIFIER',
98
+ );
99
+ ```
100
+
101
+ ## Production Deployment
102
+
103
+ Run your framework's production build as usual. For Vite applications, this is typically:
104
+
105
+ ```bash
106
+ npm run build
107
+ ```
108
+
109
+ Vite emits the SDK's WebAssembly binary into the production output and rewrites the loader to its generated asset URL. Deploy the complete build output, including the generated `.wasm` asset, without renaming or omitting files.
110
+
111
+ Your CDN or web server must serve `.wasm` files with this response header:
112
+
113
+ ```http
114
+ Content-Type: application/wasm
115
+ ```
116
+
117
+ Also ensure SPA fallback rules do not return `index.html` for `.wasm` asset requests. Receiving HTML instead of the binary produces errors such as `expected magic word 00 61 73 6d`.
118
+
119
+ For non-Vite applications, use the same deployment rules: the bundler must emit the package's `.wasm` asset, the asset must be deployed with the application, and the host must serve it with the WASM MIME type.
120
+
121
+ ## Public API
122
+
123
+ The following APIs are available to client projects.
124
+
125
+ ### `init(appKey, platformKey, version, buildIdentifier)`
126
+
127
+ Initializes the SDK and returns an `AX` instance.
128
+
129
+ #### JavaScript
130
+
131
+ ```javascript
132
+ const ax = await init('APP_KEY', 'PLATFORM_KEY', 'YOUR_APP_VERSION', 'YOUR_BUILD_IDENTIFIER');
133
+ ```
134
+
135
+ #### TypeScript
136
+
137
+ ```typescript
138
+ import type { AX } from '@appxiom/web';
139
+
140
+ const ax: AX = await init('APP_KEY', 'PLATFORM_KEY', 'YOUR_APP_VERSION', 'YOUR_BUILD_IDENTIFIER');
141
+ ```
142
+
143
+ Both forms also support values loaded from application configuration:
144
+
145
+ ```javascript
146
+ const ax = await init(
147
+ config.appKey,
148
+ config.platformKey,
149
+ config.version,
150
+ config.buildId
151
+ );
152
+ ```
153
+
154
+ ```typescript
155
+ import type { AX } from '@appxiom/web';
156
+
157
+ const ax: AX = await init(
158
+ config.appKey,
159
+ config.platformKey,
160
+ config.version,
161
+ config.buildId,
162
+ );
163
+ ```
164
+
165
+ ### `AX` class
166
+
167
+ The package also exports the `AX` class.
168
+
169
+ #### JavaScript
170
+
171
+ ```javascript
172
+ import init, { AX } from '@appxiom/web';
173
+ ```
174
+
175
+ #### TypeScript
176
+
177
+ ```typescript
178
+ import init, { AX } from '@appxiom/web';
179
+
180
+ const ax: AX = await init('APP_KEY', 'PLATFORM_KEY', 'YOUR_APP_VERSION', 'YOUR_BUILD_IDENTIFIER');
181
+ ```
182
+
183
+ ### `ax.launch()`
184
+
185
+ Starts SDK runtime initialization. This is called by `init(...)`, so you usually do not need to call it manually.
186
+
187
+ ### `ax.setCustomId(customId)`
188
+
189
+ Associates your user/account identifier with telemetry.
190
+
191
+ #### JavaScript
192
+
193
+ ```javascript
194
+ ax.setCustomId('user-12345');
195
+ ```
196
+
197
+ #### TypeScript
198
+
199
+ ```typescript
200
+ ax.setCustomId('user-12345');
201
+ ```
202
+
203
+ ### `ax.startGoal(name)`
204
+
205
+ Starts a named goal.
206
+
207
+ #### JavaScript
208
+
209
+ ```javascript
210
+ ax.startGoal('checkout-flow');
211
+ ```
212
+
213
+ #### TypeScript
214
+
215
+ ```typescript
216
+ ax.startGoal('checkout-flow');
217
+ ```
218
+
219
+ ### `ax.endGoal(name, properties = {}, value = null)`
220
+
221
+ Ends a named goal.
222
+
223
+ #### JavaScript
224
+
225
+ ```javascript
226
+ ax.endGoal('checkout-flow', { cartValue: 120.0 }, 120.0);
227
+ ```
228
+
229
+ #### TypeScript
230
+
231
+ ```typescript
232
+ ax.endGoal('checkout-flow', { cartValue: 120.0 }, 120.0);
233
+ ```
234
+
235
+ ### `ax.logActivity(name, properties = {})`
236
+
237
+ Adds a custom activity entry.
238
+
239
+ #### JavaScript
240
+
241
+ ```javascript
242
+ ax.logActivity('Checkout Step Completed', {
243
+ step: 'payment',
244
+ orderId: 'ORD-10023'
245
+ });
246
+ ```
247
+
248
+ #### TypeScript
249
+
250
+ ```typescript
251
+ ax.logActivity('Checkout Step Completed', {
252
+ step: 'payment',
253
+ orderId: 'ORD-10023',
254
+ });
255
+ ```
256
+
257
+ ### `ax.reportCustomIssue(title, description, severity, data = {}, stacktrace = null)`
258
+
259
+ Reports a custom issue from your application. Severity values are `0` (Minor), `1` (Major), and `2` (Fatal).
260
+
261
+ #### JavaScript
262
+
263
+ ```javascript
264
+ ax.reportCustomIssue(
265
+ 'Checkout Validation Failed',
266
+ 'Payment token was missing.',
267
+ 1,
268
+ { module: 'checkout' },
269
+ new Error('Missing payment token').stack
270
+ );
271
+ ```
272
+
273
+ #### TypeScript
274
+
275
+ ```typescript
276
+ import type { IssueSeverity } from '@appxiom/web';
277
+
278
+ const severity: IssueSeverity = 1;
279
+ ax.reportCustomIssue(
280
+ 'Checkout Validation Failed',
281
+ 'Payment token was missing.',
282
+ severity,
283
+ { module: 'checkout' },
284
+ new Error('Missing payment token').stack,
285
+ );
286
+ ```
287
+
288
+ ### Type exports
289
+
290
+ The package exports the following TypeScript declarations:
291
+
292
+ - `AX`: the initialized SDK instance returned by `init(...)`.
293
+ - `AppxiomProperties`: a string-keyed object for telemetry metadata.
294
+ - `IssueSeverity`: `0 | 1 | 2`, corresponding to Minor, Major, and Fatal.
295
+
296
+ ## Error Types
297
+
298
+ The SDK categorizes detected problems into a set of structured error types so that telemetry, debugging, and reporting are easier to analyze. The values below correspond to the internal error-type mapping used by the SDK.
299
+
300
+ - `HTTPStatusError`: Indicates that an HTTP request completed with a non-success status code such as `4xx` or `5xx`. This is commonly used for failed API responses or backend-side errors.
301
+ - `HTTPDuplicateRequestError`: Represents a situation where the same request was issued more than once, often causing duplicate work or duplicate network activity.
302
+ - `HTTPDelayedResponseError`: Signals that an HTTP request took longer than expected to respond. This usually points to latency, slow network conditions, or backend delays.
303
+ - `HTTPExceptionError`: Captures unexpected exceptions thrown during the HTTP request lifecycle, such as runtime failures, parsing issues, or transport-level exceptions.
304
+ - `MemoryLeak`: Indicates a suspected memory leak where memory usage grows over time without being released.
305
+ - `MemoryAnomaly`: Represents abnormal memory behavior that does not necessarily meet the threshold of a full leak, but still suggests unusual retention or allocation patterns.
306
+ - `MemoryRisk`: Marks a potential memory-related issue that should be monitored closely, even if it has not yet become a confirmed leak or spike.
307
+ - `MemorySpike`: Represents a sudden rise in memory consumption over a short time window, often indicating pressure from a temporary workload or an underlying issue.
308
+ - `AutoCapturedError`: Refers to errors that the SDK captures automatically from the runtime environment without requiring manual instrumentation.
309
+ - `ResourceLoadError`: Indicates that a critical resource such as an image, script, stylesheet, or other asset failed to load properly.
310
+ - `CustomException`: Represents an exception that your application reports manually through the SDK for domain-specific or application-level errors.
311
+ - `CustomIssue`: Denotes a manually reported issue that is not necessarily an exception, but still needs to be tracked as a meaningful product or engineering problem.
312
+ - `FrameDrop`: Signals a frame-rate drop or rendering anomaly that may indicate performance degradation, jank, or excessive main-thread work.
313
+
@@ -0,0 +1,192 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * LeakAnalyzer Struct
6
+ */
7
+ export class LeakAnalyzer {
8
+ free(): void;
9
+ [Symbol.dispose](): void;
10
+ /**
11
+ * Evaluate current records for leaks
12
+ */
13
+ evaluate_leaks(): Promise<LeakRecord[]>;
14
+ /**
15
+ * Create a new LeakAnalyzer
16
+ */
17
+ constructor();
18
+ /**
19
+ * Notify a GC epoch occurrence
20
+ */
21
+ notify_gc_epoch(): Promise<void>;
22
+ /**
23
+ * Report a detected leak
24
+ * Convert the LeakRecord to MemoryLeak.
25
+ */
26
+ static report_leak(leak_record: LeakRecord): Promise<void>;
27
+ /**
28
+ * Track a detached instance
29
+ */
30
+ track_instance(instance_id: number): Promise<void>;
31
+ }
32
+
33
+ /**
34
+ * Leak Record Struct
35
+ */
36
+ export class LeakRecord {
37
+ private constructor();
38
+ free(): void;
39
+ [Symbol.dispose](): void;
40
+ age: number;
41
+ first_seen: bigint;
42
+ gc_survivals: number;
43
+ instance_id: number;
44
+ last_gc_epoch: number;
45
+ }
46
+
47
+ /**
48
+ * End a goal
49
+ */
50
+ export function end_goal(name: string): Promise<void>;
51
+
52
+ /**
53
+ * JS interface for get_device_state function. This allows JavaScript code to call this Rust function and get the device state information as a JavaScript object.
54
+ */
55
+ export function get_device_state_js(): Promise<any>;
56
+
57
+ /**
58
+ * API handler when API call is initiated`
59
+ */
60
+ export function handle_api_after_request(url: string, request: any, request_timestamp: bigint): Promise<void>;
61
+
62
+ /**
63
+ * API handler when API call is done`
64
+ */
65
+ export function handle_api_after_response(url: string, request: any, request_timestamp: bigint, response: any, response_timestamp: bigint | null | undefined, error: any): Promise<void>;
66
+
67
+ /**
68
+ * API handler when API call fails due to network error or other reasons.
69
+ */
70
+ export function handle_api_on_error(url: string, request: any, request_timestamp: bigint, error: any): Promise<void>;
71
+
72
+ /**
73
+ * Init the SDK with the given app key, platform key, version, and build identifier.
74
+ * sdk_type is configured at build time via AX_SDK_TYPE.
75
+ * if app_key is not provided, it will be set to 01KJ7FF0CS16ZPXF2T4TCN9EKB
76
+ * if platform_key is not provided, it will be set to 1d7a4689674373fac78b4d5fe8555d8fdcf2e2bc28fc4d196dcf7c69931c89b7
77
+ *
78
+ */
79
+ export function init(app_key: string, platform_key: string, version: string, build_identifier?: string | null): Promise<void>;
80
+
81
+ /**
82
+ * Add activity
83
+ */
84
+ export function log_activity(name: string, details: any): Promise<void>;
85
+
86
+ /**
87
+ * Log event
88
+ */
89
+ export function log_event(type_id: number, info: any): Promise<void>;
90
+
91
+ /**
92
+ * Add Event Activity
93
+ */
94
+ export function log_event_activity(name: string, details: any): Promise<void>;
95
+
96
+ /**
97
+ * Log resource load error
98
+ */
99
+ export function log_resource_load_error(url: string, data: any): Promise<void>;
100
+
101
+ /**
102
+ * Report CustomIssue
103
+ */
104
+ export function report_custom_issue(title: string, description: string, severity: number, data: any, stacktrace?: string | null): Promise<void>;
105
+
106
+ /**
107
+ * Report Error
108
+ */
109
+ export function report_error(error: any): Promise<void>;
110
+
111
+ /**
112
+ * Set custom ID for the current device. This can be used to link the device with user information in the application.
113
+ */
114
+ export function set_custom_id(custom_id: string): Promise<void>;
115
+
116
+ /**
117
+ * Start a goal
118
+ */
119
+ export function start_goal(name: string): Promise<void>;
120
+
121
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
122
+
123
+ export interface InitOutput {
124
+ readonly memory: WebAssembly.Memory;
125
+ readonly __wbg_get_leakrecord_age: (a: number) => number;
126
+ readonly __wbg_get_leakrecord_first_seen: (a: number) => bigint;
127
+ readonly __wbg_get_leakrecord_gc_survivals: (a: number) => number;
128
+ readonly __wbg_get_leakrecord_instance_id: (a: number) => number;
129
+ readonly __wbg_get_leakrecord_last_gc_epoch: (a: number) => number;
130
+ readonly __wbg_leakanalyzer_free: (a: number, b: number) => void;
131
+ readonly __wbg_leakrecord_free: (a: number, b: number) => void;
132
+ readonly __wbg_set_leakrecord_age: (a: number, b: number) => void;
133
+ readonly __wbg_set_leakrecord_first_seen: (a: number, b: bigint) => void;
134
+ readonly __wbg_set_leakrecord_gc_survivals: (a: number, b: number) => void;
135
+ readonly __wbg_set_leakrecord_instance_id: (a: number, b: number) => void;
136
+ readonly __wbg_set_leakrecord_last_gc_epoch: (a: number, b: number) => void;
137
+ readonly end_goal: (a: number, b: number) => number;
138
+ readonly get_device_state_js: () => number;
139
+ readonly handle_api_after_request: (a: number, b: number, c: number, d: bigint) => number;
140
+ readonly handle_api_after_response: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: bigint, h: number) => number;
141
+ readonly handle_api_on_error: (a: number, b: number, c: number, d: bigint, e: number) => number;
142
+ readonly init: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
143
+ readonly leakanalyzer_evaluate_leaks: (a: number) => number;
144
+ readonly leakanalyzer_new: () => number;
145
+ readonly leakanalyzer_notify_gc_epoch: (a: number) => number;
146
+ readonly leakanalyzer_report_leak: (a: number) => number;
147
+ readonly leakanalyzer_track_instance: (a: number, b: number) => number;
148
+ readonly log_activity: (a: number, b: number, c: number) => number;
149
+ readonly log_event: (a: number, b: number) => number;
150
+ readonly log_event_activity: (a: number, b: number, c: number) => number;
151
+ readonly log_resource_load_error: (a: number, b: number, c: number) => number;
152
+ readonly report_custom_issue: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
153
+ readonly report_error: (a: number) => number;
154
+ readonly set_custom_id: (a: number, b: number) => number;
155
+ readonly start_goal: (a: number, b: number) => number;
156
+ readonly __wasm_bindgen_func_elem_458: (a: number, b: number, c: number) => void;
157
+ readonly __wasm_bindgen_func_elem_1045: (a: number, b: number, c: number, d: number) => void;
158
+ readonly __wasm_bindgen_func_elem_1102: (a: number, b: number, c: number, d: number) => void;
159
+ readonly __wasm_bindgen_func_elem_455: (a: number, b: number, c: number) => void;
160
+ readonly __wasm_bindgen_func_elem_461: (a: number, b: number, c: number) => void;
161
+ readonly __wasm_bindgen_func_elem_461_4: (a: number, b: number, c: number) => void;
162
+ readonly __wasm_bindgen_func_elem_450: (a: number, b: number, c: number) => void;
163
+ readonly __wasm_bindgen_func_elem_465: (a: number, b: number) => void;
164
+ readonly __wbindgen_export: (a: number, b: number) => number;
165
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
166
+ readonly __wbindgen_export3: (a: number) => void;
167
+ readonly __wbindgen_export4: (a: number, b: number) => void;
168
+ readonly __wbindgen_export5: (a: number, b: number, c: number) => void;
169
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
170
+ }
171
+
172
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
173
+
174
+ /**
175
+ * Instantiates the given `module`, which can either be bytes or
176
+ * a precompiled `WebAssembly.Module`.
177
+ *
178
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
179
+ *
180
+ * @returns {InitOutput}
181
+ */
182
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
183
+
184
+ /**
185
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
186
+ * for everything else, calls `WebAssembly.instantiate` directly.
187
+ *
188
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
189
+ *
190
+ * @returns {Promise<InitOutput>}
191
+ */
192
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;