Options
All
  • Public
  • Public/Protected
  • All
Menu

A nodejs library for crash-hunter

const CrashHunter = require('crash-hunter');

Index

Type aliases

AnyMap

AnyMap: Record<string, unknown>

CrashEvent

CrashEvent<Context, Metadata>: { context?: Context; event_id?: undefined | string; message?: undefined | string; metadata?: Metadata; name?: undefined | string; stacktrace?: undefined | string; timestamp?: undefined | number }

Type parameters

Type declaration

  • Optional context?: Context
  • Optional event_id?: undefined | string
  • Optional message?: undefined | string
  • Optional metadata?: Metadata
  • Optional name?: undefined | string
  • Optional stacktrace?: undefined | string
  • Optional timestamp?: undefined | number

CrashHunterClientInitOptions

CrashHunterClientInitOptions<Context, Metadata>: Partial<Omit<CrashHunterClientOptions<Context, Metadata>, RequiredOptionKey>> & Pick<CrashHunterClientOptions<Context, Metadata>, RequiredOptionKey>

Type parameters

CrashHunterClientOptions

CrashHunterClientOptions<Context, Metadata>: { debug: boolean; interval: number; max_size: number; metadata: Metadata; node_config: { not_exit_on_uncaught_exception: boolean; not_exit_on_unhandled_rejection: boolean }; request: (data: CrashEvent<Context, Metadata>[]) => Promise<void> }

Type parameters

Type declaration

  • debug: boolean

    Enable debug log. Defaults to false.

  • interval: number

    Error cache list flush interval. Defaults to 1000.

  • max_size: number

    Error cache list max size. Defaults to 20.

  • metadata: Metadata

    SDK Metadata. Defaults to {}.

  • node_config: { not_exit_on_uncaught_exception: boolean; not_exit_on_unhandled_rejection: boolean }

    SDK node special config args.

    • not_exit_on_uncaught_exception: boolean

      not_exit_on_uncaught_exception. Defaults to false.

    • not_exit_on_unhandled_rejection: boolean

      not_exit_on_uncaught_exception. Defaults to false.

  • request: (data: CrashEvent<Context, Metadata>[]) => Promise<void>

    SDK request method.

      • (data: CrashEvent<Context, Metadata>[]): Promise<void>
      • Parameters

        Returns Promise<void>

GetLogger

GetLogger: () => Record<"log" | "info" | "warn" | "error", { (...data: any[]): void; (message?: any, ...optionalParams: any[]): void }> & { setDebug: (debug: boolean) => void }

Type declaration

    • (): Record<"log" | "info" | "warn" | "error", { (...data: any[]): void; (message?: any, ...optionalParams: any[]): void }> & { setDebug: (debug: boolean) => void }
    • Returns Record<"log" | "info" | "warn" | "error", { (...data: any[]): void; (message?: any, ...optionalParams: any[]): void }> & { setDebug: (debug: boolean) => void }

RequiredOptionKey

RequiredOptionKey: "request"

Variables

Let debug

debug: boolean = false

Const methods

methods: ["log", "info", "warn", "error"] = ['log', 'info', 'warn', 'error'] as const

Functions

Const getLogger

  • getLogger(): Record<"log" | "info" | "warn" | "error", log> & { setDebug: (debug: boolean) => void }
  • Returns Record<"log" | "info" | "warn" | "error", log> & { setDebug: (debug: boolean) => void }

Object literals

Const CrashHunter

CrashHunter<Context, Metadata>: object

A CrashHunter library.

Type parameters

constructor

Private _enable

_enable: boolean

Private _headCrashEventList

_headCrashEventList: CrashEvent[]

Private _pulgins

_pulgins: IPlugin[]

Private _tailCrashEventList

_tailCrashEventList: CrashEvent[]

Private Optional _timer

_timer: null | Timeout

Private options

options: CrashHunterClientOptions<Context, Metadata>

Static Private SDK_VERSION

SDK_VERSION: string = (process.env.SDK_VERSION as unknown) as string

init

Private _send

  • _send(): Promise<void>

Private addCrashToList

asyncAttempt

  • asyncAttempt<TResult>(func: (...args: any[]) => Promise<TResult>, ...args: any[]): Promise<Error | TResult>
  • Type parameters

    • TResult

    Parameters

    • func: (...args: any[]) => Promise<TResult>
        • (...args: any[]): Promise<TResult>
        • Parameters

          • Rest ...args: any[]

          Returns Promise<TResult>

    • Rest ...args: any[]

    Returns Promise<Error | TResult>

attempt

  • attempt<TResult>(func: (...args: any[]) => TResult, ...args: any[]): Error | TResult
  • Type parameters

    • TResult

    Parameters

    • func: (...args: any[]) => TResult
        • (...args: any[]): TResult
        • Parameters

          • Rest ...args: any[]

          Returns TResult

    • Rest ...args: any[]

    Returns Error | TResult

captureException

  • captureException(exception: Error, context?: Context): string | undefined
  • Parameters

    • exception: Error
    • Default value context: Context = {} as Context

    Returns string | undefined

captureMessage

  • captureMessage(message: string, context?: Context, name?: string, stacktrace?: string): string | undefined
  • Parameters

    • message: string
    • Default value context: Context = {} as Context
    • Default value name: string = ""
    • Default value stacktrace: string = ""

    Returns string | undefined

close

  • close(timeout?: number): Promise<boolean>

enableDebugLog

  • enableDebugLog(enable: boolean): void

flush

  • flush(timeout?: number): Promise<boolean>

getLogger

getOption

getSDKVersion

  • getSDKVersion(): string

setMetadataValue

  • setMetadataValue(key: keyof Metadata, value: Metadata[typeof key]): void

Legend

  • Method
  • Method
  • Private property

Generated using TypeDoc