Automatic environment derivation
@agentmark-ai/sdk’s initTracing() reads Vercel’s system environment variables and picks the target environment for you. A Vercel deploy needs no selector configuration.
VERCEL_ENV | Signal | Traces attributed to |
|---|---|---|
preview | An open pull request (VERCEL_GIT_PULL_REQUEST_ID) | That PR’s preview environment |
preview | A branch deploy with no open PR | An environment named after the branch ref |
development | (none) | The dev environment |
production | (none) | The key’s pinned or promoted environment |
initTracing({ environment, prNumber }) option, or the AGENTMARK_ENVIRONMENT / AGENTMARK_PR_NUMBER environment variables, override it. See Attributing traces to an environment.
What the deployment needs
For derivation to authorize the right environment, the deployment’sAGENTMARK_API_KEY should be a key scoped to environment kinds (with Preview included, and Production if production traces should flow), not a key pinned to a single environment. A kind-scoped key lets the SDK select the target per request, and the gateway authorizes the derived environment against the key’s allowed kinds. See API key environment scope.
Set these on the Vercel project (the same three values the SDK and client read everywhere):
AGENTMARK_API_KEY, a kind-scoped key (Preview, plus Production if needed).AGENTMARK_APP_ID.AGENTMARK_BASE_URL, the gateway URL.
A one-click Vercel Marketplace connect that writes these three values into your Vercel project for you isn’t available yet. Until it ships, set the three variables in the Vercel project’s environment-variable settings yourself. The SDK already ships the automatic environment derivation described above, so it works as soon as you set those variables.
Have questions?
Reach out any time:
- Email the team at hello@agentmark.co for support
- Schedule an Enterprise Demo to learn about AgentMark’s business solutions