Dispatch 'complete' event when streaming connection closed#383
Dispatch 'complete' event when streaming connection closed#383
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #383 +/- ##
==========================================
+ Coverage 96.73% 96.77% +0.04%
==========================================
Files 27 27
Lines 1653 1671 +18
==========================================
+ Hits 1599 1617 +18
Misses 54 54 |
Add more functional test cases for onComplete behavior
Correct the documentation for response content as a fallback to error response content Alphabetize items
Reorganize view to move scrollable data view to the top and not truncate text Add visual indicators to scrollable data view
kevinlind
left a comment
There was a problem hiding this comment.
Looks good. Added comments for a few minor issues.
| @@ -64,10 +64,10 @@ class NetworkResponseHandler { | |||
| /// Remove the requestId in the internal `sentEventsWaitingResponse` along with the associated list of events. | |||
| /// - Parameter requestId: batch request id | |||
| /// - Returns: the list of unique event ids associated with the requestId that were removed | |||
There was a problem hiding this comment.
Update comment to state it returns the events.
| XCTAssertEqual(1, dispatchedEvents.count) | ||
|
|
||
| let flattenedData = flattenDictionary(dict: dispatchedEvents.first?.data ?? [:]) | ||
| XCTAssertEqual(1, flattenedData.count) | ||
| XCTAssertEqual(requestID, flattenedData["requestId"] as? String) |
There was a problem hiding this comment.
You can use assertResponseCompleteEventWithData here.
There was a problem hiding this comment.
Thank you! Updated
Documentation/event-reference.md
Outdated
| ### Edge response content | ||
|
|
||
| This event is a response to an [Edge request content](#edge-request-content) event. | ||
| This event is a fallback to an [Edge error response content](#edge-error-response-content) event. |
There was a problem hiding this comment.
This is technically the fallback when a network response handle doesn't define a type, not for errors. I've updated the Android definition to state this event include the Edge Network response handles and com.adobe.eventSource.responseContent is used if the response handle doesn't define a type. I'm not sure if we want to include that specific of information, however.
There was a problem hiding this comment.
Thank you for clarifying! I've updated to align with the updates you've made on the Android side. I think it could be helpful to include in the off chance someone runs into this event case and uses the reference
Documentation/event-reference.md
Outdated
| The `sendCompletion` flag is used within the Edge request to indicate whether a "complete" event should be dispatched once the streaming connection is closed. This flag is part of the `request` object, which is at the same hierarchical level as the `data` and `xdm` objects in the Edge Experience Event. | ||
|
|
||
| ```json | ||
| { | ||
| "xdm": { ... }, | ||
| "request": { "sendCompletion" : true } | ||
| } | ||
| ``` | ||
|
|
||
| When the `sendCompletion` flag in the request is set to `true`, the Edge extension will dispatch a *paired* response event. This event notifies the caller that the connection has been closed and that no further streaming response handles will be dispatched. The [response event](#edge-content-complete) includes only the `requestId` in its data, for debugging purposes. The `parentID` of this event corresponds to the UUID of the originating request event. |
There was a problem hiding this comment.
I like this write up, however these parameters are only send in the request content events. Having a separate flags section seems to imply that any of the request event could contain the sendCompletion flag. In the Android PR, I've split this information to include the request parameter in the request content section, while adding the sendCompletion in the content complete section. Having all this under the request content section is a good option too. What do you think?
There was a problem hiding this comment.
I agree that having the flags section separate could be confusing; I like the way that you've organized the information! Updated to align this doc with the latest Android changes
timkimadobe
left a comment
There was a problem hiding this comment.
Thanks for the review @kevinlind! Updated based on feedback
| @@ -64,10 +64,10 @@ class NetworkResponseHandler { | |||
| /// Remove the requestId in the internal `sentEventsWaitingResponse` along with the associated list of events. | |||
| /// - Parameter requestId: batch request id | |||
| /// - Returns: the list of unique event ids associated with the requestId that were removed | |||
| XCTAssertEqual(1, dispatchedEvents.count) | ||
|
|
||
| let flattenedData = flattenDictionary(dict: dispatchedEvents.first?.data ?? [:]) | ||
| XCTAssertEqual(1, flattenedData.count) | ||
| XCTAssertEqual(requestID, flattenedData["requestId"] as? String) |
There was a problem hiding this comment.
Thank you! Updated
Documentation/event-reference.md
Outdated
| ### Edge response content | ||
|
|
||
| This event is a response to an [Edge request content](#edge-request-content) event. | ||
| This event is a fallback to an [Edge error response content](#edge-error-response-content) event. |
There was a problem hiding this comment.
Thank you for clarifying! I've updated to align with the updates you've made on the Android side. I think it could be helpful to include in the off chance someone runs into this event case and uses the reference
Documentation/event-reference.md
Outdated
| The `sendCompletion` flag is used within the Edge request to indicate whether a "complete" event should be dispatched once the streaming connection is closed. This flag is part of the `request` object, which is at the same hierarchical level as the `data` and `xdm` objects in the Edge Experience Event. | ||
|
|
||
| ```json | ||
| { | ||
| "xdm": { ... }, | ||
| "request": { "sendCompletion" : true } | ||
| } | ||
| ``` | ||
|
|
||
| When the `sendCompletion` flag in the request is set to `true`, the Edge extension will dispatch a *paired* response event. This event notifies the caller that the connection has been closed and that no further streaming response handles will be dispatched. The [response event](#edge-content-complete) includes only the `requestId` in its data, for debugging purposes. The `parentID` of this event corresponds to the UUID of the originating request event. |
There was a problem hiding this comment.
I agree that having the flags section separate could be confusing; I like the way that you've organized the information! Updated to align this doc with the latest Android changes
Description
Paired with Android implementation adobe/aepsdk-edge-android#83
This PR updates:
NetworkResponseHandlerto add a new method processResponseOnComplete which handles the sending of "complete" eventssendCompletionflag set totrueRelated Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: