<commit_before>/*global ga*/

// Simple module for in-app analytics.  Currently sends data to GA but could be extended to anything else.
var MetabaseAnalytics = {
    // track a pageview (a.k.a. route change)
    trackPageView: function(url) {
        if (url) {
            // scrub query builder urls to remove serialized json queries from path
            url = (url.lastIndexOf('/q/', 0) === 0) ? '/q/' : url;

            ga('set', 'page', url);
            ga('send', 'pageview', url);
        }
    },

    // track an event
    trackEvent: function(category, action, label, value) {
        // category & action are required, rest are optional
        if (category && action) {
            ga('send', 'event', category, action, label, value);
        }
    }
}

export default MetabaseAnalytics;
<commit_msg>add version to GA event tracking.<commit_after>/*global ga*/

import MetabaseSettings from "metabase/lib/settings";


// Simple module for in-app analytics.  Currently sends data to GA but could be extended to anything else.
var MetabaseAnalytics = {
    // track a pageview (a.k.a. route change)
    trackPageView: function(url) {
        if (url) {
            // scrub query builder urls to remove serialized json queries from path
            url = (url.lastIndexOf('/q/', 0) === 0) ? '/q/' : url;

            ga('set', 'page', url);
            ga('send', 'pageview', url);
        }
    },

    // track an event
    trackEvent: function(category, action, label, value) {
        const { tag } = MetabaseSettings.get('version');

        // category & action are required, rest are optional
        if (category && action) {
            ga('set', 'dimension1', tag);
            ga('send', 'event', category, action, label, value);
        }
    }
}

export default MetabaseAnalytics;

{'fraction_non_alphanumeric': 0.13053097345132744, 'fraction_numerical': 0.0027654867256637168, 'mean_word_length': 2.2535971223021583, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3076344', 'n_tokens_mistral': 515, 'n_tokens_neox': 503, 'n_words': 177}