Ejemplo n.º 1
0
        public Tracker(string propertyId, IPlatformInfoProvider platformInfoProvider, IServiceManager serviceManager)
        {
            this.serviceManager = serviceManager;

            if (string.IsNullOrEmpty(serviceManager.UserAgent))
            {
                serviceManager.UserAgent = platformInfoProvider.UserAgent;
            }

            this.platformInfoProvider = platformInfoProvider;

            engine = new PayloadFactory
            {
                PropertyId           = propertyId,
                AnonymousClientId    = platformInfoProvider.AnonymousClientId,
                ScreenColorDepthBits = platformInfoProvider.ScreenColorDepthBits,
                ScreenResolution     = platformInfoProvider.ScreenResolution,
                UserAgentOverride    = platformInfoProvider.UserAgent,
                UserLanguage         = platformInfoProvider.UserLanguage,
                ViewportSize         = platformInfoProvider.ViewPortResolution,
                //DocumentEncoding = platformInfoProvider.DocumentEncoding,
            };

            SampleRate     = 100.0F;
            hitTokenBucket = new TokenBucket(60, .5);
        }
Ejemplo n.º 2
0
        private static void RunPlatformInfoTest(string propertyId, ref IPlatformInfoProvider platformInfoProvider,
                                                ref MockServiceManager mockServiceManager)
        {
            var tracker = new Tracker(propertyId, platformInfoProvider, mockServiceManager);

            if (platformInfoProvider != null)
            {
                tracker.ClientId         = platformInfoProvider.AnonymousClientId;
                tracker.ScreenColors     = platformInfoProvider.ScreenColors;
                tracker.ScreenResolution = platformInfoProvider.ScreenResolution;
                tracker.ViewportSize     = platformInfoProvider.ViewPortResolution;
            }

            tracker.Send(new Dictionary <string, string>()
            {
                { "platform", platformInfoProvider.AnonymousClientId ?? "me" }
            });

            mockServiceManager.EnumerateDataEnqueed();
            Assert.IsTrue(mockServiceManager.LastDataEnqueued[ParameterNames.PropertyId] == propertyId);

            if (platformInfoProvider.UserLanguage != null)
            {
                Assert.IsNotNull(mockServiceManager.LastDataEnqueued[ParameterNames.UserLanguage]);
                Assert.IsTrue(mockServiceManager.LastDataEnqueued[ParameterNames.UserLanguage] == platformInfoProvider.UserLanguage);
            }
            else
            {
                Assert.IsFalse(mockServiceManager.LastDataEnqueued.ContainsKey(ParameterNames.UserLanguage));
            }

            if (platformInfoProvider.ScreenColors != null)
            {
                Assert.IsTrue(mockServiceManager.LastDataEnqueued[ParameterNames.ScreenColors] == platformInfoProvider.ScreenColors.Value.ToString());
            }
            else
            {
                Assert.IsFalse(mockServiceManager.LastDataEnqueued.ContainsKey(ParameterNames.ScreenColors));
            }

            if (platformInfoProvider.ViewPortResolution != null)
            {
                Assert.IsNotNull(mockServiceManager.LastDataEnqueued[ParameterNames.ViewportSize]);
            }
            else
            {
                Assert.IsFalse(mockServiceManager.LastDataEnqueued.ContainsKey(ParameterNames.ViewportSize));
            }


            if (platformInfoProvider.AnonymousClientId != null)
            {
                Assert.IsNotNull(mockServiceManager.LastDataEnqueued[ParameterNames.ClientId]);
                Assert.IsTrue(mockServiceManager.LastDataEnqueued[ParameterNames.ClientId] == platformInfoProvider.AnonymousClientId);
            }
            // Here do not validate that ClientId is missing because it can also come from tracker.ClientId
        }
 public TrackerConfig(IPlatformInfoProvider provider)
 {
     SessionTimeout               = TimeSpan.FromSeconds(30);
     DispatchPeriod               = TimeSpan.Zero;
     SampleFrequency              = 100.0F;
     AutoAppLifetimeMonitoring    = true;
     AutoTrackNetworkConnectivity = true;
     InstallMessage               = "Install";
     StartMessage         = "Start";
     ServiceCategoryName  = "App";
     platformInfoProvider = provider;
 }
 /// <summary>
 /// Instantiates a new instance of <see cref="Tracker"/>.
 /// </summary>
 /// <param name="propertyId">the property ID to track to.</param>
 /// <param name="platformInfoProvider">An object capable of providing platform and environment specific information.</param>
 /// <param name="serviceManager">The object used to send <see cref="Hit"/>s to the service.</param>
 public Tracker(string propertyId, IPlatformInfoProvider platformInfoProvider, IServiceManager serviceManager)
     : base(propertyId, serviceManager)
 {
     this.platformInfoProvider = platformInfoProvider;
     if (platformInfoProvider != null)
     {
         ClientId         = platformInfoProvider.AnonymousClientId;
         ScreenColors     = platformInfoProvider.ScreenColors;
         ScreenResolution = platformInfoProvider.ScreenResolution;
         Language         = platformInfoProvider.UserLanguage;
         ViewportSize     = platformInfoProvider.ViewPortResolution;
         platformInfoProvider.ViewPortResolutionChanged += platformTrackingInfo_ViewPortResolutionChanged;
         platformInfoProvider.ScreenResolutionChanged   += platformTrackingInfo_ScreenResolutionChanged;
     }
 }
Ejemplo n.º 5
0
        public void NativePlatformInfoTest()
        {
            IPlatformInfoProvider platformInfo = null;

            var initializeWindowTask = Windows.ApplicationModel.Core.CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                                                                                                                  () =>
            {
                platformInfo = new PlatformInfoProvider();
            }).AsTask();

            initializeWindowTask.Wait();
            if (platformInfo != null)
            {
                var mockServiceManager = new MockServiceManager();
                RunPlatformInfoTest("fakePropertyId", ref platformInfo, ref mockServiceManager);
            }
            else
            {
                Assert.Fail("Failed to test UI thread required properties");
            }
        }
 public TrackerManager(IPlatformInfoProvider platformTrackingInfo)
 {
     trackers             = new Dictionary <string, Tracker>();
     PlatformTrackingInfo = platformTrackingInfo;
     GAServiceManager.Current.UserAgent = PlatformTrackingInfo.UserAgent;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Instantiates a new instance of <see cref="AnalyticsManager"/>
 /// </summary>
 /// <param name="platformInfoProvider"> The platform info provider to be used by this Analytics Manager. Can not be null.</param>
 public AnalyticsManager(IPlatformInfoProvider platformInfoProvider) : base(platformInfoProvider)
 {
     this.application = Application.Current;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Instantiates a new instance of <see cref="TrackerManager"/>.
 /// </summary>
 /// <param name="platformInfoProvider">An object capable of providing platform and environment specific information.</param>
 public TrackerManager(IPlatformInfoProvider platformInfoProvider)
 {
     trackers = new Dictionary <string, Tracker>();
     this.platformInfoProvider = platformInfoProvider;
     UserAgent = platformInfoProvider.UserAgent;
 }
Ejemplo n.º 9
0
 /// <inheritdoc />
 /// <summary>
 ///     Instantiates a new instance of <see cref="T:GoogleAnalytics.TrackerManager" />.
 /// </summary>
 /// <param name="platformInfoProvider">An object capable of providing platform and environment specific information.</param>
 public TrackerManager(IPlatformInfoProvider platformInfoProvider)
 {
     _trackers            = new Dictionary <string, Tracker>();
     PlatformTrackingInfo = platformInfoProvider;
     UserAgent            = platformInfoProvider.UserAgent;
 }