Initialize() public method

Initializes this instance of SessionTelemetryModule and begins session tracking.
public Initialize ( ) : void
return void
示例#1
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);
            }
示例#2
0
            public void InitializeSetsSessionIdOfGivenTelemetryAfterApplicationIsStarted()
            {
                SessionTelemetryModule module = this.CreateSessionTelemetryModule();

                module.Initialize();

                var telemetry = new StubTelemetry();

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

                Assert.NotEmpty(telemetry.Context.Session.Id);
            }
示例#3
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);
            }
示例#4
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);
            }