Skip to content

fix: Add event type to item header when envelopes are forced #3676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function eventToSentryRequest(event: Event, api: API): SentryRequest {
...(api.forceEnvelope() && { dsn: api.getDsn().toString() }),
});
const itemHeaders = JSON.stringify({
type: event.type,
type: eventType,

// TODO: Right now, sampleRate may or may not be defined (it won't be in the cases of inheritance and
// explicitly-set sampling decisions). Are we good with that?
Expand Down
14 changes: 14 additions & 0 deletions packages/core/test/lib/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,20 @@ describe('eventToSentryRequest', () => {
}),
);
});

it('adds default "event" item type to item header if tunnel is configured', () => {
api = new API(ingestDsn, {}, tunnel);
delete event.type;

const result = eventToSentryRequest(event, api);
const envelope = parseEnvelopeRequest(result);

expect(envelope.itemHeader).toEqual(
expect.objectContaining({
type: 'event',
}),
);
});
});

describe('sessionToSentryRequest', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface Event {
}

/** JSDoc */
export type EventType = 'transaction';
export type EventType = 'event' | 'transaction';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this EventType refer to Error, Transaction, Default? Which unfortunately might not match envelope header requirements


/** JSDoc */
export interface EventHint {
Expand Down