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

configure msw to blacklist sentry #652

Merged
merged 2 commits into from Mar 16, 2024
Merged

Conversation

fredericrous
Copy link
Contributor

fix #651

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

I think I'd rather add a handler for these and use passthrough.

@fredericrous
Copy link
Contributor Author

fredericrous commented Mar 14, 2024

how would you achieve this with passthrough?

we cannot do something like this

const miscHandlers = process.env.REMIX_DEV_ORIGIN ? [
    http.post(`${process.env.REMIX_DEV_ORIGIN}ping`, passthrough),
    process.env.SENTRY_DSN && http.post(process.env.SENTRY_DSN, passthrough)
].filter(Boolean) : []

because the url we have in SENTRY_DNS is something like

https://user@password.ingest.us.sentry.io/project-key

but the post request is actually made towards

https://user.ingest.us.sentry.io/api/project-key

there is an extra /api

therefore I cannot think of an elegant solution with passthrough without getting hacky

the solution I proposed in this PR used to be in the doc if I remember correctly, at least it's the one I have been using for years. I actually did not bother looking in my old projects and googled it to get this peace of code from the author of mswjs mswjs/msw#1589 (comment)

@kentcdodds
Copy link
Member

Could we not add http.get('https://user.ingest.us.sentry.io/api/project-key', passthrough)?

@fredericrous
Copy link
Contributor Author

fredericrous commented Mar 15, 2024

"user" here is unique for everyone, I could do this and it would only work for me and I'll be sharing a username that was private before (defined by env variable)

using glob pattern is not supported. the following won't work

  http.post('https://*.ingest.us.sentry.io/api/', passthrough)

using parameters won't work in this situation neither because :userId is a cname

  http.post('https://:userId.ingest.us.sentry.io/api/:projectId/envelope', passthrough)

There is actually a feature request to intercept urls with more granularity

mswjs/msw#1804

@kentcdodds
Copy link
Member

Gotcha. In that case, could you add a comment above the code to reference that issue and then we can merge this :)

using request handler with passthrough requires a more permissible url catching system
Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Thanks!

@kentcdodds kentcdodds merged commit bb8d6b4 into epicweb-dev:main Mar 16, 2024
5 checks passed
@jacobparis
Copy link
Contributor

It looks like this commit didn't make it into main, possible got mulched by a later rebase?

https://github.com/fredericrous/epic-stack/blob/c423926f232dfb6d18ee67a72d1074f893ec7c9e/tests/mocks/index.ts

@kentcdodds
Copy link
Member

Hmm... What are we missing? Looks like it's in main right now: https://github.com/epicweb-dev/epic-stack/blob/78ef2528cf3d6ae284bd183c85c9a7270a90b933/tests/mocks/index.ts

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.

sentry.io flood playwright tests output
3 participants