Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Apr 16, 2024
1 parent e86eeac commit c4a5142
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ sentryTest('should create spans for fetch requests', async ({ getLocalTestPath,
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: tracingEvent.contexts?.trace?.trace_id,
data: {
'http.method': 'GET',
'http.url': `http://example.com/${index}`,
url: `http://example.com/${index}`,
'server.address': 'example.com',
type: 'fetch',
},
}),
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ sentryTest('should create spans for XHR requests', async ({ getLocalTestPath, pa
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: eventData.contexts?.trace?.trace_id,
data: {
'http.method': 'GET',
'http.url': `http://example.com/${index}`,
url: `http://example.com/${index}`,
'server.address': 'example.com',
type: 'xhr',
},
}),
);
});
Expand Down
1 change: 1 addition & 0 deletions packages/browser/src/tracing/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ export function xhrCallback(
attributes: {
type: 'xhr',
'http.method': sentryXhrData.method,
'http.url': sentryXhrData.url,
url: sentryXhrData.url,
'server.address': parsedUrl.host,
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.browser',
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export function instrumentFetchRequest(
url,
type: 'fetch',
'http.method': method,
'http.url': url,
'server.address': parsedUrl.host,
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: spanOrigin,
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.client',
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/test/integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@sentry/nextjs": "file:../../",
"next": "latest",
"next": "13.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
41 changes: 41 additions & 0 deletions packages/nextjs/test/integration/package.json.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "with-typescript",
"license": "MIT",
"scripts": {
"dev": "next",
"build": "next build",
"predebug": "source ../integration_test_utils.sh && link_monorepo_packages '../../..' && yarn build",
"start": "next start",
"pretest": "yarn build",
"test:client": "playwright test",
"test:server": "jest --forceExit --runInBand"
},
"dependencies": {
"@sentry/nextjs": "file:../../",
"next": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "^15.3.1",
"@types/react": "17.0.47",
"@types/react-dom": "17.0.17",
"nock": "^13.1.0",
"typescript": "4.9.5",
"yargs": "^16.2.0"
},
"resolutions": {
"@sentry/browser": "file:../../../browser",
"@sentry/core": "file:../../../core",
"@sentry/node": "file:../../../node",
"@sentry/opentelemetry": "file:../../../opentelemetry",
"@sentry/react": "file:../../../react",
"@sentry-internal/browser-utils": "file:../../../browser-utils",
"@sentry-internal/replay": "file:../../../replay-internal",
"@sentry-internal/replay-canvas": "file:../../../replay-canvas",
"@sentry-internal/feedback": "file:../../../feedback",
"@sentry/types": "file:../../../types",
"@sentry/utils": "file:../../../utils",
"@sentry/vercel-edge": "file:../../../vercel-edge"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ test('should correctly instrument `fetch` for performance tracing', async ({ pag
data: {
'http.method': 'GET',
url: 'http://example.com',
'http.url': 'http://example.com',
'server.address': 'example.com',
type: 'fetch',
'http.response_content_length': expect.any(Number),
'http.response.status_code': 200,
Expand Down

0 comments on commit c4a5142

Please sign in to comment.