File tree Expand file tree Collapse file tree 4 files changed +49
-0
lines changed Expand file tree Collapse file tree 4 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 88
99## Unreleased
1010
11+ ### Features
12+
13+ - Adds GraphQL integration ([ #5299 ] ( https://github.com/getsentry/sentry-react-native/pull/5299 ) )
14+
1115### Dependencies
1216
1317- Bump Bundler Plugins from v4.4.0 to v4.5.0 ([ #5283 ] ( https://github.com/getsentry/sentry-react-native/pull/5283 ) )
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ export { timeToDisplayIntegration } from '../tracing/integrations/timeToDisplayI
2525export { breadcrumbsIntegration } from './breadcrumbs' ;
2626export { primitiveTagIntegration } from './primitiveTagIntegration' ;
2727export { logEnricherIntegration } from './logEnricherIntegration' ;
28+ export { graphqlIntegration } from './graphql' ;
2829
2930export {
3031 browserApiErrorsIntegration ,
Original file line number Diff line number Diff line change 1+ import { graphqlClientIntegration as browserGraphqlClientIntegration } from '@sentry/browser' ;
2+ import type { Integration } from '@sentry/core' ;
3+
4+ interface GraphQLReactNativeIntegrationOptions {
5+ endpoints : Array < string | RegExp > ;
6+ }
7+
8+ /**
9+ * This integration ensures that GraphQL requests made in the React Native apps
10+ * have their GraphQL-specific data captured and attached to spans and breadcrumbs.
11+ */
12+ export function graphqlIntegration ( options : GraphQLReactNativeIntegrationOptions ) : Integration {
13+ return browserGraphqlClientIntegration ( { endpoints : options . endpoints } ) ;
14+ }
Original file line number Diff line number Diff line change 1+ import { graphqlClientIntegration as browserGraphqlClientIntegration } from '@sentry/browser' ;
2+ import { graphqlIntegration } from '../../src/js' ;
3+
4+ jest . mock ( '@sentry/browser' , ( ) => ( {
5+ graphqlClientIntegration : jest . fn ( ( ) => ( { name : 'GraphQL' } ) ) ,
6+ } ) ) ;
7+
8+ describe ( 'GraphQL Integration' , ( ) => {
9+ afterEach ( ( ) => {
10+ jest . resetAllMocks ( ) ;
11+ } ) ;
12+
13+ it ( 'passes React Native options to browserGraphqlClientIntegration' , ( ) => {
14+ const result = graphqlIntegration ( { endpoints : [ 'test' ] } ) ;
15+
16+ expect ( browserGraphqlClientIntegration ) . toHaveBeenCalledWith ( {
17+ endpoints : [ 'test' ] ,
18+ } ) ;
19+ expect ( result ) . toBeDefined ( ) ;
20+ } ) ;
21+
22+ it ( 'handles RegExp patterns' , ( ) => {
23+ const pattern = / g r a p h q l / ;
24+ graphqlIntegration ( { endpoints : [ pattern ] } ) ;
25+
26+ expect ( browserGraphqlClientIntegration ) . toHaveBeenCalledWith ( {
27+ endpoints : [ pattern ] ,
28+ } ) ;
29+ } ) ;
30+ } ) ;
You can’t perform that action at this time.
0 commit comments