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(
|
||||
message: string,
|
||||
category: BreadcrumbCategory = 'custom',
|
||||
category?: BreadcrumbCategory,
|
||||
level?: SeverityLevel,
|
||||
data?: Record<string, unknown>
|
||||
): void;
|
||||
@ -264,14 +264,14 @@ export class TelemetryClient {
|
||||
|
||||
// Apply beforeSend hook
|
||||
const beforeSendResult = this.options.beforeSend(event);
|
||||
if (beforeSendResult === false) {
|
||||
if (beforeSendResult === false || beforeSendResult === null) {
|
||||
if (this.options.debug || enableDebugLogging) {
|
||||
console.log('[IronTelemetry] Event dropped by beforeSend hook');
|
||||
}
|
||||
return { success: true, eventId: event.eventId };
|
||||
}
|
||||
|
||||
const eventToSend = beforeSendResult === true ? event : beforeSendResult;
|
||||
const eventToSend = beforeSendResult === true ? event : beforeSendResult as TelemetryEvent;
|
||||
|
||||
// Try to send
|
||||
const result = await this.transport.send(eventToSend);
|
||||
|
||||
25
src/index.ts
25
src/index.ts
@ -208,20 +208,27 @@ const IronTelemetry = {
|
||||
|
||||
export default IronTelemetry;
|
||||
|
||||
// Extension for Error prototype
|
||||
declare global {
|
||||
interface Error {
|
||||
capture(): Error;
|
||||
}
|
||||
/**
|
||||
* Enable the Error.prototype.capture() extension.
|
||||
* This is opt-in to avoid TypeScript conflicts in projects that create
|
||||
* 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
|
||||
}
|
||||
|
||||
/**
|
||||
* Capture this error and return it for re-throwing
|
||||
*/
|
||||
Error.prototype.capture = function (): Error {
|
||||
(Error.prototype as any).capture = function (): Error {
|
||||
captureException(this);
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
// Type augmentation for projects that call enableErrorCapture()
|
||||
// Users can add this to their project if they want type support:
|
||||
// declare global { interface Error { capture(): Error; } }
|
||||
|
||||
/**
|
||||
* Set up global unhandled exception handler
|
||||
|
||||
@ -8,6 +8,7 @@ export type SeverityLevel = 'debug' | 'info' | 'warning' | 'error' | 'fatal';
|
||||
*/
|
||||
export type BreadcrumbCategory =
|
||||
| 'ui'
|
||||
| 'user'
|
||||
| 'http'
|
||||
| 'navigation'
|
||||
| 'console'
|
||||
@ -181,9 +182,9 @@ export interface TelemetryOptions {
|
||||
|
||||
/**
|
||||
* 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 */
|
||||
enableOfflineQueue?: boolean;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user