-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Problem Statement
With our Span/Transcation API changes, the Event types are diverging between what properties of an event we can use and access while the event is processed in the SDK vs. what data is sent to Sentry as an EventItem in an envelope.
This was always "problematic" in the sense that e.g. serialized spans would never have methods although the EventItem type permits that. However, it has only become noticeable with us deprecating (and in v8 removing) properties from event payloads like for example a Span.
A concrete place where this is now causing difficulties for us are the Playwright browser integration tests. Here we assume that when we intercept an event envelope, the payload will be of type Event. However, in reality, it's not and functions like spanToJSON can't work correctly because they require methods on the span and not just a serialized and re-parsed JSON object. This leads to the weird situation that:
- Accessing e.g.
span.opmakes our linter (and VSCode) complain because according toEvent['spans'],opis deprecated- In reality,
span.opwill continue to be sent as long as we don't fully drop it in favor of thespan.attributes['sentry.op']property.
- In reality,
- Using
spanToJSON(span)will return an empty object instead of the JSON object becausespanhas nogetSpanJSONmethod. - In v8,
span.opwill be removed according to the type, but in fact still be present in the envelope.
Note: span.op serves as a good example but is not the only affected field.
Solution Brainstorm
Change the envelope EventItem type
// envelope.ts
// from
export type EventItem = BaseEnvelopeItem<EventItemHeaders, Event>;
// to
export type EventItem = BaseEnvelopeItem<EventItemHeaders, SerializedEvent>;It's gonna be quite a challenge to figure out the subtle differences when creating SerializedEvent but this would be more correct overall.