zivl / sentry-testkit

A Sentry plugin to allow Sentry report interception and further inspection of the data being sent
https://zivl.github.io/sentry-testkit/
MIT License
112 stars 26 forks source link

Expose events #106

Closed rchl closed 1 year ago

rchl commented 2 years ago

Is your feature request related to a problem? Please describe. I'd like to test that a custom integration like rrweb is sending its data on error but those events are not captured and not exposed through sentry-testkit.

rrweb triggers POST requests like https://sentry.io/api/000001/events/6fd7cc13658e4ade9b7217b748144f41/attachments/?sentry_key=acacaeaccacacacabcaacdacdacadaca&sentry_version=7&sentry_client=rrweb

where the content type is Content-Type: multipart/form-data; boundary=....

Describe the solution you'd like An API like testkit.events() that collects all such events. I'm not sure how would the payload be exposed and whether the content type is something that the integrations gets to choose or it's somewhat standardized in the API.

Just to clarify, I'd be using localServer for this.

zivl commented 2 years ago

lets us explore a few possible solutions here so we can be agnostic to content type (in this manner)

rchl commented 2 years ago

That /api/{projectId}/events/{eventId}/attachments/ endpoint is not really documented as part of the public SDK so I would be hesitant to add handler for that. I think it's just an internal endpoint that Sentry uses and they've also used it for rrweb as it's developed by them.

With that in mind, I think a nice way of handling this could be to have an API in sentry-testkit that would allow extending the built-in express routes with custom ones. At least for the "local server" use case.

(I've also inquired about that endpoint on Sentry's Discord but as I'm writing this, I haven't received a reply yet.)

zivl commented 2 years ago

@rchl

to have an API in sentry-testkit that would allow extending the built-in express routes with custom ones.

this might be a good approach for solution. It could be awesome if you check for possible implementation and PR your solution here?

zivl commented 2 years ago

@rchl I see your PR here https://github.com/wix/sentry-testkit/pull/119 is this suites your case or you want maybe to expand it so content-type could be configurable?

rchl commented 2 years ago

That could be changed if needed when implementing the solution for this issue but I imagine that it wouldn't be needed because someone could just configure body parser specifically for the custom endpoint.

zivl commented 2 years ago

i'm flexible on this :) let me know what you decide and then i'll merge

rchl commented 2 years ago

I'm fine with https://github.com/wix/sentry-testkit/pull/119 being merged right now.

zivl commented 2 years ago

@rchl can this be closed?

rchl commented 2 years ago

This specific use case is not addressed yet. rrweb is posting attachements to /api/000001/events/*/attachments/ endpoint that does not exist. I suppose we could just expose the router and let user add arbitrary endpoints though I haven't tried doing that in practice yet.

github-actions[bot] commented 1 year ago

Stale issue message