UNPKG

2.57 kBTypeScriptView Raw
1import type { Attachment, AttachmentItem, DataCategory, DsnComponents, Envelope, EnvelopeItemType, Event, EventEnvelopeHeaders, SdkInfo, SdkMetadata, SpanItem, SpanJSON } from '@sentry/types';
2/**
3 * Creates an envelope.
4 * Make sure to always explicitly provide the generic to this function
5 * so that the envelope types resolve correctly.
6 */
7export declare function createEnvelope<E extends Envelope>(headers: E[0], items?: E[1]): E;
8/**
9 * Add an item to an envelope.
10 * Make sure to always explicitly provide the generic to this function
11 * so that the envelope types resolve correctly.
12 */
13export declare function addItemToEnvelope<E extends Envelope>(envelope: E, newItem: E[1][number]): E;
14/**
15 * Convenience function to loop through the items and item types of an envelope.
16 * (This function was mostly created because working with envelope types is painful at the moment)
17 *
18 * If the callback returns true, the rest of the items will be skipped.
19 */
20export declare function forEachEnvelopeItem<E extends Envelope>(envelope: Envelope, callback: (envelopeItem: E[1][number], envelopeItemType: E[1][number][0]['type']) => boolean | void): boolean;
21/**
22 * Returns true if the envelope contains any of the given envelope item types
23 */
24export declare function envelopeContainsItemType(envelope: Envelope, types: EnvelopeItemType[]): boolean;
25/**
26 * Serializes an envelope.
27 */
28export declare function serializeEnvelope(envelope: Envelope): string | Uint8Array;
29/**
30 * Parses an envelope
31 */
32export declare function parseEnvelope(env: string | Uint8Array): Envelope;
33/**
34 * Creates envelope item for a single span
35 */
36export declare function createSpanEnvelopeItem(spanJson: Partial<SpanJSON>): SpanItem;
37/**
38 * Creates attachment envelope items
39 */
40export declare function createAttachmentEnvelopeItem(attachment: Attachment): AttachmentItem;
41/**
42 * Maps the type of an envelope item to a data category.
43 */
44export declare function envelopeItemTypeToDataCategory(type: EnvelopeItemType): DataCategory;
45/** Extracts the minimal SDK info from the metadata or an events */
46export declare function getSdkMetadataForEnvelopeHeader(metadataOrEvent?: SdkMetadata | Event): SdkInfo | undefined;
47/**
48 * Creates event envelope headers, based on event, sdk info and tunnel
49 * Note: This function was extracted from the core package to make it available in Replay
50 */
51export declare function createEventEnvelopeHeaders(event: Event, sdkInfo: SdkInfo | undefined, tunnel: string | undefined, dsn?: DsnComponents): EventEnvelopeHeaders;
52//# sourceMappingURL=envelope.d.ts.map
\No newline at end of file