Tracks user sessions for Store Apps (Windows Store and Windows Phone).
Inheritance: ITelemetryInitializer, ITelemetryModule
Ejemplo n.º 1
0
            public void InitializeDoesNotSetSessionIdOfGivenTelemetryBeforeApplicationIsStarted()
            {
                SessionTelemetryModule module = this.CreateSessionTelemetryModule();

                var telemetry = new StubTelemetry();

                ((ITelemetryInitializer)module).Initialize(telemetry);

                Assert.Null(telemetry.Context.Session.Id);
            }
Ejemplo n.º 2
0
            public void AddsItselfToTelemetryInitializersToSetSessionIdForAllTelemetryTypes()
            {
                ServiceLocator.AddService <IApplicationService>(new ApplicationService());
                var module        = new SessionTelemetryModule(new StubPlatform(), new StubClock());
                var configuration = new TelemetryConfiguration();

                configuration.TelemetryChannel = new InMemoryChannel();
                module.Initialize();

                Assert.Contains(module, TelemetryConfiguration.Active.TelemetryInitializers);
            }
Ejemplo n.º 3
0
            public void InitializeSetsSessionIdOfGivenTelemetryAfterApplicationIsStarted()
            {
                SessionTelemetryModule module = this.CreateSessionTelemetryModule();

                module.Initialize();

                var telemetry = new StubTelemetry();

                ((ITelemetryInitializer)module).Initialize(telemetry);

                Assert.NotEmpty(telemetry.Context.Session.Id);
            }
Ejemplo n.º 4
0
            public void InitializePreservesExistingSessionIdOfGivenTelemetry()
            {
                SessionTelemetryModule module = this.CreateSessionTelemetryModule();

                string expectedSessionId = "Telemetry Session ID";
                var    telemetry         = new StubTelemetry();

                telemetry.Context.Session.Id = expectedSessionId;
                ((ITelemetryInitializer)module).Initialize(telemetry);

                Assert.Equal(expectedSessionId, telemetry.Context.Session.Id);
            }
Ejemplo n.º 5
0
            public void InitializePreservesExistingIsFirstSessionOfGivenTelemetry()
            {
                SessionTelemetryModule module = this.CreateSessionTelemetryModule();

                module.Initialize();

                var telemetry = new StubTelemetry();

                telemetry.Context.Session.IsFirst = false;
                ((ITelemetryInitializer)module).Initialize(telemetry);

                Assert.Equal(false, telemetry.Context.Session.IsFirst);
            }
Ejemplo n.º 6
0
            public void InitializeDoesNotSetSessionIsFirstWhenPreviousSessionTimedOut()
            {
                SessionTelemetryModule module = this.CreateSessionTelemetryModule();

                // Application started and suspended 1 day ago
                this.clock.Time = DateTimeOffset.Now - TimeSpan.FromDays(1);
                module.Initialize();
                module.HandleApplicationStoppingEvent(null, null);

                // Application resumes today
                this.clock.Time = DateTimeOffset.Now;
                module.HandleApplicationStartedEvent(null, null);

                var telemetry = new StubTelemetry();

                ((ITelemetryInitializer)module).Initialize(telemetry);

                Assert.Null(telemetry.Context.Session.IsFirst);
            }
            public void AddsItselfToTelemetryInitializersToSetSessionIdForAllTelemetryTypes()
            {
                ServiceLocator.AddService<IApplicationService>(new ApplicationService());
                var module = new SessionTelemetryModule(new StubPlatform(), new StubClock());
                var configuration = new TelemetryConfiguration();
                configuration.TelemetryChannel = new InMemoryChannel();
                module.Initialize();

                Assert.Contains(module, TelemetryConfiguration.Active.TelemetryInitializers);
            }
Ejemplo n.º 8
0
            public void TimeoutSetterThrowsArgumentOutOfRangeExceptionWhenTimeoutIsLessThanZero()
            {
                SessionTelemetryModule initializer = this.CreateSessionTelemetryModule();

                Assert.Throws <ArgumentOutOfRangeException>(() => initializer.Timeout = TimeSpan.FromTicks(-1));
            }
Ejemplo n.º 9
0
            public void TimeoutValueIsAppropriateForMostStoreAppsByDefault()
            {
                SessionTelemetryModule initializer = this.CreateSessionTelemetryModule();

                Assert.Equal(TimeSpan.FromSeconds(20), initializer.Timeout);
            }