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

fix: Kit integration forwarding unplanned/blocked events when fired early on app run #394

Merged
merged 4 commits into from
Jun 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ public void loadKitLibrary() {
.onKitsLoaded(() -> {
mKitManager = kitManager;
setKitsLoaded(true);
updateDataplan(mCoreCallbacks.getDataplanOptions());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this reads like a race condition - we need to ensure that the data plan is set before kits are loaded. specifically - we need to make sure that no user attribute, events, etc can be sent to kits prior to the data plan.

in my view ideally we'd load the data plan in the same function updateKits above that loads kit configuration. the idea of KitConfiguration is that it should contain absolutely everything needed, and we only start kits after it's been completely parsed.

}
);
} else {
mKitManager = kitManager;
updateDataplan(mCoreCallbacks.getDataplanOptions());
}
updateDataplan(mCoreCallbacks.getDataplanOptions());
} catch (Exception e) {
Logger.debug("No Kit Framework detected.");
setKitsLoaded(true);
Expand Down Expand Up @@ -128,7 +129,7 @@ void setKitsLoaded(boolean kitsLoaded) {
disableQueuing();
}
List<KitsLoadedListener> kitsLoadedListenersCopy = new ArrayList<>(kitsLoadedListeners);
for (KitsLoadedListener kitsLoadedListener: kitsLoadedListenersCopy) {
for (KitsLoadedListener kitsLoadedListener : kitsLoadedListenersCopy) {
if (kitsLoadedListener != null) {
kitsLoadedListener.onKitsLoaded();
}
Expand Down Expand Up @@ -198,7 +199,7 @@ void replayEvents() {
break;
case AttributeChange.INCREMENT_ATTRIBUTE:
if (attributeChange.value instanceof String) {
mKitManager.incrementUserAttribute(attributeChange.key, attributeChange.incrementedBy, (String)attributeChange.value, attributeChange.mpid);
mKitManager.incrementUserAttribute(attributeChange.key, attributeChange.incrementedBy, (String) attributeChange.value, attributeChange.mpid);
}
break;
case AttributeChange.TAG:
Expand Down Expand Up @@ -630,7 +631,7 @@ public void onModifyCompleted(MParticleUser user, IdentityApiRequest request) {
mKitManager.onModifyCompleted(user, request);
}
}

@Override
public void onConsentStateUpdated(ConsentState oldState, ConsentState newState, long mpid) {
if (mKitManager != null) {
Expand Down