private void DoWork() { while (true) { try { _logger.InfoFormat("Mobile Analytics Manager is trying to deliver events in background thread."); IDictionary <string, MobileAnalyticsManager> instanceDictionary = MobileAnalyticsManager.CopyOfInstanceDictionary; foreach (string appId in instanceDictionary.Keys) { try { MobileAnalyticsManager manager = MobileAnalyticsManager.GetInstance(appId); manager.BackgroundDeliveryClient.AttemptDelivery(); } catch (System.Exception e) { _logger.Error(e, "An exception occurred in Mobile Analytics Delivery Client."); } } Thread.Sleep(BackgroundSubmissionWaitTime * 1000); } catch (System.Exception e) { _logger.Error(e, "An exception occurred in Mobile Analytics Manager."); } } }
private void ResumeSession() { DateTime currentTime = DateTime.UtcNow; // update session info lock (_lock) { _preStartTime = currentTime; } // record session resume event CustomEvent customEvent = new CustomEvent(SESSION_RESUME_EVENT_TYPE); lock (_lock) { if (_stopTime != null) { customEvent.StopTimestamp = ((DateTime)_stopTime).ToString(AWSSDKUtils.ISO8601DateFormat); } customEvent.Duration = _duration; } AddStoredGlobalAttributesAndMetricsToEvent(customEvent); MobileAnalyticsManager.GetInstance(_appid).RecordEvent(customEvent); }
private void DoWork() { while (!ShouldStop) { try { _logger.InfoFormat("Mobile Analytics Manager is trying to deliver events in background thread."); IDictionary <string, MobileAnalyticsManager> instanceDictionary = MobileAnalyticsManager.CopyOfInstanceDictionary; foreach (string appId in instanceDictionary.Keys) { MobileAnalyticsManager manager = null; try { manager = MobileAnalyticsManager.GetInstance(appId); manager.BackgroundDeliveryClient.AttemptDelivery(); } catch (System.Exception e) { _logger.Error(e, "An exception occurred in Mobile Analytics Delivery Client."); if (null != manager) { MobileAnalyticsErrorEventArgs eventArgs = new MobileAnalyticsErrorEventArgs(this.GetType().Name, "An exception occurred when deliverying events to Amazon Mobile Analytics.", e, new List <Amazon.MobileAnalytics.Model.Event>()); manager.OnRaiseErrorEvent(eventArgs); } } } Thread.Sleep(BackgroundSubmissionWaitTime * 1000); } catch (System.Exception e) { _logger.Error(e, "An exception occurred in Mobile Analytics Manager."); } } }
private void ResumeSessionHelper() { DateTime currentTime = DateTime.UtcNow; // update session info lock (_lock) { PreStartTime = currentTime; } // record session resume event CustomEvent resumeSessionEvent = new CustomEvent(Constants.SESSION_RESUME_EVENT_TYPE); lock (_lock) { resumeSessionEvent.StartTimestamp = StartTime; if (StopTime != null) { resumeSessionEvent.StopTimestamp = StopTime; } resumeSessionEvent.SessionId = SessionId; resumeSessionEvent.Duration = Duration; } MobileAnalyticsManager.GetInstance(_appId).RecordEvent(resumeSessionEvent); }
private void PauseSessionHelper() { DateTime currentTime = DateTime.UtcNow; // update session info lock (_lock) { StopTime = currentTime; Duration += Convert.ToInt64((currentTime - PreStartTime).TotalMilliseconds); } // record session pause event CustomEvent pauseSessionEvent = new CustomEvent(Constants.SESSION_PAUSE_EVENT_TYPE); lock (_lock) { pauseSessionEvent.StartTimestamp = StartTime; if (StopTime != null) { pauseSessionEvent.StopTimestamp = StopTime; } pauseSessionEvent.SessionId = SessionId; pauseSessionEvent.Duration = Duration; } MobileAnalyticsManager.GetInstance(_appId).RecordEvent(pauseSessionEvent); }
public void TestConstructor() { string appID1 = Guid.NewGuid().ToString(); MobileAnalyticsManager.GetOrCreateInstance(appID1, TestRunner.Credentials, RegionEndpoint.USEast1); MobileAnalyticsManager mam = MobileAnalyticsManager.GetInstance(appID1); Assert.IsNotNull(mam); string appID2 = Guid.NewGuid().ToString(); MobileAnalyticsManager.GetOrCreateInstance(appID2, TestRunner.Credentials, RegionEndpoint.USEast1, new MobileAnalyticsManagerConfig()); Assert.IsNotNull(MobileAnalyticsManager.GetInstance(appID2)); string notInstantiatedID = Guid.NewGuid().ToString(); try { MobileAnalyticsManager.GetInstance(notInstantiatedID); Assert.Fail(); } catch (InvalidOperationException e) { Utils.AssertTrue(e is InvalidOperationException); } }
private void StopSessionHelper() { DateTime currentTime = DateTime.UtcNow; // update session info lock (_lock) { StopTime = currentTime; } // record session stop event CustomEvent stopSessionEvent = new CustomEvent(Constants.SESSION_STOP_EVENT_TYPE); lock (_lock) { stopSessionEvent.StartTimestamp = StartTime; if (StopTime != null) { stopSessionEvent.StopTimestamp = StopTime; } stopSessionEvent.SessionId = SessionId; stopSessionEvent.Duration = Duration; } MobileAnalyticsManager.GetInstance(_appID).RecordEvent(stopSessionEvent); }
private async Task DoWorkAsync(int millisecondsDelay) { while (true) { await Task.Delay(millisecondsDelay); try { _logger.InfoFormat("Mobile Analytics Manager is trying to deliver events in background thread."); IDictionary <string, MobileAnalyticsManager> instanceDictionary = MobileAnalyticsManager.CopyOfInstanceDictionary; foreach (string appId in instanceDictionary.Keys) { try { MobileAnalyticsManager manager = MobileAnalyticsManager.GetInstance(appId); await manager.BackgroundDeliveryClient.AttemptDeliveryAsync(); } catch (System.Exception e) { _logger.Error(e, "An exception occurred in Mobile Analytics Delivery Client : {0}", e.ToString()); } } } catch (System.Exception e) { _logger.Error(e, "An exception occurred in Mobile Analytics Manager : {0}", e.ToString()); } } }
private void NewSession() { lock (_lock) { _startTime = DateTime.UtcNow; _preStartTime = DateTime.UtcNow; _stopTime = null; _sessionId = Guid.NewGuid().ToString(); _duration = 0; } CustomEvent customEvent = new CustomEvent(SESSION_START_EVENT_TYPE); MobileAnalyticsManager.GetInstance(_appid).RecordEvent(customEvent); }
private void NewSessionHelper() { StartTime = DateTime.UtcNow; PreStartTime = DateTime.UtcNow; StopTime = null; SessionId = Guid.NewGuid().ToString(); Duration = 0; CustomEvent sessionStartEvent = new CustomEvent(Constants.SESSION_START_EVENT_TYPE); sessionStartEvent.StartTimestamp = StartTime; sessionStartEvent.SessionId = SessionId; MobileAnalyticsManager.GetInstance(_appID).RecordEvent(sessionStartEvent); }
/// <summary> /// Sends Mobile Analytics events to server on background thread. /// </summary> private void DoWork() { while (!_shouldStop) { try { _logger.InfoFormat("Mobile Analytics Manager is trying to deliver events in background thread."); IDictionary <string, MobileAnalyticsManager> instanceDictionary = MobileAnalyticsManager.CopyOfInstanceDictionary; foreach (string appId in instanceDictionary.Keys) { MobileAnalyticsManager manager = null; try { manager = MobileAnalyticsManager.GetInstance(appId); manager.BackgroundDeliveryClient.AttemptDelivery(); } catch (System.Exception e) { _logger.Error(e, "An exception occurred in Mobile Analytics Delivery Client : {0}", e.ToString()); if (null != manager) { MobileAnalyticsErrorEventArgs eventArgs = new MobileAnalyticsErrorEventArgs(this.GetType().Name, "An exception occurred when deliverying events to Amazon Mobile Analytics.", e, new List <Amazon.MobileAnalytics.Model.Event>()); manager.OnRaiseErrorEvent(eventArgs); } } } Thread.Sleep(BackgroundSubmissionWaitTime * 1000); } catch (ThreadAbortException tae) { _logger.DebugFormat("Mobile Analytics Manager thread aborted"); } catch (System.Exception e) { _logger.Error(e, "An exception occurred in Mobile Analytics Manager."); } UnityRequestQueue.Instance.ExecuteOnMainThread(() => { if (Application.isEditor && !Application.isPlaying) { AbortBackgroundThread(); } }); } }
private void PauseSession() { DateTime currentTime = DateTime.UtcNow; // update session info lock (_lock) { _stopTime = currentTime; _duration += Convert.ToInt64((currentTime - _preStartTime).TotalMilliseconds); } // record session pause event CustomEvent customEvent = new CustomEvent(SESSION_PAUSE_EVENT_TYPE); MobileAnalyticsManager.GetInstance(_appid).RecordEvent(customEvent); }
private void StopSession() { //DateTime currentTime = DateTime.UtcNow; // record session stop event CustomEvent managerEvent = new CustomEvent(SESSION_STOP_EVENT_TYPE); lock (_lock) { if (_stopTime != null) { managerEvent.StopTimestamp = ((DateTime)_stopTime).ToString(AWSSDKUtils.ISO8601DateFormat); managerEvent.Duration = Convert.ToInt64(((DateTime)_stopTime - _startTime).TotalMilliseconds); } } MobileAnalyticsManager.GetInstance(_appid).RecordEvent(managerEvent); }
private void StopSession() { DateTime currentTime = DateTime.UtcNow; // record session stop event CustomEvent managerEvent = new CustomEvent(SESSION_STOP_EVENT_TYPE); lock (_lock) { if (_stopTime != null) { managerEvent.StopTimestamp = ((DateTime)_stopTime).ToString(AWSSDKUtils.ISO8601DateFormatNoMS); } managerEvent.Duration = _duration; } MobileAnalyticsManager.GetInstance(_appid).RecordEvent(managerEvent); }
private async Task DoWorkAsync(int millisecondsDelay) { while (!ShouldStop) { await Task.Delay(millisecondsDelay).ConfigureAwait(false); if (ShouldStop) { break; } try { _logger.InfoFormat("Mobile Analytics Manager is trying to deliver events in background thread."); IDictionary <string, MobileAnalyticsManager> instanceDictionary = MobileAnalyticsManager.CopyOfInstanceDictionary; foreach (string appId in instanceDictionary.Keys) { MobileAnalyticsManager manager = null; try { manager = MobileAnalyticsManager.GetInstance(appId); await manager.BackgroundDeliveryClient.AttemptDeliveryAsync().ConfigureAwait(false); } catch (System.Exception e) { _logger.Error(e, "An exception occurred in Mobile Analytics Delivery Client : {0}", e.ToString()); if (null != manager) { MobileAnalyticsErrorEventArgs eventArgs = new MobileAnalyticsErrorEventArgs(this.GetType().Name, "An exception occurred when deliverying events to Amazon Mobile Analytics.", e, new List <Amazon.MobileAnalytics.Model.Event>()); manager.OnRaiseErrorEvent(eventArgs); } } } } catch (System.Exception e) { _logger.Error(e, "An exception occurred in Mobile Analytics Manager : {0}", e.ToString()); } } }
/// <summary> /// Sends Mobile Analytics events to server on background thread. /// </summary> private static void DoWork() { while (true) { #if UNITY_EDITOR if (UnityInitializer.IsEditorPlaying && !UnityInitializer.IsEditorPaused) { #endif try { _logger.InfoFormat("Mobile Analytics Manager is trying to deliver events in background thread."); IDictionary <string, MobileAnalyticsManager> instanceDictionary = MobileAnalyticsManager.InstanceDictionary; foreach (string appId in instanceDictionary.Keys) { try { MobileAnalyticsManager manager = MobileAnalyticsManager.GetInstance(appId); manager.BackgroundDeliveryClient.AttemptDelivery(); } catch (System.Exception e) { _logger.Error(e, "An exception occurred in Mobile Analytics Delivery Client."); } } Thread.Sleep(Convert.ToInt32(AWSConfigsMobileAnalytics.BackgroundSubmissionWaitTime) * 1000); } catch (System.Exception e) { _logger.Error(e, "An exception occurred in Mobile Analytics Manager."); } #if UNITY_EDITOR } else if (!UnityInitializer.IsEditorPlaying) { _thread.Abort(); } #endif } }
public void TestConstructor() { string appID1 = Guid.NewGuid().ToString(); MobileAnalyticsManager.GetOrCreateInstance(appID1, CommonTests.Framework.TestRunner.Credentials, RegionEndpoint.USEast1); Assert.IsNotNull(MobileAnalyticsManager.GetInstance(appID1)); string appID2 = Guid.NewGuid().ToString(); MobileAnalyticsManager.GetOrCreateInstance(appID2, CommonTests.Framework.TestRunner.Credentials, RegionEndpoint.USEast1, new MobileAnalyticsManagerConfig()); Assert.IsNotNull(MobileAnalyticsManager.GetInstance(appID2)); string notInstantiatedID = Guid.NewGuid().ToString(); try { MobileAnalyticsManager.GetInstance(notInstantiatedID); } catch (InvalidOperationException e) { Console.WriteLine("get exception in constrctor :", e.ToString()); Assert.IsTrue(e is InvalidOperationException); } }
public void TestConstructor() { string appID1 = Guid.NewGuid().ToString(); try { MobileAnalyticsManager.GetOrCreateInstance(appID1, Credentials, RegionEndpoint.USEast1); } catch (Exception e) { Console.WriteLine("get exception in constrctor :", e.ToString()); Assert.Fail(); } Assert.IsTrue(null != MobileAnalyticsManager.GetInstance(appID1)); string appID2 = Guid.NewGuid().ToString(); try { MobileAnalyticsManager.GetOrCreateInstance(appID2, Credentials, RegionEndpoint.USEast1, new MobileAnalyticsManagerConfig()); } catch (Exception e) { Console.WriteLine("get exception in constrctor :", e.ToString()); Assert.Fail(); } Assert.IsTrue(null != MobileAnalyticsManager.GetInstance(appID2)); string notInstantiatedID = Guid.NewGuid().ToString(); try { MobileAnalyticsManager.GetInstance(notInstantiatedID); } catch (InvalidOperationException e) { Console.WriteLine("get exception in constrctor :", e.ToString()); Assert.IsTrue(e is InvalidOperationException); } #if BCL string appID3 = Guid.NewGuid().ToString(); try { MobileAnalyticsManager.GetOrCreateInstance(appID3); } catch (Exception e) { Console.WriteLine("get exception in constrctor :", e.ToString()); Assert.Fail(); } Assert.IsTrue(null != MobileAnalyticsManager.GetInstance(appID3)); string appID4 = Guid.NewGuid().ToString(); try { MobileAnalyticsManager.GetOrCreateInstance(appID4, Credentials); } catch (Exception e) { Console.WriteLine("get exception in constrctor :", e.ToString()); Assert.Fail(); } Assert.IsTrue(null != MobileAnalyticsManager.GetInstance(appID4)); string appID5 = Guid.NewGuid().ToString(); try { MobileAnalyticsManager.GetOrCreateInstance(appID5, RegionEndpoint.USEast1); } catch (Exception e) { Console.WriteLine("get exception in constrctor :", e.ToString()); Assert.Fail(); } Assert.IsTrue(null != MobileAnalyticsManager.GetInstance(appID5)); string appID6 = Guid.NewGuid().ToString(); try { MobileAnalyticsManager.GetOrCreateInstance(appID6, new MobileAnalyticsManagerConfig()); } catch (Exception e) { Console.WriteLine("get exception in constrctor :", e.ToString()); Assert.Fail(); } Assert.IsTrue(null != MobileAnalyticsManager.GetInstance(appID6)); #endif }