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(issue-details): Add runtime label for JS issues #88312

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Mar 31, 2025

Add "Frontend" and "Backend" to quickly see the runtime.

image

image

part of #85732

@s1gr1d s1gr1d self-assigned this Mar 31, 2025
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Mar 31, 2025
@s1gr1d s1gr1d changed the title feat(issue-details): Add runtime label for Meta-Frameworks feat(issue-details): Add runtime label for JS issues Apr 4, 2025
@s1gr1d s1gr1d force-pushed the sig/runtime-label branch from 571ee2b to 021ad3f Compare April 4, 2025 14:16
@s1gr1d s1gr1d requested review from scttcper, leeandher and mydea April 4, 2025 14:16
@s1gr1d s1gr1d marked this pull request as ready for review April 4, 2025 14:16
@s1gr1d s1gr1d requested a review from a team as a code owner April 4, 2025 14:16
Copy link
Member

@scttcper scttcper left a 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

Copy link

codecov bot commented Apr 9, 2025

Codecov Report

All 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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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) ||
Copy link
Member

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.

Copy link
Member Author

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 👍

Copy link
Member

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:

  1. For bun: runtime: { name: 'bun', version: Bun.version },
  2. For cloudflare: runtime: { name: 'cloudflare' },
  3. For deno: runtime: { name: 'deno', version: Deno.version.deno },
  4. For node: runtime: { name: 'node', version: global.process.version },
  5. 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...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants