build: add package-lock.json and update telemetry dependencies
Adds package-lock.json with development dependencies including TypeScript, ESLint, and Vitest. Updates client, index, and types modules to support the new telemetry package structure.
This commit is contained in:
parent
88246a8509
commit
935022bd54
3440
package-lock.json
generated
Normal file
3440
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -118,7 +118,7 @@ export class TelemetryClient {
|
|||||||
*/
|
*/
|
||||||
addBreadcrumb(
|
addBreadcrumb(
|
||||||
message: string,
|
message: string,
|
||||||
category: BreadcrumbCategory = 'custom',
|
category?: BreadcrumbCategory,
|
||||||
level?: SeverityLevel,
|
level?: SeverityLevel,
|
||||||
data?: Record<string, unknown>
|
data?: Record<string, unknown>
|
||||||
): void;
|
): void;
|
||||||
@ -264,14 +264,14 @@ export class TelemetryClient {
|
|||||||
|
|
||||||
// Apply beforeSend hook
|
// Apply beforeSend hook
|
||||||
const beforeSendResult = this.options.beforeSend(event);
|
const beforeSendResult = this.options.beforeSend(event);
|
||||||
if (beforeSendResult === false) {
|
if (beforeSendResult === false || beforeSendResult === null) {
|
||||||
if (this.options.debug || enableDebugLogging) {
|
if (this.options.debug || enableDebugLogging) {
|
||||||
console.log('[IronTelemetry] Event dropped by beforeSend hook');
|
console.log('[IronTelemetry] Event dropped by beforeSend hook');
|
||||||
}
|
}
|
||||||
return { success: true, eventId: event.eventId };
|
return { success: true, eventId: event.eventId };
|
||||||
}
|
}
|
||||||
|
|
||||||
const eventToSend = beforeSendResult === true ? event : beforeSendResult;
|
const eventToSend = beforeSendResult === true ? event : beforeSendResult as TelemetryEvent;
|
||||||
|
|
||||||
// Try to send
|
// Try to send
|
||||||
const result = await this.transport.send(eventToSend);
|
const result = await this.transport.send(eventToSend);
|
||||||
|
|||||||
29
src/index.ts
29
src/index.ts
@ -208,20 +208,27 @@ const IronTelemetry = {
|
|||||||
|
|
||||||
export default IronTelemetry;
|
export default IronTelemetry;
|
||||||
|
|
||||||
// Extension for Error prototype
|
/**
|
||||||
declare global {
|
* Enable the Error.prototype.capture() extension.
|
||||||
interface Error {
|
* This is opt-in to avoid TypeScript conflicts in projects that create
|
||||||
capture(): Error;
|
* Error-like objects without the capture method.
|
||||||
|
*
|
||||||
|
* After calling this, you can use: throw new Error('msg').capture()
|
||||||
|
*/
|
||||||
|
export function enableErrorCapture(): void {
|
||||||
|
if (typeof (Error.prototype as any).capture === 'function') {
|
||||||
|
return; // Already enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(Error.prototype as any).capture = function (): Error {
|
||||||
|
captureException(this);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Type augmentation for projects that call enableErrorCapture()
|
||||||
* Capture this error and return it for re-throwing
|
// Users can add this to their project if they want type support:
|
||||||
*/
|
// declare global { interface Error { capture(): Error; } }
|
||||||
Error.prototype.capture = function (): Error {
|
|
||||||
captureException(this);
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up global unhandled exception handler
|
* Set up global unhandled exception handler
|
||||||
|
|||||||
@ -8,6 +8,7 @@ export type SeverityLevel = 'debug' | 'info' | 'warning' | 'error' | 'fatal';
|
|||||||
*/
|
*/
|
||||||
export type BreadcrumbCategory =
|
export type BreadcrumbCategory =
|
||||||
| 'ui'
|
| 'ui'
|
||||||
|
| 'user'
|
||||||
| 'http'
|
| 'http'
|
||||||
| 'navigation'
|
| 'navigation'
|
||||||
| 'console'
|
| 'console'
|
||||||
@ -181,9 +182,9 @@ export interface TelemetryOptions {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook called before sending an event
|
* Hook called before sending an event
|
||||||
* Return false to drop the event
|
* Return false or null to drop the event, or return the (modified) event to send
|
||||||
*/
|
*/
|
||||||
beforeSend?: (event: TelemetryEvent) => boolean | TelemetryEvent;
|
beforeSend?: (event: TelemetryEvent) => boolean | TelemetryEvent | null;
|
||||||
|
|
||||||
/** Enable offline queue for failed events */
|
/** Enable offline queue for failed events */
|
||||||
enableOfflineQueue?: boolean;
|
enableOfflineQueue?: boolean;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user