Skip to content

Commit d3a2f0a

Browse files
authored
fix: Null-check sentryClient._options (#736)
We got a report of an error when we tried to set `sentryClient._options.tracesSampler` implying that `sentryClient._options` might be `null` or `undefined`. This patch adds protection around that.
1 parent 2c2ad9f commit d3a2f0a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

.changeset/neat-zoos-kiss.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@spotlightjs/spotlight': patch
3+
'@spotlightjs/electron': patch
4+
'@spotlightjs/overlay': patch
5+
'@spotlightjs/astro': patch
6+
---
7+
8+
fix: Null-check sentryClient.\_options

packages/overlay/src/integrations/sentry/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,15 @@ function addSpotlightIntegrationToSentry(options: SentryIntegrationOptions, side
239239
// @ts-ignore
240240
sentryClient._dsn = undefined;
241241
// @ts-ignore
242+
if (!sentryClient._options) {
243+
// @ts-ignore
244+
sentryClient._options = {};
245+
}
246+
// @ts-ignore
242247
sentryClient._options.tracesSampler = () => 1;
243248
// @ts-ignore
244249
sentryClient._options.sampleRate = 1;
250+
// TODO: Enable profiling and set sample rate to 1 for that too
245251

246252
try {
247253
// @ts-expect-error ts(2339) -- We're accessing a private property here

0 commit comments

Comments
 (0)