-
Notifications
You must be signed in to change notification settings - Fork 54
/
stackdriver-errors.d.ts
174 lines (151 loc) · 3.36 KB
/
stackdriver-errors.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
declare module 'stackdriver-errors-js' {
/**
* Context to be sent along with the error
*/
interface Context {
/**
* User who caused or was affected by the error
*/
userId?: string;
[x: string]: any;
}
/**
* Context to be sent along with the error
*/
interface PayloadContext extends Context {
httpRequest: {
/**
* Requesting agent
*/
userAgent: string;
/**
* Website URL
*/
url: string;
};
}
/**
* Service context
*/
interface ServiceContext {
/**
* Name of the service reporting the error
*/
service: string;
/**
* Version identifier of the service reporting the error
*/
version: string;
}
/**
* Payload passed to the custom reporting function
*/
interface Payload {
/**
* Context related to this error
*/
context: PayloadContext;
/**
* Error message
*/
message: string;
/**
* Service context
*/
serviceContext: ServiceContext;
}
/**
* Initial configuration
*/
interface InitialConfiguration {
/**
* Overwrite endpoint that errors are reported to.
*/
targetUrl?: string;
/**
* The context in which the error occurred
*/
context?: Context;
/**
* Custom function to be called with the error payload for reporting,
* instead of HTTP request
*
* @param payload Error payload
*/
customReportingFunction?: (payload: Payload) => Promise<void>;
/**
* Set to true to not send error reports, this can be used when
* developing locally
*
* @default false
*/
disabled?: boolean;
/**
* The API key to use to call the API
*/
key: string;
/**
* The Google Cloud Platform project ID to report errors to
*/
projectId: string;
/**
* Set to false to prevent reporting unhandled exceptions
*
* @default true
*/
reportUncaughtExceptions?: boolean;
/**
* Set to false to prevent reporting unhandled promise rejections
*
* @default true
*/
reportUnhandledPromiseRejections?: boolean;
/**
* Name of the service reporting the error
*
* @default "web"
*/
service?: string;
/**
* Version identifier of the service reporting the error
*/
version?: string;
}
/**
* Error report options
*/
interface ReportOptions {
/**
* Omit number of frames if creating stack
*
* @default 1
*/
skipLocalFrames?: number;
}
/**
* An Error handler that sends errors to the Stackdriver Error Reporting API
*/
class StackdriverErrorReporter {
/**
* Initializes the client
*
* @param options Initial configuration
*/
start(options: InitialConfiguration): void;
/**
* Report an error to the Stackdriver Error Reporting API
*
* @param error The Error object or message string to report
* @param options Configuration for this report
*/
report(error: string | Error, options?: ReportOptions): Promise<void>;
/**
* Set the user for the current context.
*
* @param user The unique identifier of the user (can be ID, email or
* custom token) or undefined if not logged in
*/
setUser(user?: string): void;
}
export default StackdriverErrorReporter;
}