Skip to content

Commit d0de03b

Browse files
committed
Improve payload type for configuration
Added types for Payload instead of using `object` Added comments with links to documentation Added comments to aid in understaning code_version Added optional Promise return type for transform Added DeprecatedNumber type for person.id and javascript.code_version
1 parent c4eb37a commit d0de03b

File tree

1 file changed

+82
-2
lines changed

1 file changed

+82
-2
lines changed

index.d.ts

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ declare namespace Rollbar {
4040
) => void | Promise<TResult>;
4141
export type MaybeError = Error | undefined | null;
4242
export type Level = "debug" | "info" | "warning" | "error" | "critical";
43+
/**
44+
* {@link https://docs.rollbar.com/docs/rollbarjs-configuration-reference#reference}
45+
*/
4346
export interface Configuration {
4447
accessToken?: string;
4548
addErrorContext?: boolean;
@@ -52,7 +55,15 @@ declare namespace Rollbar {
5255
captureUnhandledRejections?: boolean;
5356
captureUsername?: boolean;
5457
checkIgnore?: (isUncaught: boolean, args: LogArgument[], item: object) => boolean;
58+
/**
59+
* `codeVersion` takes precedence over `code_version`, if provided.
60+
* `client.javascript.code_version` takes precedence over both top level properties.
61+
*/
5562
codeVersion?: string;
63+
/**
64+
* `codeVersion` takes precedence over `code_version`, if provided.
65+
* `client.javascript.code_version` takes precedence over both top level properties.
66+
*/
5667
code_version?: string;
5768
enabled?: boolean;
5869
endpoint?: string;
@@ -77,7 +88,7 @@ declare namespace Rollbar {
7788
nodeSourceMaps?: boolean;
7889
onSendCallback?: (isUncaught: boolean, args: LogArgument[], item: object) => void;
7990
overwriteScrubFields?: boolean;
80-
payload?: object;
91+
payload?: Payload;
8192
reportLevel?: Level;
8293
rewriteFilenamePatterns?: string[];
8394
scrubFields?: string[];
@@ -89,7 +100,7 @@ declare namespace Rollbar {
89100
stackTraceLimit?: number;
90101
telemetryScrubber?: TelemetryScrubber;
91102
timeout?: number;
92-
transform?: (data: object, item: object) => void;
103+
transform?: (data: object, item: object) => void | Promise<void>;
93104
transmit?: boolean;
94105
uncaughtErrorLevel?: Level;
95106
verbose?: boolean;
@@ -169,4 +180,73 @@ declare namespace Rollbar {
169180
scrub?: ScrubType,
170181
truncation?: TruncationType
171182
}
183+
184+
/**
185+
* @deprecated number is deprecated for this field
186+
*/
187+
export type DeprecatedNumber = number;
188+
189+
/**
190+
* {@link https://docs.rollbar.com/docs/rollbarjs-configuration-reference#payload-1}
191+
*/
192+
export interface Payload {
193+
person?: {
194+
id: string | DeprecatedNumber;
195+
username?: string;
196+
email?: string;
197+
[property: string]: any;
198+
},
199+
context?: any;
200+
client?: {
201+
javascript?: {
202+
/**
203+
* Version control number (i.e. git SHA) of the current revision. Used for linking filenames in stacktraces to GitHub.
204+
* Note: for the purposes of nesting under the payload key, only code_version will correctly set the value in the final item.
205+
* However, if you wish to set this code version at the top level of the configuration object rather than nested under
206+
* the payload key, we will accept both codeVersion and code_version with codeVersion given preference if both happened
207+
* to be defined. Furthermore, if code_version is nested under the payload key this will have the final preference over
208+
* any value set at the top level.
209+
*/
210+
code_version?: string | DeprecatedNumber;
211+
/**
212+
* When true, the Rollbar service will attempt to find and apply source maps to all frames in the stack trace.
213+
* @default false
214+
*/
215+
source_map_enabled?: boolean;
216+
/**
217+
* When true, the Rollbar service will attempt to apply source maps to frames even if they are missing column numbers.
218+
* Works best when the minified javascript file is generated using newlines instead of semicolons.
219+
* @default false
220+
*/
221+
guess_uncaught_frames?: boolean;
222+
[property: string]: any;
223+
}
224+
[property: string]: any;
225+
},
226+
/**
227+
* The environment that your code is running in.
228+
* @default undefined
229+
*/
230+
environment?: string;
231+
server?: {
232+
/**
233+
* @default master
234+
*/
235+
branch?: string;
236+
/**
237+
* The hostname of the machine that rendered the page.
238+
*/
239+
host?: string;
240+
/**
241+
* It is used in two different ways: `source maps`, and `source control`.
242+
*
243+
* If you are looking for more information on it please go to:
244+
* {@link https://docs.rollbar.com/docs/source-maps}
245+
* {@link https://docs.rollbar.com/docs/source-control}
246+
*/
247+
root?: string;
248+
[property: string]: any;
249+
},
250+
[property: string]: any;
251+
}
172252
}

0 commit comments

Comments
 (0)