From defc5a7a91f5720ab88966803caeee9043eb5251 Mon Sep 17 00:00:00 2001 From: TidusJar Date: Sun, 11 Dec 2016 19:21:42 +0000 Subject: [PATCH] error checking around GA --- PlexRequests.Helpers/Analytics/Analytics.cs | 80 ++++++++++++++++----- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/PlexRequests.Helpers/Analytics/Analytics.cs b/PlexRequests.Helpers/Analytics/Analytics.cs index ed7eed4fd..67a92ed33 100644 --- a/PlexRequests.Helpers/Analytics/Analytics.cs +++ b/PlexRequests.Helpers/Analytics/Analytics.cs @@ -49,41 +49,89 @@ namespace PlexRequests.Helpers.Analytics public void TrackEvent(Category category, Action action, string label, string username, string clientId, int? value = null) { - var cat = category.ToString(); - var act = action.ToString(); - Track(HitType.@event, username, cat, act, label, clientId, value); + try + { + + var cat = category.ToString(); + var act = action.ToString(); + Track(HitType.@event, username, cat, act, label, clientId, value); + } + catch (Exception ex) + { + Log.Error(ex); + } } public async void TrackEventAsync(Category category, Action action, string label, string username, string clientId, int? value = null) { - var cat = category.ToString(); - var act = action.ToString(); - await TrackAsync(HitType.@event, username, cat, act, clientId, label, value); + try + { + var cat = category.ToString(); + var act = action.ToString(); + await TrackAsync(HitType.@event, username, cat, act, clientId, label, value); + + } + catch (Exception ex) + { + Log.Error(ex); + } } public void TrackPageview(Category category, Action action, string label, string username, string clientId, int? value = null) { - var cat = category.ToString(); - var act = action.ToString(); - Track(HitType.@pageview, username, cat, act, clientId, label, value); + try + { + var cat = category.ToString(); + var act = action.ToString(); + Track(HitType.@pageview, username, cat, act, clientId, label, value); + + } + catch (Exception ex) + { + Log.Error(ex); + } } public async Task TrackPageviewAsync(Category category, Action action, string label, string username, string clientId, int? value = null) { - var cat = category.ToString(); - var act = action.ToString(); - await TrackAsync(HitType.@pageview, username, cat, act, clientId, label, value); + try + { + var cat = category.ToString(); + var act = action.ToString(); + await TrackAsync(HitType.@pageview, username, cat, act, clientId, label, value); + + } + catch (Exception ex) + { + Log.Error(ex); + } } public void TrackException(string message, string username, string clientId, bool fatal) { - var fatalInt = fatal ? 1 : 0; - Track(HitType.exception, message, fatalInt, username, clientId); + try + { + + var fatalInt = fatal ? 1 : 0; + Track(HitType.exception, message, fatalInt, username, clientId); + } + catch (Exception ex) + { + Log.Error(ex); + } } public async Task TrackExceptionAsync(string message, string username, string clientId, bool fatal) { - var fatalInt = fatal ? 1 : 0; - await TrackAsync(HitType.exception, message, fatalInt, username, clientId); + try + { + + var fatalInt = fatal ? 1 : 0; + await TrackAsync(HitType.exception, message, fatalInt, username, clientId); + } + catch (Exception ex) + { + Log.Error(ex); + } } private void Track(HitType type, string username, string category, string action, string clientId, string label, int? value = null)