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

Adopt changes in Core 2.0 #76

Merged
merged 6 commits into from
Nov 29, 2022
Merged

Conversation

prudrabhat
Copy link
Contributor

@prudrabhat prudrabhat commented Nov 17, 2022

Description

In this PR :

 - .gradle changes
    - Add jitpack to repositories
    - Consume Core 2.0 via com.github.adobe.aepsdk-core-android:core:de-v2.0.0-SNAPSHOT
      from jitpack
    - Prevent transitive dependencies from other extensions
    - Change moduleVersion, mavenCoreVersion to 2.0.0.

 - Change IdentityConstants.EXTENSION_VERSION to 2.0.0
 - Expose IdentityExtension.class via Idenity.EXTENSION
 - Switch to MobileCore.dispatchEventWithResponseCallback(event, timeout, callbackWithError)
   and ExtensionApi.dispatch(event)

 - Switch to using new shared state api
   - Remove multiple instance creation of SharedStateCallback.
   - Streamline shared state calls via SharedStateCallback within and
      outside the Identity extension

 - Implement IdentityExtension.onRegistered()
   - Change event listener registration to be done in onRegistered() instead of the
     IdentityExtension's constructor
 - Remove Listener*.java classes in favor of inline methods
   - Remove the inhouse executor service and mutex as the events are now incident
     via a single thread maintained by the extension container housing this extension.

 - Implement IdentityExtension.readyForEvent()
   - Add logic to wait for EventHub state and IdentityDirect registration check
     if ECID from persisted properties is unavailable.
   - Remove the logic to cache events internally. Take advantage of the Hub
     shared state fetching to boot up and disambiguate between Identity direct and
     EdgeIdentity.

 - Switch to use public utility classes and methods from Core where applicable
   - Use StringUtils.isEmpty()
   - Use JSONUtil.toMap() and JSONUtil.toList()
   - Use TimeUtils
   - Use DataReader.opt*() to read and parse event data. Remove class cast
     exception guards and resolve unchecked cast warnings where possible.

 - General changes done on code path toched
   - private and finals where applicable
   - Use cascading constructors to eliminate constructor divergence risk and
     ease test injection

Out of scope for this PR

 - Switching to Log from MobileCore.Log
 - Using EventSource and EventType from Core
 - Switching to ServiceProvider
 - Switching IdentityStorageService to NamedCollection
 - Test changes
 - PowerMock elimination

Related Issue

MOB-17065

Motivation and Context

Core 2.0 changes will allow architectural consistency with iOS.

How Has This Been Tested?

  • Verified that the ci-build passes locally.
  • Verified operations from test app
  • Unit tests and integration tests (not in this PR) in progress.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

 - .gradle changes
    - Add jitpack to repositories
    - Consume Core 2.0 via com.github.adobe.aepsdk-core-android:core:v2.0.0-SNAPSHOT
      from jitpack
    - Prevent transitive dependencies from other extensions
    - Change moduleVersion, mavenCoreVersion to 2.0.0.

 - Change IdentityConstants.EXTENSION_VERSION to 2.0.0
 - Expose IdentityExtension.class via Idenity.EXTENSION
 - Switch to MobileCore.dispatchEventWithResponseCallback(event, timeout, callbackWithError)
   and ExtensionApi.dispatch(event)

 - Switch to using new shared state api
   - Remove multiple instance creation of SharedStateCallback.
   - Streamline shared state calls via SharedStateCallback within and
      outside the Identity extension

 - Implement IdentityExtension.onRegistered()
   - Change event listener registration to be done in onRegistered() instead of the
     IdentityExtension's constructor
 - Remove Listener*.java classes in favor of inline methods
   - Remove the inhouse executor service and mutex as the events are now incident
     via a single thread maintained by the extension container housing this extension.

 - Implement IdentityExtension.readyForEvent()
   - Add logic to wait for EventHub state and IdentityDirect registration check
     if ECID from persisted properties is unavailable.
   - Remove the logic to cache events internally. Take advantage of the Hub
     shared state fetching to boot up and disambiguate between Identity direct and
     EdgeIdentity.

 - Switch to use public utility classes and methods from Core where applicable
   - Use StringUtils.isEmpty()
   - Use JSONUtil.toMap() and JSONUtil.toList()
   - Use DataReader.opt*() to read and parse event data. Remove class cast
     exception guards and resolve unchecked cast warnings where possible.

 - General changes done on code path toched
   - private and finals where applicable
   - Use cascading constructors to eliminate constructor divergence risk and
     ease test injection

Out of scope for this PR
 - Switching to Log from MobileCore.Log
 - Switching IdentityStorageService to NamedCollection
 - Test changes
 - PowerMock elimination
 - .gradle changes
    - Add jitpack to repositories
    - Consume Core 2.0 via com.github.adobe.aepsdk-core-android:core:v2.0.0-SNAPSHOT
      from jitpack
    - Prevent transitive dependencies from other extensions
    - Change moduleVersion, mavenCoreVersion to 2.0.0.

 - Change IdentityConstants.EXTENSION_VERSION to 2.0.0
 - Expose IdentityExtension.class via Idenity.EXTENSION
 - Switch to MobileCore.dispatchEventWithResponseCallback(event, timeout, callbackWithError)
   and ExtensionApi.dispatch(event)

 - Switch to using new shared state api
   - Remove multiple instance creation of SharedStateCallback.
   - Streamline shared state calls via SharedStateCallback within and
      outside the Identity extension

 - Implement IdentityExtension.onRegistered()
   - Change event listener registration to be done in onRegistered() instead of the
     IdentityExtension's constructor
 - Remove Listener*.java classes in favor of inline methods
   - Remove the inhouse executor service and mutex as the events are now incident
     via a single thread maintained by the extension container housing this extension.

 - Implement IdentityExtension.readyForEvent()
   - Add logic to wait for EventHub state and IdentityDirect registration check
     if ECID from persisted properties is unavailable.
   - Remove the logic to cache events internally. Take advantage of the Hub
     shared state fetching to boot up and disambiguate between Identity direct and
     EdgeIdentity.

 - Switch to use public utility classes and methods from Core where applicable
   - Use StringUtils.isEmpty()
   - Use JSONUtil.toMap() and JSONUtil.toList()
   - Use DataReader.opt*() to read and parse event data. Remove class cast
     exception guards and resolve unchecked cast warnings where possible.

 - General changes done on code path toched
   - private and finals where applicable
   - Use cascading constructors to eliminate constructor divergence risk and
     ease test injection

Out of scope for this PR
 - Switching to Log from MobileCore.Log
 - Switching IdentityStorageService to NamedCollection
 - Test changes
 - PowerMock elimination
@prudrabhat prudrabhat requested review from kevinlind, addb, emdobrin, cacheung and timkimadobe and removed request for addb November 17, 2022 20:28
// Reuse the ECID from Identity Direct (if registered) or generate new ECID on first launch
if (identityProperties.getECID() == null) {
// Wait for all extensions to be registered as forth coming logic depends on Identity Direct state
if (!areAllExtensionsRegistered(callback)) return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to add similar logic in iOS to ensure hub ss is ready before bootup?
cc @kevinlind

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be safe to add this to iOS as well. I don't remember the full conversation but I was under the impression that the EventHub shared state was the first (or one of the first) events dispatched when the SDK starts. Adding a check like this for the EventHub shared state makes the code more robust, so it's a good idea.

- Switch to using handlers for each event listener
- Use TimeUtils where applicable
- Eliminate two calls to get event hub shared state
- Add comments and TODOs for verification and logging

/**
* Defines the public APIs for the AEP Edge Identity extension.
*/
public class Identity {

public static final Class<? extends Extension> EXTENSION = IdentityExtension.class;
private static final long CALLBACK_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(5);
Copy link
Collaborator

Choose a reason for hiding this comment

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

The documented API timeout is 500 ms. The timeout is short primarily because of getExperienceCloudId, which needs to be fast for customers implementing a hybrid application which contains a web view. As these APIs are time sensitive for customers, I'd suggest keeping the 500 ms value.
cc @emdobrin

Copy link
Contributor Author

@prudrabhat prudrabhat Nov 22, 2022

Choose a reason for hiding this comment

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

I did not realize that the documented value of timeout is 500ms and so made it match the default max timeout for a response callback instead.
I have now changed it to 500ms to match the documented contract 👍🏼

@emdobrin emdobrin merged commit 4279014 into adobe:dev-v2.0.0 Nov 29, 2022
@prudrabhat prudrabhat deleted the core_2x0_adoption branch November 29, 2022 19:11
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.

4 participants