Ejemplo n.º 1
0
        /// <summary>
        /// Static constructor permits a once-on-load analytics collection event.
        /// </summary>
        static ARCoreAnalytics()
        {
            // Create the new instance.
            Instance = new ARCoreAnalytics();
            Instance.Load();

            // Send analytics immediately.
            Instance.SendAnalytics(k_GoogleAnalyticsHost, LogRequestUtils.BuildLogRequest(), false);

            // Use the Editor Update callback to monitor the communication to the server.
            EditorApplication.update +=
                new EditorApplication.CallbackFunction(Instance._OnAnalyticsUpdate);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Periodically checks back to update the current logging request, or if
        /// enough time has passed, initiate a new logging request.
        /// </summary>
        private void OnAnalyticsUpdate()
        {
#if UNITY_2017_1_OR_NEWER
            // Nothing to do if Analytics isn't enabled.
            if (EnableAnalytics == false)
            {
                return;
            }

            // Process the current web request.
            if (_webRequest != null)
            {
                if (_webRequest.isDone == true)
                {
                    if (_verbose == true)
                    {
#if UNITY_2020_2_OR_NEWER
                        if (_webRequest.result == UnityWebRequest.Result.ConnectionError)
#else
                        if (_webRequest.isNetworkError == true)
#endif
                        {
                            Debug.Log("Error sending Google ARCore SDK for Unity analytics: " +
                                      _webRequest.error);
                        }
                        else
                        {
                            Debug.Log("Google ARCore SDK for Unity analytics sent: " +
                                      _webRequest.downloadHandler.text);
                        }
                    }

                    _webRequest = null;
                }
            }

            // Resend analytics periodically (once per week if the editor remains open.)
            if (DateTime.Now.Ticks - _lastUpdateTicks >= _analyticsResendDelayTicks)
            {
                Instance.SendAnalytics(
                    _googleAnalyticsHost, LogRequestUtils.BuildLogRequest(), false);
            }
#endif
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Periodically checks back to update the current logging request, or if
        /// enough time has passed, initiate a new logging request.
        /// </summary>
        private void _OnAnalyticsUpdate()
        {
            // Nothing to do if Analytics isn't enabled.
            if (EnableAnalytics == false)
            {
                return;
            }

            // Process the current web request.
#if UNITY_2017_1_OR_NEWER
            if (m_WebRequest != null)
            {
                if (m_WebRequest.isDone == true)
                {
                    if (m_Verbose == true)
                    {
                        if (m_WebRequest.isNetworkError == true)
                        {
                            Debug.Log("Error sending analytics: " + m_WebRequest.error);
                        }
                        else
                        {
                            Debug.Log("Analytics sent: " + m_WebRequest.downloadHandler.text);
                        }
                    }

                    m_WebRequest = null;
                }
            }
#endif

            // Resend analytics periodically (once per week if the editor remains open.)
            if (DateTime.Now.Ticks - m_LastUpdateTicks >= k_AnalyticsResendDelayTicks)
            {
                Instance.SendAnalytics(
                    k_GoogleAnalyticsHost, LogRequestUtils.BuildLogRequest(), false);
            }
        }