public async Task TrackDependencyAsync(string dependencyType, string dependencyName, DateTimeOffset startTime, TimeSpan duration, bool success, int resultCode = 0, Exception exception = null) { try { var builder = new HitBuilders.TimingBuilder(); builder.SetCategory(dependencyType); builder.SetVariable(dependencyName); builder.SetValue(duration.Milliseconds); builder.SetLabel(success.ToString()); var dependencyToTrack = builder.Build(); dependencyToTrack.Add("ResultCode", resultCode.ToString()); if (exception != null) { dependencyToTrack.Add("Exception message", exception.Message); dependencyToTrack.Add("StackTrace", exception.StackTrace); if (exception.InnerException != null) { dependencyToTrack.Add("Inner exception message", exception.InnerException.Message); dependencyToTrack.Add("Inner exception stackTrace", exception.InnerException.StackTrace); } } Tracker.Send(dependencyToTrack); } catch (Exception ex) { _ = TinyInsights.TrackErrorAsync(ex); } }
public void TrackTime(string timingCategory, string timingName, long timingInterval, string timingLabel = "AppSpeed") { if (Verbosity >= VerbosityLevel.TimeTracking) { var builder = new HitBuilders.TimingBuilder(); SetUserIDDimension(builder); builder.SetCategory(timingCategory); builder.SetVariable(timingName); builder.SetLabel(timingLabel); builder.SetValue(timingInterval); GATracker.Send(builder.Build()); } }