Skip to content

[AMSDK-11130] Collect consent#166

Merged
emdobrin merged 10 commits intoadobe:feature/consentfrom
emdobrin:AMSDK-11130
Mar 6, 2021
Merged

[AMSDK-11130] Collect consent#166
emdobrin merged 10 commits intoadobe:feature/consentfrom
emdobrin:AMSDK-11130

Conversation

@emdobrin
Copy link
Copy Markdown
Contributor

@emdobrin emdobrin commented Mar 2, 2021

Description

  • Adds Edge + Consent integration and updates the hit queue based on current consent status as follows:
    • When collect consent is yes, the hitQueue is resumed and data is being sent to the Edge network.
    • When collect consent is no, the previously queued hits are cleared from persistence and no new experience events are queued anymore. Consent update events are still queued and sent to the Edge network.
    • When collect consent is pending, the queue is suspended waiting for a new consent update to yes/no.
    • When Consent extension is not registered, the default collect consent status is yes.
  • Drops the integration with core privacy status in favor of consent settings.
  • Tests for consent update requests and experience events handling based on current collect consent status.

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.

@testable import AEPEdge
import XCTest

class EdgePublicAPITests: XCTestCase {
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.

Replaces EdgeTests

@testable import AEPServices
import Foundation

/// MockDataQueue - see also AEPServices/Mocks
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.

MockDataQueue, MockHitProcessor and TestableExtensionRuntime are copied from core.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 2, 2021

Codecov Report

Merging #166 (24e723a) into feature/consent (a2c5fe1) will increase coverage by 2.88%.
The diff coverage is 96.00%.

@@                 Coverage Diff                 @@
##           feature/consent     #166      +/-   ##
===================================================
+ Coverage            90.18%   93.06%   +2.88%     
===================================================
  Files                   21       24       +3     
  Lines                  774      793      +19     
===================================================
+ Hits                   698      738      +40     
+ Misses                  76       55      -21     

Copy link
Copy Markdown
Contributor

@PravinPK PravinPK left a comment

Choose a reason for hiding this comment

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

Neat. The logic looks good to me

let consentRequests = self.getNetworkRequestsWith(url: FunctionalTestConst.EX_EDGE_CONSENT_URL_STR, httpMethod: HttpMethod.post, timeout: 1)
XCTAssertEqual(0, consentRequests.count)
}

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.

good to have a few more tests here.. with Consents obtained from defaultConfig only and no Consent API's are called

I guess we for those test we should wait for that Bootup Consent PR to be merged.

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.

There are some more tests for this scenario in EdgeExtensionTests -> testBootup with different Consent shared states (see testBootup_whenNoConsentSharedState_usesDefaultYes)

beginProcessing()
case .no:
clear()
beginProcessing()
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.

do we need beginProcessing() here ?

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.

Yes, this is required for us to keep queuing and processing consent update events while collect consent is no, while ignoring experience events.

self = .yes
case "n":
self = .no
default:
Copy link
Copy Markdown
Contributor

@nporter-adbe nporter-adbe Mar 4, 2021

Choose a reason for hiding this comment

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

The default case is a bit confusing for me, as we have two default values in our constants based on specific scenarios. I wonder if it's the correct thing to default to pending here.

What if we made it a failable initializer and returned nil instead of providing a default value as it can vary based on the situation?

init?(rawValue: Self.RawValue)

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.

Don't think it will help much because I am already unwrapping the string before calling CollectConsent(rawValue:) - see getCollectConsentOrDefault. Changed to return the Defaults.COLLECT_CONSENT_PENDING.

The only case where we use default yes is on bootup when Consent extension is not registered.

guard !hasBooted else { return }

// check if consent extension is registered
if let consentSharedState = getXDMSharedState(EdgeConstants.SharedState.Consent.SHARED_OWNER_NAME, nil) {
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.

I think we should be reading the EventHub shared state to determine if the consent extension is registered. I think this approach of checking if the shared state exists to determine if an extension is registered can lead to false negatives.

We've used this method in our legacy codebase before, but I think we've found it tricky in some situations. Just because shared state doesn't exist for an extension doesn't mean it doesn't exist.

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 looked at using either the shared state or MobileCore.getRegisteredExtensions API but found that it only includes the friendly name and version of each extension, whereas other extensions should rely on is the extension name (aka shared state name) as the friendly name can anytime change. I discussed a bit about this with @shalehaha and we are considering it, but are still evaluating the implications for Assurance UI before making any changes.

I am willing to change this logic to check for hub shared state/getRegisteredExtensions as soon as the extension name is included in there.

@emdobrin emdobrin merged commit 0a243d7 into adobe:feature/consent Mar 6, 2021
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