adobe / aepsdk-core-ios

Adobe Experience Platform Mobile Core SDK in Swift
Apache License 2.0
24 stars 40 forks source link

Replace InstrumentedExtension with wildcard listener #1085

Open timkimadobe opened 4 days ago

timkimadobe commented 4 days ago

Task description

Currently InstrumentedExtension is used to capture events sent through the EventHub using a wildcard event handler, but this has downsides:

  1. Impacts extension registration process
    1. Processing time/operations to register this extension
    2. EventHub shared state event for the InstrumentedExtension
  2. No easy way to get a reference to the extension instance itself

These can be addressed by replacing this implementation in TestBase with a wildcard listener registered with MobileCore:

public typealias EventListener = (Event) -> Void

MobileCore.registerEventListener(type: EventType.wildcard, source: EventSource.wildcard, listener: EventCollector)

Where EventCollector (name not set in stone) is an implementation of the EventListener type

Breaking change

Note that removing InstrumentedExtension will be a breaking change of two categories:

  1. Direct usage
  2. Indirect extension startup event expectations (vast majority of usage cases)

Direct usage IdentityIntegrationTests.swift: https://github.com/adobe/aepsdk-core-ios/blob/eab8353a2ccc2d3cc760c98f8e48e2dd9fc5168d/AEPIntegrationTests/IdentityIntegrationTests.swift#L50

NetworkResponseHandlerFunctionalTests.swift: https://github.com/adobe/aepsdk-edge-ios/blob/726f7b158a80fea0b827ceca5ddc9e71932689bf/Tests/FunctionalTests/NetworkResponseHandlerFunctionalTests.swift#L33

Indirect extension startup event expectations Once removed, these test cases will need to reduce their expected event counts to account for the removal of the InstrumentedExtension.

Usage search: https://github.com/search?q=org%3Aadobe+InstrumentedExtension&type=code&p=1

Addresses the deprecation in: https://github.com/adobe/aepsdk-core-ios/pull/1084

Additional implementation details or code snippet(s)

No response