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

Passing an instanceName other than "\$default_instance" fails with TimeoutException #39

Closed
wilburx9 opened this issue Oct 19, 2023 · 4 comments

Comments

@wilburx9
Copy link

wilburx9 commented Oct 19, 2023

When you pass an instanceName other than "\$default_instance" to the Configuration, it throws:

java.util.concurrent.ExecutionException: java.lang.IllegalStateException: java.util.concurrent.TimeoutException: Timed out waiting for Amplitude Analytics SDK to initialize. You should ensure that the analytics SDK is initialized prior to calling fetch()

This works:

val config = ExperimentConfig.builder()
      .build()
val experiment = Experiment.initializeWithAmplitudeAnalytics(app, $API_KEY  config,)
val user = ExperimentUser.builder()
.userId(userAuth0Id)
.deviceId(deviceIdFromAnalytics)
 .build()
experiment?.start(user)?.get()

This also works:

val config = ExperimentConfig.builder()
      .instanceName("\$default_instance")
      .build()
val experiment = Experiment.initializeWithAmplitudeAnalytics(app, $API_KEY  config,)
val user = ExperimentUser.builder()
.userId(userAuth0Id)
.deviceId(deviceIdFromAnalytics)
 .build()
experiment?.start(user)?.get()

But this throws the exception mentioned earlier:

val config = ExperimentConfig.builder()
      .instanceName("lorem_ipsum")
      .build()
val experiment = Experiment.initializeWithAmplitudeAnalytics(app, $API_KEY  config,)
val user = ExperimentUser.builder()
.userId(userAuth0Id)
.deviceId(deviceIdFromAnalytics)
 .build()
experiment?.start(user)?.get()

Why do I need multiple instances? This is e trying to solve #40, one for logged in session and the other before they log in.

I am using v1.11.0

@tyiuhc
Copy link
Collaborator

tyiuhc commented Oct 19, 2023

Hi @wilburx9, many thanks for reaching out. To help us better assist on this, please let us know:

  1. Which analytics SDK, and what version of it are you using?
  2. Are you setting the instance name of the analytics SDK to be the same as the one set in you experiment SDK?

@wilburx9
Copy link
Author

wilburx9 commented Oct 20, 2023

  1. "com.amplitude:android-sdk:2.36.1"
  2. Nope, I don't set the instance name on the analytics SDK.

Edit 1:
I have set the instanceName on the SDK with same name as I am using for the experiment instance but that didn't fix it either. Note: I am setting the instance after initializing the SDK.


Edit 2:
Setting the SDK's configuration instanceName before instantiating the SDK and using the same name on the experiment instance name fixes this. Is this the expexted behaviour? The SDK's instance name can't be changed after instantiating?

@tyiuhc
Copy link
Collaborator

tyiuhc commented Oct 20, 2023

On edit 2: Yes, this is the expected behavior. The SDK's instance name cannot be changed after instantiating.

@wilburx9
Copy link
Author

Thanks for the clarification. Can the documentation be updated to reflect this behaviour? It currently says "You can dynamically set the configuration after initialization."

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

2 participants