Skip to content

Commit 78adfa8

Browse files
committed
update with rollup bundle path
1 parent 43c45d2 commit 78adfa8

File tree

10 files changed

+6
-156
lines changed

10 files changed

+6
-156
lines changed

dev-packages/browser-integration-tests/suites/tracing/ai-providers/anthropic/mocks.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
// Mock Anthropic client for browser testing
22
export class MockAnthropic {
33
constructor(config) {
4-
// eslint-disable-next-line no-console
5-
console.log('[Mock Anthropic] Constructor called with config:', config);
64
this.apiKey = config.apiKey;
75

86
// Main focus: messages.create functionality
97
this.messages = {
108
create: async (...args) => {
11-
// eslint-disable-next-line no-console
12-
console.log('[Mock Anthropic] messages.create called with args:', args);
139
const params = args[0];
1410
// Simulate processing time
1511
await new Promise(resolve => setTimeout(resolve, 10));
@@ -41,8 +37,6 @@ export class MockAnthropic {
4137
cache_read_input_tokens: 0,
4238
},
4339
};
44-
// eslint-disable-next-line no-console
45-
console.log('[Mock Anthropic] Returning response:', response);
4640
return response;
4741
},
4842
countTokens: async (..._args) => ({ id: 'mock', type: 'model', model: 'mock', input_tokens: 0 }),
Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,22 @@
11
import * as Sentry from '@sentry/browser';
22
import { MockAnthropic } from './mocks.js';
33

4-
// eslint-disable-next-line no-console
5-
console.log('[Anthropic Test] Starting test...');
6-
7-
// eslint-disable-next-line no-console
8-
console.log('[Anthropic Test] Creating mock client...');
94
const mockClient = new MockAnthropic({
105
apiKey: 'mock-api-key',
116
});
127

13-
// eslint-disable-next-line no-console
14-
console.log('[Anthropic Test] Mock client created:', mockClient);
15-
16-
// eslint-disable-next-line no-console
17-
console.log('[Anthropic Test] Instrumenting client with Sentry...');
188
const client = Sentry.instrumentAnthropicAiClient(mockClient);
199

20-
// eslint-disable-next-line no-console
21-
console.log('[Anthropic Test] Client instrumented:', client);
22-
2310
// Test that manual instrumentation doesn't crash the browser
2411
// The instrumentation automatically creates spans
25-
// eslint-disable-next-line no-console
26-
console.log('[Anthropic Test] Calling messages.create...');
2712
const response = await client.messages.create({
2813
model: 'claude-3-haiku-20240307',
2914
messages: [{ role: 'user', content: 'What is the capital of France?' }],
3015
temperature: 0.7,
3116
max_tokens: 100,
3217
});
3318

34-
// eslint-disable-next-line no-console
35-
console.log('[Anthropic Test] Response received:', JSON.stringify(response));
19+
console.log("Received response", response)
3620

37-
// eslint-disable-next-line no-console
38-
console.log('[Anthropic Test] Flushing Sentry...');
3921
// Ensure transaction is flushed in CI
4022
await Sentry.flush(2000);
41-
42-
// eslint-disable-next-line no-console
43-
console.log('[Anthropic Test] Test completed!');

dev-packages/browser-integration-tests/suites/tracing/ai-providers/anthropic/test.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,16 @@ import { envelopeRequestParser, waitForTransactionRequest } from '../../../../ut
88
// and that gen_ai transactions are sent.
99

1010
sentryTest('manual Anthropic instrumentation sends gen_ai transactions', async ({ getLocalTestUrl, page }) => {
11-
// Listen for console logs
12-
page.on('console', msg => {
13-
// eslint-disable-next-line no-console
14-
console.log(`[Browser Console ${msg.type()}]`, msg.text());
15-
});
16-
17-
// Listen for page errors
18-
page.on('pageerror', error => {
19-
// eslint-disable-next-line no-console
20-
console.error('[Browser Error]', error);
21-
});
22-
2311
const transactionPromise = waitForTransactionRequest(page, event => {
24-
// eslint-disable-next-line no-console
25-
console.log('[Test] Received transaction event:', JSON.stringify(event, null, 2));
2612
return !!event.transaction?.includes('claude-3-haiku-20240307');
2713
});
2814

2915
const url = await getLocalTestUrl({ testDir: __dirname });
30-
// eslint-disable-next-line no-console
31-
console.log('[Test] Navigating to URL:', url);
3216
await page.goto(url);
3317

34-
// eslint-disable-next-line no-console
35-
console.log('[Test] Waiting for transaction...');
3618
const req = await transactionPromise;
37-
// eslint-disable-next-line no-console
38-
console.log('[Test] Transaction received!');
3919

4020
const eventData = envelopeRequestParser(req);
41-
// eslint-disable-next-line no-console
42-
console.log('[Test] Parsed event data:', JSON.stringify(eventData, null, 2));
4321

4422
// Verify it's a gen_ai transaction
4523
expect(eventData.transaction).toBe('messages claude-3-haiku-20240307');

dev-packages/browser-integration-tests/suites/tracing/ai-providers/google-genai/mocks.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
// Mock Google GenAI client for browser testing
22
export class MockGoogleGenAI {
33
constructor(config) {
4-
// eslint-disable-next-line no-console
5-
console.log('[Mock Google GenAI] Constructor called with config:', config);
64
this.apiKey = config.apiKey;
75

86
// models.generateContent functionality
97
this.models = {
108
generateContent: async (...args) => {
11-
// eslint-disable-next-line no-console
12-
console.log('[Mock Google GenAI] models.generateContent called with args:', args);
139
const params = args[0];
1410
// Simulate processing time
1511
await new Promise(resolve => setTimeout(resolve, 10));
@@ -65,16 +61,12 @@ export class MockGoogleGenAI {
6561
// chats.create implementation
6662
this.chats = {
6763
create: (...args) => {
68-
// eslint-disable-next-line no-console
69-
console.log('[Mock Google GenAI] chats.create called with args:', args);
7064
const params = args[0];
7165
const model = params.model;
7266

7367
return {
7468
modelVersion: model,
7569
sendMessage: async (..._messageArgs) => {
76-
// eslint-disable-next-line no-console
77-
console.log('[Mock Google GenAI] chat.sendMessage called with args:', _messageArgs);
7870
// Simulate processing time
7971
await new Promise(resolve => setTimeout(resolve, 10));
8072

@@ -100,8 +92,6 @@ export class MockGoogleGenAI {
10092
},
10193
modelVersion: model, // Include model version in response
10294
};
103-
// eslint-disable-next-line no-console
104-
console.log('[Mock Google GenAI] Returning response:', response);
10595
return response;
10696
},
10797
sendMessageStream: async () => {
Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,15 @@
11
import * as Sentry from '@sentry/browser';
22
import { MockGoogleGenAI } from './mocks.js';
33

4-
// eslint-disable-next-line no-console
5-
console.log('[Google GenAI Test] Starting test...');
6-
7-
// eslint-disable-next-line no-console
8-
console.log('[Google GenAI Test] Creating mock client...');
94
const mockClient = new MockGoogleGenAI({
105
apiKey: 'mock-api-key',
116
});
127

13-
// eslint-disable-next-line no-console
14-
console.log('[Google GenAI Test] Mock client created:', mockClient);
15-
16-
// eslint-disable-next-line no-console
17-
console.log('[Google GenAI Test] Instrumenting client with Sentry...');
188
const client = Sentry.instrumentGoogleGenAIClient(mockClient);
199

20-
// eslint-disable-next-line no-console
21-
console.log('[Google GenAI Test] Client instrumented:', client);
22-
2310
// Test that manual instrumentation doesn't crash the browser
2411
// The instrumentation automatically creates spans
2512
// Test both chats and models APIs
26-
// eslint-disable-next-line no-console
27-
console.log('[Google GenAI Test] Creating chat...');
2813
const chat = client.chats.create({
2914
model: 'gemini-1.5-pro',
3015
config: {
@@ -40,19 +25,11 @@ const chat = client.chats.create({
4025
],
4126
});
4227

43-
// eslint-disable-next-line no-console
44-
console.log('[Google GenAI Test] Sending message...');
4528
const response = await chat.sendMessage({
4629
message: 'Tell me a joke',
4730
});
4831

49-
// eslint-disable-next-line no-console
50-
console.log('[Google GenAI Test] Response received:', JSON.stringify(response));
32+
console.log("Received response", response)
5133

52-
// eslint-disable-next-line no-console
53-
console.log('[Google GenAI Test] Flushing Sentry...');
5434
// Ensure transaction is flushed in CI
5535
await Sentry.flush(2000);
56-
57-
// eslint-disable-next-line no-console
58-
console.log('[Google GenAI Test] Test completed!');

dev-packages/browser-integration-tests/suites/tracing/ai-providers/google-genai/test.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,16 @@ import { envelopeRequestParser, waitForTransactionRequest } from '../../../../ut
88
// and that gen_ai transactions are sent.
99

1010
sentryTest('manual Google GenAI instrumentation sends gen_ai transactions', async ({ getLocalTestUrl, page }) => {
11-
// Listen for console logs
12-
page.on('console', msg => {
13-
// eslint-disable-next-line no-console
14-
console.log(`[Browser Console ${msg.type()}]`, msg.text());
15-
});
16-
17-
// Listen for page errors
18-
page.on('pageerror', error => {
19-
// eslint-disable-next-line no-console
20-
console.error('[Browser Error]', error);
21-
});
22-
2311
const transactionPromise = waitForTransactionRequest(page, event => {
24-
// eslint-disable-next-line no-console
25-
console.log('[Test] Received transaction event:', JSON.stringify(event, null, 2));
2612
return !!event.transaction?.includes('gemini-1.5-pro');
2713
});
2814

2915
const url = await getLocalTestUrl({ testDir: __dirname });
30-
// eslint-disable-next-line no-console
31-
console.log('[Test] Navigating to URL:', url);
3216
await page.goto(url);
3317

34-
// eslint-disable-next-line no-console
35-
console.log('[Test] Waiting for transaction...');
3618
const req = await transactionPromise;
37-
// eslint-disable-next-line no-console
38-
console.log('[Test] Transaction received!');
3919

4020
const eventData = envelopeRequestParser(req);
41-
// eslint-disable-next-line no-console
42-
console.log('[Test] Parsed event data:', JSON.stringify(eventData, null, 2));
4321

4422
// Verify it's a gen_ai transaction
4523
expect(eventData.transaction).toBe('chat gemini-1.5-pro create');

dev-packages/browser-integration-tests/suites/tracing/ai-providers/openai/mocks.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
// Mock OpenAI client for browser testing
22
export class MockOpenAi {
33
constructor(config) {
4-
// eslint-disable-next-line no-console
5-
console.log('[Mock OpenAI] Constructor called with config:', config);
64
this.apiKey = config.apiKey;
75

86
this.chat = {
97
completions: {
108
create: async (...args) => {
11-
// eslint-disable-next-line no-console
12-
console.log('[Mock OpenAI] chat.completions.create called with args:', args);
139
const params = args[0];
1410
// Simulate processing time
1511
await new Promise(resolve => setTimeout(resolve, 10));
@@ -43,8 +39,6 @@ export class MockOpenAi {
4339
total_tokens: 25,
4440
},
4541
};
46-
// eslint-disable-next-line no-console
47-
console.log('[Mock OpenAI] Returning response:', response);
4842
return response;
4943
},
5044
},
Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
11
import * as Sentry from '@sentry/browser';
22
import { MockOpenAi } from './mocks.js';
33

4-
// eslint-disable-next-line no-console
5-
console.log('[OpenAI Test] Starting test...');
6-
7-
// eslint-disable-next-line no-console
8-
console.log('[OpenAI Test] Creating mock client...');
94
const mockClient = new MockOpenAi({
105
apiKey: 'mock-api-key',
116
});
127

13-
// eslint-disable-next-line no-console
14-
console.log('[OpenAI Test] Mock client created:', mockClient);
15-
16-
// eslint-disable-next-line no-console
17-
console.log('[OpenAI Test] Instrumenting client with Sentry...');
188
const client = Sentry.instrumentOpenAiClient(mockClient);
199

20-
// eslint-disable-next-line no-console
21-
console.log('[OpenAI Test] Client instrumented:', client);
22-
2310
// Test that manual instrumentation doesn't crash the browser
2411
// The instrumentation automatically creates spans
25-
// eslint-disable-next-line no-console
26-
console.log('[OpenAI Test] Calling chat.completions.create...');
2712
const response = await client.chat.completions.create({
2813
model: 'gpt-3.5-turbo',
2914
messages: [
@@ -34,13 +19,7 @@ const response = await client.chat.completions.create({
3419
max_tokens: 100,
3520
});
3621

37-
// eslint-disable-next-line no-console
38-
console.log('[OpenAI Test] Response received:', JSON.stringify(response));
22+
console.log("Received response", response)
3923

40-
// eslint-disable-next-line no-console
41-
console.log('[OpenAI Test] Flushing Sentry...');
4224
// Ensure transaction is flushed in CI
4325
await Sentry.flush(2000);
44-
45-
// eslint-disable-next-line no-console
46-
console.log('[OpenAI Test] Test completed!');

dev-packages/browser-integration-tests/suites/tracing/ai-providers/openai/test.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,16 @@ import { envelopeRequestParser, waitForTransactionRequest } from '../../../../ut
88
// and that gen_ai transactions are sent.
99

1010
sentryTest('manual OpenAI instrumentation sends gen_ai transactions', async ({ getLocalTestUrl, page }) => {
11-
// Listen for console logs
12-
page.on('console', msg => {
13-
// eslint-disable-next-line no-console
14-
console.log(`[Browser Console ${msg.type()}]`, msg.text());
15-
});
16-
17-
// Listen for page errors
18-
page.on('pageerror', error => {
19-
// eslint-disable-next-line no-console
20-
console.error('[Browser Error]', error);
21-
});
22-
2311
const transactionPromise = waitForTransactionRequest(page, event => {
24-
// eslint-disable-next-line no-console
25-
console.log('[Test] Received transaction event:', JSON.stringify(event, null, 2));
2612
return !!event.transaction?.includes('gpt-3.5-turbo');
2713
});
2814

2915
const url = await getLocalTestUrl({ testDir: __dirname });
30-
// eslint-disable-next-line no-console
31-
console.log('[Test] Navigating to URL:', url);
3216
await page.goto(url);
3317

34-
// eslint-disable-next-line no-console
35-
console.log('[Test] Waiting for transaction...');
3618
const req = await transactionPromise;
37-
// eslint-disable-next-line no-console
38-
console.log('[Test] Transaction received!');
3919

4020
const eventData = envelopeRequestParser(req);
41-
// eslint-disable-next-line no-console
42-
console.log('[Test] Parsed event data:', JSON.stringify(eventData, null, 2));
4321

4422
// Verify it's a gen_ai transaction
4523
expect(eventData.transaction).toBe('chat gpt-3.5-turbo');

packages/browser/rollup.bundle.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ const reexportedPluggableIntegrationFiles = [
1313
'modulemetadata',
1414
'graphqlclient',
1515
'spotlight',
16+
'instrumentanthropicaiclient',
17+
'instrumentopenaiclient',
18+
'instrumentgooglegenaiclient',
1619
];
1720

1821
browserPluggableIntegrationFiles.forEach(integrationName => {

0 commit comments

Comments
 (0)