示例#1
0
        public Tracker GetTracker(AnalyticsConfiguration configuration)
        {
            if (Tracker == null) {
                var analytics = GoogleAnalytics.GetInstance (Application.Context);
                analytics.Logger.LogLevel = (int)configuration.LogLevel;
                analytics.SetLocalDispatchPeriod (configuration.DispatchPeriod);
                analytics.SetDryRun (configuration.DryRun);

                Tracker = analytics.NewTracker (configuration.TrackingId);
                Tracker.SetSampleRate (configuration.SampleFrequency);
                Tracker.SetAnonymizeIp (configuration.AnonymizeIp);
                Tracker.EnableExceptionReporting (configuration.ReportUncaughtExceptions);

                if (!string.IsNullOrEmpty (configuration.AppName)) {
                    Tracker.SetAppName (configuration.AppName);
                }

                if (!string.IsNullOrEmpty (configuration.AppVersion)) {
                    Tracker.SetAppVersion (configuration.AppVersion);
                }
            }

            return Tracker;
        }
示例#2
0
        public IGAITracker GetTracker(AnalyticsConfiguration configuration)
        {
            if (Tracker == null) {
                GAI.SharedInstance.Logger.SetLogLevel (GetLogLevel (configuration.LogLevel));
                GAI.SharedInstance.DispatchInterval = configuration.DispatchPeriod;
                GAI.SharedInstance.DryRun = configuration.DryRun;
                GAI.SharedInstance.TrackUncaughtExceptions = configuration.ReportUncaughtExceptions;

                Tracker = GAI.SharedInstance.GetTracker (configuration.TrackingId);

                Tracker.Set (GAIConstants.SampleRate, configuration.SampleFrequency.ToString ());
                Tracker.Set (GAIConstants.AnonymizeIp, configuration.AnonymizeIp.ToString ());

                if (!string.IsNullOrEmpty (configuration.AppName)) {
                    Tracker.Set (GAIConstants.AppName, configuration.AppName);
                }

                if (!string.IsNullOrEmpty (configuration.AppVersion)) {
                    Tracker.Set (GAIConstants.AppVersion, configuration.AppVersion);
                }
            }

            return Tracker;
        }