コード例 #1
0
        public static void Init(int verbosity, Context context, string trackingId, int localDispatchPeriod = 1800, bool trackUncaughtExceptions = true, bool enableAutoActivityTracking = false, int userIdDimensionIndex = 0)
        {
            Verbosity = (VerbosityLevel)verbosity;

            GAInstance = GoogleAnalytics.GetInstance(context);
            GAInstance.SetLocalDispatchPeriod(localDispatchPeriod);

            GATracker = GAInstance.NewTracker(trackingId);
            GATracker.EnableAutoActivityTracking(enableAutoActivityTracking);
            GATracker.EnableExceptionReporting(false);

            if (trackUncaughtExceptions)
            {
                AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
                {
                    var ex = (Exception)e.ExceptionObject;
                    TrackUnhandledException(ex);
                };

                TaskScheduler.UnobservedTaskException += (sender, e) =>
                {
                    var ex = e.Exception;
                    TrackUnhandledException(ex);
                };
            }

            UserIdDimensionIndex = userIdDimensionIndex;
        }
コード例 #2
0
        public GoogleAnalyticsService(Context c, IPackageInfo packageInfo, IAppSettings settings, ILogger logger)
        {
            Trackers = new List <Tracker>();

            try
            {
                var instance = GoogleAnalytics.GetInstance(c);
                instance.SetLocalDispatchPeriod(20);

                // Prevent testing/debugging data from being sent to GA
                #if DEBUG
                instance.SetDryRun(true);
                #endif

                // MK's tracking id
                Trackers.Add(instance.NewTracker("UA-44714416-1"));

                if (settings.Data.GoogleAnalyticsTrackingId.HasValue())
                {
                    // Company's own tracking id
                    Trackers.Add(instance.NewTracker(settings.Data.GoogleAnalyticsTrackingId));
                }

                var appName = settings.Data.TaxiHail.ApplicationName.Replace(' ', '_');
                var version = packageInfo.Version;
                Trackers.ForEach(x => {
                    x.SetAppName(appName);
                    x.SetAppVersion(version);
                });
            }
            catch (Exception ex)
            {
                logger.LogError(ex);
            }
        }
コード例 #3
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);
        }
コード例 #4
0
        private void RegisterComponents()
        {
            Services.Register();

            // Register Joey components:
            ServiceContainer.Register <Logger> (() => new AndroidLogger());
            ServiceContainer.Register <Context> (this);
            ServiceContainer.Register <IPlatformInfo> (this);
            ServiceContainer.Register <SettingsStore> (() => new SettingsStore(Context));
            ServiceContainer.Register <ISettingsStore> (() => ServiceContainer.Resolve <SettingsStore> ());
            ServiceContainer.Register <SyncMonitor> ();
            ServiceContainer.Register <GcmRegistrationManager> ();
            ServiceContainer.Register <AndroidNotificationManager> ();
            ServiceContainer.Register <IBugsnagClient> (delegate {
                return(new BugsnagClient(this, Build.BugsnagApiKey)
                {
                    DeviceId = ServiceContainer.Resolve <SettingsStore> ().InstallId,
                    ProjectNamespaces = new List <string> ()
                    {
                        "Toggl."
                    },
                });
            });
            ServiceContainer.Register <Tracker> (delegate {
                var ga = GoogleAnalytics.GetInstance(this);
                #if DEBUG
                ga.SetDryRun(true);
                #endif

                var tracker = ga.NewTracker(Resource.Xml.Analytics);
                tracker.Set("&tid", Build.GoogleAnalyticsId);
                return(tracker);
            });
            ServiceContainer.Register <INetworkPresence> (() => new NetworkPresence(Context, (ConnectivityManager)GetSystemService(ConnectivityService)));
        }
コード例 #5
0
        protected override void OnStart()
        {
            base.OnStart();
            // set your tracking code here.
            tracker = GoogleAnalytics.GetInstance(this).GetTracker("UA-XXXX-Y");

            tracker.SendView("/HomeScreen");
        }
コード例 #6
0
        protected override void OnStart()
        {
            base.OnStart();

            // Make sure the tracker is initialized
            ServiceContainer.Resolve <Tracker> ();

            GoogleAnalytics.GetInstance(this).ReportActivityStart(this);
        }
コード例 #7
0
ファイル: AnalyticsManager.cs プロジェクト: IshaDawar/Xamarin
 public IAnalyticsManager InitWithId(string analyiticsId)
 {
     gaInstance = GoogleAnalytics.GetInstance(Android.App.Application.Context);
     gaInstance.SetLocalDispatchPeriod(10);
     tracker = gaInstance.NewTracker(analyiticsId);
     tracker.EnableExceptionReporting(true);
     tracker.EnableAutoActivityTracking(true);
     return(this);
 }
コード例 #8
0
 private void InitGa()
 {
     Rep.Instance.GaInstance = GoogleAnalytics.GetInstance(ApplicationContext);
     Rep.Instance.GaInstance.SetLocalDispatchPeriod(10);
     Rep.Instance.GaTracker = Rep.Instance.GaInstance.NewTracker("UA-71751285-2");
     Rep.Instance.GaTracker.EnableExceptionReporting(true);
     Rep.Instance.GaTracker.EnableAdvertisingIdCollection(true);
     Rep.Instance.GaTracker.EnableAutoActivityTracking(true);
 }
コード例 #9
0
 public GoogleMobileAnalyticsProvider()
 {
     GoogleMobileAnalyticsProvider.GAInstance = GoogleAnalytics.GetInstance(Application.get_Context());
     GoogleMobileAnalyticsProvider.GAInstance.SetLocalDispatchPeriod(10);
     GoogleMobileAnalyticsProvider.GATracker = GoogleMobileAnalyticsProvider.GAInstance.NewTracker(ConfigurationRepository.EnvironmentSetting.GoogleAnalyticsTrackingId);
     GoogleMobileAnalyticsProvider.GATracker.EnableExceptionReporting(true);
     GoogleMobileAnalyticsProvider.GATracker.EnableAdvertisingIdCollection(true);
     GoogleMobileAnalyticsProvider.GATracker.EnableAutoActivityTracking(true);
 }
コード例 #10
0
        private GoogleAnalyticsTracker(string trackingID, int dispatchPeriod)
        {
            trackingId = trackingID;
            var analytics = GoogleAnalytics.GetInstance(Application.Context);

            analytics.SetLocalDispatchPeriod(dispatchPeriod);
            GaTracker = analytics.NewTracker(trackingId);
            GaTracker.EnableAdvertisingIdCollection(true);
            GaTracker.EnableExceptionReporting(true);
        }
コード例 #11
0
        public Tracker ProvidesGoogleAnalyticsTracker(Context context)
        {
            GoogleAnalytics ga = GoogleAnalytics.GetInstance(context);
//            var tracker = ga.NewTracker(BuildConfig.GA_TRACKING_ID);
            var tracker = ga.NewTracker(string.Empty);

            tracker.EnableAdvertisingIdCollection(true);
            tracker.EnableExceptionReporting(true);
            return(tracker);
        }
コード例 #12
0
        public static void LogEvent(string category, string action, string userName, string label)
        {
            string trackingId = AppSettings.TrackingId;

            var _tracker = GoogleAnalytics.GetInstance(Android.App.Application.Context).NewTracker(trackingId);

            _tracker.SetScreenName(null);

            _tracker.Send(new Android.Gms.Analytics.HitBuilders.EventBuilder().SetCategory(category).SetAction(action).SetLabel(label).Build());
        }
コード例 #13
0
        public GoogleAnalyticsManager()
        {
            var analytics = GoogleAnalytics.GetInstance(Application.Context);

                        #if (DEBUG)
            analytics.SetDryRun(true);
                        #endif
            _tracker = analytics.NewTracker("UA-54114842-3");
            _tracker.EnableExceptionReporting(true);
        }
コード例 #14
0
        public static void LogScreen(string screenName, string userName)
        {
            string trackingId = AppSettings.TrackingId;

            var _tracker = GoogleAnalytics.GetInstance(Android.App.Application.Context).NewTracker(trackingId);

            _tracker.SetScreenName(screenName);

            _tracker.Send(new Android.Gms.Analytics.HitBuilders.ScreenViewBuilder().Build());
        }
コード例 #15
0
        public void Initialize(string trackingID, string appName, int dispatchPeriodInSeconds)
        {
            TrackingID = trackingID;

            GAInstance = GoogleAnalytics.GetInstance(_appContext);
            GAInstance.SetLocalDispatchPeriod(dispatchPeriodInSeconds);

            GATracker = GAInstance.NewTracker(TrackingID);
            GATracker.EnableExceptionReporting(true);
            GATracker.EnableAdvertisingIdCollection(true);
        }
コード例 #16
0
        public void Initialize(Context context)
        {
            _instance        = GetInstance();
            _googleAnalytics = GoogleAnalytics.GetInstance(context.ApplicationContext);
            _googleAnalytics.SetLocalDispatchPeriod(10);

            _tracker = _googleAnalytics.NewTracker(TrackingId);
            _tracker.EnableExceptionReporting(true);
            _tracker.EnableAdvertisingIdCollection(true);
            _tracker.EnableAutoActivityTracking(true);
        }
コード例 #17
0
        public void Init(string gaTrackingId, Context AppContext = null, int dispatchPeriodInSeconds = 10)
        {
            analyticsInstance = GoogleAnalytics.GetInstance(AppContext.ApplicationContext);
            analyticsInstance.SetLocalDispatchPeriod(dispatchPeriodInSeconds);

            mapper = new AnalyticsProductMapper();

            analyticsTracker = analyticsInstance.NewTracker(gaTrackingId);
            analyticsTracker.EnableExceptionReporting(true);
            analyticsTracker.EnableAdvertisingIdCollection(true);
            analyticsTracker.Set(clientId_key, Guid.NewGuid().ToString());
        }
コード例 #18
0
        private static void ForceError()
        {
            IDictionary <string, string> data = new Dictionary <string, string>
            {
                { "k", "v" },
            };

            GoogleAnalytics analytics = GoogleAnalytics.GetInstance(Application.Context);

            Android.Gms.Analytics.Tracker t = analytics.NewTracker("aaa");
            t.Send(data);

            return;
        }
コード例 #19
0
        public GoogleAnalyticsService(
            Context appContext,
            IAppIdService appIdService,
            IAuthService authService)
        {
            _authService = authService;

            _instance = GoogleAnalytics.GetInstance(appContext.ApplicationContext);
            _instance.SetLocalDispatchPeriod(10);

            _tracker = _instance.NewTracker("UA-81915606-2");
            _tracker.EnableExceptionReporting(true);
            _tracker.EnableAdvertisingIdCollection(true);
            _tracker.EnableAutoActivityTracking(true);
            _tracker.SetClientId(appIdService.AnonymousAppId);
        }
コード例 #20
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView(inflater, container, savedInstanceState);

            var v = inflater.Inflate(Resource.Layout.screenview, container, false);

            setupAppview(v, Resource.Id.homePageview, Resource.String.homePath);
            setupAppview(v, Resource.Id.helpPageview, Resource.String.helpPath);

            v.FindViewById <Button> (Resource.Id.pageviewDispatch).Click += (sender, e) => {
                // Manually start a dispatch (Unnecessary if the tracker has a dispatch interval)
                GoogleAnalytics.GetInstance(Activity.BaseContext).DispatchLocalHits();
            };

            return(v);
        }