1 | import type { Event, ExtractedNodeRequestData, PolymorphicRequest, TransactionSource, WebFetchHeaders, WebFetchRequest } from '@sentry/types';
|
2 | declare const DEFAULT_REQUEST_INCLUDES: string[];
|
3 | export declare const DEFAULT_USER_INCLUDES: string[];
|
4 | /**
|
5 | * Options deciding what parts of the request to use when enhancing an event
|
6 | */
|
7 | export type AddRequestDataToEventOptions = {
|
8 | /** Flags controlling whether each type of data should be added to the event */
|
9 | include?: {
|
10 | ip?: boolean;
|
11 | request?: boolean | Array<(typeof DEFAULT_REQUEST_INCLUDES)[number]>;
|
12 | transaction?: boolean | TransactionNamingScheme;
|
13 | user?: boolean | Array<(typeof DEFAULT_USER_INCLUDES)[number]>;
|
14 | };
|
15 | /** Injected platform-specific dependencies */
|
16 | deps?: {
|
17 | cookie: {
|
18 | parse: (cookieStr: string) => Record<string, string>;
|
19 | };
|
20 | url: {
|
21 | parse: (urlStr: string) => {
|
22 | query: string | null;
|
23 | };
|
24 | };
|
25 | };
|
26 | };
|
27 | export type TransactionNamingScheme = 'path' | 'methodPath' | 'handler';
|
28 | /**
|
29 | * Extracts a complete and parameterized path from the request object and uses it to construct transaction name.
|
30 | * If the parameterized transaction name cannot be extracted, we fall back to the raw URL.
|
31 | *
|
32 | * Additionally, this function determines and returns the transaction name source
|
33 | *
|
34 | * eg. GET /mountpoint/user/:id
|
35 | *
|
36 | * @param req A request object
|
37 | * @param options What to include in the transaction name (method, path, or a custom route name to be
|
38 | * used instead of the request's route)
|
39 | *
|
40 | * @returns A tuple of the fully constructed transaction name [0] and its source [1] (can be either 'route' or 'url')
|
41 | */
|
42 | export declare function extractPathForTransaction(req: PolymorphicRequest, options?: {
|
43 | path?: boolean;
|
44 | method?: boolean;
|
45 | customRoute?: string;
|
46 | }): [string, TransactionSource];
|
47 | /**
|
48 | * Normalize data from the request object, accounting for framework differences.
|
49 | *
|
50 | * @param req The request object from which to extract data
|
51 | * @param options.include An optional array of keys to include in the normalized data. Defaults to
|
52 | * DEFAULT_REQUEST_INCLUDES if not provided.
|
53 | * @param options.deps Injected, platform-specific dependencies
|
54 | * @returns An object containing normalized request data
|
55 | */
|
56 | export declare function extractRequestData(req: PolymorphicRequest, options?: {
|
57 | include?: string[];
|
58 | }): ExtractedNodeRequestData;
|
59 | /**
|
60 | * Add data from the given request to the given event
|
61 | *
|
62 | * @param event The event to which the request data will be added
|
63 | * @param req Request object
|
64 | * @param options.include Flags to control what data is included
|
65 | * @param options.deps Injected platform-specific dependencies
|
66 | * @returns The mutated `Event` object
|
67 | */
|
68 | export declare function addRequestDataToEvent(event: Event, req: PolymorphicRequest, options?: AddRequestDataToEventOptions): Event;
|
69 | /**
|
70 | * Transforms a `Headers` object that implements the `Web Fetch API` (https://developer.mozilla.org/en-US/docs/Web/API/Headers) into a simple key-value dict.
|
71 | * The header keys will be lower case: e.g. A "Content-Type" header will be stored as "content-type".
|
72 | */
|
73 | export declare function winterCGHeadersToDict(winterCGHeaders: WebFetchHeaders): Record<string, string>;
|
74 | /**
|
75 | * Converts a `Request` object that implements the `Web Fetch API` (https://developer.mozilla.org/en-US/docs/Web/API/Headers) into the format that the `RequestData` integration understands.
|
76 | */
|
77 | export declare function winterCGRequestToRequestData(req: WebFetchRequest): PolymorphicRequest;
|
78 | export {};
|
79 | //# sourceMappingURL=requestdata.d.ts.map |
\ | No newline at end of file |