Skip to content

Commit bca399f

Browse files
antonisclaude
andauthored
fix(spotlight): Forward image attachments to Spotlight (#6818)
* fix(spotlight): Forward image attachments to Spotlight The Spotlight integration stripped image content-type items from the envelope before forwarding it to the sidecar, as a workaround for the sidecar not supporting images at the time (#3550, Jan 2024). Spotlight has supported image attachment display since overlay 4.5.0, and the upstream `@sentry/browser` integration forwards envelopes unmodified. Stop stripping images so screenshots and replay frames reach Spotlight. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Simplify changelog --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 934a328 commit bca399f

3 files changed

Lines changed: 5 additions & 12 deletions

File tree

‎CHANGELOG.md‎

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

1111
### Fixes
1212

13+
- Forward image attachments to Spotlight instead of stripping them from the envelope ([#6818](https://github.com/getsentry/sentry-react-native/pull/6818))
1314
- Don't crash the iOS app when Sentry is initialized with an invalid DSN ([#6825](https://github.com/getsentry/sentry-react-native/pull/6825))
1415
- Populate the Hermes runtime version on JS profiles instead of sending an empty value ([#6817](https://github.com/getsentry/sentry-react-native/pull/6817))
1516

‎packages/core/src/js/integrations/spotlight.ts‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,7 @@ function sendEnvelopesToSidecar(client: Client, sidecarUrl: string): void {
4747
return;
4848
}
4949

50-
client.on('beforeEnvelope', (originalEnvelope: Envelope) => {
51-
// TODO: This is a workaround for spotlight/sidecar not supporting images
52-
const spotlightEnvelope: Envelope = [...originalEnvelope];
53-
const envelopeItems = [...originalEnvelope[1]].filter(
54-
item => typeof item[0].content_type !== 'string' || !item[0].content_type.startsWith('image'),
55-
);
56-
57-
spotlightEnvelope[1] = envelopeItems as Envelope[1];
58-
50+
client.on('beforeEnvelope', (envelope: Envelope) => {
5951
const xhr = createStealthXhr();
6052
if (!xhr) {
6153
debug.error('[Spotlight] Sentry SDK can not create XHR object');
@@ -80,7 +72,7 @@ function sendEnvelopesToSidecar(client: Client, sidecarUrl: string): void {
8072
}
8173
};
8274

83-
xhr.send(serializeEnvelope(spotlightEnvelope));
75+
xhr.send(serializeEnvelope(envelope));
8476
});
8577
}
8678

‎packages/core/test/integrations/spotlight.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('spotlight', () => {
3535
expect(originalEnvelopeReference).toEqual(createMockEnvelope());
3636
});
3737

38-
it('should remove image attachments from spotlight envelope', async () => {
38+
it('should forward image attachments to spotlight', async () => {
3939
const mockClient = createMockClient();
4040

4141
const spotlight = spotlightIntegration();
@@ -47,7 +47,7 @@ describe('spotlight', () => {
4747

4848
const [{ request }] = requestListener.mock.calls[0];
4949
expect(spotlightBeforeEnvelope).toBeDefined();
50-
expect((await request.text()).includes('image/png')).toBe(false);
50+
expect((await request.text()).includes('image/png')).toBe(true);
5151
});
5252
});
5353

0 commit comments

Comments
 (0)