<commit_before>/* eslint-disable strict */
/**
 * Google Analytics Code snippet and supporting logic.
 */

/**
  * fetch user info.
  * @param {string} token
  */
const fetchUserInfo = (token) => {
    const url = document.location.origin + '/services/auth/api/V2/me';
    return fetch(url, {
        method: 'GET',
        mode: 'cors',
        headers: {
            'Content-Type': 'application/json',
            'Authorization': token,
        },
    })
        .then(response => response.json())
        .then(response => response)
        .catch(error => console.error('error occered during fetch user id', error));
};
/**
 * find kbase session ID from cookies and get user name.
 * @param {string} cookies
 */
const getUserName = (cookies) => {
    const cookiesArr = cookies.split(';');
    for (let i=0; i<cookiesArr.length; i+=1){
        const cookie = cookiesArr[i];
        if (cookie.includes('kbase_session')) {
            const token = cookie.slice(cookie.indexOf('=') + 1);
            return fetchUserInfo(token).then(response => response['user']);
        }
    }
};

/**
 * Google Analytics code snippet
 */
window.onpopstate = function () {
    const str = document.URL.toLowerCase();
    const sliceAt = str.indexOf('kbase.us') + 'kbase.us'.length;
    const path = str.slice(sliceAt);
    const regex = /\/#\/|#\/|\/#/gi;
    const title = path.replace(regex, '');
    window.dataLayer = window.dataLayer || [];
    function gtag() { dataLayer.push(arguments); }
    // if cookies are set, get user name to add to config.
    if (document.cookie){
        getUserName(document.cookie).then((value) => {
            gtag('js', new Date());
            gtag('config', 'UA-137652528-1', {
                'username': value,
                'Page_location': document.URL,
                'page_path': path,
                'page_title': title
            });
            gtag('set', {'user_id': value});
        });
    } else {
        // take URL into page_path and page title that gtag config can use.
        gtag('js', new Date());
        gtag('config', 'UA-137652528-1', {
            'Page_location': document.URL,
            'page_path': path,
            'page_title': title
        });
    }
    gtag('config', 'AW-753507180');
};<commit_msg>const location<commit_after>/* eslint-disable strict */
/**
 * Google Analytics Code snippet and supporting logic.
 */

/**
  * fetch user info.
  * @param {string} token
  */
const fetchUserInfo = (token) => {
    const url = document.location.origin + '/services/auth/api/V2/me';
    return fetch(url, {
        method: 'GET',
        mode: 'cors',
        headers: {
            'Content-Type': 'application/json',
            'Authorization': token,
        },
    })
        .then(response => response.json())
        .then(response => response)
        .catch(error => console.error('error occered during fetch user id', error));
};
/**
 * find kbase session ID from cookies and get user name.
 * @param {string} cookies
 */
const getUserName = (cookies) => {
    const cookiesArr = cookies.split(';');
    for (let i=0; i<cookiesArr.length; i+=1){
        const cookie = cookiesArr[i];
        if (cookie.includes('kbase_session')) {
            const token = cookie.slice(cookie.indexOf('=') + 1);
            return fetchUserInfo(token).then(response => response['user']);
        }
    }
};

/**
 * Google Analytics code snippet
 */
window.onpopstate = function () {
    const location = document.URL;
    const str = location.toLowerCase();
    const sliceAt = str.indexOf('kbase.us') + 'kbase.us'.length;
    const path = str.slice(sliceAt);
    const regex = /\/#\/|#\/|\/#/gi;
    const title = path.replace(regex, '');
    window.dataLayer = window.dataLayer || [];
    function gtag() { dataLayer.push(arguments); }
    // if cookies are set, get user name to add to config.
    if (document.cookie){
        getUserName(document.cookie).then((value) => {
            gtag('js', new Date());
            gtag('config', 'UA-137652528-1', {
                'username': value,
                'Page_location': location,
                'page_path': path,
                'page_title': title
            });
            gtag('set', {'user_id': value});
        });
    } else {
        // take URL into page_path and page title that gtag config can use.
        gtag('js', new Date());
        gtag('config', 'UA-137652528-1', {
            'Page_location': location,
            'page_path': path,
            'page_title': title
        });
    }
    gtag('config', 'AW-753507180');
};
{'fraction_non_alphanumeric': 0.16178399650196765, 'fraction_numerical': 0.014429383471797114, 'mean_word_length': 2.1815020862308763, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '6057544', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1354, 'n_words': 334}