Skip to content

Commit

Permalink
feat(nextjs): Remove EdgeClient and use ServerRuntimeClient (#8932)
Browse files Browse the repository at this point in the history
This PR removes the `EdgeClient` and duplicate `eventbuilder` functions.
  • Loading branch information
timfish authored Sep 6, 2023
1 parent 66a925e commit d3fe473
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 365 deletions.
174 changes: 0 additions & 174 deletions packages/nextjs/src/edge/edgeclient.ts

This file was deleted.

130 changes: 0 additions & 130 deletions packages/nextjs/src/edge/eventbuilder.ts

This file was deleted.

30 changes: 26 additions & 4 deletions packages/nextjs/src/edge/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { getIntegrationsToSetup, initAndBind, Integrations as CoreIntegrations } from '@sentry/core';
import type { ServerRuntimeClientOptions } from '@sentry/core';
import {
getIntegrationsToSetup,
initAndBind,
Integrations as CoreIntegrations,
SDK_VERSION,
ServerRuntimeClient,
} from '@sentry/core';
import type { Options } from '@sentry/types';
import { createStackParser, GLOBAL_OBJ, nodeStackLineParser, stackParserFromStackParserOptions } from '@sentry/utils';

import { getVercelEnv } from '../common/getVercelEnv';
import { setAsyncLocalStorageAsyncContextStrategy } from './asyncLocalStorageAsyncContextStrategy';
import { EdgeClient } from './edgeclient';
import { makeEdgeTransport } from './transport';

const nodeStackParser = createStackParser(nodeStackLineParser());
Expand Down Expand Up @@ -53,14 +59,30 @@ export function init(options: EdgeOptions = {}): void {
options.instrumenter = 'sentry';
}

const clientOptions = {
const clientOptions: ServerRuntimeClientOptions = {
...options,
stackParser: stackParserFromStackParserOptions(options.stackParser || nodeStackParser),
integrations: getIntegrationsToSetup(options),
transport: options.transport || makeEdgeTransport,
};

initAndBind(EdgeClient, clientOptions);
clientOptions._metadata = clientOptions._metadata || {};
clientOptions._metadata.sdk = clientOptions._metadata.sdk || {
name: 'sentry.javascript.nextjs',
packages: [
{
name: 'npm:@sentry/nextjs',
version: SDK_VERSION,
},
],
version: SDK_VERSION,
};

clientOptions.platform = 'edge';
clientOptions.runtime = { name: 'edge' };
clientOptions.serverName = process.env.SENTRY_NAME;

initAndBind(ServerRuntimeClient, clientOptions);

// TODO?: Sessiontracking
}
Expand Down
Loading

0 comments on commit d3fe473

Please sign in to comment.