Adobe-Marketing-Cloud / aep-sdks-documentation

Documentation repository for the Adobe Experience Platform Mobile SDKs
MIT License
26 stars 106 forks source link

Server API Documentation #836

Open rf19l opened 1 year ago

rf19l commented 1 year ago

Hello, there's currently a gap in documentation on how to send events to assurance when using the server api. This page mentions that I can use the same mechanism as the Experience Platform Debugger, but doesn't mention what that is.

It also says I can create a assurance session and use that session ID in my edge requests, but doesn't clarify what exactly to do with that value. I'd appreciate any guidance.

Here is the documentation for the server api for reference https://experienceleague.adobe.com/docs/experience-platform/edge-network-server-api/troubleshooting.html?lang=en

longAdobe commented 1 year ago

@rf19l We'll work on updating docs. In the meantime, I hope the following answers your question.

Option 1 - Experience Platform Debugger

Open the Experience Platform Debugger and navigate to Experience Platform Web SDK -> Edge Transactions tab -> Login In. As long as the webpage/tab you are viewing is sending edge requests to an org you have access to, you should see the edge transaction tracing in this view so you can get details about the data being sent to edge and processing happening within Adobe's services. Screenshot 2023-04-24 at 12 07 23 PM

The debugger will automatically enable edge transaction tracing and show you the details in the Experience Platform Debugger Edge Transactions view.

Option 2 - Manual Tracing

First, log into Assurance(https://experience.adobe.com/#/assurance) and create a session. When you have the session ID from the browser url bar, you can use that in an edge request to see the edge tracing in the Assurance UI.

Screenshot 2023-04-24 at 12 27 39 PM

You'll need to pass the assurance session id as a header to the edge request for this header key x-adobe-aep-validation-token. Below is an example curl edge request.

curl -v 'https://edge.adobedc.net/ee/v1/interact?configId=3fe09304-5504-47a9-919d-54c636364b87' \
--header 'Content-Type: application/json' \
--header 'x-adobe-aep-validation-token: 11111111-1111-1111-1111-111111111111' \
--data-raw '{...}'

After making the above request, the Assurance UI should show you the edge transaction details in the raw events view or the edge transactions view.

The edge request will be associated with an edge configuration. The edge configuration belongs to a specific org. The org the session was created MUST match the org that the edge configuration belongs to. If there is no match, the server side events will not show in your session.

Side Note: If you want to set up a 3rd party event provider, we don't currently support that. We have it on the backlog, but could use your help to get it prioritized. If this is what you're after, let me know and I can forward the request to our PM to help move it up the board. If you want to create the session via API and read the events from the API, you can use the Assurance API docs here - https://developer.adobe.com/adobe-assurance-public-apis/

rf19l commented 1 year ago

Hi thanks for your response. Option 2 is more relevant to my use case as I'm working on a hybrid mobile implementation. I'm using a slightly different url format found from the server api docs and found that passing the assurance id in as a query string paramater. (leaving out the headers for brevity) POST "https://server.adobedc.net/ee/v2/interact?dataStreamId={DATASTREAM_ID}&debugSessionId={ASSURANCE_SESSION}" I found this worked with the authenticated endpoint and I'm able to pass this when deeplinking from the assurance UI to start sending events from the server.

I have another question I'm not sure if I should post here or in another thread. Is there any way using the iOS and Android sdk's to detect when the client disconnects from the session? Currently I add the parameter mentioned above when starting the session and remove it when the app is closed. If I don't remove the parameter when the app is backgrounded, I will continue sending events to the assurance session even after the client disconnects.

It would be really helpful if there was a callback that invokes when the client disconnects, that way I can keep sending events from the server as long as the client is connected, and stop sending events once it disconnects.

longAdobe commented 1 year ago

@rf19l I don't believe there is a callback. I'll run it by the SDK team to try to get it added.

I'm assuming you're injecting the assurance session id into the web views to capture the traces, is this roughly how you're pursuing it? This is a feature we've been wanting to add for a while now. Is there anything you can share with us that may help us with implementation or design?

rf19l commented 1 year ago

I wrote a Kotlin Multiplatform wrapper around the Adobe Edge Server Api to allow our Android and iOS apps to share business logic for creating and sending events to the edge network. We are still using the native adobe sdk's for existing code, but are looking for opportunities to share code as we go forward.

Currently in a debug build I've added UI on each platform to allow testers to enter the debug session id, or automatically pass the debug session id when using the qr code to deeplink.

I was hoping there would be a simple callback or listener that I could pass in when starting the session via the assurance mobile sdk.

Something like this: Assurance.startSession(url:String, mySessionCompletionListener) or startSession(url:String,invokeOnComplete:()->())

ahmyr commented 6 months ago

@rf19l, we'd rather not expose this listener in favor of hybrid app support that we plan to do some time in the future.