public void track(string event_name, string event_id, string event_value, bool launch, string trait_key, string trait_value, IGoedleUploadHandler goedleUploadHandler)
        {
            if (!_adaptation_only)
            {
                bool   ga_active      = !String.IsNullOrEmpty(_ga_tracking_id);
                string authentication = null;
                string content        = null;
                int    ts             = getTimeStamp();
                // -1 because c# returns -1 for UTC +1 , * 1000 from Seconds to Milliseconds
                int        timezone = (int)(((DateTime.UtcNow - DateTime.Now).TotalSeconds) * -1 * 1000);
                GoedleAtom rt       = new GoedleAtom(_app_key, _user_id, ts, event_name, event_id, event_value, timezone, _app_version, _anonymous_id, trait_key, trait_value, ga_active);
                if (rt == null)
                {
                    Console.Write("Data Object is None, there must be an error in the SDK!");
                    return;
                }
                else
                {
                    content        = rt.getGoedleAtomDictionary().ToString();
                    authentication = _goedleUtils.encodeToUrlParameter(content, _api_key);
                }
                string url = GoedleConstants.TRACK_URL;
                Console.WriteLine(event_name);
                Console.WriteLine(event_id);
                goedleUploadHandler.add(content);

                _gio_http_client.sendPost(url, authentication, _gwr, goedleUploadHandler, _staging);
                // Sending tp Google Analytics for now we only support the Event tracking
                string type = "event";
                if (ga_active)
                {
                    trackGoogleAnalytics(event_name, event_id, event_value, type);
                }
            }
        }
Beispiel #2
0
        public void checkBehaviorWebRequestSendPost()
        {
            string stringContent = null;

            // Here we write the value which is passed through the add function to stringContent
            _guh.add(Arg.Do <string>(x => stringContent = x));
            _gw.isHttpError.Returns(false);
            _gw.isNetworkError.Returns(false);
            _http_client.sendPost("{\"test\": \"test\"}", _gw, _guh);
            var result = JSON.Parse(stringContent);

            Assert.AreEqual(result["test"].Value, "test");
        }
Beispiel #3
0
        public IEnumerator basicPostClient(string content, IGoedleWebRequest gwr, IGoedleUploadHandler guh)
        {
            guh.add(content);
            gwr.unityWebRequest = new UnityWebRequest();
            using (gwr.unityWebRequest)
            {
                gwr.method        = "POST";
                gwr.url           = "url";
                gwr.uploadHandler = guh.uploadHandler;
                gwr.unityWebRequest.SetRequestHeader("Content-Type", "application/json");
                gwr.chunkedTransfer = false;
                yield return(gwr.unityWebRequest.SendWebRequest());

                if (gwr.isNetworkError || gwr.isHttpError)
                {
                    Debug.LogError("isHttpError: " + gwr.isHttpError);
                    Debug.LogError("isNetworkError: " + gwr.isNetworkError);
                }
            }
        }
Beispiel #4
0
        public void checkBehaviorGoedleWebRequestAnalyticsIdentifyPOST()
        {
            _gio_object = new GoedleAnalytics(_api_key, _app_key, _user_id, _app_version, _GA_TRACKIND_ID, _app_name, _GA_CD_1, _GA_CD_2, _GA_CD_EVENT, _gio_http_client, _gw, _guh, _staging, _tracking);

            string stringContent = null;

            _guh.add(Arg.Do <string>(x => stringContent = x));

            _gw.isHttpError.Returns(false);
            _gw.isNetworkError.Returns(false);
            _gio_object.track(GoedleConstants.IDENTIFY, null, null, false, null, null, _guh);
            var result = JSON.Parse(stringContent);

            Assert.AreEqual(result["event"].Value, "identify");
            _gw.Received(2).SendWebRequest();
            _gw.Received(2).SetRequestHeader(Arg.Is <string>("Content-Type"), Arg.Is <string>("application/json"));
            _gw.Received(2).SetRequestHeader(Arg.Is <string>("Authorization"), Arg.Any <string>());
        }