<commit_before>module ghost.browser.data
{
    export class Analytics
    {
        protected static _instance:Analytics;
        public static instance():Analytics
        {
            if(!Analytics._instance)
            {
                new Analytics();
            }
            return Analytics._instance;
        }
        private static fakePiwik():IPiwik
        {
            return {
                trackEvent:function(){},
                trackSiteSearch:function(){},
                setCustomVariable:function(){},
                setUserId:function(){}
            };
        }
        private static fakeGA():any
        {
            return function(){};
        }

        protected _piwik:IPiwik;

        public constructor()
        {
            Analytics._instance = this;
        }

        protected ga():any
        {
            return window["ga"]?window["ga"]:Analytics.fakeGA();
        }
        protected piwik():IPiwik
        {
            if(!this._piwik)
            {
                this._piwik = window["Piwik"]?window["Piwik"].getAsyncTracker():Analytics.fakePiwik();
            }
            return this._piwik;
        }
        public trackEvent(category:string, action:string, label?:string, value?:number):void
        {
            this.piwik().trackEvent.apply(this.piwik(), Array.prototype.slice.call(arguments));
            this.ga().apply(null, ["send", "event"].concat(Array.prototype.slice.call(arguments)));
        }
        public trackSearch(keyword:string, category?:string, resultsCount?:number):void
        {
            this.piwik().trackSiteSearch.apply(this.piwik(), Array.prototype.slice.call(arguments));
            this.ga()("send","event", "search", category, keyword, resultsCount);
        }
        public setUserID(id:string):void
        {
            this.piwik().setUserId(id);
        }
        public setVariable(index, value, name?:string, scope?:string):void
        {
            if(name && index<=4)
            {
                if(!scope)
                {
                    scope = "visit";
                }
                debugger;
                this.piwik().setCustomVariable(index+1, name, value, scope);
            }
            if(index<20)
            {
                var data = {};
                var key:string = (typeof value == "number"?"metric":"dimension")+index;
                data[key] = value;
                this.ga()("set", data);
            }
            }

    }
    export interface IPiwik
    {
        trackEvent(category:string, action:string, name?:string, value?:number);<commit_msg>abandon analytics enhancemnt for now - #427<commit_after>module ghost.browser.data
{
    export class Analytics
    {
        protected static _instance:Analytics;
        public static instance():Analytics
        {
            if(!Analytics._instance)
            {
                new Analytics();
            }
            return Analytics._instance;
        }
        private static fakePiwik():IPiwik
        {
            return {
                trackEvent:function(){},
                trackSiteSearch:function(){},
                setCustomVariable:function(){},
                setUserId:function(){}
            };
        }
        private static fakeGA():any
        {
            return function(){};
        }

        protected _piwik:IPiwik;

        public constructor()
        {
            Analytics._instance = this;
        }

        protected ga():any
        {
            return window["ga"]?window["ga"]:Analytics.fakeGA();
        }
        protected piwik():IPiwik
        {
            if(!this._piwik)
            {
                this._piwik = window["Piwik"]?window["Piwik"].getAsyncTracker():Analytics.fakePiwik();
            }
            window["p"] = this._piwik;
            return this._piwik;
        }
        public trackEvent(category:string, action:string, label?:string, value?:number):void
        {
            this.piwik().trackEvent.apply(this.piwik(), Array.prototype.slice.call(arguments));
            this.ga().apply(null, ["send", "event"].concat(Array.prototype.slice.call(arguments)));
        }
        public trackSearch(keyword:string, category?:string, resultsCount?:number):void
        {
            this.piwik().trackSiteSearch.apply(this.piwik(), Array.prototype.slice.call(arguments));
            this.ga()("send","event", "search", category, keyword, resultsCount);
        }
        public setUserID(id:string):void
        {
            this.piwik().setUserId(id);
        }
        public setVariable(index, value, name?:string, scope?:string):void
        {
            if(name && index<=4)
            {
                if(!scope)
                {
                    scope = "visit";
                }
                this.piwik().setCustomVariable(index+1, name, value, scope);
            }
            if(index<20)
            {
                var data = {};
                var key:string = (typeof value == "number"?"metric":"dimension")+index;
                data[key] = value;
                this.ga()("set", data);
            }
            }

    }
    export interface IPiwik
    {
        trackEvent(category:string, action:string, name?:string, value?:number);
{'fraction_non_alphanumeric': 0.12768383051491544, 'fraction_numerical': 0.0020900627018810565, 'mean_word_length': 1.5590666018473505, 'pattern_counts': {'":': 2, '<': 7, '<?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': '2100088', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1325, 'n_words': 213}