Example #1
0
        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);
                }
            }
        }
Example #2
0
        public void checkBehaviorGoedleWebRequestPOST()
        {
            _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);

            _gw.unityWebRequest.Returns(new UnityWebRequest());
            _gw.isHttpError.Returns(false);
            _gw.isNetworkError.Returns(false);

            string authentification = "12345";

            _gio_http_client.sendPost(_url, authentification, _gw, _guh, _staging);
            _gw.Received(2).SendWebRequest();
            _gw.Received(2).SetRequestHeader(Arg.Is <string>("Content-Type"), Arg.Is <string>("application/json"));
            _gw.Received(1).SetRequestHeader(Arg.Is <string>("Authorization"), Arg.Is <string>("12345"));
            _gw.Received(2).SetRequestHeader(Arg.Is <string>("Authorization"), Arg.Any <string>());
        }