{"size": 2212, "ext": "js", "max_stars_repo_path": "sprd/manager/RaygunErrorTrackingManager.js", "max_stars_repo_name": "spreadshirt/rAppid.js-sprd", "max_stars_repo_stars_event_min_datetime": "2015-07-07T04:55:43.000Z", "max_stars_repo_stars_event_max_datetime": "2017-12-05T11:40:42.000Z", "max_issues_repo_path": "sprd/manager/RaygunErrorTrackingManager.js", "max_issues_repo_name": "spreadshirt/rAppid.js-sprd", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sprd/manager/RaygunErrorTrackingManager.js", "max_forks_repo_name": "spreadshirt/rAppid.js-sprd", "max_forks_repo_forks_event_min_datetime": "2016-06-28T08:49:34.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-20T20:16:28.000Z"}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": 4, "avg_line_length": 33.5151515152, "max_line_length": 126, "alphanum_fraction": 0.4349005425}
define(["sprd/manager/IErrorTrackingManager", "require"], function (IErrorTrackingManager, require) {

    return IErrorTrackingManager.inherit("sprd.manager.RaygunErrorTrackingManager", {

        defaults: {
            apiKey: null,
            beforeSendFnc: null
        },

        _initializationComplete: function () {
            if (!this.$.enabled) {
                return;
            }

            if (!this.runsInBrowser()) {
                return;
            }

            var apiKey = this.$.apiKey;
            if (!apiKey) {
                this.log("Raygun apiKey not defined");
                return;
            }

            var self = this;
            setTimeout(function () {
                require(["sprd/lib/raygun"], function (Raygun) {

                    if (!Raygun) {
                        self.log("Raygun not found", "warn");
                        return;
                    }

                    Raygun.init(apiKey, {
                        allowInsecureSubmissions: true,  // IE8,
                        ignore3rdPartyErrors: true, // This option removes nonsense 'Script Error's from your Raygun dashboard
                        disablePulse: true
                    }).attach();

                    if(self.$.beforeSendFnc){
                        var scope = self.getScopeForFncName(self.$.beforeSendFnc);
                        if(scope && scope[self.$.beforeSendFnc] instanceof Function){
                            Raygun.onBeforeSend(function(payload){
                                if (payload && payload.Details && payload.Details.User) {
                                    localStorage.setItem("RayGunUser", JSON.stringify(payload.Details.User));
                                }
                                return scope[self.$.beforeSendFnc].call(scope, payload);
                            });
                        }

                    }

                    var version = self.$stage.$parameter.version;
                    if (version) {
                        Raygun.setVersion(version);
                    }

                    self._setTracker(Raygun);
                });
            }, 2000);

        }

    });

});