Aws-sdk-android: Pinpoint: Sending more than 100 events in one submitEvents

Created on 26 May 2019  路  7Comments  路  Source: aws-amplify/aws-sdk-android

State your question
How do I send more than 100 events at once?

Which AWS Services are you utilizing?
PinpointManager - AnalyticsClient

Provide code snippets (if applicable)

for (int i = 0; i < 105; i++) {
                        final AnalyticsEvent event =
                                pinpointManager.getAnalyticsClient().createEvent("EventName")
                                        .withAttribute("DemoAttribute1", "DemoAttributeValue1")
                                        .withAttribute("DemoAttribute2", "DemoAttributeValue2")
                                        .withMetric("DemoMetric1", Math.random());
                        pinpointManager.getAnalyticsClient().recordEvent(event);
}
pinpointManager.getAnalyticsClient().submitEvents();

Environment(please complete the following information):

  • SDK Version: [e.g. 2.6.25]
    2.13

Device Information (please complete the following information):

  • Device: [e.g. Pixel XL, Simulator]
  • Android Version: [e.g. Nougat 7.1.2]
  • Specific to simulators:
    all

I'm getting the following error and losing all event information. How can I just split the stored events to several requests? maybe I need to remove sandbox limitations? what am I doing wrong?

E/EventRecorder: Failed to submit events to EventService: statusCode: 400 errorCode: 
    com.amazonaws.services.pinpoint.model.BadRequestException: The number of events per BatchItem should be less than or equal to 100. (Service: AmazonPinpoint; Status Code: 400; Error Code: BadRequestException; Request ID: acaacc6b-7fc5-11e9-ae65-3774a34e8d2c)
        at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:730)
        at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:405)
        at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:212)
        at com.amazonaws.services.pinpoint.AmazonPinpointClient.invoke(AmazonPinpointClient.java:4037)
        at com.amazonaws.services.pinpoint.AmazonPinpointClient.putEvents(AmazonPinpointClient.java:3074)
        at com.amazonaws.mobileconnectors.pinpoint.internal.event.EventRecorder.submitEventsAndEndpoint(EventRecorder.java:382)
        at com.amazonaws.mobileconnectors.pinpoint.internal.event.EventRecorder.submitEventsAndEndpoint(EventRecorder.java:361)
        at com.amazonaws.mobileconnectors.pinpoint.internal.event.EventRecorder.processEvents(EventRecorder.java:332)
        at com.amazonaws.mobileconnectors.pinpoint.internal.event.EventRecorder$1.run(EventRecorder.java:246)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
E/EventRecorder: Failed submission of 105 events, events will be removed from the local database. 
    com.amazonaws.services.pinpoint.model.BadRequestException: The number of events per BatchItem should be less than or equal to 100. (Service: AmazonPinpoint; Status Code: 400; Error Code: BadRequestException; Request ID: acaacc6b-7fc5-11e9-ae65-3774a34e8d2c)
        at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:730)
        at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:405)
        at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:212)
        at com.amazonaws.services.pinpoint.AmazonPinpointClient.invoke(AmazonPinpointClient.java:4037)
        at com.amazonaws.services.pinpoint.AmazonPinpointClient.putEvents(AmazonPinpointClient.java:3074)
        at com.amazonaws.mobileconnectors.pinpoint.internal.event.EventRecorder.submitEventsAndEndpoint(EventRecorder.java:382)
        at com.amazonaws.mobileconnectors.pinpoint.internal.event.EventRecorder.submitEventsAndEndpoint(EventRecorder.java:361)
        at com.amazonaws.mobileconnectors.pinpoint.internal.event.EventRecorder.processEvents(EventRecorder.java:332)
        at com.amazonaws.mobileconnectors.pinpoint.internal.event.EventRecorder$1.run(EventRecorder.java:246)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)

If you need help with understanding how to implement something in particular then we suggest that you first look into our developer guide. You can also simplify your process of creating an application, as well as the associated backend setup by using the Amplify CLI.

Feature Request Pinpoint closing-soon-if-no-response

All 7 comments

@ronzeidman This is currently a hard limit imposed by the Pinpoint service. We will take this as a backlog item to add client side validation to enforce the limits imposed by the Pinpoint Service.

@kvasukib thanks for the response.
From what you're saying can I understand that it's by design? So even when you enforce a client side validation the best thing you can do is to truncate the events to fit the request (and lose the old unsent data) and you won't split it to several requests (conserving all the data). Right?

@ronzeidman Not necessarily. The ideal situation would be to batch up-to 100 events in a single network call to Pinpoint and send multiple batches from the events stored in the local database on the device so we avoid data loss.

The limit of 100 events per network call is imposed by Pinpoint service and cannot be altered at this moment. See https://docs.aws.amazon.com/pinpoint/latest/developerguide/limits.html#limits-events for more information on the limits.

Thanks, should I track this question for the fix or you've opened a new issue I should subscribed to?

@ronzeidman I have tagged this as a feature request, so we will use this GitHub issue for tracking it.

We release the fix in 2.13.7 version of the SDK. Please refer to the CHANGELOG for more details.

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mockturtl picture mockturtl  路  4Comments

PikkaPikkachu picture PikkaPikkachu  路  4Comments

pedronveloso picture pedronveloso  路  3Comments

logo17 picture logo17  路  4Comments

chorniyn picture chorniyn  路  3Comments