<commit_before>/**
 * Send JavaScript error information to Google Analytics.
 *
 * @param  {Window} window A reference to the "window".
 * @return {void}
 * @author <NAME> <https://github.com/philsawicki>
 */
(function (window) {
    'use strict';
    
    // Retain a reference to the previous global error handler, in case it has been set:
    var originalWindowErrorCallback = window.onerror;

    /**
     * Log any script error to Google Analytics.
     *
     * Third-party scripts without CORS will only provide "Script Error." as an error message.
     *
     * @param  {String}           errorMessage Error message.
     * @param  {String}           url          URL where error was raised.
     * @param  {Number}           lineNumber   Line number where error was raised.
     * @param  {Number|undefined} columnNumber Column number for the line where the error occurred.
     * @param  {Object|undefined} errorObject  Error Object.
     * @return {Boolean}                       When the function returns true, this prevents the
     *                                         firing of the default event handler.
     */
    window.onerror = function customErrorHandler (errorMessage, url, lineNumber, columnNumber, errorObject) {
        // Send error details to Google Analytics, if the library is already available:
        if (typeof ga === 'function') {
            // In case the "errorObject" is available, use its data, else fallback
            // on the default "errorMessage" provided:
            var exceptionDescription = errorMessage;
            if (typeof errorObject !== 'undefined' && typeof errorObject.message !== 'undefined') {
                exceptionDescription = errorObject.message;
            }

            // Format the message to log to Analytics (might also use "errorObject.stack" if defined):
            exceptionDescription += ' @ ' + url + ':' + lineNumber + ':' + columnNumber;

            ga('send', 'exception', {
                'exDescription': exceptionDescription
            });
        }

        // If the previous "window.onerror" callback can be called, pass it the data:
        if (typeof originalWindowErrorCallback === 'function') {
            return originalWindowErrorCallback(errorMessage, url, lineNumber, columnNumber, errorObject);
        }
        // Otherwise, Let the default handler run:
        return false;
    };<commit_msg>Try to catch errors only coming from our scripts.<commit_after>/**
 * Send JavaScript error information to Google Analytics.
 *
 * @param  {Window} window A reference to the "window".
 * @return {void}
 * @author <NAME> <https://github.com/philsawicki>
 */
(function (window) {
    'use strict';

    // Retain a reference to the previous global error handler, in case it has been set:
    var originalWindowErrorCallback = window.onerror;

    /**
     * Log any script error to Google Analytics.
     *
     * Third-party scripts without CORS will only provide "Script Error." as an error message.
     *
     * @param  {String}           errorMessage Error message.
     * @param  {String}           url          URL where error was raised.
     * @param  {Number}           lineNumber   Line number where error was raised.
     * @param  {Number|undefined} columnNumber Column number for the line where the error occurred.
     * @param  {Object|undefined} errorObject  Error Object.
     * @return {Boolean}                       When the function returns true, this prevents the
     *                                         firing of the default event handler.
     */
    window.onerror = function customErrorHandler (errorMessage, url, lineNumber, columnNumber, errorObject) {
        // only track events from our scripts
        url = url || '';
        if(url.indexOf('//www.bizcardmaker.com/') === -1) {
          return;
        }

        // Send error details to Google Analytics, if the library is already available:
        if (typeof ga === 'function') {
            // In case the "errorObject" is available, use its data, else fallback
            // on the default "errorMessage" provided:
            var exceptionDescription = errorMessage;
            if (typeof errorObject !== 'undefined' && typeof errorObject.message !== 'undefined') {
                exceptionDescription = errorObject.message;
            }

            // Format the message to log to Analytics (might also use "errorObject.stack" if defined):
            exceptionDescription += ' @ ' + url + ':' + lineNumber + ':' + columnNumber;

            ga('send', 'exception', {
                'exDescription': exceptionDescription
            });
        }

        // If the previous "window.onerror" callback can be called, pass it the data:
        if (typeof originalWindowErrorCallback === 'function') {
            return originalWindowErrorCallback(errorMessage, url, lineNumber, columnNumber, errorObject);
        }
        // Otherwise, Let the default handler run:
        return false;
    };
{'fraction_non_alphanumeric': 0.09348781462245305, 'fraction_numerical': 0.00019976028765481422, 'mean_word_length': 2.2096153846153848, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2718576', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1174, 'n_words': 461}