Skip to content

Commit 9c35c6c

Browse files
authored
Merge branch 'main' into rz/feat/screenshot-strategy-option
2 parents 54ba0e8 + a02314a commit 9c35c6c

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Features
1212

13+
- Adds GraphQL integration ([#5299](https://github.com/getsentry/sentry-react-native/pull/5299))
1314
- Add new _experimental_ Canvas Capture Strategy for Session Replay ([#5301](https://github.com/getsentry/sentry-react-native/pull/5301))
1415
- A new screenshot capture strategy that uses Android's Canvas API for more accurate and reliable text and image masking
1516
- Any .drawText() or .drawBitmap() calls are replaced by rectangles, ensuring no text or images are present in the resulting output
@@ -27,7 +28,6 @@
2728
});
2829
```
2930

30-
3131
### Dependencies
3232

3333
- Bump Bundler Plugins from v4.4.0 to v4.5.0 ([#5283](https://github.com/getsentry/sentry-react-native/pull/5283))

packages/core/src/js/integrations/exports.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export { timeToDisplayIntegration } from '../tracing/integrations/timeToDisplayI
2525
export { breadcrumbsIntegration } from './breadcrumbs';
2626
export { primitiveTagIntegration } from './primitiveTagIntegration';
2727
export { logEnricherIntegration } from './logEnricherIntegration';
28+
export { graphqlIntegration } from './graphql';
2829

2930
export {
3031
browserApiErrorsIntegration,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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 = /graphql/;
24+
graphqlIntegration({ endpoints: [pattern] });
25+
26+
expect(browserGraphqlClientIntegration).toHaveBeenCalledWith({
27+
endpoints: [pattern],
28+
});
29+
});
30+
});

0 commit comments

Comments
 (0)