Skip to content

Commit fee263b

Browse files
gggritsoandrewshie-sentry
authored andcommitted
chore: Initialize Sentry SDK before the config store (#93471)
This allows us to log warnings during config store initialization. Config store initialization technically mutates the user config, but the SDK initialization doesn't seem to rely on that data.
1 parent 6dda344 commit fee263b

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

static/app/bootstrap/initializeApp.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import {renderMain} from './renderMain';
1111
import {renderOnDomReady} from './renderOnDomReady';
1212

1313
export function initializeApp(config: Config) {
14-
commonInitialization(config);
1514
initializeSdk(config);
15+
// Initialize the config store after the SDK, so we can log errors to Sentry during config initialization if needed. N.B. This mutates the config slightly
16+
commonInitialization(config);
1617

1718
// Used for operational metrics to determine that the application js
1819
// bundle was loaded by browser.

static/app/bootstrap/initializePipelineView.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {renderOnDomReady} from './renderOnDomReady';
77
import {renderPipelineView} from './renderPipelineView';
88

99
export function initializePipelineView(config: Config) {
10-
commonInitialization(config);
1110
/**
1211
* XXX: Note we do not include routingInstrumentation because importing
1312
* `app/routes` significantly increases bundle size.
@@ -17,6 +16,9 @@ export function initializePipelineView(config: Config) {
1716
*/
1817
initializeSdk(config);
1918

19+
// Initialize the config store after the SDK, so we can log errors to Sentry during config initialization if needed. N.B. This mutates the config slightly
20+
commonInitialization(config);
21+
2022
// Used for operational metrics to determine that the application js
2123
// bundle was loaded by browser.
2224
metric.mark({name: 'sentry-pipeline-init'});

static/app/bootstrap/initializeSdk.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ function getSentryIntegrations() {
8787
* entrypoints require this.
8888
*/
8989
export function initializeSdk(config: Config) {
90+
// NOTE: This config is mutated by `commonInitialization`
9091
const {apmSampling, sentryConfig, userIdentity} = config;
9192
const tracesSampleRate = apmSampling ?? 0;
9293
const extraTracePropagationTargets = SPA_DSN

static/app/stores/configStore.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ const storeConfig: ConfigStoreDefinition = {
4545
};
4646

4747
// TODO(dcramer): abstract this out of ConfigStore
48-
if (config.user) {
49-
config.user.permissions = new Set(config.user.permissions);
48+
if (this.state.user) {
49+
this.state.user.permissions = new Set(this.state.user.permissions);
5050

5151
const systemTimeZone = moment.tz.guess();
52-
const userTimeZone = config.user.options.timezone;
52+
const userTimeZone = this.state.user.options.timezone;
5353

5454
const nowInSystemTimezone = moment.tz(undefined, systemTimeZone);
5555
const nowInUserTimezone = moment.tz(undefined, userTimeZone);
@@ -64,7 +64,7 @@ const storeConfig: ConfigStoreDefinition = {
6464
moment.tz.setDefault(userTimeZone);
6565
}
6666

67-
this.trigger(config);
67+
this.trigger(this.state);
6868
},
6969

7070
getState() {

static/gsAdmin/init.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ import {QueryClient, QueryClientProvider} from 'sentry/utils/queryClient';
1313
import {routes6} from 'admin/routes';
1414

1515
export function init(config: Config) {
16-
commonInitialization(config);
1716
initializeSdk(config);
1817

18+
// Initialize the config store after the SDK, so we can log errors to Sentry during config initialization if needed
19+
commonInitialization(config);
20+
1921
ConfigStore.set('getsentry.sendgridApiKey', window.__sendGridApiKey);
2022
}
2123

0 commit comments

Comments
 (0)