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

feat(core): Add replay_event type for events #6481

Merged
merged 4 commits into from Jan 5, 2023
Merged

Conversation

mydea
Copy link
Member

@mydea mydea commented Dec 9, 2022

As a first step for #6480, this adds the replay event type.

Note that replay is a bit special, in that it has two event types: replay_event and replay_recording. These are sent in one envelope, where replay_event contains the replay metadata etc, and replay_recording the actual recording as string.

IMHO for the event type we have here it is sufficient to have replay_event, as the replay_recording is not really passed around but only need to be considered when we (eventually) build the envelope.

@mydea mydea self-assigned this Dec 9, 2022
@@ -233,7 +233,7 @@ export class Hub implements HubInterface {
*/
public captureEvent(event: Event, hint?: EventHint): string {
const eventId = hint && hint.event_id ? hint.event_id : uuid4();
if (event.type !== 'transaction') {
if (!event.type) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Question: I guess replays should not count here? (Eventually - currently they do not go through this method at all)

Copy link
Member

Choose a reason for hiding this comment

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

Reading #3966, I think you're right.

Copy link
Member

Choose a reason for hiding this comment

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

We might also add a test for the new event type here:

test('transactions do not set lastEventId', () => {
const event: Event = {
extra: { b: 3 },
type: 'transaction',
};
const testClient = makeClient();
const hub = new Hub(testClient);
hub.captureEvent(event);
const args = getPassedArgs(testClient.captureEvent);
expect(args[1].event_id).not.toEqual(hub.lastEventId());
});

Copy link
Member Author

Choose a reason for hiding this comment

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

done in 37535a0

@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.82 KB (+0.1% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 61.36 KB (+0.08% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.6 KB (+0.11% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 54.92 KB (+0.08% 🔺)
@sentry/browser - Webpack (gzipped + minified) 20.37 KB (+0.1% 🔺)
@sentry/browser - Webpack (minified) 66.54 KB (+0.07% 🔺)
@sentry/react - Webpack (gzipped + minified) 20.39 KB (+0.1% 🔺)
@sentry/nextjs Client - Webpack (gzipped + minified) 47.64 KB (+0.04% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.79 KB (+0.09% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.22 KB (+0.07% 🔺)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 42.99 KB (-0.03% 🔽)
@sentry/replay - Webpack (gzipped + minified) 37.68 KB (-0.02% 🔽)

@@ -233,7 +233,7 @@ export class Hub implements HubInterface {
*/
public captureEvent(event: Event, hint?: EventHint): string {
const eventId = hint && hint.event_id ? hint.event_id : uuid4();
if (event.type !== 'transaction') {
if (!event.type) {
Copy link
Member

Choose a reason for hiding this comment

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

Reading #3966, I think you're right.

@@ -233,7 +233,7 @@ export class Hub implements HubInterface {
*/
public captureEvent(event: Event, hint?: EventHint): string {
const eventId = hint && hint.event_id ? hint.event_id : uuid4();
if (event.type !== 'transaction') {
if (!event.type) {
Copy link
Member

Choose a reason for hiding this comment

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

We might also add a test for the new event type here:

test('transactions do not set lastEventId', () => {
const event: Event = {
extra: { b: 3 },
type: 'transaction',
};
const testClient = makeClient();
const hub = new Hub(testClient);
hub.captureEvent(event);
const args = getPassedArgs(testClient.captureEvent);
expect(args[1].event_id).not.toEqual(hub.lastEventId());
});


// TODO: Handle replay_event here
// Currently, this is done by replay, but we want to upstream this here
const eventType = event.type && event.type !== 'replay_event' ? event.type : 'event';
Copy link
Member Author

Choose a reason for hiding this comment

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

To note, this is technically correct, but may increase the bundle size slightly for "nothing", as this will not really be hit right now. I'd still rather leave this in and remove it once we (hopefully soon!) actually handle replay events "normally". WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good to me.

@mydea mydea force-pushed the fn/add-replay-types branch 2 times, most recently from 37535a0 to 4e35eb8 Compare December 9, 2022 12:31
@@ -22,7 +19,7 @@ export function handleGlobalEventListener(replay: ReplayContainer): (event: Even

// Only tag transactions with replayId if not waiting for an error
// @ts-ignore private
if (event.type !== 'transaction' || !replay._waitForError) {
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason for this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

To be explicit that we only want this when the event is an error. This is IMHO more future proof, as when/if we add further event types, we'll need to explicitly handle them.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2023

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants