Tried to recordEvent but it got queued? (Android) [SOLVED]


#1

Hello,

I am developing an Android app that will record an event called "basicInfo" to Countly, when first opened after installation, sending device information. Also when a user logs in to my app the "basicInfo" event will be fired again, now sending user information along with device information.

But what happened was as follows:

  1. The first "basicInfo" was not set to Countly when I opened my app after installation.
  2. Only after user logs in to my app the second "basicInfo" is being sent, along with the first one.
  3. In Event Logs of Countly Dashboard, I can see that the Request Time of the first "basicInfo" matches the time I opened the app, and its Request Received matches the time user logs in to the app. (I tried multiple times and got the same result)

That brings me to think that the first "basicInfo" may be queued, so I tried setEventQueueSizeToSend(0) but it didn't work.

I should also include that when I tried my app In some devices, the recordEvent works as it is supposed to, and in some other devices it always got the above cases.

My questions are:

  1. What happened?
  2. Why can the behavior be different across devices?
  3. Is it possible to force recordEvent? If so, how to do it?
  4. Can there be any possible scenario leading to what happened beside the queue?

Any help appreciated.
Please tell me if you need more data.

Thank you.


#2

Hello! Could you show me how you initialize countly? Also, at which point do you call the initialization?
Have you enabled logging and tried checking the Countly printer log messages?


#3

I also forgot to ask, which SDK version are you using?


#4

Thanks for replying!
I am using Countly SDK ver 18.04.

Here's my implementation:
So in onCreate I initialize Countly
Countly countly = this.countly.init(mContext, countlyServerURL, clientAppId);
then after checking this.countly.isInitialized()
I put my device info into a map, then
this.countly.setEventQueueSizeToSend(0);
this.countly.recordEvent(key, map, 1); where key is just string.

On user login I just put my device and user info into a map
and then do
this.countly.setEventQueueSizeToSend(0);
this.countly.recordEvent(key, map, 1);
again.

It turns out that I didn't set Countly logging on.
When I run my app again with logging on I see that on first recordEvent it says
No Device ID available yet, skipping request
in my Logcat.

What should I do?
Also how do I check Countly printer log messages?

Thank you.


#5

UPDATE: SOLVED

Apparently it is actually because the device ID is not available yet.
So I made an AsyncTask retreving the device ID then call recordEvent
and it works.

Thank you