@appxiom/web 0.1.10 → 0.1.11

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 CHANGED
@@ -4,6 +4,7 @@ The official client-side JavaScript SDK for Appxiom. Use this package to initial
4
4
 
5
5
  ## Table of Contents
6
6
 
7
+ - [Before You Begin](#before-you-begin)
7
8
  - [Installation](#installation)
8
9
  - [Quick Start](#quick-start)
9
10
  - [Vite](#vite)
@@ -12,6 +13,15 @@ The official client-side JavaScript SDK for Appxiom. Use this package to initial
12
13
  - [Public API](#public-api)
13
14
  - [Error Types](#error-types)
14
15
 
16
+ ## Before You Begin
17
+
18
+ 1. Register for an Appxiom account at [appxiom.com](https://www.appxiom.com/) and log in to the dashboard.
19
+ 2. Use the `+` at the top left corner to create an app.
20
+ 3. Link your web application to Appxiom using the domain (eg: app.xyz.com) in the settings page. No PORT needs to be provided.
21
+ 4. Copy the APP KEY and PLATFORM KEY from the Appxiom dashboard.
22
+ 5. Integrate the Appxiom Web package into your application as mentioned in installation section.
23
+ 6. Test your integration to ensure monitoring and reporting are working as expected.
24
+
15
25
  ## Installation
16
26
 
17
27
  ```bash
@@ -54,6 +64,8 @@ const ax: AX = await init(
54
64
 
55
65
  `@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
66
 
67
+ ### JavaScript
68
+
57
69
  ```javascript
58
70
  import { defineConfig } from 'vite';
59
71
 
@@ -64,6 +76,18 @@ export default defineConfig({
64
76
  });
65
77
  ```
66
78
 
79
+ ### TypeScript
80
+
81
+ ```typescript
82
+ import { defineConfig } from 'vite';
83
+
84
+ export default defineConfig({
85
+ optimizeDeps: {
86
+ exclude: ['@appxiom/web'],
87
+ },
88
+ });
89
+ ```
90
+
67
91
  After adding this setting, clear Vite's optimized-dependency cache and restart the development server:
68
92
 
69
93
  ```bash
@@ -93,6 +93,11 @@ export function log_event(type_id: number, info: any): Promise<void>;
93
93
  */
94
94
  export function log_event_activity(name: string, details: any): Promise<void>;
95
95
 
96
+ /**
97
+ * Add Lifecycle Activity
98
+ */
99
+ export function log_lifecycle_activity(name: string, details: any): Promise<void>;
100
+
96
101
  /**
97
102
  * Log resource load error
98
103
  */
@@ -148,14 +153,15 @@ export interface InitOutput {
148
153
  readonly log_activity: (a: number, b: number, c: number) => number;
149
154
  readonly log_event: (a: number, b: number) => number;
150
155
  readonly log_event_activity: (a: number, b: number, c: number) => number;
156
+ readonly log_lifecycle_activity: (a: number, b: number, c: number) => number;
151
157
  readonly log_resource_load_error: (a: number, b: number, c: number) => number;
152
158
  readonly report_custom_issue: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
153
159
  readonly report_error: (a: number) => number;
154
160
  readonly set_custom_id: (a: number, b: number) => number;
155
161
  readonly start_goal: (a: number, b: number) => number;
156
162
  readonly __wasm_bindgen_func_elem_458: (a: number, b: number, c: number) => void;
157
- readonly __wasm_bindgen_func_elem_1038: (a: number, b: number, c: number, d: number) => void;
158
- readonly __wasm_bindgen_func_elem_1095: (a: number, b: number, c: number, d: number) => void;
163
+ readonly __wasm_bindgen_func_elem_1042: (a: number, b: number, c: number, d: number) => void;
164
+ readonly __wasm_bindgen_func_elem_1099: (a: number, b: number, c: number, d: number) => void;
159
165
  readonly __wasm_bindgen_func_elem_455: (a: number, b: number, c: number) => void;
160
166
  readonly __wasm_bindgen_func_elem_461: (a: number, b: number, c: number) => void;
161
167
  readonly __wasm_bindgen_func_elem_461_4: (a: number, b: number, c: number) => void;
@@ -274,6 +274,19 @@ export function log_event_activity(name, details) {
274
274
  return takeObject(ret);
275
275
  }
276
276
 
277
+ /**
278
+ * Add Lifecycle Activity
279
+ * @param {string} name
280
+ * @param {any} details
281
+ * @returns {Promise<void>}
282
+ */
283
+ export function log_lifecycle_activity(name, details) {
284
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
285
+ const len0 = WASM_VECTOR_LEN;
286
+ const ret = wasm.log_lifecycle_activity(ptr0, len0, addHeapObject(details));
287
+ return takeObject(ret);
288
+ }
289
+
277
290
  /**
278
291
  * Log resource load error
279
292
  * @param {string} url
@@ -745,7 +758,7 @@ function __wbg_get_imports() {
745
758
  const a = state0.a;
746
759
  state0.a = 0;
747
760
  try {
748
- return __wasm_bindgen_func_elem_1095(a, state0.b, arg0, arg1);
761
+ return __wasm_bindgen_func_elem_1099(a, state0.b, arg0, arg1);
749
762
  } finally {
750
763
  state0.a = a;
751
764
  }
@@ -775,7 +788,7 @@ function __wbg_get_imports() {
775
788
  const a = state0.a;
776
789
  state0.a = 0;
777
790
  try {
778
- return __wasm_bindgen_func_elem_1095(a, state0.b, arg0, arg1);
791
+ return __wasm_bindgen_func_elem_1099(a, state0.b, arg0, arg1);
779
792
  } finally {
780
793
  state0.a = a;
781
794
  }
@@ -1025,7 +1038,7 @@ function __wbg_get_imports() {
1025
1038
  }, arguments); },
1026
1039
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1027
1040
  // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 51, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1028
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1038);
1041
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1042);
1029
1042
  return addHeapObject(ret);
1030
1043
  },
1031
1044
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
@@ -1123,10 +1136,10 @@ function __wasm_bindgen_func_elem_450(arg0, arg1, arg2) {
1123
1136
  }
1124
1137
  }
1125
1138
 
1126
- function __wasm_bindgen_func_elem_1038(arg0, arg1, arg2) {
1139
+ function __wasm_bindgen_func_elem_1042(arg0, arg1, arg2) {
1127
1140
  try {
1128
1141
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1129
- wasm.__wasm_bindgen_func_elem_1038(retptr, arg0, arg1, addHeapObject(arg2));
1142
+ wasm.__wasm_bindgen_func_elem_1042(retptr, arg0, arg1, addHeapObject(arg2));
1130
1143
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1131
1144
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1132
1145
  if (r1) {
@@ -1137,8 +1150,8 @@ function __wasm_bindgen_func_elem_1038(arg0, arg1, arg2) {
1137
1150
  }
1138
1151
  }
1139
1152
 
1140
- function __wasm_bindgen_func_elem_1095(arg0, arg1, arg2, arg3) {
1141
- wasm.__wasm_bindgen_func_elem_1095(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1153
+ function __wasm_bindgen_func_elem_1099(arg0, arg1, arg2, arg3) {
1154
+ wasm.__wasm_bindgen_func_elem_1099(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1142
1155
  }
1143
1156
 
1144
1157
  function __wasm_bindgen_func_elem_458(arg0, arg1, arg2) {
Binary file
@@ -27,14 +27,15 @@ export const leakanalyzer_track_instance: (a: number, b: number) => number;
27
27
  export const log_activity: (a: number, b: number, c: number) => number;
28
28
  export const log_event: (a: number, b: number) => number;
29
29
  export const log_event_activity: (a: number, b: number, c: number) => number;
30
+ export const log_lifecycle_activity: (a: number, b: number, c: number) => number;
30
31
  export const log_resource_load_error: (a: number, b: number, c: number) => number;
31
32
  export const report_custom_issue: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
32
33
  export const report_error: (a: number) => number;
33
34
  export const set_custom_id: (a: number, b: number) => number;
34
35
  export const start_goal: (a: number, b: number) => number;
35
36
  export const __wasm_bindgen_func_elem_458: (a: number, b: number, c: number) => void;
36
- export const __wasm_bindgen_func_elem_1038: (a: number, b: number, c: number, d: number) => void;
37
- export const __wasm_bindgen_func_elem_1095: (a: number, b: number, c: number, d: number) => void;
37
+ export const __wasm_bindgen_func_elem_1042: (a: number, b: number, c: number, d: number) => void;
38
+ export const __wasm_bindgen_func_elem_1099: (a: number, b: number, c: number, d: number) => void;
38
39
  export const __wasm_bindgen_func_elem_455: (a: number, b: number, c: number) => void;
39
40
  export const __wasm_bindgen_func_elem_461: (a: number, b: number, c: number) => void;
40
41
  export const __wasm_bindgen_func_elem_461_4: (a: number, b: number, c: number) => void;
package/core/ax.js CHANGED
@@ -69,6 +69,10 @@ export default class AX {
69
69
  // - 2 -> Fatal
70
70
  reportCustomIssue(title, description, severity, data = {}, stacktrace = null) {
71
71
  if (this.wasm && this.wasm.report_custom_issue) {
72
+ // if the stacktrace is not provided, generate one
73
+ if (!stacktrace) {
74
+ stacktrace = new Error('Custom issue stacktrace.').stack ?? null;
75
+ }
72
76
  this.wasm.report_custom_issue(title, description, severity, data, stacktrace);
73
77
  }
74
78
  }
@@ -93,4 +97,22 @@ export default class AX {
93
97
  this.wasm.log_event_activity(name, properties);
94
98
  }
95
99
  }
100
+
101
+ // Raise a test issue using the reportCustomIssue method
102
+ raiseTestIssue() {
103
+ const data = {
104
+ source: 'ax-sdk-test',
105
+ test: true,
106
+ timestamp: Date.now(),
107
+ };
108
+ const stack = new Error('Test issue generated by the AX SDK.').stack ?? null;
109
+
110
+ this.reportCustomIssue(
111
+ 'Test Issue',
112
+ 'This is a test issue generated by the AX SDK.',
113
+ 1, // Major severity
114
+ data,
115
+ stack
116
+ );
117
+ }
96
118
  }
package/event/ax-event.js CHANGED
@@ -14,7 +14,7 @@ function reportExit() {
14
14
 
15
15
  // Track page load
16
16
  window.addEventListener("load", () => {
17
- AX.instance.wasm.log_event_activity("Page Load", {
17
+ AX.instance.wasm.log_lifecycle_activity("Page Load", {
18
18
  url: location.href,
19
19
  referrer: document.referrer,
20
20
  userAgent: navigator.userAgent,
@@ -49,7 +49,7 @@ window.addEventListener("load", () => {
49
49
  // Track SPA route changes (if using a SPA framework)
50
50
  // This is a generic example; you may need to adapt it based on your SPA framework.
51
51
  window.addEventListener("popstate", () => {
52
- AX.instance.wasm.log_event_activity("SPA Route Change", {
52
+ AX.instance.wasm.log_lifecycle_activity("SPA Route Change", {
53
53
  url: location.href,
54
54
  ts: Date.now(),
55
55
  });
@@ -57,7 +57,7 @@ window.addEventListener("popstate", () => {
57
57
 
58
58
  // Track hash changes for SPA routing
59
59
  window.addEventListener("hashchange", () => {
60
- AX.instance.wasm.log_event_activity("Hash Change", {
60
+ AX.instance.wasm.log_lifecycle_activity("Hash Change", {
61
61
  url: location.href,
62
62
  ts: Date.now(),
63
63
  });
@@ -69,7 +69,7 @@ window.addEventListener("hashchange", () => {
69
69
  const originalReplaceState = history.replaceState;
70
70
 
71
71
  history.pushState = function (...args) {
72
- AX.instance.wasm.log_event_activity("SPA Route Change (pushState)", {
72
+ AX.instance.wasm.log_lifecycle_activity("SPA Route Change (pushState)", {
73
73
  url: location.href,
74
74
  ts: Date.now(),
75
75
  });
@@ -82,7 +82,7 @@ window.addEventListener("hashchange", () => {
82
82
  };
83
83
 
84
84
  history.replaceState = function (...args) {
85
- AX.instance.wasm.log_event_activity("SPA Route Change (replaceState)", {
85
+ AX.instance.wasm.log_lifecycle_activity("SPA Route Change (replaceState)", {
86
86
  url: location.href,
87
87
  ts: Date.now(),
88
88
  });
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "author": "BasilGregory Software Labs Private Limited",
6
6
  "homepage": "https://www.appxiom.com",
7
- "version": "0.1.10",
7
+ "version": "0.1.11",
8
8
  "publishConfig": {
9
9
  "access": "public"
10
10
  },