Skip to content

Commit 283ab4b

Browse files
committed
feat(node): Add vercel ai input/outputs if sendDefaultPii is true
1 parent dcdf074 commit 283ab4b

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

dev-packages/node-integration-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"@types/mongodb": "^3.6.20",
3737
"@types/mysql": "^2.15.21",
3838
"@types/pg": "^8.6.5",
39-
"ai": "^4.0.6",
39+
"ai": "^4.3.16",
4040
"amqplib": "^0.10.7",
4141
"apollo-server": "^3.11.1",
4242
"body-parser": "^1.20.3",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const INTEGRATION_NAME = 'VercelAI';

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ import type { IntegrationFn } from '@sentry/core';
33
import { defineIntegration, SEMANTIC_ATTRIBUTE_SENTRY_OP, spanToJSON } from '@sentry/core';
44
import { generateInstrumentOnce } from '../../../otel/instrument';
55
import { addOriginToSpan } from '../../../utils/addOriginToSpan';
6+
import { INTEGRATION_NAME } from './constants';
67
import { SentryVercelAiInstrumentation } from './instrumentation';
78

8-
const INTEGRATION_NAME = 'VercelAI';
9-
109
export const instrumentVercelAi = generateInstrumentOnce(INTEGRATION_NAME, () => new SentryVercelAiInstrumentation({}));
1110

1211
const _vercelAIIntegration = (() => {

packages/node/src/integrations/tracing/vercelai/instrumentation.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { InstrumentationConfig, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';
22
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
3-
import { SDK_VERSION } from '@sentry/core';
3+
import { getCurrentScope, SDK_VERSION } from '@sentry/core';
4+
import { INTEGRATION_NAME } from './constants';
45
import type { TelemetrySettings } from './types';
56

67
// List of patched methods
@@ -70,14 +71,18 @@ export class SentryVercelAiInstrumentation extends InstrumentationBase {
7071
return (...args: MethodArgs) => {
7172
const existingExperimentalTelemetry = args[0].experimental_telemetry || {};
7273
const isEnabled = existingExperimentalTelemetry.isEnabled;
74+
const client = getCurrentScope().getClient();
75+
const shouldRecordImportAndExports = client?.getIntegrationByName(INTEGRATION_NAME)
76+
? client.getOptions().sendDefaultPii
77+
: false;
7378

7479
// if `isEnabled` is not explicitly set to `true` or `false`, enable telemetry
7580
// but disable capturing inputs and outputs by default
7681
if (isEnabled === undefined) {
7782
args[0].experimental_telemetry = {
7883
isEnabled: true,
79-
recordInputs: false,
80-
recordOutputs: false,
84+
recordInputs: shouldRecordImportAndExports,
85+
recordOutputs: shouldRecordImportAndExports,
8186
...existingExperimentalTelemetry,
8287
};
8388
}

0 commit comments

Comments
 (0)