Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postpone initialization of Adjust config, and Adjust instance #341

Open
ghost opened this issue Jun 21, 2018 · 9 comments
Open

Postpone initialization of Adjust config, and Adjust instance #341

ghost opened this issue Jun 21, 2018 · 9 comments

Comments

@ghost
Copy link

ghost commented Jun 21, 2018

Hi,
I would like to delay the creation of Adjust instance until i get a response from the server, is there a way this can be done in adjust itself?

I have tried using setOfflineMode method, but this stores everything in a queue, and it makes me get a 404 when the offline mode is turned false and adjust re-enabled.

Kindly assist.

@uerceg uerceg added the support label Jun 21, 2018
@uerceg
Copy link
Contributor

uerceg commented Jun 21, 2018

Hi @hearbeathorror

We tend to think that there is no reason for SDK initialisation to be delayed unless maybe you are awaiting some kind of response from you backend in order to attach that information to install session as a callback/partner parameter. For this purpose, we have added an option to "delay start" of the SDK (more info in this chapter: https:/adjust/android_sdk#delay-start). Idea of this feature is to leave SDK initialisation where it should be according to README, but if this option is set, SDK will wait for your input with some additional info you might want to get from your backend in order to attach it as session/callback parameters. If you attached them within delay time (10 seconds max), SDK will pick them up and send with install session. This feature however doesn't have abort mechanism.

If your requirement is to decide whether to initialise SDK at all based on some info you will obtain from your backend, then I guess mentioned feature is not the thing you're looking for and in that case you simply need to wait for input from your backend to initialise SDK or not. The only advice in this case is that if you decide to initialise SDK when your initial activity is already displayed (first ever call to onResume() lifecycle method happened), please call Adjust.onResume() method on your own right after Adjust.onCreate(config), in order to initialise SDK and make it send install session ASAP.

In case your use case is different from what I described, please explain it a bit more to see if there's anything else you can possibly do.

Cheers

@ghost
Copy link
Author

ghost commented Jun 21, 2018

@uerceg

So my case is this, there are some customers who would like to have adjust as their functionality and some dont want so. Based, on the api response i would like to track adjust fully or never at all. And there are probabilities that their choice might vary in the middle of the application usage, so in such cases, adjust should track for sure.

I tried setting offline mode to true initially until i get a response, and it works fine till then, and if the value is false so adjust is disabled completely. But if in the middle, i set adjust to enabled state, and setOfflineMode to false, session event gets fired, but i get 404.

Does this mean, whether or not the app is enabled, offline mode will continue queueing up the events? (That's an added question I had). So considering this use-case, how best could i go about it?

Thanks

@uerceg
Copy link
Contributor

uerceg commented Jun 21, 2018

I see. Hm. Maybe you can give Adjust.setEnable method a try. For example, you can do following:

  • Follow SDK README in terms of when SDK should be initialised and how.
  • Before making a call to actually initialise it (Adjust.onCreate), call Adjust.setEnabled(false); - this call will disable SDK and even though Adjust.onCreate/Adjust.onResume are called afterwards, SDK remains disabled. This sounds like something you need for your use case, since once disabled, SDK is literally dead - nothing is done, nothing is tracked nor queued.
  • Once you receive ping from your backend that this user wants to use Adjust SDK, call Adjust.setEnabled(true);. In this moment, Adjust SDK will initialise and send install session (if we assume it was launched with being disabled).
  • If at any point of time, this user needs to stop using Adjust SDK, call Adjust.setEnasbled(false); again and from that moment on (until SDK is re-enabled again) nothing will get tracked nor queued.

Maybe you can give this scenario a shot and see if it fits your needs.

Also one thing to have in mind is that disable/enable setting is persisted and kept between app launches. So, if you have disabled SDK, app gets killed and reopened (everything newly loaded into memory), SDK will remain disabled. Only way to toggle "enableness" is by explicitly making a call to Adjust.setEnabled method with negated value from the last call. Stressing this out since if misintegrated, you can end up with having SDK disabled for people who need to have it enabled and in this case, all the potential traffic that needed to happen won't be visible to you in the dashboard, since once disabled, SDK just ignores everything it would normally do when enabled.

@ghost
Copy link
Author

ghost commented Jun 21, 2018

@uerceg

Sure, this solutions seems to be feasible. I will try it. Also, since after every launch i am hitting this api, and enabling adjust , i presume that will overcome the issue of persistence right?

I noticed that adjust gives me a wierd token sesison not found error , is it because i have over-used it? That is how it looks on charles unfortunately , and no other events seem to get tracked.

screen shot 2018-06-21 at 9 00 52 pm

@uerceg
Copy link
Contributor

uerceg commented Jun 21, 2018

Seems like it might work for you, be sure to test this flow well on your side.

On these sessions note, can you show the response our backend is sending? Make sure to obfuscate your sensitive data when pasting in here backend reply.

@ghost
Copy link
Author

ghost commented Jun 22, 2018

Hi @uerceg 👍
Thanks alot for that solution of setting enabled false and then setting it to true, i tested it, turns out well. And with regards to the session issue, i think when the queue_size = 46 , it started causing that issue, on restart of everything, and doing it afresh, this error was not caused.

sometimes as a response i would get token not found , or 404.

@uerceg
Copy link
Contributor

uerceg commented Jun 26, 2018

@hearbeathorror

If queue size was saying 46, that just means that for some reason you managed to queue 46 packages, most probably while tracking things when SDK was set to be offline. Eventually those packages will get dequeued if SDK is brought back to online mode and if there's internet connectivity. With disabling option, nothing would get queued while SDK is disabled.

Not sure where does 404 come from. Can you share maybe the response from backend in that case? Token not found can mean that you either set app or event token wrongly in your setup.

@uerceg
Copy link
Contributor

uerceg commented Jul 27, 2018

@hearbeathorror Any update on this one?

@ghost
Copy link
Author

ghost commented Nov 29, 2018

@uerceg : i did not do this. I changed code to simply ignore adjust method tracking if that was the case for specific users. It was queuing it up, but that is not what i wanted. I did not want to let it queue up and then send it over to the server when it is enabled again.

@uerceg uerceg removed the support label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant