From cb8a7d846d2cf57877c1394986bb23504d5c9c94 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Wed, 18 Oct 2023 18:04:02 -0400 Subject: [PATCH] feat(types): Add statsd envelope types --- packages/types/src/datacategory.ts | 4 +++- packages/types/src/envelope.ts | 7 ++++++- packages/utils/src/envelope.ts | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/types/src/datacategory.ts b/packages/types/src/datacategory.ts index 06f64c8525bb..84340cffc4f1 100644 --- a/packages/types/src/datacategory.ts +++ b/packages/types/src/datacategory.ts @@ -23,4 +23,6 @@ export type DataCategory = // Profile event type | 'profile' // Check-in event (monitor) - | 'monitor'; + | 'monitor' + // Unknown data category + | 'unknown'; diff --git a/packages/types/src/envelope.ts b/packages/types/src/envelope.ts index 288453fc4fdb..a039874a2d54 100644 --- a/packages/types/src/envelope.ts +++ b/packages/types/src/envelope.ts @@ -34,7 +34,8 @@ export type EnvelopeItemType = | 'profile' | 'replay_event' | 'replay_recording' - | 'check_in'; + | 'check_in' + | 'statsd'; export type BaseEnvelopeHeaders = { [key: string]: unknown; @@ -72,6 +73,7 @@ type ClientReportItemHeaders = { type: 'client_report' }; type ReplayEventItemHeaders = { type: 'replay_event' }; type ReplayRecordingItemHeaders = { type: 'replay_recording'; length: number }; type CheckInItemHeaders = { type: 'check_in' }; +type StatsdItemHeaders = { type: 'statsd' }; export type EventItem = BaseEnvelopeItem; export type AttachmentItem = BaseEnvelopeItem; @@ -84,18 +86,21 @@ export type ClientReportItem = BaseEnvelopeItem; type ReplayEventItem = BaseEnvelopeItem; type ReplayRecordingItem = BaseEnvelopeItem; +export type StatsdItem = BaseEnvelopeItem; export type EventEnvelopeHeaders = { event_id: string; sent_at: string; trace?: DynamicSamplingContext }; type SessionEnvelopeHeaders = { sent_at: string }; type CheckInEnvelopeHeaders = { trace?: DynamicSamplingContext }; type ClientReportEnvelopeHeaders = BaseEnvelopeHeaders; type ReplayEnvelopeHeaders = BaseEnvelopeHeaders; +type StatsdEnvelopeHeaders = BaseEnvelopeHeaders; export type EventEnvelope = BaseEnvelope; export type SessionEnvelope = BaseEnvelope; export type ClientReportEnvelope = BaseEnvelope; export type ReplayEnvelope = [ReplayEnvelopeHeaders, [ReplayEventItem, ReplayRecordingItem]]; export type CheckInEvelope = BaseEnvelope; +export type StatsdEnvelope = BaseEnvelope; export type Envelope = EventEnvelope | SessionEnvelope | ClientReportEnvelope | ReplayEnvelope | CheckInEvelope; export type EnvelopeItem = Envelope[1][number]; diff --git a/packages/utils/src/envelope.ts b/packages/utils/src/envelope.ts index e249564eca51..54772c6ae6fc 100644 --- a/packages/utils/src/envelope.ts +++ b/packages/utils/src/envelope.ts @@ -208,6 +208,8 @@ const ITEM_TYPE_TO_DATA_CATEGORY_MAP: Record = { replay_event: 'replay', replay_recording: 'replay', check_in: 'monitor', + // TODO: This is a temporary workaround until we have a proper data category for metrics + statsd: 'unknown', }; /**