<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';
import bowser from 'bowser';
import BrowserModalComponent from '../components/browser-modal/browser-modal.jsx';
import CrashMessageComponent from '../components/crash-message/crash-message.jsx';
import log from '../lib/log.js';
import supportedBrowser from '../lib/supported-browser';
import analytics from '../lib/analytics';

class ErrorBoundary extends React.Component {
    constructor (props) {
        super(props);
        this.state = {
            hasError: false,
            errorId: null
        };
    }

    componentDidCatch (error, info) {
        // Error object may be undefined (IE?)
        error = error || {
            stack: 'Unknown stack',
            message: 'Unknown error'
        };

        // Display fallback UI
        this.setState({
            hasError: true,
            errorId: window.Sentry ? window.Sentry.lastEventId() : null
        });

        // Log errors to analytics, separating supported browsers from unsupported.
        if (supportedBrowser()) {
            analytics.event({
                category: 'error',
                action: this.props.action,
                label: error.message
            });
            if (window.Sentry) {
                window.Sentry.withScope(scope => {
                    Object.keys(info).forEach(key => {
                        scope.setExtra(key, info[key]);
                    });
                    window.Sentry.captureException(error);
                });
            }
        } else {
            analytics.event({
                category: 'Unsupported Browser Error',
                action: `(Unsupported Browser) ${this.props.action}`,
                label: `${bowser.name} ${error.message}`
            });
        }

        // Log error locally for debugging as well.
        log.error(`Unhandled Error: ${error.stack}\nComponent stack: ${info.componentStack}`);
    }
<commit_msg>Include the action in the sentry report<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';
import bowser from 'bowser';
import BrowserModalComponent from '../components/browser-modal/browser-modal.jsx';
import CrashMessageComponent from '../components/crash-message/crash-message.jsx';
import log from '../lib/log.js';
import supportedBrowser from '../lib/supported-browser';
import analytics from '../lib/analytics';

class ErrorBoundary extends React.Component {
    constructor (props) {
        super(props);
        this.state = {
            hasError: false,
            errorId: null
        };
    }

    componentDidCatch (error, info) {
        // Error object may be undefined (IE?)
        error = error || {
            stack: 'Unknown stack',
            message: 'Unknown error'
        };

        // Display fallback UI
        this.setState({
            hasError: true,
            errorId: window.Sentry ? window.Sentry.lastEventId() : null
        });

        // Log errors to analytics, separating supported browsers from unsupported.
        if (supportedBrowser()) {
            analytics.event({
                category: 'error',
                action: this.props.action,
                label: error.message
            });
            if (window.Sentry) {
                window.Sentry.withScope(scope => {
                    Object.keys(info).forEach(key => {
                        scope.setExtra(key, info[key]);
                    });
                    scope.setExtra('action', this.props.action);
                    window.Sentry.captureException(error);
                });
            }
        } else {
            analytics.event({
                category: 'Unsupported Browser Error',
                action: `(Unsupported Browser) ${this.props.action}`,
                label: `${bowser.name} ${error.message}`
            });
        }

        // Log error locally for debugging as well.
        log.error(`Unhandled Error: ${error.stack}\nComponent stack: ${info.componentStack}`);
    }

{'fraction_non_alphanumeric': 0.11846266115300413, 'fraction_numerical': 0.0, 'mean_word_length': 1.7783783783783784, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6254642', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1020, 'n_words': 258}