Skip to content

Commit 9ac9d92

Browse files
committed
setTimeout is only needed in setupOnce
1 parent 5d0e024 commit 9ac9d92

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

packages/replay/src/integration.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,16 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
177177
}
178178

179179
this._setup();
180-
this._initialize();
180+
181+
// Once upon a time, we tried to create a transaction in `setupOnce` and it would
182+
// potentially create a transaction before some native SDK integrations have run
183+
// and applied their own global event processor. An example is:
184+
// https://github.com/getsentry/sentry-javascript/blob/b47ceafbdac7f8b99093ce6023726ad4687edc48/packages/browser/src/integrations/useragent.ts
185+
//
186+
// So we call `this._initialize()` in next event loop as a workaround to wait for other
187+
// global event processors to finish. This is no longer needed, but keeping it
188+
// here to avoid any future issues.
189+
setTimeout(() => this._initialize());
181190
}
182191

183192
/**
@@ -248,21 +257,11 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
248257
* Initializes replay.
249258
*/
250259
protected _initialize(): void {
251-
// Once upon a time, we tried to create a transaction in `setupOnce` and it would
252-
// potentially create a transaction before some native SDK integrations have run
253-
// and applied their own global event processor. An example is:
254-
// https://github.com/getsentry/sentry-javascript/blob/b47ceafbdac7f8b99093ce6023726ad4687edc48/packages/browser/src/integrations/useragent.ts
255-
//
256-
// So we call `replay.initialize()` in next event loop as a workaround to wait for other
257-
// global event processors to finish. This is no longer needed, but keeping it
258-
// here to avoid any future issues.
259-
setTimeout(() => {
260-
if (!this._replay) {
261-
return;
262-
}
260+
if (!this._replay) {
261+
return;
262+
}
263263

264-
this._replay.initializeSampling();
265-
});
264+
this._replay.initializeSampling();
266265
}
267266

268267
/** Setup the integration. */

0 commit comments

Comments
 (0)