<commit_before>'use strict';

var _ = require('underscore');
var url = require('url');
var { isServerSide } = require('./misc');
var console = require('./patched-console');

var analytics = module.exports = {

    initializeGoogleAnalytics : function(trackingID = null, isAnalyticsScriptOnPage = true){

        if (trackingID === null){
            trackingID = analytics.getTrackingId()
        }
        if (typeof trackingID !== 'string') return false;

        if (isServerSide()) return false;

        if (!isAnalyticsScriptOnPage){
            // If true, we already have <script src="...analytics.js">, e.g. in app.js so should skip this.
            (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
            })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
        }

        if (typeof window.ga === 'undefined'){
            console.error("Google Analytics is not initialized. Fine if this appears in a test.");
            return false;
        }

        ga('create', trackingID, 'auto');
        console.info("Initialized google analytics.");
        analytics.registerPageView();
        return true;
    },

    registerPageView : function(href = null){
        if (isServerSide() || typeof window.ga === 'undefined') {
            console.error("Google Analytics is not initialized.");<commit_msg>Tiny Edit<commit_after>'use strict';

var _ = require('underscore');
var url = require('url');
var { isServerSide } = require('./misc');
var console = require('./patched-console');

var analytics = module.exports = {

    initializeGoogleAnalytics : function(trackingID = null, isAnalyticsScriptOnPage = true){

        if (trackingID === null){
            trackingID = analytics.getTrackingId()
        }
        if (typeof trackingID !== 'string') return false;

        if (isServerSide()) return false;

        if (!isAnalyticsScriptOnPage){
            // If true, we already have <script src="...analytics.js">, e.g. in app.js so should skip this.
            (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
            })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
        }

        if (typeof window.ga === 'undefined'){
            console.error("Google Analytics is not initialized. Fine if this appears in a test.");
            return false;
        }

        ga('create', trackingID, 'auto');
        console.info("Initialized google analytics.");
        analytics.registerPageView();
        return true;
    },

    registerPageView : function(href = null){
        if (isServerSide() || typeof window.ga === 'undefined') {
            console.error("Google Analytics is not initialized. Fine if this appears in a test.");
{'fraction_non_alphanumeric': 0.16455294863665187, 'fraction_numerical': 0.0019023462270133164, 'mean_word_length': 2.8950617283950617, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '6337861', 'n_tokens_mistral': 935, 'n_tokens_neox': 912, 'n_words': 201}