Skip to content

Commit c8f69fe

Browse files
mydeaZen-cronic
authored andcommitted
Add graphqlclient CDN bundle & fix bundle tests
1 parent 41dc493 commit c8f69fe

File tree

8 files changed

+29
-6
lines changed

8 files changed

+29
-6
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect } from '@playwright/test';
22
import type { Event } from '@sentry/core';
33

44
import { sentryTest } from '../../../../utils/fixtures';
5-
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';
5+
import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers';
66

77
// Duplicate from subject.js
88
const query = `query Test{
@@ -13,7 +13,11 @@ const query = `query Test{
1313
}`;
1414
const queryPayload = JSON.stringify({ query });
1515

16-
sentryTest('should update spans for GraphQL Fetch requests', async ({ getLocalTestUrl, page }) => {
16+
sentryTest('should update spans for GraphQL fetch requests', async ({ getLocalTestUrl, page }) => {
17+
if (shouldSkipTracingTest()) {
18+
return;
19+
}
20+
1721
const url = await getLocalTestUrl({ testDir: __dirname });
1822

1923
await page.route('**/foo', route => {
@@ -57,7 +61,11 @@ sentryTest('should update spans for GraphQL Fetch requests', async ({ getLocalTe
5761
});
5862
});
5963

60-
sentryTest('should update breadcrumbs for GraphQL Fetch requests', async ({ getLocalTestUrl, page }) => {
64+
sentryTest('should update breadcrumbs for GraphQL fetch requests', async ({ getLocalTestUrl, page }) => {
65+
if (shouldSkipTracingTest()) {
66+
return;
67+
}
68+
6169
const url = await getLocalTestUrl({ testDir: __dirname });
6270

6371
await page.route('**/foo', route => {

dev-packages/browser-integration-tests/suites/integrations/graphqlClient/init.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import * as Sentry from '@sentry/browser';
2+
// Must import this like this to ensure the test transformation for CDN bundles works
3+
import { graphqlClientIntegration } from '@sentry/browser';
24

35
window.Sentry = Sentry;
46

57
Sentry.init({
68
dsn: 'https://[email protected]/1337',
79
integrations: [
810
Sentry.browserTracingIntegration(),
9-
Sentry.graphqlClientIntegration({
11+
graphqlClientIntegration({
1012
endpoints: ['http://sentry-test.io/foo'],
1113
}),
1214
],

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect } from '@playwright/test';
22
import type { Event } from '@sentry/core';
33

44
import { sentryTest } from '../../../../utils/fixtures';
5-
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';
5+
import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers';
66

77
// Duplicate from subject.js
88
const query = `query Test{
@@ -14,6 +14,10 @@ const query = `query Test{
1414
const queryPayload = JSON.stringify({ query });
1515

1616
sentryTest('should update spans for GraphQL XHR requests', async ({ getLocalTestUrl, page }) => {
17+
if (shouldSkipTracingTest()) {
18+
return;
19+
}
20+
1721
const url = await getLocalTestUrl({ testDir: __dirname });
1822

1923
await page.route('**/foo', route => {
@@ -58,6 +62,10 @@ sentryTest('should update spans for GraphQL XHR requests', async ({ getLocalTest
5862
});
5963

6064
sentryTest('should update breadcrumbs for GraphQL XHR requests', async ({ getLocalTestUrl, page }) => {
65+
if (shouldSkipTracingTest()) {
66+
return;
67+
}
68+
6169
const url = await getLocalTestUrl({ testDir: __dirname });
6270

6371
await page.route('**/foo', route => {

dev-packages/browser-integration-tests/utils/generatePlugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const IMPORTED_INTEGRATION_CDN_BUNDLE_PATHS: Record<string, string> = {
3636
reportingObserverIntegration: 'reportingobserver',
3737
feedbackIntegration: 'feedback',
3838
moduleMetadataIntegration: 'modulemetadata',
39+
graphqlClientIntegration: 'graphqlclient',
3940
// technically, this is not an integration, but let's add it anyway for simplicity
4041
makeMultiplexedTransport: 'multiplexedtransport',
4142
};

packages/browser/rollup.bundle.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const reexportedPluggableIntegrationFiles = [
1212
'rewriteframes',
1313
'feedback',
1414
'modulemetadata',
15+
'graphqlclient',
1516
];
1617

1718
browserPluggableIntegrationFiles.forEach(integrationName => {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { graphqlClientIntegration } from '../integrations/graphqlClient';

packages/browser/src/integrations/graphqlClient.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export function getGraphQLRequestPayload(payload: string): GraphQLRequestPayload
193193
}
194194

195195
/**
196-
* GraphQL Client integration for the browser.
196+
* This integration ensures that GraphQL requests made in the browser
197+
* have their GraphQL-specific data captured and attached to spans and breadcrumbs.
197198
*/
198199
export const graphqlClientIntegration = defineIntegration(_graphqlClientIntegration);

packages/browser/src/utils/lazyLoadIntegration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const LazyLoadableIntegrations = {
1515
linkedErrorsIntegration: 'linkederrors',
1616
dedupeIntegration: 'dedupe',
1717
extraErrorDataIntegration: 'extraerrordata',
18+
graphqlClientIntegration: 'graphqlclient',
1819
httpClientIntegration: 'httpclient',
1920
reportingObserverIntegration: 'reportingobserver',
2021
rewriteFramesIntegration: 'rewriteframes',

0 commit comments

Comments
 (0)