Пример #1
0
 public void SetUp()
 {
     _app_key         = "test_app_key";
     _user_id         = "u1";
     _app_version     = "v_test";
     _ts              = 0;
     _app_name        = "test_app";
     _timezone        = 360000;
     _event_name      = "test_event";
     _event_id        = null;
     _event_value     = null;
     _ga_active       = false;
     _anonymous_id    = null;
     _trait_key       = null;
     _trait_value     = null;
     _api_key         = "test_api_key";
     _GA_TRACKIND_ID  = null;
     _GA_CD_1         = 0;
     _GA_CD_2         = 0;
     _GA_CD_EVENT     = "group";
     _url             = "test_url";
     _staging         = false;
     _gio_http_client = (new GameObject("GoedleHTTPClient")).AddComponent <GoedleHttpClient>();
     _guh             = Substitute.For <IGoedleUploadHandler>();
     _gw              = Substitute.For <IGoedleWebRequest>();
 }
Пример #2
0
        //private string locale = null;

        public GoedleAnalytics(
            string api_key,
            string app_key,
            string user_id,
            string app_version,
            string ga_tracking_id,
            string app_name,
            int cd1,
            int cd2,
            string cd_event,
            GoedleHttpClient gio_http_client,
            IGoedleWebRequest gwr,
            IGoedleUploadHandler guh,
            bool staging,
            bool adaptation_only)    //, string locale)
        {
            _api_key         = api_key;
            _app_key         = app_key;
            _user_id         = user_id;
            _app_version     = app_version;
            _ga_tracking_id  = ga_tracking_id;
            _app_name        = app_name;
            _cd1             = cd1;
            _cd2             = cd2;
            _cd_event        = cd_event;
            _gio_http_client = gio_http_client;
            _gwr             = gwr;
            _staging         = staging;
            _adaptation_only = adaptation_only;
            //this.locale = GoedleLanguageMapping.GetLanguageCode (locale);
            track_launch(guh);
        }
        public void SetUp()
        {
            _app_key        = "test_app_key";
            _user_id        = "u1";
            _app_version    = "v_test";
            _ts             = 0;
            _app_name       = "test_app";
            _timezone       = 360000;
            _event_name     = "test_event";
            _event_id       = null;
            _event_value    = null;
            _ga_active      = false;
            _anonymous_id   = null;
            _trait_key      = null;
            _trait_value    = null;
            _api_key        = "test_api_key";
            _GA_TRACKIND_ID = null;
            _GA_CD_1        = 0;
            _GA_CD_2        = 0;
            _GA_CD_EVENT    = "group";
            _url            = "test_url";
            _staging        = false;
            _content        = true;

            _gw         = Substitute.For <IGoedleWebRequest>();
            _guh        = Substitute.For <IGoedleUploadHandler>();
            _gdb        = Substitute.For <IGoedleDownloadBuffer>();
            _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,
                _content);
        }
Пример #4
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);
                }
            }
        }
Пример #5
0
 public void sendPost(string content, IGoedleWebRequest gwr, IGoedleUploadHandler guh)
 {
     StartCoroutine(basicPostClient(content, gwr, guh));
 }
Пример #6
0
 public void SetUp()
 {
     _http_client = (new GameObject("BasicHttpClient")).AddComponent <BasicHttpClient>();
     _guh         = Substitute.For <IGoedleUploadHandler>();
     _gw          = Substitute.For <IGoedleWebRequest>();
 }
Пример #7
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);
                }
            }
        }
Пример #8
0
 public void track_launch(IGoedleUploadHandler goedleUploadHandler)
 {
     track(GoedleConstants.EVENT_NAME_INIT, null, null, true, null, null, goedleUploadHandler);
 }
Пример #9
0
 public void set_user_id(string user_id, IGoedleUploadHandler goedleUploadHandler)
 {
     _anonymous_id = _user_id;
     _user_id      = user_id;
     track(GoedleConstants.IDENTIFY, null, null, false, null, null, goedleUploadHandler);
 }
Пример #10
0
 public void trackTraits(string trait_key, string trait_value, IGoedleUploadHandler goedleUploadHandler)
 {
     track(GoedleConstants.IDENTIFY, null, null, false, trait_key, trait_value, goedleUploadHandler);
 }
Пример #11
0
 public void trackGroup(string group_type, string group_member, IGoedleUploadHandler goedleUploadHandler)
 {
     track("group", group_type, group_member, false, null, null, goedleUploadHandler);
 }
Пример #12
0
 public void track(string event_name, string event_id, string event_value, IGoedleUploadHandler goedleUploadHandler)
 {
     track(event_name, event_id, event_value, false, null, null, goedleUploadHandler);
 }
Пример #13
0
        public void track(string event_name, int event_id_i, IGoedleUploadHandler goedleUploadHandler)
        {
            string event_id = event_id_i.ToString();

            track(event_name, event_id, null, false, null, null, goedleUploadHandler);
        }
Пример #14
0
        public IEnumerator postJSONRequest(string url, string authentification, IGoedleWebRequest gwr, IGoedleUploadHandler guh, bool staging)
        {
            if (staging)
            {
                Debug.Log("Staging is on you would request from this url:\n" + url + "\n The data would look like this:\n" + guh.getDataString());
            }
            else
            {
                gwr.unityWebRequest = new UnityWebRequest();
                using (gwr.unityWebRequest)
                {
                    gwr.method        = "POST";
                    gwr.url           = url;
                    gwr.uploadHandler = guh.uploadHandler;
                    gwr.SetRequestHeader("Content-Type", "application/json");
                    if (!string.IsNullOrEmpty(authentification))
                    {
                        gwr.SetRequestHeader("Authorization", authentification);
                    }
                    gwr.chunkedTransfer = false;
                    yield return(gwr.SendWebRequest());

                    if (gwr.isNetworkError || gwr.isHttpError)
                    {
                        Debug.Log("{\"error\": {  \"isHttpError\": \"" + gwr.isHttpError + "\",  \"isNetworkError\": \"" + gwr.isNetworkError + "\" } }");
                    }
                    yield break;
                }
            }
        }
Пример #15
0
 public void sendPost(string url, string authentification, IGoedleWebRequest gwr, IGoedleUploadHandler guh, bool staging)
 {
     StartCoroutine(postJSONRequest(url, authentification, gwr, guh, staging));
 }