Skip to content

Conversation

@AbhiPrasad
Copy link
Member

ref https://linear.app/getsentry/issue/LOGS-516/add-vercel-drain-urls-as-environmental-variables-to-vercel-integration

As part of our work to add on-click install drains for Vercel, I'm updating the Vercel integration to add three new environmental variables.

  1. SENTRY_VERCEL_LOG_DRAIN_URL: The Vercel log drain URL
  2. SENTRY_OTLP_TRACES_URL: The OTLP traces URL that is used for vercel trace drains
  3. SENTRY_PUBLIC_KEY: The public key that is used to authenticate with sentry

To get an idea of how these are used, check out the vercel drain docs: https://docs.sentry.io/product/drains/integration/vercel/

Previously we were populating these environmental variables with the get_env_var_map helper function. This is also used in the getsentry codebase. As this was difficult to manage, I replaced it with a VercelEnvVarMapBuilder builder class, that offers us more extensibility in case we need to add more environmental variables in the future. After we've updated the get_env_var_map usage in the getsentry codebase, we can remove it here as well.

To make the new environmental variables work with rpcs, I've had to serialize two new variables into RpcProjectKey. These are public_key, used to populate SENTRY_PUBLIC_KEY and integration_endpoint, used to populate both SENTRY_VERCEL_LOG_DRAIN_URL and SENTRY_OTLP_TRACES_URL.

I'm still not sure about the naming for SENTRY_PUBLIC_KEY, so open to any feedback there for that.

@AbhiPrasad AbhiPrasad self-assigned this Nov 25, 2025
@AbhiPrasad AbhiPrasad requested review from a team as code owners November 25, 2025 18:03
@linear
Copy link

linear bot commented Nov 25, 2025

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 25, 2025
@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

❌ Patch coverage is 92.10526% with 3 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/integrations/vercel/integration.py 91.66% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #103986      +/-   ##
===========================================
+ Coverage   76.12%    80.61%   +4.49%     
===========================================
  Files        9311      9313       +2     
  Lines      397260    397439     +179     
  Branches    25356     25356              
===========================================
+ Hits       302403    320404   +18001     
+ Misses      94416     76594   -17822     
  Partials      441       441              

.with_project(sentry_project)
.with_project_key(project_key)
.with_auth_token(sentry_auth_token)
.with_framework(vercel_project.get("framework"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Framework validation fails when Vercel project lacks framework

The builder calls with_framework(vercel_project.get("framework")) which passes None when a Vercel project lacks a framework field. However, the build() method raises ValueError("framework is required") when framework is None. This breaks integration setup for Vercel projects without a detected framework, which is a valid scenario. The old implementation expected a string framework parameter, but the new code doesn't handle the missing framework case.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Member

@vgrozdanic vgrozdanic left a comment

Choose a reason for hiding this comment

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

Looks good to me, i just wouldn't raise the error if the framework is None

Comment on lines 207 to 208
if self._framework is None:
raise ValueError("framework is required")
Copy link
Member

Choose a reason for hiding this comment

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

Is the framework really required here?

From what i could tell it is only important to know if it is Next.js or not

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah you're right - fixed with 048a857

@AbhiPrasad AbhiPrasad merged commit 1b4a7fc into master Nov 26, 2025
67 checks passed
@AbhiPrasad AbhiPrasad deleted the abhi-vercel-integration-drain-env-variables branch November 26, 2025 19:08
AbhiPrasad added a commit that referenced this pull request Nov 26, 2025
Now that getsentry/getsentry#18932 and
#103986 has merged, we can
remove the `get_env_var_map` as you should now just use the
`VercelEnvVarMapBuilder` class instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants