<commit_before>/* eslint-disable */

import React from 'react'
import { registerObserver } from 'react-perf-devtool'
import { initGA, logPageView, logException } from '.'

let Raven
let LogRocket
let LogRocketReact
if (process.env.SENTRY_DSN) {
  Raven = require('raven-js')
}
if (process.env.LOGROCKET) {
  LogRocket = require('logrocket')
  LogRocketReact = require('logrocket-react')
}

export default (cfg = {}) =>
  function withLogging(Child) {
    // merge default and passed config
    const config = {
      chatlio: true,
      googleAnalytics: true,
      logRocket: true,
      sentry: true,
      ...cfg,
    }

    const isProd = process.env.NODE_ENV === 'production'
    const isDev = process.env.NODE_ENV === 'development'

    return class WrappedComponent extends React.Component {
      static getInitialProps(context) {
        if (Child.getInitialProps) {
          return Child.getInitialProps(context)
        }
        return {}
      }
      constructor(props) {
        super(props)
        this.state = { error: null }
      }

      componentDidMount() {
        if (typeof window !== 'undefined') {
          if (isDev && !window.INIT_PERF) {
            // setup react-perf-devtool
            registerObserver()

            // setup why-did-you-update
            // eslint-disable-next-line import/no-extraneous-dependencies
            // const { whyDidYouUpdate } = require('why-did-you-update')
            // whyDidYouUpdate(React)

            window.INIT_PERF = true
          }

          // include google analytics
          if (!window.INIT_GA) {
            initGA()
            logPageView()

            window.INIT_GA = true
          }<commit_msg>(fix) Only enable GA in production<commit_after>/* eslint-disable */

import React from 'react'
import { registerObserver } from 'react-perf-devtool'
import { initGA, logPageView, logException } from '.'

let Raven
let LogRocket
let LogRocketReact
if (process.env.SENTRY_DSN) {
  Raven = require('raven-js')
}
if (process.env.LOGROCKET) {
  LogRocket = require('logrocket')
  LogRocketReact = require('logrocket-react')
}

export default (cfg = {}) =>
  function withLogging(Child) {
    // merge default and passed config
    const config = {
      chatlio: true,
      googleAnalytics: true,
      logRocket: true,
      sentry: true,
      ...cfg,
    }

    const isProd = process.env.NODE_ENV === 'production'
    const isDev = process.env.NODE_ENV === 'development'

    return class WrappedComponent extends React.Component {
      static getInitialProps(context) {
        if (Child.getInitialProps) {
          return Child.getInitialProps(context)
        }
        return {}
      }
      constructor(props) {
        super(props)
        this.state = { error: null }
      }

      componentDidMount() {
        if (typeof window !== 'undefined') {
          if (isDev && !window.INIT_PERF) {
            // setup react-perf-devtool
            registerObserver()

            // setup why-did-you-update
            // eslint-disable-next-line import/no-extraneous-dependencies
            // const { whyDidYouUpdate } = require('why-did-you-update')
            // whyDidYouUpdate(React)

            window.INIT_PERF = true
          }

          // include google analytics
          if (isProd && !window.INIT_GA) {
            initGA()
            logPageView()

            window.INIT_GA = true
          }
{'fraction_non_alphanumeric': 0.11341712949429991, 'fraction_numerical': 0.0, 'mean_word_length': 2.110909090909091, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '318568', 'n_tokens_mistral': 1006, 'n_tokens_neox': 996, 'n_words': 220}