message: feat: Wrap methods in try/catch (getsentry/sentry-replay#315)
  We want to make sure that errors do not propagate up to customer Sentry
  instances. Make sure we catch errors and log them.
  Fixes getsentry/sentry-replay#296
diff: @@ -310,10 +310,15 @@ export class Replay implements Integration {
  * Note that this will cause a new DOM checkout
  */
  startRecording() {
  + try {
  this.stopRecording = record({
  ...this.recordingOptions,
  emit: this.handleRecordingEmit,
  });
  + } catch (err) {
  + logger.error(err);
  + captureInternalException(err);
  + }
  }
  /**
  @@ -324,24 +329,36 @@ export class Replay implements Integration {
  if (!isBrowser) {
  return;
  }
  +
  + try {
  logger.log('Stopping Replays');
  this.isEnabled = false;
  this.removeListeners();
  this.stopRecording?.();
  this.eventBuffer?.destroy();
  this.eventBuffer = null;
  + } catch (err) {
  + logger.error(err);
  + captureInternalException(err);
  + }
  }
  /**
  * Pause some replay functionality. See comments for `isPaused`.
  * This differs from stop as this only stops DOM recording, it is
  - * not as thorough of a shutdown as `stop()`. */
  + * not as thorough of a shutdown as `stop()`.
  + */
  pause() {
  this.isPaused = true;
  + try {
  if (this.stopRecording) {
  this.stopRecording();
  this.stopRecording = undefined;
  }
  + } catch (err) {
  + logger.error(err);
  + captureInternalException(err);
  + }
  }
  /**
  @@ -356,8 +373,13 @@ export class Replay implements Integration {
  }
  clearSession() {
  + try {
  deleteSession();
  this.session = undefined;
  + } catch (err) {
  + logger.error(err);
  + captureInternalException(err);
  + }
  }
  /**
  @@ -409,7 +431,11 @@ export class Replay implements Integration {
  * Adds listeners to record events for the replay
  */
  addListeners() {
  - document.addEventListener('visibilitychange', this.handleVisibilityChange);
  + try {
  + document.addEventListener(
  + 'visibilitychange',
  + this.handleVisibilityChange
  + );
  window.addEventListener('blur', this.handleWindowBlur);
  window.addEventListener('focus', this.handleWindowFocus);
  @@ -422,7 +448,10 @@ export class Replay implements Integration {
  'dom',
  this.handleCoreBreadcrumbListener('dom')
  );
  - addInstrumentationHandler('fetch', this.handleCoreSpanListener('fetch'));
  + addInstrumentationHandler(
  + 'fetch',
  + this.handleCoreSpanListener('fetch')
  + );
  addInstrumentationHandler('xhr', this.handleCoreSpanListener('xhr'));
  addInstrumentationHandler(
  'history',
  @@ -435,6 +464,10 @@ export class Replay implements Integration {
  this.hasInitializedCoreListeners = true;
  }
  + } catch (err) {
  + logger.error(err);
  + captureInternalException(err);
  + }
  // PerformanceObserver //
  if (!('PerformanceObserver' in window)) {
  @@ -473,6 +506,7 @@ export class Replay implements Integration {
  * Cleans up listeners that were created in `addListeners`
  */
  removeListeners() {
  + try {
  document.removeEventListener(
  'visibilitychange',
  this.handleVisibilityChange
  @@ -485,6 +519,10 @@ export class Replay implements Integration {
  this.performanceObserver.disconnect();
  this.performanceObserver = null;
  }
  + } catch (err) {
  + logger.error(err);
  + captureInternalException(err);
  + }
  }
  /**
  