Skip to content
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

fix(hub): Don't set lastEventID for transactions #3966

Merged
merged 3 commits into from Sep 9, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/hub/src/hub.ts
Expand Up @@ -248,7 +248,11 @@ export class Hub implements HubInterface {
* @inheritDoc
*/
public captureEvent(event: Event, hint?: EventHint): string {
const eventId = (this._lastEventId = uuid4());
const eventId = uuid4();
if (event.type !== 'transaction') {
this._lastEventId = eventId;
}

this._invokeClient('captureEvent', event, {
...hint,
event_id: eventId,
Expand Down
23 changes: 23 additions & 0 deletions packages/hub/test/hub.test.ts
Expand Up @@ -279,6 +279,29 @@ describe('Hub', () => {
// @ts-ignore Says mock object is type unknown
expect(spy.mock.calls[0][2].event_id).toBeTruthy();
});

test('sets lastEventId', () => {
const event: Event = {
extra: { b: 3 },
};
const hub = new Hub();
const spy = jest.spyOn(hub as any, '_invokeClient');
hub.captureEvent(event);
// @ts-ignore Says mock object is type unknown
expect(spy.mock.calls[0][2].event_id).toEqual(hub.lastEventId());
});

test('transactions do not set lastEventId', () => {
const event: Event = {
extra: { b: 3 },
type: 'transaction',
};
const hub = new Hub();
const spy = jest.spyOn(hub as any, '_invokeClient');
hub.captureEvent(event);
// @ts-ignore Says mock object is type unknown
expect(spy.mock.calls[0][2].event_id).not.toEqual(hub.lastEventId());
});
});

test('lastEventId should be the same as last created', () => {
Expand Down