@nexussdk/contracts 0.0.3 → 0.0.4
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/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/tracker.d.mts +144 -1
- package/dist/tracker.d.ts +144 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Account, AccountStatus, ApiKey, ApiKeyType, Environment, GeneratedApiKeyResponse, LoginDto, PlanTier, Project, RegisterAccountDto, SessionPayload } from './auth.mjs';
|
|
2
2
|
export { BatchFlagEvaluation, CreateFlagDto, FeatureFlag, FlagEvaluationResult, FlagStreamEvent, FlagVariants, RuleOperator, TargetingRule, UpdateFlagDto, UserContext, VariantValue } from './flags.mjs';
|
|
3
|
-
export { Breadcrumb, BreadcrumbCategory, DeviceContext, ErrorEventEntity, ErrorEventPayload, ErrorGroupSummary, SeverityLevel, StackFrame } from './tracker.mjs';
|
|
3
|
+
export { Breadcrumb, BreadcrumbCategory, DevServerEventEnvelope, DeviceContext, ErrorEventEntity, ErrorEventPayload, ErrorGroupSummary, NexusErrorInfo, PerformanceVitalEntry, PerformanceVitalsOptions, SamplingConfig, SeverityLevel, StackFrame, TransportPlugin, VitalMetricName } from './tracker.mjs';
|
|
4
4
|
export { NEXUS_ERROR_BASE, ProblemDetails } from './rfc7807.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Account, AccountStatus, ApiKey, ApiKeyType, Environment, GeneratedApiKeyResponse, LoginDto, PlanTier, Project, RegisterAccountDto, SessionPayload } from './auth.js';
|
|
2
2
|
export { BatchFlagEvaluation, CreateFlagDto, FeatureFlag, FlagEvaluationResult, FlagStreamEvent, FlagVariants, RuleOperator, TargetingRule, UpdateFlagDto, UserContext, VariantValue } from './flags.js';
|
|
3
|
-
export { Breadcrumb, BreadcrumbCategory, DeviceContext, ErrorEventEntity, ErrorEventPayload, ErrorGroupSummary, SeverityLevel, StackFrame } from './tracker.js';
|
|
3
|
+
export { Breadcrumb, BreadcrumbCategory, DevServerEventEnvelope, DeviceContext, ErrorEventEntity, ErrorEventPayload, ErrorGroupSummary, NexusErrorInfo, PerformanceVitalEntry, PerformanceVitalsOptions, SamplingConfig, SeverityLevel, StackFrame, TransportPlugin, VitalMetricName } from './tracker.js';
|
|
4
4
|
export { NEXUS_ERROR_BASE, ProblemDetails } from './rfc7807.js';
|
package/dist/tracker.d.mts
CHANGED
|
@@ -194,4 +194,147 @@ interface ErrorGroupSummary {
|
|
|
194
194
|
lastSeenAt: string;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
|
|
197
|
+
/**
|
|
198
|
+
* Normalized error information passed to NexusGuard fallback render function.
|
|
199
|
+
* Framework-agnostic — used by React, Vue, and Vanilla integrations.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* // React render prop
|
|
203
|
+
* <NexusGuard fallback={({ error, errorId, reset }) => (
|
|
204
|
+
* <div>Error #{errorId}: {error.message} <button onClick={reset}>Retry</button></div>
|
|
205
|
+
* )}>
|
|
206
|
+
* <App />
|
|
207
|
+
* </NexusGuard>
|
|
208
|
+
*/
|
|
209
|
+
interface NexusErrorInfo {
|
|
210
|
+
/** The original Error object that triggered the boundary. */
|
|
211
|
+
error: Error;
|
|
212
|
+
/**
|
|
213
|
+
* Deterministic fingerprint ID for this error class.
|
|
214
|
+
* Can be shown to users as a support reference code.
|
|
215
|
+
*/
|
|
216
|
+
errorId: string;
|
|
217
|
+
/** Resets the error boundary back to normal rendering state. */
|
|
218
|
+
reset: () => void;
|
|
219
|
+
/** Component stack trace (React/Vue only — undefined in Vanilla). */
|
|
220
|
+
componentStack?: string;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Custom transport plugin for SDK error event delivery.
|
|
224
|
+
* Allows complete replacement of the default fetch-based ingestion transport.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* // Custom Sentry forwarding transport
|
|
228
|
+
* const sentryTransport: TransportPlugin = async (event) => {
|
|
229
|
+
* Sentry.captureException(new Error(event.errorMessage));
|
|
230
|
+
* };
|
|
231
|
+
*
|
|
232
|
+
* Nexus.init({ transport: sentryTransport });
|
|
233
|
+
*/
|
|
234
|
+
type TransportPlugin = 'fetch' | 'console' | 'localStorage' | ((event: ErrorEventPayload) => void | Promise<void>);
|
|
235
|
+
/**
|
|
236
|
+
* Client-side event sampling and rate limiting configuration.
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* Nexus.init({
|
|
240
|
+
* sampling: {
|
|
241
|
+
* rate: 0.5, // Capture 50% of errors
|
|
242
|
+
* dedupeWindow: 5000, // 5s dedup window
|
|
243
|
+
* maxPerSession: 25, // Max 25 unique errors per session
|
|
244
|
+
* }
|
|
245
|
+
* });
|
|
246
|
+
*/
|
|
247
|
+
interface SamplingConfig {
|
|
248
|
+
/**
|
|
249
|
+
* Fraction of errors to capture and transmit. Range: 0.0 (none) to 1.0 (all).
|
|
250
|
+
* @default 1.0
|
|
251
|
+
*/
|
|
252
|
+
rate?: number;
|
|
253
|
+
/**
|
|
254
|
+
* Milliseconds sliding window for client-side deduplication.
|
|
255
|
+
* Duplicate errors within this window are counted but not retransmitted.
|
|
256
|
+
* @default 10000
|
|
257
|
+
*/
|
|
258
|
+
dedupeWindow?: number;
|
|
259
|
+
/**
|
|
260
|
+
* Maximum number of unique error fingerprints captured per browser session.
|
|
261
|
+
* Prevents event storms in crash-loop scenarios.
|
|
262
|
+
* @default 100
|
|
263
|
+
*/
|
|
264
|
+
maxPerSession?: number;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Web Vitals metric names measured by the Performance observer.
|
|
268
|
+
*/
|
|
269
|
+
type VitalMetricName = 'LCP' | 'CLS' | 'FID' | 'TTFB' | 'INP' | 'FCP';
|
|
270
|
+
/**
|
|
271
|
+
* Captured Web Vitals performance metric entry.
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* const entry: PerformanceVitalEntry = {
|
|
275
|
+
* name: 'LCP',
|
|
276
|
+
* value: 1200,
|
|
277
|
+
* rating: 'good',
|
|
278
|
+
* delta: 1200,
|
|
279
|
+
* navigationType: 'navigate',
|
|
280
|
+
* };
|
|
281
|
+
*/
|
|
282
|
+
interface PerformanceVitalEntry {
|
|
283
|
+
/** Metric name. */
|
|
284
|
+
name: VitalMetricName;
|
|
285
|
+
/** Metric value in milliseconds (or unitless score for CLS). */
|
|
286
|
+
value: number;
|
|
287
|
+
/** Quality rating based on Core Web Vitals thresholds. */
|
|
288
|
+
rating: 'good' | 'needs-improvement' | 'poor';
|
|
289
|
+
/** Delta from previous measurement in the same session. */
|
|
290
|
+
delta: number;
|
|
291
|
+
/** Navigation type that initiated the metric measurement. */
|
|
292
|
+
navigationType: 'navigate' | 'reload' | 'back-forward' | 'prerender' | string;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Configuration for the Web Vitals performance observer.
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* attachWebVitals(tracker, {
|
|
299
|
+
* captureAsEvents: true,
|
|
300
|
+
* poorRatingOnly: true,
|
|
301
|
+
* });
|
|
302
|
+
*/
|
|
303
|
+
interface PerformanceVitalsOptions {
|
|
304
|
+
/**
|
|
305
|
+
* When true, captures poor/needs-improvement vitals as full error events.
|
|
306
|
+
* When false, captures all vitals as breadcrumbs only.
|
|
307
|
+
* @default false
|
|
308
|
+
*/
|
|
309
|
+
captureAsEvents?: boolean;
|
|
310
|
+
/**
|
|
311
|
+
* When true, only captures metrics rated 'poor' or 'needs-improvement'.
|
|
312
|
+
* @default false
|
|
313
|
+
*/
|
|
314
|
+
poorRatingOnly?: boolean;
|
|
315
|
+
/**
|
|
316
|
+
* Subset of vital names to observe. Defaults to all supported vitals.
|
|
317
|
+
* @default ['LCP', 'CLS', 'FID', 'TTFB', 'INP', 'FCP']
|
|
318
|
+
*/
|
|
319
|
+
vitals?: VitalMetricName[];
|
|
320
|
+
/**
|
|
321
|
+
* Long task duration threshold in milliseconds. Tasks exceeding this
|
|
322
|
+
* are recorded as breadcrumbs with category 'performance'.
|
|
323
|
+
* @default 50
|
|
324
|
+
*/
|
|
325
|
+
longTaskThresholdMs?: number;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Event envelope used by the nexus-dev local ingestion server.
|
|
329
|
+
* Wraps ErrorEventPayload with server-assigned metadata.
|
|
330
|
+
*/
|
|
331
|
+
interface DevServerEventEnvelope {
|
|
332
|
+
/** Monotonically increasing server-assigned event ID. */
|
|
333
|
+
id: number;
|
|
334
|
+
/** ISO timestamp when the dev server received the event. */
|
|
335
|
+
receivedAt: string;
|
|
336
|
+
/** The captured error event payload. */
|
|
337
|
+
payload: ErrorEventPayload;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export { type Breadcrumb, type BreadcrumbCategory, type DevServerEventEnvelope, type DeviceContext, type ErrorEventEntity, type ErrorEventPayload, type ErrorGroupSummary, type NexusErrorInfo, type PerformanceVitalEntry, type PerformanceVitalsOptions, type SamplingConfig, type SeverityLevel, type StackFrame, type TransportPlugin, UserContext, type VitalMetricName };
|
package/dist/tracker.d.ts
CHANGED
|
@@ -194,4 +194,147 @@ interface ErrorGroupSummary {
|
|
|
194
194
|
lastSeenAt: string;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
|
|
197
|
+
/**
|
|
198
|
+
* Normalized error information passed to NexusGuard fallback render function.
|
|
199
|
+
* Framework-agnostic — used by React, Vue, and Vanilla integrations.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* // React render prop
|
|
203
|
+
* <NexusGuard fallback={({ error, errorId, reset }) => (
|
|
204
|
+
* <div>Error #{errorId}: {error.message} <button onClick={reset}>Retry</button></div>
|
|
205
|
+
* )}>
|
|
206
|
+
* <App />
|
|
207
|
+
* </NexusGuard>
|
|
208
|
+
*/
|
|
209
|
+
interface NexusErrorInfo {
|
|
210
|
+
/** The original Error object that triggered the boundary. */
|
|
211
|
+
error: Error;
|
|
212
|
+
/**
|
|
213
|
+
* Deterministic fingerprint ID for this error class.
|
|
214
|
+
* Can be shown to users as a support reference code.
|
|
215
|
+
*/
|
|
216
|
+
errorId: string;
|
|
217
|
+
/** Resets the error boundary back to normal rendering state. */
|
|
218
|
+
reset: () => void;
|
|
219
|
+
/** Component stack trace (React/Vue only — undefined in Vanilla). */
|
|
220
|
+
componentStack?: string;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Custom transport plugin for SDK error event delivery.
|
|
224
|
+
* Allows complete replacement of the default fetch-based ingestion transport.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* // Custom Sentry forwarding transport
|
|
228
|
+
* const sentryTransport: TransportPlugin = async (event) => {
|
|
229
|
+
* Sentry.captureException(new Error(event.errorMessage));
|
|
230
|
+
* };
|
|
231
|
+
*
|
|
232
|
+
* Nexus.init({ transport: sentryTransport });
|
|
233
|
+
*/
|
|
234
|
+
type TransportPlugin = 'fetch' | 'console' | 'localStorage' | ((event: ErrorEventPayload) => void | Promise<void>);
|
|
235
|
+
/**
|
|
236
|
+
* Client-side event sampling and rate limiting configuration.
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* Nexus.init({
|
|
240
|
+
* sampling: {
|
|
241
|
+
* rate: 0.5, // Capture 50% of errors
|
|
242
|
+
* dedupeWindow: 5000, // 5s dedup window
|
|
243
|
+
* maxPerSession: 25, // Max 25 unique errors per session
|
|
244
|
+
* }
|
|
245
|
+
* });
|
|
246
|
+
*/
|
|
247
|
+
interface SamplingConfig {
|
|
248
|
+
/**
|
|
249
|
+
* Fraction of errors to capture and transmit. Range: 0.0 (none) to 1.0 (all).
|
|
250
|
+
* @default 1.0
|
|
251
|
+
*/
|
|
252
|
+
rate?: number;
|
|
253
|
+
/**
|
|
254
|
+
* Milliseconds sliding window for client-side deduplication.
|
|
255
|
+
* Duplicate errors within this window are counted but not retransmitted.
|
|
256
|
+
* @default 10000
|
|
257
|
+
*/
|
|
258
|
+
dedupeWindow?: number;
|
|
259
|
+
/**
|
|
260
|
+
* Maximum number of unique error fingerprints captured per browser session.
|
|
261
|
+
* Prevents event storms in crash-loop scenarios.
|
|
262
|
+
* @default 100
|
|
263
|
+
*/
|
|
264
|
+
maxPerSession?: number;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Web Vitals metric names measured by the Performance observer.
|
|
268
|
+
*/
|
|
269
|
+
type VitalMetricName = 'LCP' | 'CLS' | 'FID' | 'TTFB' | 'INP' | 'FCP';
|
|
270
|
+
/**
|
|
271
|
+
* Captured Web Vitals performance metric entry.
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* const entry: PerformanceVitalEntry = {
|
|
275
|
+
* name: 'LCP',
|
|
276
|
+
* value: 1200,
|
|
277
|
+
* rating: 'good',
|
|
278
|
+
* delta: 1200,
|
|
279
|
+
* navigationType: 'navigate',
|
|
280
|
+
* };
|
|
281
|
+
*/
|
|
282
|
+
interface PerformanceVitalEntry {
|
|
283
|
+
/** Metric name. */
|
|
284
|
+
name: VitalMetricName;
|
|
285
|
+
/** Metric value in milliseconds (or unitless score for CLS). */
|
|
286
|
+
value: number;
|
|
287
|
+
/** Quality rating based on Core Web Vitals thresholds. */
|
|
288
|
+
rating: 'good' | 'needs-improvement' | 'poor';
|
|
289
|
+
/** Delta from previous measurement in the same session. */
|
|
290
|
+
delta: number;
|
|
291
|
+
/** Navigation type that initiated the metric measurement. */
|
|
292
|
+
navigationType: 'navigate' | 'reload' | 'back-forward' | 'prerender' | string;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Configuration for the Web Vitals performance observer.
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* attachWebVitals(tracker, {
|
|
299
|
+
* captureAsEvents: true,
|
|
300
|
+
* poorRatingOnly: true,
|
|
301
|
+
* });
|
|
302
|
+
*/
|
|
303
|
+
interface PerformanceVitalsOptions {
|
|
304
|
+
/**
|
|
305
|
+
* When true, captures poor/needs-improvement vitals as full error events.
|
|
306
|
+
* When false, captures all vitals as breadcrumbs only.
|
|
307
|
+
* @default false
|
|
308
|
+
*/
|
|
309
|
+
captureAsEvents?: boolean;
|
|
310
|
+
/**
|
|
311
|
+
* When true, only captures metrics rated 'poor' or 'needs-improvement'.
|
|
312
|
+
* @default false
|
|
313
|
+
*/
|
|
314
|
+
poorRatingOnly?: boolean;
|
|
315
|
+
/**
|
|
316
|
+
* Subset of vital names to observe. Defaults to all supported vitals.
|
|
317
|
+
* @default ['LCP', 'CLS', 'FID', 'TTFB', 'INP', 'FCP']
|
|
318
|
+
*/
|
|
319
|
+
vitals?: VitalMetricName[];
|
|
320
|
+
/**
|
|
321
|
+
* Long task duration threshold in milliseconds. Tasks exceeding this
|
|
322
|
+
* are recorded as breadcrumbs with category 'performance'.
|
|
323
|
+
* @default 50
|
|
324
|
+
*/
|
|
325
|
+
longTaskThresholdMs?: number;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Event envelope used by the nexus-dev local ingestion server.
|
|
329
|
+
* Wraps ErrorEventPayload with server-assigned metadata.
|
|
330
|
+
*/
|
|
331
|
+
interface DevServerEventEnvelope {
|
|
332
|
+
/** Monotonically increasing server-assigned event ID. */
|
|
333
|
+
id: number;
|
|
334
|
+
/** ISO timestamp when the dev server received the event. */
|
|
335
|
+
receivedAt: string;
|
|
336
|
+
/** The captured error event payload. */
|
|
337
|
+
payload: ErrorEventPayload;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export { type Breadcrumb, type BreadcrumbCategory, type DevServerEventEnvelope, type DeviceContext, type ErrorEventEntity, type ErrorEventPayload, type ErrorGroupSummary, type NexusErrorInfo, type PerformanceVitalEntry, type PerformanceVitalsOptions, type SamplingConfig, type SeverityLevel, type StackFrame, type TransportPlugin, UserContext, type VitalMetricName };
|