Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/nextjs/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export function init(options: NextjsOptions): void {

configureScope(scope => {
scope.setTag('runtime', 'node');
if (process.env.VERCEL) {
scope.setTag('vercel', true);
}
});

if (activeDomain) {
Expand Down
24 changes: 24 additions & 0 deletions packages/nextjs/test/index.server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,30 @@ describe('Server init()', () => {
expect(currentScope._tags).toEqual({ runtime: 'node' });
});

it('applies `vercel` tag when running on vercel', () => {
const currentScope = getCurrentHub().getScope();

process.env.VERCEL = '1';

init({});

// @ts-ignore need access to protected _tags attribute
expect(currentScope._tags.vercel).toEqual(true);

delete process.env.VERCEL;
});

it('does not apply `vercel` tag when not running on vercel', () => {
const currentScope = getCurrentHub().getScope();

expect(process.env.VERCEL).toBeUndefined();

init({});

// @ts-ignore need access to protected _tags attribute
expect(currentScope._tags.vercel).toBeUndefined();
});

it("initializes both global hub and domain hub when there's an active domain", () => {
const globalHub = getCurrentHub();
const local = domain.create();
Expand Down