-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use Rollup + tsc to generate type definitions * Fix types * Update type tests * Exclude internal fields * Combine typedefs into one * Update docs * Fix publish config * Simplify exported type declarations * Fix TS tests * Update CHANGELOG.md Co-authored-by: Josh Wood <[email protected]>
- Loading branch information
Showing
20 changed files
with
309 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,7 @@ | ||
// Type definitions for honeybadger.js | ||
// Project: https://github.com/honeybadger-io/honeybadger-js | ||
import { NextFunction, Request, Response } from 'express' | ||
import Server from './dist/server/types/server' | ||
import Browser from './dist/browser/types/browser' | ||
|
||
declare class Honeybadger { | ||
public getVersion(): string | ||
public factory(opts?: Partial<Honeybadger.Config>): Honeybadger | ||
public notify(notice: Error | string | Partial<Honeybadger.Notice>, name?: string | Partial<Honeybadger.Notice>, extra?: string | Partial<Honeybadger.Notice>): Honeybadger.Notice | false | ||
public configure(opts: Partial<Honeybadger.Config>): Honeybadger | ||
public beforeNotify(func: Honeybadger.BeforeNotifyHandler): Honeybadger | ||
public afterNotify(func: Honeybadger.AfterNotifyHandler): Honeybadger | ||
public setContext(context: Record<string, unknown>): Honeybadger | ||
public resetContext(context?: Record<string, unknown>): Honeybadger | ||
public clear(): Honeybadger | ||
public addBreadcrumb(message: string, opts?: Partial<Honeybadger.BreadcrumbRecord>): Honeybadger | ||
|
||
// Server middleware | ||
public requestHandler(req: Request, res: Response, next: NextFunction): void | ||
public errorHandler(err: any, req: Request, _res: Response, next: NextFunction): unknown | ||
public lambdaHandler(handler: any): (event: any, context: any, callback: any) => void | ||
} | ||
|
||
declare namespace Honeybadger { | ||
interface Logger { | ||
log(...args: unknown[]): unknown | ||
info(...args: unknown[]): unknown | ||
debug(...args: unknown[]): unknown | ||
warn(...args: unknown[]): unknown | ||
error(...args: unknown[]): unknown | ||
} | ||
|
||
interface Config { | ||
apiKey: string | undefined | ||
endpoint: string, | ||
developmentEnvironments: string[] | ||
environment: string | undefined | ||
hostname: string | undefined | ||
projectRoot: string | undefined | ||
component: string | undefined | ||
action: string | undefined | ||
revision: string | undefined | ||
disabled: boolean | ||
debug: boolean | ||
reportData: boolean | ||
breadcrumbsEnabled: boolean | Partial<{ dom: boolean, network: boolean, navigation: boolean, console: boolean }> | ||
maxBreadcrumbs: number | ||
maxObjectDepth: number | ||
logger: Logger | ||
enableUncaught: boolean | ||
afterUncaught: (err: Error) => void | ||
enableUnhandledRejection: boolean | ||
tags: string | string[] | unknown | ||
filters: string[] | ||
[x: string]: unknown | ||
|
||
// Browser | ||
async: boolean | ||
maxErrors: number | ||
} | ||
|
||
interface BeforeNotifyHandler { | ||
(notice: Notice): boolean | void | ||
} | ||
|
||
interface AfterNotifyHandler { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(error: any, notice: Notice): boolean | void | ||
} | ||
|
||
interface Notice { | ||
id: string | undefined, | ||
name: string, | ||
message: string, | ||
stack: string, | ||
backtrace: BacktraceFrame[], | ||
fingerprint?: string | undefined, | ||
url?: string | undefined, | ||
component?: string | undefined, | ||
action?: string | undefined, | ||
context: Record<string, unknown>, | ||
cgiData: Record<string, unknown>, | ||
params: Record<string, unknown>, | ||
session: Record<string, unknown>, | ||
headers: Record<string, unknown>, | ||
cookies: Record<string, unknown> | string, | ||
projectRoot?: string | undefined, | ||
environment?: string | undefined, | ||
revision?: string | undefined, | ||
afterNotify?: AfterNotifyHandler | ||
tags: string | string[] | ||
} | ||
|
||
interface BacktraceFrame { | ||
file: string, | ||
method: string, | ||
number: number, | ||
column: number | ||
} | ||
|
||
interface BreadcrumbRecord { | ||
category: string, | ||
message: string, | ||
metadata: Record<string, unknown>, | ||
timestamp: string | ||
} | ||
} | ||
|
||
declare const singleton: Honeybadger | ||
export = singleton | ||
declare const Honeybadger: typeof Server & typeof Browser | ||
export = Honeybadger |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.