use of com.adobe.target.delivery.v1.model.Telemetry in project target-java-sdk by adobe.
the class DefaultTargetService method executeNotification.
@Override
public ResponseStatus executeNotification(TargetDeliveryRequest deliveryRequest) {
TimingTool timer = new TimingTool();
timer.timeStart(TIMING_EXECUTE_REQUEST);
NotificationService.setBeaconToFalse(deliveryRequest.getDeliveryRequest());
TargetDeliveryResponse targetDeliveryResponse;
Telemetry telemetry = telemetryService.getTelemetry();
if (!telemetry.getEntries().isEmpty()) {
deliveryRequest.getDeliveryRequest().setTelemetry(telemetry);
}
ResponseWrapper response = callDeliveryApi(deliveryRequest);
targetDeliveryResponse = getTargetDeliveryResponse(deliveryRequest, response.getHttpResponse());
telemetryService.addTelemetry(deliveryRequest, timer, targetDeliveryResponse, response.getParsingTime(), response.getResponseSize());
return new ResponseStatus(response.getHttpResponse().getStatus(), response.getHttpResponse().getStatusText());
}
use of com.adobe.target.delivery.v1.model.Telemetry in project target-java-sdk by adobe.
the class DefaultTargetService method executeRequestAsync.
@Override
public CompletableFuture<TargetDeliveryResponse> executeRequestAsync(TargetDeliveryRequest deliveryRequest) {
TimingTool timer = new TimingTool();
timer.timeStart(TIMING_EXECUTE_REQUEST);
Telemetry telemetry = telemetryService.getTelemetry();
if (!telemetry.getEntries().isEmpty()) {
deliveryRequest.getDeliveryRequest().setTelemetry(telemetry);
}
CompletableFuture<ResponseWrapper<DeliveryResponse>> responseCompletableFuture = callDeliveryApiAsync(deliveryRequest);
return responseCompletableFuture.thenApply(response -> {
TargetDeliveryResponse targetDeliveryResponse = getTargetDeliveryResponse(deliveryRequest, response.getHttpResponse());
telemetryService.addTelemetry(deliveryRequest, timer, targetDeliveryResponse, response.getParsingTime(), response.getResponseSize());
return targetDeliveryResponse;
});
}
use of com.adobe.target.delivery.v1.model.Telemetry in project target-java-sdk by adobe.
the class DefaultTargetService method executeNotificationAsync.
@Override
public CompletableFuture<ResponseStatus> executeNotificationAsync(TargetDeliveryRequest deliveryRequest) {
TimingTool timer = new TimingTool();
timer.timeStart(TIMING_EXECUTE_REQUEST);
NotificationService.setBeaconToFalse(deliveryRequest.getDeliveryRequest());
Telemetry telemetry = telemetryService.getTelemetry();
if (!telemetry.getEntries().isEmpty()) {
deliveryRequest.getDeliveryRequest().setTelemetry(telemetry);
}
CompletableFuture<ResponseWrapper<DeliveryResponse>> responseCompletableFuture = callDeliveryApiAsync(deliveryRequest);
return responseCompletableFuture.thenApply(response -> {
TargetDeliveryResponse targetDeliveryResponse = getTargetDeliveryResponse(deliveryRequest, response.getHttpResponse());
telemetryService.addTelemetry(deliveryRequest, timer, targetDeliveryResponse, response.getParsingTime(), response.getResponseSize());
return new ResponseStatus(response.getHttpResponse().getStatus(), response.getHttpResponse().getStatusText());
});
}
use of com.adobe.target.delivery.v1.model.Telemetry in project target-java-sdk by adobe.
the class TelemetryService method getTelemetry.
public Telemetry getTelemetry() {
List<TelemetryEntry> telemetryEntryList = new ArrayList<>();
TelemetryEntry telemetryEntry;
while ((telemetryEntry = storedTelemetries.poll()) != null) {
telemetryEntryList.add(telemetryEntry);
}
return new Telemetry().entries(telemetryEntryList);
}
use of com.adobe.target.delivery.v1.model.Telemetry in project target-java-sdk by adobe.
the class TelemetryServiceTest method testTelemetryForServerSide.
/**
* Test case to call get offers for server side, in first request we capture the telemetry & in
* next call we send it with any getOffers() call or sendNotifications() call
*
* @throws NoSuchFieldException
*/
@Test
void testTelemetryForServerSide() throws NoSuchFieldException {
setup(true, DecisioningMethod.SERVER_SIDE, "testTelemetryForServerSide");
Context context = getContext();
PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
ExecuteRequest executeRequest = getMboxExecuteRequest();
String nonDefaultToken = "non-default-token";
TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).property(new Property().token(nonDefaultToken)).decisioningMethod(DecisioningMethod.SERVER_SIDE).build();
TargetDeliveryResponse targetDeliveryResponse1 = targetJavaClient.getOffers(targetDeliveryRequest);
assertNull(targetDeliveryResponse1.getRequest().getTelemetry());
// In next call we see telemetry data added to the deliveryRequest
TargetDeliveryResponse targetDeliveryResponse2 = targetJavaClient.getOffers(targetDeliveryRequest);
verify(telemetryServiceSpy, atLeast(2)).getTelemetry();
verify(telemetryServiceSpy, times(2)).addTelemetry(any(TargetDeliveryRequest.class), any(TimingTool.class), any(TargetDeliveryResponse.class), any(Double.class), any(Long.class));
assertEquals(1, telemetryServiceSpy.getTelemetry().getEntries().size());
assertNotNull(targetDeliveryResponse2);
assertNotNull(targetDeliveryResponse2.getRequest());
assertNotNull(targetDeliveryResponse2.getRequest().getTelemetry());
assertEquals(1, targetDeliveryResponse2.getRequest().getTelemetry().getEntries().size());
}
Aggregations