Skip to content

Commit 719d727

Browse files
committed
fix(browser): Resolve rebase conflicts
Signed-off-by: Kaung Zin Hein <[email protected]>
1 parent 630d678 commit 719d727

File tree

15 files changed

+47
-561
lines changed

15 files changed

+47
-561
lines changed

dev-packages/browser-integration-tests/suites/integrations/graphqlClient/fetch/test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const query = `query Test{
1313
}`;
1414
const queryPayload = JSON.stringify({ query });
1515

16-
sentryTest('should update spans for GraphQL Fetch requests', async ({ getLocalTestPath, page }) => {
17-
const url = await getLocalTestPath({ testDir: __dirname });
16+
sentryTest('should update spans for GraphQL Fetch requests', async ({ getLocalTestUrl, page }) => {
17+
const url = await getLocalTestUrl({ testDir: __dirname });
1818

1919
await page.route('**/foo', route => {
2020
return route.fulfill({
@@ -57,8 +57,8 @@ sentryTest('should update spans for GraphQL Fetch requests', async ({ getLocalTe
5757
});
5858
});
5959

60-
sentryTest('should update breadcrumbs for GraphQL Fetch requests', async ({ getLocalTestPath, page }) => {
61-
const url = await getLocalTestPath({ testDir: __dirname });
60+
sentryTest('should update breadcrumbs for GraphQL Fetch requests', async ({ getLocalTestUrl, page }) => {
61+
const url = await getLocalTestUrl({ testDir: __dirname });
6262

6363
await page.route('**/foo', route => {
6464
return route.fulfill({

dev-packages/browser-integration-tests/suites/integrations/graphqlClient/xhr/test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const query = `query Test{
1313
}`;
1414
const queryPayload = JSON.stringify({ query });
1515

16-
sentryTest('should update spans for GraphQL XHR requests', async ({ getLocalTestPath, page }) => {
17-
const url = await getLocalTestPath({ testDir: __dirname });
16+
sentryTest('should update spans for GraphQL XHR requests', async ({ getLocalTestUrl, page }) => {
17+
const url = await getLocalTestUrl({ testDir: __dirname });
1818

1919
await page.route('**/foo', route => {
2020
return route.fulfill({
@@ -57,8 +57,8 @@ sentryTest('should update spans for GraphQL XHR requests', async ({ getLocalTest
5757
});
5858
});
5959

60-
sentryTest('should update breadcrumbs for GraphQL XHR requests', async ({ getLocalTestPath, page }) => {
61-
const url = await getLocalTestPath({ testDir: __dirname });
60+
sentryTest('should update breadcrumbs for GraphQL XHR requests', async ({ getLocalTestUrl, page }) => {
61+
const url = await getLocalTestUrl({ testDir: __dirname });
6262

6363
await page.route('**/foo', route => {
6464
return route.fulfill({

packages/browser/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ import { feedbackSyncIntegration } from './feedbackSync';
3232
export { feedbackAsyncIntegration, feedbackSyncIntegration, feedbackSyncIntegration as feedbackIntegration };
3333
export { getFeedback, sendFeedback } from '@sentry-internal/feedback';
3434

35-
export * from './metrics';
36-
3735
export { defaultRequestInstrumentationOptions, instrumentOutgoingRequests } from './tracing/request';
3836
export {
3937
browserTracingIntegration,

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {
3535
parseUrl,
3636
safeJoin,
3737
severityLevelFromString,
38-
} from '@sentry/utils';
38+
} from '@sentry/core';
3939

4040
import type { FetchHint, XhrHint } from '@sentry-internal/replay';
4141
import { DEBUG_BUILD } from '../debug-build';
@@ -293,6 +293,7 @@ function _getFetchBreadcrumbHandler(client: Client): (handlerData: HandlerDataFe
293293
};
294294

295295
if (handlerData.error) {
296+
const data: FetchBreadcrumbData = handlerData.fetchData;
296297
const hint: FetchBreadcrumbHint = {
297298
data: handlerData.error,
298299
input: handlerData.args,
@@ -312,6 +313,10 @@ function _getFetchBreadcrumbHandler(client: Client): (handlerData: HandlerDataFe
312313
addBreadcrumb(breadcrumb, hint);
313314
} else {
314315
const response = handlerData.response as Response | undefined;
316+
const data: FetchBreadcrumbData = {
317+
...handlerData.fetchData,
318+
status_code: response && response.status,
319+
};
315320

316321
breadcrumbData.request_body_size = handlerData.fetchData.request_body_size;
317322
breadcrumbData.response_body_size = handlerData.fetchData.response_body_size;

packages/browser/src/integrations/graphqlClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import {
88
defineIntegration,
99
spanToJSON,
1010
} from '@sentry/core';
11-
import type { Client, IntegrationFn } from '@sentry/types';
12-
import { isString, stringMatchesSomePattern } from '@sentry/utils';
11+
import type { Client, IntegrationFn } from '@sentry/core';
12+
import { isString, stringMatchesSomePattern } from '@sentry/core';
1313

1414
interface GraphQLClientOptions {
1515
endpoints: Array<string | RegExp>;

packages/browser/src/tracing/request.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
addPerformanceInstrumentationHandler,
44
addXhrInstrumentationHandler,
55
} from '@sentry-internal/browser-utils';
6+
import { XhrHint } from '@sentry-internal/replay';
67
import type { Client, HandlerDataXhr, SentryWrappedXMLHttpRequest, Span } from '@sentry/core';
78
import {
89
SEMANTIC_ATTRIBUTE_SENTRY_OP,
@@ -12,6 +13,7 @@ import {
1213
addFetchInstrumentationHandler,
1314
browserPerformanceTimeOrigin,
1415
getActiveSpan,
16+
getClient,
1517
getLocationHref,
1618
getTraceData,
1719
hasTracingEnabled,
@@ -404,6 +406,7 @@ export function xhrCallback(
404406
);
405407
}
406408

409+
const client = getClient();
407410
if (client) {
408411
client.emit('beforeOutgoingRequestSpan', span, handlerData as XhrHint);
409412
}

packages/browser/test/integrations/graphqlClient.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe('GraphqlClient', () => {
7979
queryThree,
8080
{ operationName: 'OnTestItemAdded', operationType: 'subscription' },
8181
],
82-
// ['should handle query without name', queryFour, { operationName: undefined, operationType: 'query' }],
82+
// TODO: ['should handle query without name', queryFour, { operationName: undefined, operationType: 'query' }],
8383
])('%s', (_, input, output) => {
8484
expect(parseGraphQLQuery(input)).toEqual(output);
8585
});

packages/core/src/client.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import type {
3333
TransactionEvent,
3434
Transport,
3535
TransportMakeRequestResponse,
36+
XhrBreadcrumbHint,
3637
} from './types-hoist';
3738

3839
import { getEnvelopeEndpointWithUrlEncodedAuth } from './api';
@@ -593,15 +594,25 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
593594
*/
594595
public on(hook: 'startNavigationSpan', callback: (options: StartSpanOptions) => void): () => void;
595596

596-
/** @inheritdoc */
597+
/**
598+
* A hook for GraphQL client integration to enhance a span with request data.
599+
* @returns A function that, when executed, removes the registered callback.
600+
*/
597601
public on(hook: 'beforeOutgoingRequestSpan', callback: (span: Span, hint: XhrHint | FetchHint) => void): () => void;
598602

599-
/** @inheritdoc */
603+
/**
604+
* A hook for GraphQL client integration to enhance a breadcrumb with request data.
605+
* @returns A function that, when executed, removes the registered callback.
606+
*/
600607
public on(
601608
hook: 'beforeOutgoingRequestBreadcrumb',
602609
callback: (breadcrumb: Breadcrumb, hint: XhrHint | FetchHint) => void,
603610
): () => void;
604611

612+
/**
613+
* A hook that is called when the client is flushing
614+
* @returns A function that, when executed, removes the registered callback.
615+
*/
605616
public on(hook: 'flush', callback: () => void): () => void;
606617

607618
/**
@@ -728,13 +739,19 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
728739
*/
729740
public emit(hook: 'startNavigationSpan', options: StartSpanOptions): void;
730741

731-
/** @inheritdoc */
732-
public emit(hook: 'beforeOutgoingRequestSpan', span: Span, hint: XhrHint | FetchHint): void;
742+
/**
743+
* Emit a hook event for GraphQL client integration to enhance a span with request data.
744+
*/
745+
emit(hook: 'beforeOutgoingRequestSpan', span: Span, hint: XhrHint | FetchHint): void;
733746

734-
/** @inheritdoc */
735-
public emit(hook: 'beforeOutgoingRequestBreadcrumb', breadcrumb: Breadcrumb, hint: XhrHint | FetchHint): void;
747+
/**
748+
* Emit a hook event for GraphQL client integration to enhance a breadcrumb with request data.
749+
*/
750+
emit(hook: 'beforeOutgoingRequestBreadcrumb', breadcrumb: Breadcrumb, hint: XhrHint | FetchHint): void;
736751

737-
/** @inheritdoc */
752+
/**
753+
* Emit a hook event for client flush
754+
*/
738755
public emit(hook: 'flush'): void;
739756

740757
/**

packages/core/src/fetch.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { FetchHint } from './client';
2+
import { getClient } from './currentScopes';
13
import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from './semanticAttributes';
24
import { SPAN_STATUS_ERROR, setHttpStatus, startInactiveSpan } from './tracing';
35
import { SentryNonRecordingSpan } from './tracing/sentryNonRecordingSpan';
@@ -96,6 +98,7 @@ export function instrumentFetchRequest(
9698
}
9799
}
98100

101+
const client = getClient();
99102
if (client) {
100103
// There's no 'input' key in HandlerDataFetch
101104
const fetchHint = {

packages/core/src/utils-hoist/graphql.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)