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

Add debug event support #1048

Merged
merged 6 commits into from
Jun 20, 2024
Merged

Conversation

cdhoffmann
Copy link
Contributor

@cdhoffmann cdhoffmann commented Jun 19, 2024

The SDKs often needs to change its standard business logic to enable debugging/testing workflows. We need an event structure that external systems can follow to generate an event that communicates to the listening SDK extension that it should operate in a debug mode - a mode outside of expected production behavior if one exists.

This commit adds an eventSource "com.adobe.eventSource.debug" to identify such events.
Further, it adds utility methods to identify the eventType and eventSource provided within the data.debug content of such events.
Structure:

{
        "name" : "......",
        "type" : "com.adobe.eventType.system",
        "source" : "com.adobe.eventSource.debug",
        "data" : {
            "debug": {
                "eventType": "<DEBUG_EVENT_TYPE>",
                "eventSource": "<DEBUG_EVENT_SOURCE>"
            },
             "someOtherKey":  {
               ....
               }
         }
}

Usage:

var debugType = Event.debugEventType
var debugSource = Event.debugEventSource

Related Issue

Motivation and Context

The SDKs often needs to change its standard business logic to enable debugging/testing workflows. We need an event structure that external systems can follow to generate an event that communicates to the listening SDK extension that it should operate in a debug mode - a mode outside of expected production behavior if one exists.

This commit adds an eventSource "com.adobe.eventSource.debug" to identify such events.
Further, it adds utility methods to identify the eventType and eventSource provided within the data.debug content of such events.

How Has This Been Tested?

  • Unit tests

Screenshots (if appropriate):

n/a

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.

@cdhoffmann cdhoffmann changed the base branch from main to dev-v5.1.1 June 19, 2024 17:37
@cdhoffmann
Copy link
Contributor Author

Ran swiftFormat and fixed a bunch of whitespace issues, apologies for the extra file changes.

AEPCore/Sources/core/Event+Debug.swift Outdated Show resolved Hide resolved
AEPCore/Sources/core/Event+Debug.swift Outdated Show resolved Hide resolved
AEPCore/Sources/core/CoreConstants.swift Outdated Show resolved Hide resolved
@cdhoffmann cdhoffmann requested a review from praveek June 19, 2024 18:53
Copy link
Member

@sbenedicadb sbenedicadb left a comment

Choose a reason for hiding this comment

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

looks good with one little recommendation to clean up the implementation of the extension vars

Comment on lines 26 to 31
var debugEventType: String? {
if let debugType = debugEventData?[Event.DEBUG_EVENT_TYPE_KEY] as? String {
return debugType
}
return nil
}
Copy link
Member

Choose a reason for hiding this comment

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

i think we can just clean these up like this:

    var debugEventType: String? {
        debugEventData?[Event.DEBUG_EVENT_TYPE_KEY] as? String
    }

@praveek praveek merged commit 5b0567a into adobe:dev-v5.1.1 Jun 20, 2024
17 checks passed
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