UNPKG

3.78 kBTypeScriptView Raw
1import { Event, Mechanism, StackFrame } from '@sentry/types';
2/**
3 * UUID4 generator
4 *
5 * @returns string Generated UUID4.
6 */
7export declare function uuid4(): string;
8/**
9 * Extracts either message or type+value from an event that can be used for user-facing logs
10 * @returns event's description
11 */
12export declare function getEventDescription(event: Event): string;
13/**
14 * Adds exception values, type and value to an synthetic Exception.
15 * @param event The event to modify.
16 * @param value Value of the exception.
17 * @param type Type of the exception.
18 * @hidden
19 */
20export declare function addExceptionTypeValue(event: Event, value?: string, type?: string): void;
21/**
22 * Adds exception mechanism data to a given event. Uses defaults if the second parameter is not passed.
23 *
24 * @param event The event to modify.
25 * @param newMechanism Mechanism data to add to the event.
26 * @hidden
27 */
28export declare function addExceptionMechanism(event: Event, newMechanism?: Partial<Mechanism>): void;
29/**
30 * Represents Semantic Versioning object
31 */
32interface SemVer {
33 major?: number;
34 minor?: number;
35 patch?: number;
36 prerelease?: string;
37 buildmetadata?: string;
38}
39/**
40 * Parses input into a SemVer interface
41 * @param input string representation of a semver version
42 */
43export declare function parseSemver(input: string): SemVer;
44/**
45 * This function adds context (pre/post/line) lines to the provided frame
46 *
47 * @param lines string[] containing all lines
48 * @param frame StackFrame that will be mutated
49 * @param linesOfContext number of context lines we want to add pre/post
50 */
51export declare function addContextToFrame(lines: string[], frame: StackFrame, linesOfContext?: number): void;
52/**
53 * Checks whether or not we've already captured the given exception (note: not an identical exception - the very object
54 * in question), and marks it captured if not.
55 *
56 * This is useful because it's possible for an error to get captured by more than one mechanism. After we intercept and
57 * record an error, we rethrow it (assuming we've intercepted it before it's reached the top-level global handlers), so
58 * that we don't interfere with whatever effects the error might have had were the SDK not there. At that point, because
59 * the error has been rethrown, it's possible for it to bubble up to some other code we've instrumented. If it's not
60 * caught after that, it will bubble all the way up to the global handlers (which of course we also instrument). This
61 * function helps us ensure that even if we encounter the same error more than once, we only record it the first time we
62 * see it.
63 *
64 * Note: It will ignore primitives (always return `false` and not mark them as seen), as properties can't be set on
65 * them. {@link: Object.objectify} can be used on exceptions to convert any that are primitives into their equivalent
66 * object wrapper forms so that this check will always work. However, because we need to flag the exact object which
67 * will get rethrown, and because that rethrowing happens outside of the event processing pipeline, the objectification
68 * must be done before the exception captured.
69 *
70 * @param A thrown exception to check or flag as having been seen
71 * @returns `true` if the exception has already been captured, `false` if not (with the side effect of marking it seen)
72 */
73export declare function checkOrSetAlreadyCaught(exception: unknown): boolean;
74/**
75 * Checks whether the given input is already an array, and if it isn't, wraps it in one.
76 *
77 * @param maybeArray Input to turn into an array, if necessary
78 * @returns The input, if already an array, or an array with the input as the only element, if not
79 */
80export declare function arrayify<T = unknown>(maybeArray: T | T[]): T[];
81export {};
82//# sourceMappingURL=misc.d.ts.map
\No newline at end of file