Hello, I have an API call that dose merge ids and ...
# questions
h
Hello, I have an API call that dose merge ids and in callback i do identify on the userId but somehow in mixpanel dashboard merge is happening before identify even if identify is called as a callback on success. Anyone know why?
Copy code
final OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create("[{\"event\":\"$merge\",\"properties\":{\"$distinct_ids\":[\""+userId+"\", \""+guestId+"\"]}}]", mediaType);

final okhttp3.Request request = new okhttp3.Request.Builder()
        .url("<https://api.mixpanel.com/import?strict=1&project_id=111111>")
        .post(body)
        .addHeader("accept", "application/json")
        .addHeader("content-type", "application/json")
        .addHeader("authorization", "Basic 234234234=")
        .build();

client.newCall(request).enqueue(new Callback() {
    @Override
    public void onResponse(@NonNull Call call, @NonNull okhttp3.Response response) {
        if(response.isSuccessful()) {
            mixpanelAPI.identify(userId);
            response.close();
        }
    }

    @Override
    public void onFailure(@NonNull Call call, @NonNull IOException e) {
        e.printStackTrace();
    }
});