Skip to content

Commit 7abd153

Browse files
authored
feat(types): Add statsd envelope types (#9304)
1 parent 1c2b829 commit 7abd153

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

packages/types/src/datacategory.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ export type DataCategory =
2323
// Profile event type
2424
| 'profile'
2525
// Check-in event (monitor)
26-
| 'monitor';
26+
| 'monitor'
27+
// Unknown data category
28+
| 'unknown';

packages/types/src/envelope.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export type EnvelopeItemType =
3434
| 'profile'
3535
| 'replay_event'
3636
| 'replay_recording'
37-
| 'check_in';
37+
| 'check_in'
38+
| 'statsd';
3839

3940
export type BaseEnvelopeHeaders = {
4041
[key: string]: unknown;
@@ -72,6 +73,7 @@ type ClientReportItemHeaders = { type: 'client_report' };
7273
type ReplayEventItemHeaders = { type: 'replay_event' };
7374
type ReplayRecordingItemHeaders = { type: 'replay_recording'; length: number };
7475
type CheckInItemHeaders = { type: 'check_in' };
76+
type StatsdItemHeaders = { type: 'statsd' };
7577

7678
export type EventItem = BaseEnvelopeItem<EventItemHeaders, Event>;
7779
export type AttachmentItem = BaseEnvelopeItem<AttachmentItemHeaders, string | Uint8Array>;
@@ -84,18 +86,21 @@ export type ClientReportItem = BaseEnvelopeItem<ClientReportItemHeaders, ClientR
8486
export type CheckInItem = BaseEnvelopeItem<CheckInItemHeaders, SerializedCheckIn>;
8587
type ReplayEventItem = BaseEnvelopeItem<ReplayEventItemHeaders, ReplayEvent>;
8688
type ReplayRecordingItem = BaseEnvelopeItem<ReplayRecordingItemHeaders, ReplayRecordingData>;
89+
export type StatsdItem = BaseEnvelopeItem<StatsdItemHeaders, string>;
8790

8891
export type EventEnvelopeHeaders = { event_id: string; sent_at: string; trace?: DynamicSamplingContext };
8992
type SessionEnvelopeHeaders = { sent_at: string };
9093
type CheckInEnvelopeHeaders = { trace?: DynamicSamplingContext };
9194
type ClientReportEnvelopeHeaders = BaseEnvelopeHeaders;
9295
type ReplayEnvelopeHeaders = BaseEnvelopeHeaders;
96+
type StatsdEnvelopeHeaders = BaseEnvelopeHeaders;
9397

9498
export type EventEnvelope = BaseEnvelope<EventEnvelopeHeaders, EventItem | AttachmentItem | UserFeedbackItem>;
9599
export type SessionEnvelope = BaseEnvelope<SessionEnvelopeHeaders, SessionItem>;
96100
export type ClientReportEnvelope = BaseEnvelope<ClientReportEnvelopeHeaders, ClientReportItem>;
97101
export type ReplayEnvelope = [ReplayEnvelopeHeaders, [ReplayEventItem, ReplayRecordingItem]];
98102
export type CheckInEvelope = BaseEnvelope<CheckInEnvelopeHeaders, CheckInItem>;
103+
export type StatsdEnvelope = BaseEnvelope<StatsdEnvelopeHeaders, StatsdItem>;
99104

100105
export type Envelope = EventEnvelope | SessionEnvelope | ClientReportEnvelope | ReplayEnvelope | CheckInEvelope;
101106
export type EnvelopeItem = Envelope[1][number];

packages/utils/src/envelope.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ const ITEM_TYPE_TO_DATA_CATEGORY_MAP: Record<EnvelopeItemType, DataCategory> = {
208208
replay_event: 'replay',
209209
replay_recording: 'replay',
210210
check_in: 'monitor',
211+
// TODO: This is a temporary workaround until we have a proper data category for metrics
212+
statsd: 'unknown',
211213
};
212214

213215
/**

0 commit comments

Comments
 (0)