import React from 'react'
import App, { Container } from 'next/app'
import * as Sentry from '@sentry/browser'

Sentry.init({
  dsn: 'ENTER_YOUR_SENTRY_DSN_HERE'
})

class MyApp extends App {
  static async getInitialProps ({ Component, ctx }) {
    let pageProps = {}

    if (Component.getInitialProps) {
      pageProps = await Component.getInitialProps(ctx)
    }

    return { pageProps }
  }

  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 (
      <Container>
        <Component {...pageProps} />
      </Container>
    )
  }
}

export default MyApp

@@ -188,215 +188,8 @@
 p %7B%0A
-  static async getInitialProps (%7B Component, ctx %7D) %7B%0A    let pageProps = %7B%7D%0A%0A    if (Component.getInitialProps) %7B%0A      pageProps = await Component.getInitialProps(ctx)%0A    %7D%0A%0A    return %7B pageProps %7D%0A  %7D%0A%0A
   co

Allow automatic static optimization in with-sentry-simple examp… (#8102)