-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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(issue-details): Add runtime label for JS issues #88312
base: master
Are you sure you want to change the base?
Conversation
571ee2b
to
021ad3f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While i do think this solves a problem for nextjs etc. I'm not sure it makes sense for sentry.javascript.cloudflare or even our own frontend project. Should we check the project platform?
It also maybe needs a tooltip? the word "Frontend" by itself is maybe not the most clear
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #88312 +/- ##
==========================================
+ Coverage 87.70% 87.71% +0.01%
==========================================
Files 10143 10063 -80
Lines 573197 568665 -4532
Branches 22518 22353 -165
==========================================
- Hits 502729 498817 -3912
+ Misses 70036 69452 -584
+ Partials 432 396 -36 |
|
||
if ( | ||
(event.contexts.runtime && !event.contexts.browser) || | ||
event.contexts?.cloud_resource // Cloudflare, Vercel etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
event.contexts?.cloud_resource // Cloudflare, Vercel etc. | |
event.contexts.cloud_resource // Cloudflare, Vercel etc. |
only one optional chaining here, I guess either everywhere or nowhere?
} | ||
|
||
if ( | ||
(event.contexts.runtime && !event.contexts.browser) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that backend events also get a browser context, sadly...? I believe this is extracted from the user agent of the incoming request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually not, but I can exclude the browser check here 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just check for if (event.contexts.runtime) { // this is backend }
- this should be true for all current JS SDKs, I think:
- For bun:
runtime: { name: 'bun', version: Bun.version },
- For cloudflare:
runtime: { name: 'cloudflare' },
- For deno:
runtime: { name: 'deno', version: Deno.version.deno },
- For node:
runtime: { name: 'node', version: global.process.version },
- For vercel-edge:
runtime: { name: 'vercel-edge' },
We do not set this for any other SDKs, as far as I can tell.
Obviously this is not super robust, but should be good for the time being I guess..? We could additionally also check for contexts.cloud_resource
I suppose!
alternatively we could also allow-list the values of runtime.name
:
if (['node', 'bun', 'deno', 'cloudflare', 'vercel-edge'].includes(contexts.runtime?.name)) {
// backend
}
but then we need a robust check for browser too 🤔 In the future, we could check on contexts.page
which would be robust as this would be frontend-only. Today, we can only do weird heuristics I guess - e.g. contexts.browser + !contexts.runtime
, for example...?
Add "Frontend" and "Backend" to quickly see the runtime.
part of #85732