@interfere/react 0.0.1 → 0.0.2-alpha.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.
Files changed (198) hide show
  1. package/dist/client.d.mts +15 -0
  2. package/dist/client.d.mts.map +1 -0
  3. package/dist/client.mjs +75 -0
  4. package/dist/client.mjs.map +1 -0
  5. package/dist/core/events/event-registry.d.mts +23 -0
  6. package/dist/core/events/event-registry.d.mts.map +1 -0
  7. package/dist/core/events/event-registry.mjs +32 -0
  8. package/dist/core/events/event-registry.mjs.map +1 -0
  9. package/dist/core/events/plugin-event-types.d.mts +92 -0
  10. package/dist/core/events/plugin-event-types.d.mts.map +1 -0
  11. package/dist/core/events/plugin-event-types.mjs +25 -0
  12. package/dist/core/events/plugin-event-types.mjs.map +1 -0
  13. package/dist/core/plugins/dom-utils.d.mts +9 -0
  14. package/dist/core/plugins/dom-utils.d.mts.map +1 -0
  15. package/dist/core/plugins/dom-utils.mjs +25 -0
  16. package/dist/core/plugins/dom-utils.mjs.map +1 -0
  17. package/dist/core/plugins/impl/ai-summary.d.mts +6 -0
  18. package/dist/core/plugins/impl/ai-summary.d.mts.map +1 -0
  19. package/dist/core/plugins/impl/ai-summary.mjs +122 -0
  20. package/dist/core/plugins/impl/ai-summary.mjs.map +1 -0
  21. package/dist/core/plugins/impl/errors.d.mts +9 -0
  22. package/dist/core/plugins/impl/errors.d.mts.map +1 -0
  23. package/dist/core/plugins/impl/errors.mjs +153 -0
  24. package/dist/core/plugins/impl/errors.mjs.map +1 -0
  25. package/dist/core/plugins/impl/page-events.d.mts +15 -0
  26. package/dist/core/plugins/impl/page-events.d.mts.map +1 -0
  27. package/dist/core/plugins/impl/page-events.mjs +131 -0
  28. package/dist/core/plugins/impl/page-events.mjs.map +1 -0
  29. package/dist/core/plugins/impl/rage-click.d.mts +6 -0
  30. package/dist/core/plugins/impl/rage-click.d.mts.map +1 -0
  31. package/dist/core/plugins/impl/rage-click.mjs +53 -0
  32. package/dist/core/plugins/impl/rage-click.mjs.map +1 -0
  33. package/dist/core/plugins/impl/replay.d.mts +9 -0
  34. package/dist/core/plugins/impl/replay.d.mts.map +1 -0
  35. package/dist/core/plugins/impl/replay.mjs +144 -0
  36. package/dist/core/plugins/impl/replay.mjs.map +1 -0
  37. package/dist/core/plugins/impl/server-tracing.d.mts +7 -0
  38. package/dist/core/plugins/impl/server-tracing.d.mts.map +1 -0
  39. package/dist/core/plugins/impl/server-tracing.mjs +160 -0
  40. package/dist/core/plugins/impl/server-tracing.mjs.map +1 -0
  41. package/dist/core/plugins/plugin-event-system.d.mts +47 -0
  42. package/dist/core/plugins/plugin-event-system.d.mts.map +1 -0
  43. package/dist/core/plugins/plugin-event-system.mjs +75 -0
  44. package/dist/core/plugins/plugin-event-system.mjs.map +1 -0
  45. package/dist/core/plugins/plugin-loader.d.mts +22 -0
  46. package/dist/core/plugins/plugin-loader.d.mts.map +1 -0
  47. package/dist/core/plugins/plugin-loader.mjs +142 -0
  48. package/dist/core/plugins/plugin-loader.mjs.map +1 -0
  49. package/dist/core/runtime/config.d.mts +14 -0
  50. package/dist/core/runtime/config.d.mts.map +1 -0
  51. package/dist/core/runtime/config.mjs +39 -0
  52. package/dist/core/runtime/config.mjs.map +1 -0
  53. package/dist/core/runtime/context.d.mts +25 -0
  54. package/dist/core/runtime/context.d.mts.map +1 -0
  55. package/dist/core/runtime/context.mjs +48 -0
  56. package/dist/core/runtime/context.mjs.map +1 -0
  57. package/dist/core/runtime/ingest-target.d.mts +10 -0
  58. package/dist/core/runtime/ingest-target.d.mts.map +1 -0
  59. package/dist/core/runtime/ingest-target.mjs +15 -0
  60. package/dist/core/runtime/ingest-target.mjs.map +1 -0
  61. package/dist/core/schemas.d.mts +85 -0
  62. package/dist/core/schemas.d.mts.map +1 -0
  63. package/dist/core/schemas.mjs +1 -0
  64. package/dist/effect/build-envelope.d.mts +9 -0
  65. package/dist/effect/build-envelope.d.mts.map +1 -0
  66. package/dist/effect/build-envelope.mjs +29 -0
  67. package/dist/effect/build-envelope.mjs.map +1 -0
  68. package/dist/effect/errors.d.mts +36 -0
  69. package/dist/effect/errors.d.mts.map +1 -0
  70. package/dist/effect/errors.mjs +10 -0
  71. package/dist/effect/errors.mjs.map +1 -0
  72. package/dist/effect/layers/config.layer.d.mts +13 -0
  73. package/dist/effect/layers/config.layer.d.mts.map +1 -0
  74. package/dist/effect/layers/config.layer.mjs +21 -0
  75. package/dist/effect/layers/config.layer.mjs.map +1 -0
  76. package/dist/effect/layers/context.layer.d.mts +12 -0
  77. package/dist/effect/layers/context.layer.d.mts.map +1 -0
  78. package/dist/effect/layers/context.layer.mjs +14 -0
  79. package/dist/effect/layers/context.layer.mjs.map +1 -0
  80. package/dist/effect/layers/http.layer.d.mts +21 -0
  81. package/dist/effect/layers/http.layer.d.mts.map +1 -0
  82. package/dist/effect/layers/http.layer.mjs +113 -0
  83. package/dist/effect/layers/http.layer.mjs.map +1 -0
  84. package/dist/effect/layers/queue.layer.d.mts +30 -0
  85. package/dist/effect/layers/queue.layer.d.mts.map +1 -0
  86. package/dist/effect/layers/queue.layer.mjs +232 -0
  87. package/dist/effect/layers/queue.layer.mjs.map +1 -0
  88. package/dist/effect/layers/session.layer.d.mts +26 -0
  89. package/dist/effect/layers/session.layer.d.mts.map +1 -0
  90. package/dist/effect/layers/session.layer.mjs +126 -0
  91. package/dist/effect/layers/session.layer.mjs.map +1 -0
  92. package/dist/effect/layers/storage.layer.d.mts +19 -0
  93. package/dist/effect/layers/storage.layer.d.mts.map +1 -0
  94. package/dist/effect/layers/storage.layer.mjs +200 -0
  95. package/dist/effect/layers/storage.layer.mjs.map +1 -0
  96. package/dist/effect/layers/tracer.layer.d.mts +9 -0
  97. package/dist/effect/layers/tracer.layer.d.mts.map +1 -0
  98. package/dist/effect/layers/tracer.layer.mjs +11 -0
  99. package/dist/effect/layers/tracer.layer.mjs.map +1 -0
  100. package/dist/effect/runtime-services.d.mts +22 -0
  101. package/dist/effect/runtime-services.d.mts.map +1 -0
  102. package/dist/effect/runtime-services.mjs +76 -0
  103. package/dist/effect/runtime-services.mjs.map +1 -0
  104. package/dist/effect/tags.d.mts +50 -0
  105. package/dist/effect/tags.d.mts.map +1 -0
  106. package/dist/effect/tags.mjs +7 -0
  107. package/dist/effect/tags.mjs.map +1 -0
  108. package/dist/hooks/use-runtime-and-plugins.d.mts +7 -0
  109. package/dist/hooks/use-runtime-and-plugins.d.mts.map +1 -0
  110. package/dist/hooks/use-runtime-and-plugins.mjs +153 -0
  111. package/dist/hooks/use-runtime-and-plugins.mjs.map +1 -0
  112. package/dist/hooks/use-session.d.mts +40 -0
  113. package/dist/hooks/use-session.d.mts.map +1 -0
  114. package/dist/hooks/use-session.mjs +96 -0
  115. package/dist/hooks/use-session.mjs.map +1 -0
  116. package/dist/package.mjs +100 -0
  117. package/dist/package.mjs.map +1 -0
  118. package/dist/provider.d.mts +17 -0
  119. package/dist/provider.d.mts.map +1 -0
  120. package/dist/provider.mjs +26 -0
  121. package/dist/provider.mjs.map +1 -0
  122. package/dist/server/auth.d.mts +11 -0
  123. package/dist/server/auth.d.mts.map +1 -0
  124. package/dist/server/auth.mjs +36 -0
  125. package/dist/server/auth.mjs.map +1 -0
  126. package/dist/server/capture.d.mts +18 -0
  127. package/dist/server/capture.d.mts.map +1 -0
  128. package/dist/server/capture.mjs +105 -0
  129. package/dist/server/capture.mjs.map +1 -0
  130. package/package.json +60 -27
  131. package/dist/__tests__/client.test.d.ts +0 -2
  132. package/dist/__tests__/client.test.d.ts.map +0 -1
  133. package/dist/__tests__/client.test.js +0 -447
  134. package/dist/__tests__/client.test.js.map +0 -1
  135. package/dist/__tests__/lib/core/error-handlers.test.d.ts +0 -2
  136. package/dist/__tests__/lib/core/error-handlers.test.d.ts.map +0 -1
  137. package/dist/__tests__/lib/core/error-handlers.test.js +0 -596
  138. package/dist/__tests__/lib/core/error-handlers.test.js.map +0 -1
  139. package/dist/__tests__/lib/core/event-queue.test.d.ts +0 -2
  140. package/dist/__tests__/lib/core/event-queue.test.d.ts.map +0 -1
  141. package/dist/__tests__/lib/core/event-queue.test.js +0 -290
  142. package/dist/__tests__/lib/core/event-queue.test.js.map +0 -1
  143. package/dist/__tests__/lib/core/runtime.test.d.ts +0 -2
  144. package/dist/__tests__/lib/core/runtime.test.d.ts.map +0 -1
  145. package/dist/__tests__/lib/core/runtime.test.js +0 -133
  146. package/dist/__tests__/lib/core/runtime.test.js.map +0 -1
  147. package/dist/__tests__/lib/core/session-manager.test.d.ts +0 -2
  148. package/dist/__tests__/lib/core/session-manager.test.d.ts.map +0 -1
  149. package/dist/__tests__/lib/core/session-manager.test.js +0 -356
  150. package/dist/__tests__/lib/core/session-manager.test.js.map +0 -1
  151. package/dist/__tests__/provider.test.d.ts +0 -2
  152. package/dist/__tests__/provider.test.d.ts.map +0 -1
  153. package/dist/__tests__/provider.test.js +0 -143
  154. package/dist/__tests__/provider.test.js.map +0 -1
  155. package/dist/client.d.ts +0 -78
  156. package/dist/client.d.ts.map +0 -1
  157. package/dist/client.js +0 -219
  158. package/dist/client.js.map +0 -1
  159. package/dist/index.d.ts +0 -6
  160. package/dist/index.d.ts.map +0 -1
  161. package/dist/index.js +0 -5
  162. package/dist/index.js.map +0 -1
  163. package/dist/lib/core/error-handlers.d.ts +0 -14
  164. package/dist/lib/core/error-handlers.d.ts.map +0 -1
  165. package/dist/lib/core/error-handlers.js +0 -191
  166. package/dist/lib/core/error-handlers.js.map +0 -1
  167. package/dist/lib/core/event-queue.d.ts +0 -90
  168. package/dist/lib/core/event-queue.d.ts.map +0 -1
  169. package/dist/lib/core/event-queue.js +0 -286
  170. package/dist/lib/core/event-queue.js.map +0 -1
  171. package/dist/lib/core/runtime.d.ts +0 -7
  172. package/dist/lib/core/runtime.d.ts.map +0 -1
  173. package/dist/lib/core/runtime.js +0 -16
  174. package/dist/lib/core/runtime.js.map +0 -1
  175. package/dist/lib/core/session-manager.d.ts +0 -96
  176. package/dist/lib/core/session-manager.d.ts.map +0 -1
  177. package/dist/lib/core/session-manager.js +0 -431
  178. package/dist/lib/core/session-manager.js.map +0 -1
  179. package/dist/lib/persistence/storage.d.ts +0 -5
  180. package/dist/lib/persistence/storage.d.ts.map +0 -1
  181. package/dist/lib/persistence/storage.js +0 -67
  182. package/dist/lib/persistence/storage.js.map +0 -1
  183. package/dist/lib/session/rage-click.d.ts +0 -2
  184. package/dist/lib/session/rage-click.d.ts.map +0 -1
  185. package/dist/lib/session/rage-click.js +0 -51
  186. package/dist/lib/session/rage-click.js.map +0 -1
  187. package/dist/lib/session/replay.d.ts +0 -3
  188. package/dist/lib/session/replay.d.ts.map +0 -1
  189. package/dist/lib/session/replay.js +0 -106
  190. package/dist/lib/session/replay.js.map +0 -1
  191. package/dist/lib/session/session-summary.d.ts +0 -3
  192. package/dist/lib/session/session-summary.d.ts.map +0 -1
  193. package/dist/lib/session/session-summary.js +0 -79
  194. package/dist/lib/session/session-summary.js.map +0 -1
  195. package/dist/provider.d.ts +0 -76
  196. package/dist/provider.d.ts.map +0 -1
  197. package/dist/provider.js +0 -138
  198. package/dist/provider.js.map +0 -1
package/dist/client.js DELETED
@@ -1,219 +0,0 @@
1
- import { RADIX_36, RANDOM_ID_LENGTH_MEDIUM, RANDOM_SUBSTRING_START, } from "@interfere/constants";
2
- import { EventQueue } from "./lib/core/event-queue.js";
3
- import { SessionManager } from "./lib/core/session-manager.js";
4
- // Client state
5
- let eventQueue;
6
- let sessionManager;
7
- let windowId;
8
- let debugLogger = null;
9
- // Initialize immediately if in browser
10
- if (typeof window !== "undefined") {
11
- windowId = `win_${Date.now()}_${Math.random()
12
- .toString(RADIX_36)
13
- .substring(RANDOM_SUBSTRING_START, RANDOM_SUBSTRING_START + RANDOM_ID_LENGTH_MEDIUM)}`;
14
- sessionManager = new SessionManager((newSessionId) => {
15
- if (debugLogger) {
16
- debugLogger(`Session changed to: ${newSessionId}`);
17
- }
18
- });
19
- eventQueue = new EventQueue(sendEvents, {
20
- enableOfflineQueue: true,
21
- enableCompression: true,
22
- maxRetries: 3,
23
- batchSize: 10,
24
- batchTimeout: 100,
25
- maxQueueSize: 1000,
26
- });
27
- eventQueue.setWindowId(windowId);
28
- }
29
- /**
30
- * Send events to the server
31
- */
32
- async function sendEvents(events) {
33
- // Update session activity
34
- sessionManager?.updateActivity();
35
- // Get session ID (from manager or server response)
36
- const localSessionId = sessionManager?.getSessionId();
37
- try {
38
- const response = await fetch("/api/interfere", {
39
- method: "POST",
40
- headers: {
41
- "Content-Type": "application/json",
42
- },
43
- body: JSON.stringify({
44
- events: events.map((e) => ({
45
- type: e.type,
46
- payload: e.payload,
47
- timestamp: e.timestamp,
48
- })),
49
- windowId,
50
- sessionId: localSessionId,
51
- url: window.location.href,
52
- userAgent: navigator.userAgent,
53
- }),
54
- keepalive: true,
55
- });
56
- if (!response.ok) {
57
- throw new Error(`HTTP error! status: ${response.status}`);
58
- }
59
- const data = await response.json();
60
- // Log server session if different from local
61
- if (data.sessionId && data.sessionId !== localSessionId && debugLogger) {
62
- debugLogger(`Server session ID: ${data.sessionId}`);
63
- }
64
- }
65
- catch (error) {
66
- if (debugLogger) {
67
- debugLogger("Failed to send events", error);
68
- }
69
- throw error; // Let the queue handle retry
70
- }
71
- }
72
- /**
73
- * Send an event to Interfere
74
- */
75
- export const capture = (type, payload) => {
76
- // Skip on server-side rendering
77
- if (typeof window === "undefined") {
78
- return;
79
- }
80
- eventQueue.add(type, payload);
81
- };
82
- /**
83
- * Flush any pending events immediately
84
- */
85
- export const flush = async () => {
86
- if (typeof window === "undefined") {
87
- return;
88
- }
89
- await eventQueue.flush();
90
- };
91
- /**
92
- * Get the current session ID
93
- */
94
- export const getSessionId = () => {
95
- if (typeof window === "undefined") {
96
- return "";
97
- }
98
- return sessionManager.getSessionId() || "";
99
- };
100
- /**
101
- * Get the current window ID
102
- */
103
- export const getWindowId = () => {
104
- if (typeof window === "undefined") {
105
- return "";
106
- }
107
- return windowId || "";
108
- };
109
- /**
110
- * Reset the current session
111
- */
112
- export const resetSession = () => {
113
- if (typeof window === "undefined") {
114
- return;
115
- }
116
- flush(); // Send any pending events first
117
- sessionManager.resetSession();
118
- };
119
- /**
120
- * Capture an error event
121
- */
122
- export const captureError = (error) => {
123
- capture("error", {
124
- message: error instanceof Error ? error.message : String(error),
125
- stack: error instanceof Error ? error.stack : undefined,
126
- name: error instanceof Error ? error.name : "UnknownError",
127
- });
128
- };
129
- /**
130
- * Capture a custom event
131
- */
132
- export const captureCustom = (name, data) => {
133
- capture("custom", {
134
- name,
135
- data,
136
- });
137
- };
138
- /**
139
- * Capture a UI interaction event
140
- */
141
- export const captureUIEvent = (action, metadata) => {
142
- capture("ui_event", {
143
- action,
144
- metadata,
145
- });
146
- };
147
- /**
148
- * Set a debug logger for diagnostics
149
- */
150
- export const setDebugLogger = (logger) => {
151
- debugLogger = logger || null;
152
- };
153
- /**
154
- * Get debug information about the SDK state
155
- */
156
- export const getDebugInfo = () => {
157
- if (typeof window === "undefined") {
158
- return {
159
- sessionId: null,
160
- windowId: null,
161
- pendingEventsCount: 0,
162
- hasDebugLogger: false,
163
- isServerSide: true,
164
- };
165
- }
166
- const sessionDebugInfo = sessionManager.getDebugInfo();
167
- return {
168
- sessionId: sessionDebugInfo.sessionId,
169
- windowId,
170
- pendingEventsCount: eventQueue.getQueueSize(),
171
- hasDebugLogger: !!debugLogger,
172
- isServerSide: false,
173
- sessionStartTimestamp: sessionDebugInfo.sessionStartTimestamp,
174
- lastActivityTimestamp: sessionDebugInfo.lastActivityTimestamp,
175
- sessionTimeoutMs: sessionDebugInfo.sessionTimeoutMs,
176
- sessionAge: sessionDebugInfo.sessionAge,
177
- timeSinceLastActivity: sessionDebugInfo.timeSinceLastActivity,
178
- isSessionActive: sessionDebugInfo.isSessionActive,
179
- config: {},
180
- storageInfo: sessionDebugInfo.storageInfo,
181
- queueSize: eventQueue.getQueueSize(),
182
- isOnline: eventQueue.isOnlineStatus(),
183
- };
184
- };
185
- /**
186
- * Subscribe to session ID changes
187
- */
188
- export const onSessionId = (callback) => {
189
- const POLL_INTERVAL = 1000;
190
- const interval = setInterval(() => {
191
- const currentId = getSessionId();
192
- if (currentId) {
193
- callback(currentId);
194
- }
195
- }, POLL_INTERVAL);
196
- return () => clearInterval(interval);
197
- };
198
- /**
199
- * Destroy the SDK instance and clean up
200
- */
201
- export const destroy = async () => {
202
- if (typeof window === "undefined") {
203
- return;
204
- }
205
- await flush();
206
- eventQueue?.destroy();
207
- debugLogger = null;
208
- };
209
- // Auto-flush on page unload
210
- if (typeof window !== "undefined") {
211
- window.addEventListener("beforeunload", () => flush());
212
- window.addEventListener("pagehide", () => flush());
213
- window.addEventListener("visibilitychange", () => {
214
- if (document.visibilityState === "hidden") {
215
- flush();
216
- }
217
- });
218
- }
219
- //# sourceMappingURL=client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAoB,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,eAAe;AACf,IAAI,UAAsB,CAAC;AAC3B,IAAI,cAA8B,CAAC;AACnC,IAAI,QAAgB,CAAC;AACrB,IAAI,WAAW,GAAsD,IAAI,CAAC;AAE1E,uCAAuC;AACvC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IAClC,QAAQ,GAAG,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE;SAC1C,QAAQ,CAAC,QAAQ,CAAC;SAClB,SAAS,CACR,sBAAsB,EACtB,sBAAsB,GAAG,uBAAuB,CACjD,EAAE,CAAC;IAEN,cAAc,GAAG,IAAI,cAAc,CAAC,CAAC,YAAY,EAAE,EAAE;QACnD,IAAI,WAAW,EAAE,CAAC;YAChB,WAAW,CAAC,uBAAuB,YAAY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,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,IAAmB,EAAE;IAC/C,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO;IACT,CAAC;IAED,MAAM,KAAK,EAAE,CAAC;IACd,UAAU,EAAE,OAAO,EAAE,CAAC;IACtB,WAAW,GAAG,IAAI,CAAC;AACrB,CAAC,CAAC;AAEF,4BAA4B;AAC5B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IAClC,MAAM,CAAC,gBAAgB,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;IACvD,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;IACnD,MAAM,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAC/C,IAAI,QAAQ,CAAC,eAAe,KAAK,QAAQ,EAAE,CAAC;YAC1C,KAAK,EAAE,CAAC;QACV,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
package/dist/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- /** biome-ignore-all lint/performance/noBarrelFile: We need to export everything from the client */
2
- export { capture, captureCustom, captureError, captureUIEvent, flush, getDebugInfo, getSessionId, getWindowId, resetSession, setDebugLogger, } from "./client.js";
3
- export { captureServerError } from "./lib/core/error-handlers.js";
4
- export type { InterfereProviderProps } from "./provider.js";
5
- export { InterfereProvider, useInterfere } from "./provider.js";
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mGAAmG;AAEnG,OAAO,EACL,OAAO,EACP,aAAa,EACb,YAAY,EACZ,cAAc,EACd,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,YAAY,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
package/dist/index.js DELETED
@@ -1,5 +0,0 @@
1
- /** biome-ignore-all lint/performance/noBarrelFile: We need to export everything from the client */
2
- export { capture, captureCustom, captureError, captureUIEvent, flush, getDebugInfo, getSessionId, getWindowId, resetSession, setDebugLogger, } from "./client.js";
3
- export { captureServerError } from "./lib/core/error-handlers.js";
4
- export { InterfereProvider, useInterfere } from "./provider.js";
5
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mGAAmG;AAEnG,OAAO,EACL,OAAO,EACP,aAAa,EACb,YAAY,EACZ,cAAc,EACd,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAIlE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
@@ -1,14 +0,0 @@
1
- export declare function setupClientErrorHandlers(): void;
2
- export declare function captureServerError(error: unknown, request?: Request, context?: {
3
- pathname?: string;
4
- renderingError?: boolean;
5
- [key: string]: unknown;
6
- }): void;
7
- export declare function captureErrorBoundaryError(error: Error, errorInfo: {
8
- componentStack: string;
9
- }): void;
10
- export declare function captureApiRouteError(error: unknown, req: Request, pathname: string): void;
11
- type AsyncFunction = (...args: unknown[]) => Promise<unknown>;
12
- export declare function withErrorCapture<T extends AsyncFunction>(fn: T, context?: Record<string, unknown>): T;
13
- export {};
14
- //# sourceMappingURL=error-handlers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-handlers.d.ts","sourceRoot":"","sources":["../../../src/lib/core/error-handlers.ts"],"names":[],"mappings":"AA4DA,wBAAgB,wBAAwB,IAAI,IAAI,CAiE/C;AAGD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,OAAO,EACjB,OAAO,CAAC,EAAE;IACR,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,GACA,IAAI,CAoBN;AAGD,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE,GACpC,IAAI,CAQN;AAGD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,MAAM,GACf,IAAI,CAcN;AA+BD,KAAK,aAAa,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAE9D,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,aAAa,EACtD,EAAE,EAAE,CAAC,EACL,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,CAAC,CAkBH"}
@@ -1,191 +0,0 @@
1
- import { capture } from "../../client.js";
2
- // Flag to prevent infinite loops when capturing errors
3
- let isCapturing = false;
4
- function serializeError(error) {
5
- if (error instanceof Error) {
6
- return {
7
- message: error.message,
8
- stack: error.stack,
9
- name: error.name,
10
- cause: error.cause,
11
- };
12
- }
13
- if (typeof error === "string") {
14
- return {
15
- message: error,
16
- name: "Error",
17
- };
18
- }
19
- return {
20
- message: String(error),
21
- name: "UnknownError",
22
- };
23
- }
24
- // Safe capture that doesn't throw if SDK isn't initialized
25
- function safeCapture(eventType, payload) {
26
- // Prevent recursive captures
27
- if (isCapturing) {
28
- return;
29
- }
30
- try {
31
- isCapturing = true;
32
- capture(eventType, payload);
33
- }
34
- catch {
35
- // SDK not initialized yet, skip capture
36
- // In production, you might want to queue these events for later
37
- }
38
- finally {
39
- isCapturing = false;
40
- }
41
- }
42
- // Client-side error handling
43
- export function setupClientErrorHandlers() {
44
- if (typeof window === "undefined") {
45
- return;
46
- }
47
- // Handle unhandled errors
48
- window.addEventListener("error", (event) => {
49
- const errorInfo = {
50
- message: event.message,
51
- name: "WindowError",
52
- fileName: event.filename,
53
- lineNumber: event.lineno,
54
- columnNumber: event.colno,
55
- stack: event.error?.stack,
56
- };
57
- safeCapture("error", {
58
- type: "unhandled_error",
59
- error: errorInfo,
60
- url: window.location.href,
61
- userAgent: navigator.userAgent,
62
- timestamp: Date.now(),
63
- });
64
- });
65
- // Handle unhandled promise rejections
66
- window.addEventListener("unhandledrejection", (event) => {
67
- const errorInfo = serializeError(event.reason);
68
- safeCapture("error", {
69
- type: "unhandled_rejection",
70
- error: errorInfo,
71
- url: window.location.href,
72
- userAgent: navigator.userAgent,
73
- timestamp: Date.now(),
74
- });
75
- });
76
- // Override console.error to capture logged errors
77
- // biome-ignore lint/suspicious/noConsole: We need to override console.error for error tracking
78
- const originalConsoleError = console.error;
79
- console.error = (...args) => {
80
- originalConsoleError.apply(console, args);
81
- // Convert arguments to a readable format
82
- const message = args
83
- .map((arg) => {
84
- if (typeof arg === "object") {
85
- try {
86
- return JSON.stringify(arg);
87
- }
88
- catch {
89
- return String(arg);
90
- }
91
- }
92
- return String(arg);
93
- })
94
- .join(" ");
95
- safeCapture("error", {
96
- type: "console_error",
97
- message,
98
- url: typeof window !== "undefined" ? window.location.href : undefined,
99
- timestamp: Date.now(),
100
- });
101
- };
102
- }
103
- // Server/Edge error handling for Next.js
104
- export function captureServerError(error, request, context) {
105
- const errorInfo = serializeError(error);
106
- const runtime = typeof globalThis !== "undefined" && "EdgeRuntime" in globalThis
107
- ? "edge"
108
- : "server";
109
- safeCapture(runtime === "edge" ? "edge_error" : "server_error", {
110
- type: "server_error",
111
- error: errorInfo,
112
- request: request
113
- ? {
114
- url: request.url,
115
- method: request.method,
116
- headers: Object.fromEntries(request.headers.entries()),
117
- }
118
- : undefined,
119
- context,
120
- timestamp: Date.now(),
121
- });
122
- }
123
- // Next.js specific error boundary helper
124
- export function captureErrorBoundaryError(error, errorInfo) {
125
- safeCapture("error", {
126
- type: "error_boundary",
127
- error: serializeError(error),
128
- componentStack: errorInfo.componentStack,
129
- url: typeof window !== "undefined" ? window.location.href : undefined,
130
- timestamp: Date.now(),
131
- });
132
- }
133
- // Capture Next.js API route errors
134
- export function captureApiRouteError(error, req, pathname) {
135
- const errorInfo = serializeError(error);
136
- safeCapture("server_error", {
137
- type: "api_route_error",
138
- error: errorInfo,
139
- request: {
140
- url: req.url,
141
- method: req.method,
142
- headers: Object.fromEntries(req.headers.entries()),
143
- pathname,
144
- },
145
- timestamp: Date.now(),
146
- });
147
- }
148
- // Determine runtime environment
149
- function getRuntime() {
150
- if (typeof window !== "undefined") {
151
- return "client";
152
- }
153
- if (typeof globalThis !== "undefined" && "EdgeRuntime" in globalThis) {
154
- return "edge";
155
- }
156
- return "server";
157
- }
158
- // Get event type based on runtime
159
- function getErrorEventType(runtime) {
160
- switch (runtime) {
161
- case "client":
162
- return "error";
163
- case "edge":
164
- return "edge_error";
165
- case "server":
166
- return "server_error";
167
- default:
168
- // This should never happen due to the type constraint, but satisfies the linter
169
- return "error";
170
- }
171
- }
172
- export function withErrorCapture(fn, context) {
173
- return (async (...args) => {
174
- try {
175
- return await fn(...args);
176
- }
177
- catch (error) {
178
- const runtime = getRuntime();
179
- const eventType = getErrorEventType(runtime);
180
- safeCapture(eventType, {
181
- type: "wrapped_function_error",
182
- error: serializeError(error),
183
- functionName: fn.name || "anonymous",
184
- context,
185
- timestamp: Date.now(),
186
- });
187
- throw error;
188
- }
189
- });
190
- }
191
- //# sourceMappingURL=error-handlers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-handlers.js","sourceRoot":"","sources":["../../../src/lib/core/error-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,uDAAuD;AACvD,IAAI,WAAW,GAAG,KAAgB,CAAC;AAYnC,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO;YACL,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO;YACL,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,OAAO;SACd,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC;QACtB,IAAI,EAAE,cAAc;KACrB,CAAC;AACJ,CAAC;AAED,2DAA2D;AAC3D,SAAS,WAAW,CAClB,SAAwC,EACxC,OAAsC;IAEtC,6BAA6B;IAC7B,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,WAAW,GAAG,IAAI,CAAC;QACnB,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,wCAAwC;QACxC,gEAAgE;IAClE,CAAC;YAAS,CAAC;QACT,WAAW,GAAG,KAAK,CAAC;IACtB,CAAC;AACH,CAAC;AAED,6BAA6B;AAC7B,MAAM,UAAU,wBAAwB;IACtC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO;IACT,CAAC;IAED,0BAA0B;IAC1B,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QACzC,MAAM,S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Q;YACX,OAAO,OAAO,CAAC;QACjB,KAAK,MAAM;YACT,OAAO,YAAY,CAAC;QACtB,KAAK,QAAQ;YACX,OAAO,cAAc,CAAC;QACxB;YACE,gFAAgF;YAChF,OAAO,OAAO,CAAC;IACnB,CAAC;AACH,CAAC;AAKD,MAAM,UAAU,gBAAgB,CAC9B,EAAK,EACL,OAAiC;IAEjC,OAAO,CAAC,KAAK,EAAE,GAAG,IAAmB,EAAE,EAAE;QACvC,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;YAC7B,MAAM,SAAS,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAE7C,WAAW,CAAC,SAAS,EAAE;gBACrB,IAAI,EAAE,wBAAwB;gBAC9B,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC;gBAC5B,YAAY,EAAE,EAAE,CAAC,IAAI,IAAI,WAAW;gBACpC,OAAO;gBACP,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACtB,CAAC,CAAC;YACH,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAM,CAAC;AACV,CAAC"}
@@ -1,90 +0,0 @@
1
- /**
2
- * Enhanced event queue with offline support, retry logic, and compression
3
- */
4
- import type { EventType } from "@interfere/schemas/envelope";
5
- export type QueuedEvent = {
6
- id: string;
7
- type: EventType;
8
- payload: unknown;
9
- timestamp: number;
10
- retryCount: number;
11
- windowId: string | null;
12
- };
13
- type QueueConfig = {
14
- maxRetries: number;
15
- batchSize: number;
16
- batchTimeout: number;
17
- maxQueueSize: number;
18
- enableCompression: boolean;
19
- enableOfflineQueue: boolean;
20
- storageKey: string;
21
- };
22
- export declare class EventQueue {
23
- private queue;
24
- private readonly config;
25
- private flushTimer;
26
- private readonly retryTimers;
27
- private isOnline;
28
- private readonly onFlush;
29
- private windowId;
30
- private isDestroyed;
31
- constructor(onFlush: (events: QueuedEvent[]) => Promise<void>, config?: Partial<QueueConfig>);
32
- /**
33
- * Set window ID for all events
34
- */
35
- setWindowId(id: string): void;
36
- /**
37
- * Add an event to the queue
38
- */
39
- add(type: EventType, payload: unknown): void;
40
- /**
41
- * Flush events immediately
42
- */
43
- flush(): Promise<void>;
44
- /**
45
- * Handle failed batch with retry logic
46
- */
47
- private handleFailedBatch;
48
- /**
49
- * Schedule a flush
50
- */
51
- private scheduleFlush;
52
- /**
53
- * Compress events (basic implementation - can be enhanced)
54
- */
55
- private compressEvents;
56
- /**
57
- * Handle coming online
58
- */
59
- private readonly handleOnline;
60
- /**
61
- * Handle going offline
62
- */
63
- private readonly handleOffline;
64
- /**
65
- * Save queue to storage
66
- */
67
- private saveToStorage;
68
- /**
69
- * Load queue from storage
70
- */
71
- private loadFromStorage;
72
- /**
73
- * Generate unique event ID
74
- */
75
- private generateId;
76
- /**
77
- * Clean up resources
78
- */
79
- destroy(): void;
80
- /**
81
- * Get current queue size
82
- */
83
- getQueueSize(): number;
84
- /**
85
- * Check if online
86
- */
87
- isOnlineStatus(): boolean;
88
- }
89
- export {};
90
- //# sourceMappingURL=event-queue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event-queue.d.ts","sourceRoot":"","sources":["../../../src/lib/core/event-queue.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM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