Skip to content

Commit 67a409f

Browse files
committed
feat(server-utils): initial scaffolding (#21200)
This is phase 1 of the plan to move all server utils into a single reusable package that can be shared across SSJS SDKs. Right now it does not do much, just houses the `diagnostics_channel` redis integrations. In subsequent steps: 1. Code will *not* be moved out of `@sentry/core/server` into `@sentry-internal/server-utils`, in v10. 2. Some or all code in `@sentry/core/server` may be moved into `@sentry-internal/server-utils` in v11, as this would be breaking change. (Redis channel integration was not, because it hasn't yet shipped in a release. Other high-level portable components may move over later, if justified.) 3. No components will ever live in *both* places, because `server-utils` depends on `core`, and that would create a type dependency cycle. `@sentry/core/server` will live on for at least v10, possibly into v11. New server components will be placed in `@sentry-internal/server-utils`.
1 parent a438a0c commit 67a409f

19 files changed

Lines changed: 230 additions & 34 deletions

File tree

.craft.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ targets:
1616
- name: npm
1717
id: '@sentry/node-core'
1818
includeNames: /^sentry-node-core-\d.*\.tgz$/
19+
- name: npm
20+
id: '@sentry-internal/server-utils'
21+
includeNames: /^sentry-internal-server-utils-\d.*\.tgz$/
1922
## 1.3 Browser Utils package
2023
- name: npm
2124
id: '@sentry-internal/browser-utils'

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"packages/replay-internal",
8888
"packages/replay-canvas",
8989
"packages/replay-worker",
90+
"packages/server-utils",
9091
"packages/solid",
9192
"packages/solidstart",
9293
"packages/svelte",

packages/core/src/server-exports.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,6 @@ export type {
2424
} from './integrations/express/types';
2525
export { instrumentPostgresJsSql } from './integrations/postgresjs';
2626

27-
export {
28-
IOREDIS_DC_CHANNEL_COMMAND,
29-
IOREDIS_DC_CHANNEL_CONNECT,
30-
REDIS_DC_CHANNEL_BATCH,
31-
REDIS_DC_CHANNEL_COMMAND,
32-
REDIS_DC_CHANNEL_CONNECT,
33-
subscribeRedisDiagnosticChannels,
34-
} from './integrations/redis/redis-dc-subscriber';
35-
export type {
36-
IORedisCommandData,
37-
RedisBatchData,
38-
RedisCommandData,
39-
RedisConnectData,
40-
RedisDiagnosticChannelResponseHook,
41-
RedisTracingChannel,
42-
RedisTracingChannelContextWithSpan,
43-
RedisTracingChannelFactory,
44-
RedisTracingChannelSubscribers,
45-
} from './integrations/redis/redis-dc-subscriber';
46-
4727
export { patchHttpModuleClient } from './integrations/http/client-patch';
4828
export { getHttpClientSubscriptions } from './integrations/http/client-subscriptions';
4929
export { getHttpServerSubscriptions, isStaticAssetRequest } from './integrations/http/server-subscription';

packages/deno/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
],
2626
"dependencies": {
2727
"@opentelemetry/api": "^1.9.1",
28+
"@sentry-internal/server-utils": "10.55.0",
2829
"@sentry/core": "10.55.0"
2930
},
3031
"scripts": {

packages/deno/src/integrations/redis.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
// On older runtimes the integration becomes a no-op.
44
import * as dc from 'node:diagnostics_channel';
55
import type {
6-
Integration,
7-
IntegrationFn,
86
RedisDiagnosticChannelResponseHook,
97
RedisTracingChannel,
108
RedisTracingChannelFactory,
119
RedisTracingChannelSubscribers,
12-
Span,
13-
} from '@sentry/core';
14-
import { defineIntegration, subscribeRedisDiagnosticChannels } from '@sentry/core';
10+
} from '@sentry-internal/server-utils';
11+
import { subscribeRedisDiagnosticChannels } from '@sentry-internal/server-utils';
12+
import type { Integration, IntegrationFn, Span } from '@sentry/core';
13+
import { defineIntegration } from '@sentry/core';
1514
import { setAsyncLocalStorageAsyncContextStrategy } from '../async';
1615

1716
const INTEGRATION_NAME = 'DenoRedis';

packages/node/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"@opentelemetry/instrumentation": "^0.214.0",
7171
"@opentelemetry/sdk-trace-base": "^2.6.1",
7272
"@opentelemetry/semantic-conventions": "^1.40.0",
73+
"@sentry-internal/server-utils": "10.55.0",
7374
"@sentry/core": "10.55.0",
7475
"@sentry/node-core": "10.55.0",
7576
"@sentry/opentelemetry": "10.55.0",

packages/node/src/integrations/tracing/redis/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
spanToJSON,
1010
truncate,
1111
} from '@sentry/core';
12-
import { subscribeRedisDiagnosticChannels } from '@sentry/core/server';
12+
import { subscribeRedisDiagnosticChannels } from '@sentry-internal/server-utils';
1313
import { generateInstrumentOnce } from '@sentry/node-core';
1414
import { tracingChannel as otelTracingChannel } from '@sentry/opentelemetry/tracing-channel';
1515
import type { IORedisCommandArgs } from '../../../utils/redisCache';
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"$schema": "../../node_modules/oxlint/configuration_schema.json",
3+
"extends": ["../../.oxlintrc.base.json"],
4+
"jsPlugins": [
5+
{
6+
"name": "sdk",
7+
"specifier": "@sentry-internal/eslint-plugin-sdk"
8+
}
9+
],
10+
"env": {
11+
"node": true
12+
},
13+
"rules": {
14+
"sdk/no-unsafe-random-apis": "error"
15+
},
16+
"overrides": [
17+
{
18+
"files": ["**/src/**"],
19+
"rules": {
20+
"sdk/no-class-field-initializers": "off"
21+
}
22+
},
23+
{
24+
"files": ["test/**/*.ts", "test/**/*.tsx"],
25+
"rules": {
26+
"sdk/no-unsafe-random-apis": "off"
27+
}
28+
}
29+
]
30+
}

packages/server-utils/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<p align="center">
2+
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
3+
<img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84">
4+
</a>
5+
</p>
6+
7+
# Sentry JavaScript SDK Server Utilities
8+
9+
[![npm version](https://img.shields.io/npm/v/@sentry-internal/server-utils.svg)](https://www.npmjs.com/package/@sentry-internal/server-utils)
10+
[![npm dm](https://img.shields.io/npm/dm/@sentry-internal/server-utils.svg)](https://www.npmjs.com/package/@sentry-internal/server-utils)
11+
[![npm dt](https://img.shields.io/npm/dt/@sentry-internal/server-utils.svg)](https://www.npmjs.com/package/@sentry-internal/server-utils)
12+
13+
## Links
14+
15+
- [Official SDK Docs](https://docs.sentry.io/quickstart/)
16+
17+
## General
18+
19+
Common server-only utilities used by the Sentry JavaScript server SDKs (node, node-core, bun, deno, cloudflare,
20+
aws-serverless, google-cloud-serverless, vercel-edge).
21+
22+
Note: This package is only meant to be used internally, and as such is not part of our public API contract and does not
23+
follow semver.

packages/server-utils/package.json

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"name": "@sentry-internal/server-utils",
3+
"version": "10.55.0",
4+
"description": "Server Utilities for all Sentry JavaScript SDKs",
5+
"repository": "git://github.com/getsentry/sentry-javascript.git",
6+
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/server-utils",
7+
"author": "Sentry",
8+
"license": "MIT",
9+
"engines": {
10+
"node": ">=18"
11+
},
12+
"files": [
13+
"/build"
14+
],
15+
"main": "build/cjs/index.js",
16+
"module": "build/esm/index.js",
17+
"types": "build/types/index.d.ts",
18+
"exports": {
19+
"./package.json": "./package.json",
20+
".": {
21+
"import": {
22+
"types": "./build/types/index.d.ts",
23+
"default": "./build/esm/index.js"
24+
},
25+
"require": {
26+
"types": "./build/types/index.d.ts",
27+
"default": "./build/cjs/index.js"
28+
}
29+
}
30+
},
31+
"typesVersions": {
32+
"<5.0": {
33+
"build/types/index.d.ts": [
34+
"build/types-ts3.8/index.d.ts"
35+
]
36+
}
37+
},
38+
"publishConfig": {
39+
"access": "public"
40+
},
41+
"dependencies": {
42+
"@sentry/core": "10.55.0"
43+
},
44+
"scripts": {
45+
"build": "run-p build:transpile build:types",
46+
"build:dev": "yarn build",
47+
"build:transpile": "rollup -c rollup.npm.config.mjs",
48+
"build:types": "run-s build:types:core build:types:downlevel",
49+
"build:types:core": "tsc -p tsconfig.types.json",
50+
"build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8",
51+
"build:watch": "run-p build:transpile:watch",
52+
"build:dev:watch": "run-p build:transpile:watch",
53+
"build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch",
54+
"build:tarball": "npm pack",
55+
"clean": "rimraf build coverage sentry-internal-server-utils-*.tgz",
56+
"lint:fix": "OXLINT_TSGOLINT_DANGEROUSLY_SUPPRESS_PROGRAM_DIAGNOSTICS=true oxlint . --fix --type-aware",
57+
"lint": "OXLINT_TSGOLINT_DANGEROUSLY_SUPPRESS_PROGRAM_DIAGNOSTICS=true oxlint . --type-aware",
58+
"lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module",
59+
"test:unit": "vitest run",
60+
"test": "vitest run",
61+
"test:watch": "vitest --watch",
62+
"yalc:publish": "yalc publish --push --sig"
63+
},
64+
"volta": {
65+
"extends": "../../package.json"
66+
},
67+
"sideEffects": false
68+
}

0 commit comments

Comments
 (0)