Skip to content

feat(ats): add support for android ODP events #502

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

Merged
merged 8 commits into from
Jan 17, 2023
Merged

Conversation

jaeopt
Copy link
Contributor

@jaeopt jaeopt commented Jan 11, 2023

Summary

Add support for Android-SDK ODP integration, which may not be implemented in the Android-SDK.

  1. ODPManager.Builder.withUserCommonData(commonData)
    • clients (android-sdk) will pass common data (client os, device type,...) which should be added into all ODPEvents.
  2. ODPManager.Builder.withUserCommonIdentifiers(commonIdentifiers)
    • clients (android-sdk) will pass common identifiers (vuid,...) which should be added into all ODPEvents.

Test plan

Unit tests covering builder interface and generated events.

Issues

  • FSSDK-8768

@jaeopt jaeopt changed the title feat(ats): add support for android opd events feat(ats): add support for android ODP events Jan 11, 2023
@jaeopt jaeopt requested a review from mnoman09 January 11, 2023 22:08
@jaeopt jaeopt removed their assignment Jan 11, 2023
Copy link
Contributor

@mnoman09 mnoman09 left a comment

Choose a reason for hiding this comment

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

Overall lgtm. Left few suggestions.

@@ -63,6 +66,16 @@ public ODPEventManager(@Nonnull ODPApiManager apiManager, @Nullable Integer batc
this.flushInterval = (flushInterval != null && flushInterval > 0) ? flushInterval : DEFAULT_FLUSH_INTERVAL;
}

// these user-provided common data are included in all ODP events in addition to the SDK-generated common data.
public void setUserCommonData(@Nullable Map<String, Object> commonData) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks confusing, at line 42 and 43 there is a NonNull tag and here it is nullable. I think it should be NonNull to keep it consistent. Same goes for line 75.

// sdk-generated common data
assertNotNull(merged.get("idempotence_id"));
assertEquals(merged.get("data_source_type"), "sdk");
assertNotNull(merged.get("data_source"));
Copy link
Contributor

Choose a reason for hiding this comment

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

can we verify here that the datasource is java sdk and in android we can add a unit test that will verify that it is android sdk?

@@ -26,7 +26,7 @@ public class ODPEvent {

private String type;
private String action;
private Map<String, String > identifiers;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we update the header as this is nit fix?

@@ -63,6 +63,8 @@ public String getKey() {

/**
* @deprecated use {@link #getExperimentRules()} and {@link #getDeliveryRules()} instead
*
* @return a map of ExperimentKey to OptimizelyExperiment
Copy link
Contributor

Choose a reason for hiding this comment

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

Update header.

@@ -255,6 +255,157 @@ public void validateEventData() {
assertFalse(event.isDataValid());
}

@Test
public void validateAugmentCommonData() {
Copy link
Contributor

Choose a reason for hiding this comment

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

update the header of this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have to find a way to automate these header updates :)

Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds right, every new year same old hassle :D

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

header.

@jaeopt jaeopt requested a review from mnoman09 January 12, 2023 18:30
@jaeopt
Copy link
Contributor Author

jaeopt commented Jan 12, 2023

@mnoman09 all suggestions addressed.

Copy link
Contributor

@mnoman09 mnoman09 left a comment

Choose a reason for hiding this comment

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

Overall lgtm. Added one comment, that needs to be addressed. Approving this PR, so we can merge once that comment is resolved.

@@ -182,6 +212,8 @@ public ODPManager build() {
if (eventManager == null) {
eventManager = new ODPEventManager(apiManager);
}
eventManager.setUserCommonData(userCommonData != null ? userCommonData : Collections.emptyMap());
Copy link
Contributor

Choose a reason for hiding this comment

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

can we move this null check inside the setUserCommonData to ensure the null pointer exception won't occur inside odpEventManger line 137.

@jaeopt jaeopt merged commit cbe85de into master Jan 17, 2023
@jaeopt jaeopt deleted the jae/android-support branch January 17, 2023 18:50
@jaeopt
Copy link
Contributor Author

jaeopt commented Jan 17, 2023

force-merged with FSC failures for android development support since they will be fixed in other ODP PRs.

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

Successfully merging this pull request may close these issues.

3 participants