getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.94k stars 1.56k forks source link

scope.getTransaction is not a function #3465

Closed deebov closed 3 years ago

deebov commented 3 years ago

Important Details

How are you running Sentry?

On-Premise w/ Docker, version x.y.z

Saas (sentry.io)

Other, version x.y.z, [briefly describe your environment]

    "@sentry/node": "^5.29.0",
    "@sentry/react": "^5.29.0",
    "@sentry/tracing": "^5.29.0",
    "next": "10.1.0",
    "react": "17.0.1",

Description

getting scope.getTransaction is not a function error when loading the page.

Steps to Reproduce

The issue is inconsistent. So i don't know yet how to reproduce the issue.

Source code:

This is how Sentry is implemented in nextjs app:

import * as Sentry from "@sentry/react";

Sentry.init({
  dsn: '',
  release: '',
});

class MyApp extends App {
  static async getInitialProps(appContext) {
    ...
  }

  componentDidCatch(error, errorInfo) {
    Sentry.withScope((scope) => {
      Object.keys(errorInfo).forEach((key) => {
        scope.setExtra(key, errorInfo[key]);
      });

      Sentry.captureException(error);
    });

    super.componentDidCatch(error, errorInfo);
  }

  render() {
    const { Component, pageProps } = this.props;

    return <Component {...pageProps} />
  }
}

export default Sentry.withProfiler(MyApp)
kamilogorek commented 3 years ago

Duplicate of https://github.com/getsentry/sentry-javascript/issues/3459