public void NoTelemetryLogicIfNoCallbackOrConfig() { _telemetryManager = new TelemetryManager( _serviceBundle.Config, _platformProxy, null, true); var correlationId = Guid.NewGuid().AsMatsCorrelationId(); var e1 = new ApiEvent(_logger, _crypto, correlationId) { Authority = new Uri("https://login.microsoftonline.com"), AuthorityType = "Aad" }; _telemetryManager.StartEvent(e1); _telemetryManager.StopEvent(e1); Assert.IsTrue(!_telemetryManager._completedEvents.Any()); }
public void TelemetryInternalApiSample() { var correlationId = Guid.NewGuid().AsMatsCorrelationId(); try { var e1 = new ApiEvent(_logger, _crypto, correlationId) { Authority = new Uri("https://login.microsoftonline.com"), AuthorityType = "Aad" }; _telemetryManager.StartEvent(e1); // do some stuff... e1.WasSuccessful = true; _telemetryManager.StopEvent(e1); var e2 = new HttpEvent(correlationId) { HttpPath = new Uri("https://contoso.com"), UserAgent = "SomeUserAgent", QueryParams = "?a=1&b=2" }; _telemetryManager.StartEvent(e2); // do some stuff... e2.HttpResponseStatus = 200; _telemetryManager.StopEvent(e2); } finally { _telemetryManager.Flush(correlationId); } Assert.IsTrue(_myReceiver.EventsReceived.Count > 0); }
public void TelemetrySkipEventsIfApiEventWasSuccessful() { _telemetryManager = new TelemetryManager(_serviceBundle.Config, _platformProxy, _myReceiver.HandleTelemetryEvents, true); var correlationId = Guid.NewGuid().AsMatsCorrelationId(); try { var e1 = new ApiEvent(_logger, _crypto, correlationId) { Authority = new Uri("https://login.microsoftonline.com"), AuthorityType = "Aad" }; _telemetryManager.StartEvent(e1); // do some stuff... e1.WasSuccessful = true; _telemetryManager.StopEvent(e1); var e2 = new UiEvent(correlationId) { UserCancelled = false }; _telemetryManager.StartEvent(e2); _telemetryManager.StopEvent(e2); var e3 = new UiEvent(correlationId) { AccessDenied = false }; _telemetryManager.StartEvent(e3); _telemetryManager.StopEvent(e3); } finally { _telemetryManager.Flush(correlationId); } Assert.AreEqual(0, _myReceiver.EventsReceived.Count); _telemetryManager = new TelemetryManager(_serviceBundle.Config, _platformProxy, _myReceiver.HandleTelemetryEvents); correlationId = Guid.NewGuid().AsMatsCorrelationId(); try { var e1 = new ApiEvent(_logger, _crypto, correlationId) { Authority = new Uri("https://login.microsoftonline.com"), AuthorityType = "Aad" }; _telemetryManager.StartEvent(e1); // do some stuff... e1.WasSuccessful = false; // mimic an unsuccessful event, so that this batch should be dispatched _telemetryManager.StopEvent(e1); var e2 = new UiEvent(correlationId) { UserCancelled = true }; _telemetryManager.StartEvent(e2); _telemetryManager.StopEvent(e2); var e3 = new UiEvent(correlationId) { AccessDenied = true }; _telemetryManager.StartEvent(e3); _telemetryManager.StopEvent(e3); } finally { _telemetryManager.Flush(correlationId); } Assert.IsTrue(_myReceiver.EventsReceived.Count > 0); }
public void TelemetryInternalApiSample() { var reqId = _telemetryManager.GenerateNewRequestId(); try { var e1 = new ApiEvent(new MsalLogger(Guid.NewGuid(), null)) { Authority = new Uri("https://login.microsoftonline.com"), AuthorityType = "Aad" }; _telemetryManager.StartEvent(reqId, e1); // do some stuff... e1.WasSuccessful = true; _telemetryManager.StopEvent(reqId, e1); var e2 = new HttpEvent() { HttpPath = new Uri("https://contoso.com"), UserAgent = "SomeUserAgent", QueryParams = "?a=1&b=2" }; _telemetryManager.StartEvent(reqId, e2); // do some stuff... e2.HttpResponseStatus = 200; _telemetryManager.StopEvent(reqId, e2); } finally { _telemetryManager.Flush(reqId, ClientId); } Assert.IsTrue(_myReceiver.EventsReceived.Count > 0); }