<commit_before>/**!
 * @file Injects the Google Analytics Interceptor before running each Spec.
 * @author <NAME> <http://github.com/philsawicki> 
 * @copyright <NAME> 2015
 * @license MIT
 */

// Things to do before every run:
beforeEach(function () {
    'use strict';

    // Forward "ga()" calls to the actual Google Analytics method?
    var submitToGA = browser.params.GoogleAnalyticsWebTester.config.submitToGA;


    // Register the Google Analytics Event Data Interceptors:
    if (typeof browser.driver.registerGoogleAnalyticsEventDataInterceptor === 'undefined') {
        browser.driver.registerGoogleAnalyticsEventDataInterceptor = function () {
            browser.driver.executeScript(function () {
                var submitToGA = true;
                if (arguments.length > 0) {
                    submitToGA = arguments[0];
                }

                if (window && !window.gaEventDataBuffer && !window.gaLastEventData) {
                    // Setup the data accumulators:
                    if (window.ga) {
                        window.gaOriginal = ga;
                    }
                    window.gaEventDataBuffer = [];
                    window.gaLastEventData = {};

                    // Temporarily override the original "ga()" function, in order to intercept its arguments:
                    window.ga = function () {
                        window.gaEventDataBuffer.push(arguments);
                        window.gaLastEventData = arguments;

                        if (submitToGA) {
                            // Call the original "ga()" function with the supplied arguments:
                            window.gaOriginal.apply(null, arguments);
                        }
                    };
                }
            }, submitToGA);
        };
    }

    // Unregister the Google Analytics Event Data Interceptors:
    if (typeof browser.driver.unregisterGoogleAnalyticsEventDataInterceptor === 'undefined') {
        browser.driver.unregisterGoogleAnalyticsEventDataInterceptor = function () {
            browser.driver.executeScript(function () {
                if (window && window.gaEventDataBuffer && window.gaLastEventData) {
                    if (window.gaOriginal) {
                        // Restore the original "ga()" function:
                        window.ga = window.gaOriginal;
                    }

                    // Remove the data accumulators:
                    window.gaOriginal = undefined;
                    window.gaEventDataBuffer = undefined;
                    window.gaLastEventData = undefined;
                }
            });
        };
    }
});
<commit_msg>Adds validation options to configuration<commit_after>/**!
 * @file Injects the Google Analytics Interceptor before running each Spec.
 * @author <NAME> <http://github.com/philsawicki> 
 * @copyright <NAME> 2015
 * @license MIT
 */

// Things to do before every run:
beforeEach(function () {
    'use strict';

    // Forward "ga()" calls to the actual Google Analytics method?
    var submitToGA = false;
    if (typeof browser.params !== 'undefined'
     && typeof browser.params.GoogleAnalyticsWebTester !== 'undefined'
     && typeof browser.params.GoogleAnalyticsWebTester.config !== 'undefined'
     && typeof browser.params.GoogleAnalyticsWebTester.config.submitToGA !== 'undefined') {
        submitToGA = browser.params.GoogleAnalyticsWebTester.config.submitToGA;
    }


    // Register the Google Analytics Event Data Interceptors:
    if (typeof browser.driver.registerGoogleAnalyticsEventDataInterceptor === 'undefined') {
        browser.driver.registerGoogleAnalyticsEventDataInterceptor = function () {
            browser.driver.executeScript(function () {
                var submitToGA = false;
                if (arguments.length > 0) {
                    submitToGA = arguments[0];
                }

                if (window && !window.gaEventDataBuffer && !window.gaLastEventData) {
                    // Setup the data accumulators:
                    if (window.ga) {
                        window.gaOriginal = ga;
                    }
                    window.gaEventDataBuffer = [];
                    window.gaLastEventData = {};

                    // Temporarily override the original "ga()" function, in order to intercept its arguments:
                    window.ga = function () {
                        window.gaEventDataBuffer.push(arguments);
                        window.gaLastEventData = arguments;

                        if (submitToGA && window.gaOriginal) {
                            // Call the original "ga()" function with the supplied arguments:
                            window.gaOriginal.apply(null, arguments);
                        }
                    };
                }
            }, submitToGA);
        };
    }

    // Unregister the Google Analytics Event Data Interceptors:
    if (typeof browser.driver.unregisterGoogleAnalyticsEventDataInterceptor === 'undefined') {
        browser.driver.unregisterGoogleAnalyticsEventDataInterceptor = function () {
            browser.driver.executeScript(function () {
                if (window && window.gaEventDataBuffer && window.gaLastEventData) {
                    if (window.gaOriginal) {
                        // Restore the original "ga()" function:
                        window.ga = window.gaOriginal;
                    }

                    // Remove the data accumulators:
                    window.gaOriginal = undefined;
                    window.gaEventDataBuffer = undefined;
                    window.gaLastEventData = undefined;
                }
            });
        };
    }
});

{'fraction_non_alphanumeric': 0.09235892043463022, 'fraction_numerical': 0.002103049421661409, 'mean_word_length': 1.6396854764107307, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '971369', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1270, 'n_words': 308}