Answered

app_key is always YOUR_APP_KEY

 
 

http://XXXXX.XXX/i?begin_session=1&metrics=%7B%22_app_version%22%3A%220.0%22%2C%22_ua%22%3A%22Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F83.0.4103.116%20Safari%2F537.36%22%2C%22_resolution%22%3A%221920x1080%22%2C%22_density%22%3A0.8999999761581421%2C%22_locale%22%3A%22en-CA%22%7D&app_key=YOUR_APP_KEY&device_id=cda73814-866d-4355-ae82-b109a423ac1b&sdk_name=javascript_native_web&sdk_version=20.04&timestamp=1593643580673&hour=15&dow=3

I found the app_key in the request is always YOUR_APP_KEY.

I did set the app_key in the script TWICE.

 // Provide your app key that you retrieved from Countly dashboard
    Countly.app_key = "c11c4b6c95eb41ffc98dfd39fbb7d76d138fd08a";
 
    Countly.init({
                    app_key: "c11c4b6c95eb41ffc98dfd39fbb7d76d138fd08a",
                    url: "XXXXX.XXX"
                })

Both are NOT working. Is there anything I missed?

I installed countly using docker.

Thanks.

0

Comments

4 comments
  • Official comment

    Hello. Leaving it in the queue even with a failed request is such by design. There can sometimes be circumstances where a valid request fails sending it's data (server issue, wrong firewall config, etc).

    The request won't be stuck in the queue forever. Request queue have a maximum size of 1000 requests. When that fills up, the oldest requets get's removed.

    Comment actions Permalink
  •  

    After debugging for some hours, I found what the issue is. The issue is that the first time I copy the script to my web app, which is react app and it's running. The default value of app_key is YOUR_APP_KEY, which is invalid, of course. But it is saved to queue in browser's localstorage and it's the first item in the queue. So when it's failed, it won't be removed from queue. And thus, it's stuck there forever. I believe it's a bug. It should be removed from queue, no matter is succeeded or not. So when I remove data, 'cly_queue' from localstorage, and it works.

    The following code is from line 2055 in countly.js, line 2062 should be executed no matter what err is. Missing one action is not big deal. But stuck in the queue forever is not good.

    sendXmlHttpRequest(Countly.url + apiPath, params, function(err, params){               
     log("Request Finished", params, err);

                    if (err) {

                        failTimeout = getTimestamp() + failTimeoutAmount;

                    }

                    else {

                        //remove first item from queue

                        requestQueue.shift();// <<===== Line 2062

                    }

                    store("cly_queue", requestQueue, true);

                    readyToProcess = true;

                });
    0
    Comment actions Permalink
  •  

    How long does it take to fill up 1000 items in queue?

    There is a scenario. A user creates a application in countly and set  the app_key in app. All good.

    After one day, he decides to remove the application and creates a new one which has new app_key. After he sets the new app_key, how long does he has to wait before it works again?

    0
    Comment actions Permalink
  • The fill up time depends on the app. Event creation frequency, usage of other features, etc.

    If you create a new app, you can just leave the old app still alive for it to receive requests or you could write a server side plugin which rewrites the app key from the first app to the second app and this way redirect all requests.

    0
    Comment actions Permalink

Please sign in to leave a comment.