public object DOMParse(XmlElement element, params object[] parameters)
        {
            var trackerConfig = new TrackerConfig();

            trackerConfig.setRawCopy(element.GetAttribute("rawCopy") == "yes");
            trackerConfig.setHost(element.GetAttribute("host"));
            trackerConfig.setTrackingCode(element.GetAttribute("trackingCode"));
            trackerConfig.setDebug(element.GetAttribute("debug") == "yes");
            trackerConfig.setFlushInterval(ExParsers.ParseDefault(element.GetAttribute("flushInterval"), 3));

            if (element.HasAttribute("storageType"))
            {
                trackerConfig.setStorageType(ExParsers.ParseEnum <TrackerConfig.StorageType>(element.GetAttribute("storageType")));
            }

            if (element.HasAttribute("traceFormat"))
            {
                trackerConfig.setTraceFormat(ExParsers.ParseEnum <TrackerConfig.TraceFormat>(element.GetAttribute("traceFormat")));
            }

            return(trackerConfig);
        }
        public IEnumerator StartTracker(TrackerConfig config, IBridge bridge = null)
        {
            trackerConfig = config;
            string domain = "";
            int    port   = 80;
            bool   secure = false;

            Debug.Log("[ANALYTICS] Setting up tracker...");
            try
            {
                if (config.getHost() != "")
                {
                    string[] splitted = config.getHost().Split('/');

                    if (splitted.Length > 1)
                    {
                        string[] host_splitted = splitted[2].Split(':');
                        if (host_splitted.Length > 0)
                        {
                            domain = host_splitted[0];
                            port   = (host_splitted.Length > 1) ? int.Parse(host_splitted[1]) : (splitted[0] == "https:" ? 443 : 80);
                            secure = splitted[0] == "https:";
                        }
                    }
                }
                else
                {
                    config.setHost("localhost");
                }
                Debug.Log("[ANALYTICS] Config: " + JsonConvert.SerializeObject(config));
            }
            catch (System.Exception e)
            {
                Debug.Log("Tracker error: Host bad format");
            }

            TrackerAsset.TraceFormats format;
            switch (config.getTraceFormat())
            {
            case TrackerConfig.TraceFormat.XAPI:
                format = TrackerAsset.TraceFormats.xapi;
                break;

            default:
                format = TrackerAsset.TraceFormats.csv;
                break;
            }
            Debug.Log("[ANALYTICS] Format: " + format);

            TrackerAsset.StorageTypes storage;
            switch (config.getStorageType())
            {
            case TrackerConfig.StorageType.NET:
                storage = TrackerAsset.StorageTypes.net;
                break;

            default:
                storage = TrackerAsset.StorageTypes.local;
                break;
            }
            Debug.Log("[ANALYTICS] Storage: " + storage);

            TrackerAssetSettings tracker_settings = new TrackerAssetSettings()
            {
                Host                     = domain,
                TrackingCode             = config.getTrackingCode(),
                BasePath                 = trackerConfig.getBasePath() ?? "/api",
                LoginEndpoint            = trackerConfig.getLoginEndpoint() ?? "login",
                StartEndpoint            = trackerConfig.getStartEndpoint() ?? "proxy/gleaner/collector/start/{0}",
                TrackEndpoint            = trackerConfig.getStartEndpoint() ?? "proxy/gleaner/collector/track",
                Port                     = port,
                Secure                   = secure,
                StorageType              = storage,
                TraceFormat              = format,
                BackupStorage            = config.getRawCopy(),
                UseBearerOnTrackEndpoint = trackerConfig.getUseBearerOnTrackEndpoint()
            };

            Debug.Log("[ANALYTICS] Settings: " + JsonConvert.SerializeObject(tracker_settings));
            TrackerAsset.Instance.StrictMode = false;
            TrackerAsset.Instance.Bridge     = bridge ?? new UnityBridge();
            TrackerAsset.Instance.Settings   = tracker_settings;
            TrackerAsset.Instance.StrictMode = false;

            var done = false;

            if (storage == TrackerAsset.StorageTypes.net && !string.IsNullOrEmpty(User) && !string.IsNullOrEmpty(Password))
            {
                Debug.Log("[ANALYTICS] Loging in...");
                TrackerAsset.Instance.LoginAsync(User, Password, logged =>
                {
                    Debug.Log("[ANALYTICS] Logged");
                    if (logged)
                    {
                        Debug.Log("[ANALYTICS] Starting tracker...");
                        TrackerAsset.Instance.StartAsync(() => done = true);
                    }
                    else
                    {
                        done = true;
                    }
                });
            }
            else
            {
                Debug.Log("[ANALYTICS] Starting tracker without login...");
                TrackerAsset.Instance.StartAsync(() => done = true);
            }


            this.nextFlush = config.getFlushInterval();

            Debug.Log("[ANALYTICS] Waiting until start");
            yield return(new WaitUntil(() => done));

            Debug.Log("[ANALYTICS] Start done, result: " + TrackerAsset.Instance.Started);
        }
コード例 #3
0
        private void PrepareTracker(TrackerConfig config)
        {
            trackerConfig = config;
            string domain = "";
            int    port   = 80;
            bool   secure = false;

            try
            {
                if (config.getHost() != "")
                {
                    string[] splitted = config.getHost().Split('/');

                    if (splitted.Length > 1)
                    {
                        string[] host_splitted = splitted[2].Split(':');
                        if (host_splitted.Length > 0)
                        {
                            domain = host_splitted[0];
                            port   = (host_splitted.Length > 1) ? int.Parse(host_splitted[1]) : (splitted[0] == "https:" ? 443 : 80);
                            secure = splitted[0] == "https:";
                        }
                    }
                }
                else
                {
                    config.setHost("localhost");
                }
            }
            catch (System.Exception e)
            {
                Debug.Log("Tracker error: Host bad format");
            }

            TrackerAsset.TraceFormats format;
            switch (config.getTraceFormat())
            {
            case TrackerConfig.TraceFormat.XAPI:
                format = TrackerAsset.TraceFormats.xapi;
                break;

            default:
                format = TrackerAsset.TraceFormats.csv;
                break;
            }

            TrackerAsset.StorageTypes storage;
            switch (config.getStorageType())
            {
            case TrackerConfig.StorageType.NET:
                storage = TrackerAsset.StorageTypes.net;
                break;

            default:
                storage = TrackerAsset.StorageTypes.local;
                break;
            }

            TrackerAssetSettings tracker_settings = new TrackerAssetSettings()
            {
                Host          = domain,
                TrackingCode  = config.getTrackingCode(),
                BasePath      = "/api",
                Port          = port,
                Secure        = secure,
                StorageType   = storage,
                TraceFormat   = format,
                BackupStorage = config.getRawCopy(),
            };

            TrackerAsset.Instance.StrictMode = false;
            TrackerAsset.Instance.Bridge     = new UnityBridge();
            TrackerAsset.Instance.Settings   = tracker_settings;
            TrackerAsset.Instance.StrictMode = false;

            if (PlayerPrefs.HasKey("LimesurveyToken") && PlayerPrefs.GetString("LimesurveyToken") != "ADMIN")
            {
                TrackerAsset.Instance.Login(PlayerPrefs.GetString("LimesurveyToken"), PlayerPrefs.GetString("LimesurveyToken"));
            }


            TrackerAsset.Instance.Start();
            this.nextFlush = config.getFlushInterval();
        }
コード例 #4
0
        public void StartTracker(TrackerConfig config, IBridge bridge = null)
        {
            trackerConfig = config;
            string domain = "";
            int    port   = 80;
            bool   secure = false;

            try
            {
                if (config.getHost() != "")
                {
                    string[] splitted = config.getHost().Split('/');

                    if (splitted.Length > 1)
                    {
                        string[] host_splitted = splitted[2].Split(':');
                        if (host_splitted.Length > 0)
                        {
                            domain = host_splitted[0];
                            port   = (host_splitted.Length > 1) ? int.Parse(host_splitted[1]) : (splitted[0] == "https:" ? 443 : 80);
                            secure = splitted[0] == "https:";
                        }
                    }
                }
                else
                {
                    config.setHost("localhost");
                }
            }
            catch (System.Exception e)
            {
                Debug.Log("Tracker error: Host bad format");
            }

            TrackerAsset.TraceFormats format;
            switch (config.getTraceFormat())
            {
            case TrackerConfig.TraceFormat.XAPI:
                format = TrackerAsset.TraceFormats.xapi;
                break;

            default:
                format = TrackerAsset.TraceFormats.csv;
                break;
            }

            TrackerAsset.StorageTypes storage;
            switch (config.getStorageType())
            {
            case TrackerConfig.StorageType.NET:
                storage = TrackerAsset.StorageTypes.net;
                break;

            default:
                storage = TrackerAsset.StorageTypes.local;
                break;
            }

            TrackerAssetSettings tracker_settings = new TrackerAssetSettings()
            {
                Host                     = domain,
                TrackingCode             = config.getTrackingCode(),
                BasePath                 = trackerConfig.getBasePath() ?? "/api",
                LoginEndpoint            = trackerConfig.getLoginEndpoint() ?? "login",
                StartEndpoint            = trackerConfig.getStartEndpoint() ?? "proxy/gleaner/collector/start/{0}",
                TrackEndpoint            = trackerConfig.getStartEndpoint() ?? "proxy/gleaner/collector/track",
                Port                     = port,
                Secure                   = secure,
                StorageType              = storage,
                TraceFormat              = format,
                BackupStorage            = config.getRawCopy(),
                UseBearerOnTrackEndpoint = trackerConfig.getUseBearerOnTrackEndpoint()
            };

            TrackerAsset.Instance.StrictMode = false;
            TrackerAsset.Instance.Bridge     = bridge ?? new UnityBridge();
            TrackerAsset.Instance.Settings   = tracker_settings;
            TrackerAsset.Instance.StrictMode = false;

            if (storage == TrackerAsset.StorageTypes.net && !string.IsNullOrEmpty(User) && !string.IsNullOrEmpty(Password))
            {
                TrackerAsset.Instance.Login(User, Password);
            }


            TrackerAsset.Instance.Start();
            this.nextFlush = config.getFlushInterval();
        }