Skip to content

Commit 96c36e8

Browse files
authored
fix: Add event type to item header when envelopes are forced (getsentry#3676)
1 parent 1054d3d commit 96c36e8

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

packages/core/src/request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function eventToSentryRequest(event: Event, api: API): SentryRequest {
8181
...(api.forceEnvelope() && { dsn: api.getDsn().toString() }),
8282
});
8383
const itemHeaders = JSON.stringify({
84-
type: event.type,
84+
type: eventType,
8585

8686
// TODO: Right now, sampleRate may or may not be defined (it won't be in the cases of inheritance and
8787
// explicitly-set sampling decisions). Are we good with that?

packages/core/test/lib/request.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,20 @@ describe('eventToSentryRequest', () => {
159159
}),
160160
);
161161
});
162+
163+
it('adds default "event" item type to item header if tunnel is configured', () => {
164+
api = new API(ingestDsn, {}, tunnel);
165+
delete event.type;
166+
167+
const result = eventToSentryRequest(event, api);
168+
const envelope = parseEnvelopeRequest(result);
169+
170+
expect(envelope.itemHeader).toEqual(
171+
expect.objectContaining({
172+
type: 'event',
173+
}),
174+
);
175+
});
162176
});
163177

164178
describe('sessionToSentryRequest', () => {

packages/types/src/event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export interface Event {
4747
}
4848

4949
/** JSDoc */
50-
export type EventType = 'transaction';
50+
export type EventType = 'event' | 'transaction';
5151

5252
/** JSDoc */
5353
export interface EventHint {

0 commit comments

Comments
 (0)