Skip to content

[MOB-17072] Adopt changes for Core 2.0 part 1#2

Merged
kevinlind merged 30 commits intoadobe:dev-v2.0.0from
kevinlind:mob-17072-core2
Dec 3, 2022
Merged

[MOB-17072] Adopt changes for Core 2.0 part 1#2
kevinlind merged 30 commits intoadobe:dev-v2.0.0from
kevinlind:mob-17072-core2

Conversation

@kevinlind
Copy link
Copy Markdown
Contributor

@kevinlind kevinlind commented Nov 23, 2022

Description

Part 1 of adoption of changes for Core 2.0

  • Updates .gradle files to use Core 2.0 from jitpack

  • Sets extension version to 2.0.0

  • Updates Edge public APIs for Core 2.0

  • Use new shared state api in EdgeExtension, EdgeState, EdgeHitProcessor

  • Implements EdgeExtension.onRegistered and registers listeners. Removes older Listener class

  • Implements EdgeExtension.readyForEvent which calls EdgeState.bootupIfNeeded and checks shared state dependencies for specific events.

  • Updates EdgeState and EdgeProperties for Core 2.0 changes.

  • Switch to new Log class only for the class touched by the changes above.

  • Set permission for .githooks/pre-commit for execution

Out of scope for this PR:

  • Switch to use public EventType and EventSource in all places
  • Switch to use new Log class in all places
  • Updates to hit queue, EdgeNetworkService, and NetworkResponseHandler except to get code to compile
  • Unit and functional tests do not compile or run

Related Issue

Motivation and Context

How Has This Been Tested?

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.

@SuppressWarnings("unused")
public class Edge {

private static final String LOG_SOURCE = "Edge";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As the name of this class is the same as the extension, should the source remain as "Edge" or something else like "PublicAPIs"?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Other core extensions also use the same source name the extension name, I think we can leave it as Edge to make it consistent.

Comment on lines +307 to +322
SharedStateResult assuranceStateResult = sharedStateCallback.getSharedState(
EdgeConstants.SharedState.ASSURANCE,
null
);
final String assuranceIntegrationId = EventUtils.getAssuranceIntegrationId(assuranceSharedState);

if (!Utils.isNullOrEmpty(assuranceIntegrationId)) {
if (assuranceStateResult == null || assuranceStateResult.getStatus() != SharedStateStatus.SET) {
return requestHeaders;
}

final String assuranceIntegrationId = DataReader.optString(
assuranceStateResult.getValue(),
EdgeConstants.SharedState.Assurance.INTEGRATION_ID,
null
);

if (!StringUtils.isNullOrEmpty(assuranceIntegrationId)) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've only updated EdgeHitProcessor to fix uses of getSharedState and to use the new DataReader in this getRequestHeader function. The reset of this class will be updated in another PR.

return httpConnecting[0];
} catch (final InterruptedException | IllegalArgumentException e) {
Log.warning(LOG_TAG, "Connection failure for url (%s), error: (%s)", url, e);
Log.warning(LOG_TAG, LOG_SOURCE, "Connection failure for url (%s), error: (%s)", url, e);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've only updated the EdgeNetworkService to fix this one instance of Log to get the code to compile. The reset of the class will be updated in another PR.


package com.adobe.marketing.mobile;

import com.adobe.marketing.mobile.util.StringUtils;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This line was the only needed change. Please review entire class.

*/
class NetworkResponseHandler {

private static final String LOG_SOURCE = "NetworkResponseHandler";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've only updated NetworkResponseHandler to fix the cases of Log which were failing to compile. The rest of this class will be updated in another PR.

new EdgeSharedStateCallback() {
@Override
public Map<String, Object> getSharedState(final String stateOwner, final Event event) {
public SharedStateResult getSharedState(final String stateOwner, final Event event) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The changes in EdgeStateTests were done automatically when I made the API changes. The test classes will be updated in another PR.


static final String EDGE_DATA_STORAGE = "EdgeDataStorage";
static final String EXTENSION_VERSION = "1.4.0";
static final String EXTENSION_VERSION = "2.0.0";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As this PR is just part 1 of the changes to adopt Core 2.0, I'm not able to remove any unneeded constants, such as the EdgeType and EdgeSource constants.

@SuppressWarnings("unused")
public class Edge {

private static final String LOG_SOURCE = "Edge";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Other core extensions also use the same source name the extension name, I think we can leave it as Edge to make it consistent.


// Get Hub's shared state needed to check if Identity and Consent are registered
// If not set, return false and attempt bootup at next event
final SharedStateResult eventHubStateResult = sharedStateCallback.getSharedState(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Does the actual check on whether Consent and Identity are registered happen elsewhere?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure why I said Identity here. The hub's state is needed to build ImplementationDetails using the Core version and wrapper type, and setting the default Consent if Consent is not registered. Both of those a checked in the synchronized block, in ImplementationDetails.fromEventHubState and updateCollectConsentIfNotRegistered.
I'll update the comment to make it more clear.

Copy link
Copy Markdown
Contributor

@emdobrin emdobrin left a comment

Choose a reason for hiding this comment

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

Changes look good to me with couple small follow-ups

@kevinlind kevinlind changed the base branch from dev to dev-v2.0.0 December 3, 2022 01:31
@kevinlind kevinlind merged commit 596e1c3 into adobe:dev-v2.0.0 Dec 3, 2022
@kevinlind kevinlind deleted the mob-17072-core2 branch December 3, 2022 01:32
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