-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.d.ts
96 lines (84 loc) · 2.55 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import {
Component,
Context as ReactContext,
ErrorInfo,
ReactNode,
ComponentType,
} from 'react';
import Rollbar, { Callback, Configuration } from 'rollbar';
export const LEVEL_DEBUG = 'debug';
export const LEVEL_INFO = 'info';
export const LEVEL_WARN = 'warn';
export const LEVEL_ERROR = 'error';
export const LEVEL_CRITICAL = 'critical';
export type LEVEL =
| typeof LEVEL_DEBUG
| typeof LEVEL_INFO
| typeof LEVEL_WARN
| typeof LEVEL_ERROR
| typeof LEVEL_CRITICAL;
type Extra = Record<string | number, unknown>;
export interface ErrorBoundaryProps {
children: ReactNode;
fallbackUI?: ComponentType<{ error: Error | null; resetError: () => void }>;
errorMessage?: string | (() => string);
extra?: Extra | ((error: Error, errorInfo: ErrorInfo) => Extra);
level?: LEVEL | (() => LEVEL);
callback?: Callback;
}
interface ErrorBoundaryState {
hasError: boolean;
error: Error | null;
}
export class ErrorBoundary extends Component<
ErrorBoundaryProps,
ErrorBoundaryState
> {
resetError: () => void;
}
export class RollbarContext extends Component<{
children: ReactNode;
context?: string;
}> {}
export interface ProviderProps {
Rollbar?: new (options: Configuration) => Rollbar;
children: ReactNode;
config?: Configuration | (() => Configuration);
instance?: Rollbar;
}
interface ProviderState {
rollbar: Rollbar;
options: Configuration;
}
export class Provider extends Component<ProviderProps, ProviderState> {}
declare const RollbarInstance: unique symbol;
declare const BaseOptions: unique symbol;
declare const RollbarCtor: unique symbol;
interface ContextInterface {
[RollbarInstance]: Rollbar;
[BaseOptions]: Configuration;
[RollbarCtor]: new (options: Configuration) => Rollbar;
}
export const Context: ReactContext<ContextInterface>;
export function getRollbarFromContext(
context: ReactContext<ContextInterface>,
): Rollbar;
export function useRollbar(): Rollbar;
export function useRollbarConfiguration(config: Rollbar.Configuration): void;
export function useRollbarContext(ctx?: string, isLayout?: boolean): void;
export function useRollbarPerson(person: object): void;
export function useRollbarCaptureEvent(metadata: object, level?: LEVEL): void;
export function isValidLevel(level: LEVEL): boolean;
export function historyContext(
rollbar: Rollbar,
args: {
formatter: (location: string, action: string) => string;
filter: (location: string, action: string) => boolean;
},
): (
v4Location: {
action: string;
filter: (location: string, action: string) => boolean;
},
v4action: string,
) => void;