UNPKG

4.02 kBTypeScriptView Raw
1// Type definitions for rollbar 2.3.3
2// Project: Rollbar
3
4export = Rollbar;
5
6declare class Rollbar {
7 constructor(options?: Rollbar.Configuration);
8 static init(options: Rollbar.Configuration): Rollbar;
9
10 public global(options: Rollbar.Configuration): Rollbar;
11 public configure(options: Rollbar.Configuration): Rollbar;
12 public lastError(): Rollbar.MaybeError;
13
14 public log(...args: Rollbar.LogArgument[]): Rollbar.LogResult;
15 public debug(...args: Rollbar.LogArgument[]): Rollbar.LogResult;
16 public info(...args: Rollbar.LogArgument[]): Rollbar.LogResult;
17 public warn(...args: Rollbar.LogArgument[]): Rollbar.LogResult;
18 public warning(...args: Rollbar.LogArgument[]): Rollbar.LogResult;
19 public error(...args: Rollbar.LogArgument[]): Rollbar.LogResult;
20 public critical(...args: Rollbar.LogArgument[]): Rollbar.LogResult;
21
22 public captureEvent(metadata: object, level: Rollbar.Level): Rollbar.TelemetryEvent;
23
24 public lambdaHandler(handler: Rollbar.LambdaHandler): Rollbar.LambdaHandler;
25
26 public errorHandler(): Rollbar.ExpressErrorHandler;
27}
28
29declare namespace Rollbar {
30 export type LambdaHandler = (event: object, context: object, callback: Callback) => void;
31 export type MaybeError = Error | undefined | null;
32 export type Level = "debug" | "info" | "warning" | "error" | "critical";
33 export interface Configuration {
34 accessToken?: string;
35 version?: string;
36 environment?: string;
37 codeVersion?: string;
38 scrubFields?: string[];
39 scrubHeaders?: string[];
40 logLevel?: Level;
41 reportLevel?: Level;
42 uncaughtErrorLevel?: Level;
43 endpoint?: string;
44 verbose?: boolean;
45 enabled?: boolean;
46 captureUncaught?: boolean;
47 captureUnhandledRejections?: boolean;
48 payload?: object;
49 maxItems?: number;
50 itemsPerMinute?: number;
51 ignoredMessages?: string[];
52 hostWhiteList?: string[];
53 hostBlackList?: string[];
54 autoInstrument?: AutoInstrumentOptions;
55 telemetryScrubber?: TelemetryScrubber;
56 includeItemsInTelemetry?: boolean;
57 scrubTelemetryInputs?: boolean;
58 sendConfig?: boolean;
59 captureEmail?: boolean;
60 captureUsername?: boolean;
61 captureIp?: boolean;
62 transform?: (data: object) => void;
63 checkIgnore?: (isUncaught: boolean, args: LogArgument[], item: object) => boolean;
64 onSendCallback?: (isUncaught: boolean, args: LogArgument[], item: object) => void;
65 }
66 export type Callback = (err: MaybeError, response: object) => void;
67 export type LogArgument = string | Error | object | Callback | Date | any[];
68 export interface LogResult {
69 uuid: string;
70 }
71 export interface TelemetryEvent {
72 level: Level;
73 type: string;
74 timestamp_ms: number;
75 body: object;
76 source: string;
77 uuid?: string;
78 }
79 export type AutoInstrumentOptions = boolean | AutoInstrumentSettings;
80 export interface AutoInstrumentSettings {
81 network?: boolean;
82 networkResponseHeaders?: boolean | string[];
83 networkResponseBody?: boolean;
84 networkRequestBody?: boolean;
85 log?: boolean;
86 dom?: boolean;
87 navigation?: boolean;
88 connectivity?: boolean;
89 }
90 export type TelemetryScrubber = (description: TelemetryScrubberInput) => boolean;
91 export type TelemetryScrubberInput = DomDescription | null;
92 export interface DomDescription {
93 tagName: string;
94 id: string | undefined;
95 classes: string[] | undefined;
96 attributes: DomAttribute[];
97 }
98 export type DomAttributeKey = "type" | "name" | "title" | "alt";
99 export interface DomAttribute {
100 key: DomAttributeKey;
101 value: string;
102 }
103 export type ExpressErrorHandler = (err: any, request: any, response: any, next: ExpressNextFunction) => any;
104 export interface ExpressNextFunction {
105 (err?: any): void;
106 }
107}