Amazon Pinpoint
Developer Guide

Setting Up Event Streaming

You can set up Amazon Pinpoint to send data about campaigns and transactional messages to an Amazon Kinesis stream or an Amazon Kinesis Data Firehose delivery stream.

This section includes information about setting up event streaming programmatically. You can also use the Amazon Pinpoint console to set up event streaming. For information about setting up event streaming by using the Amazon Pinpoint console, see Event Stream Settings in the Amazon Pinpoint User Guide.

Prerequisites

The examples in this section require the following input:

AWS CLI

The following AWS CLI example uses the put-event-stream command. This command configures Amazon Pinpoint to send app and campaign events to a Kinesis stream:

aws pinpoint put-event-stream \ --application-id projectId \ --write-event-stream DestinationStreamArn=streamArn,RoleArn=roleArn

AWS SDK for Java

The following Java example configures Amazon Pinpoint to send app and campaign events to a Kinesis stream:

public PutEventStreamResult createEventStream(AmazonPinpoint pinClient, String appId, String streamArn, String roleArn) { WriteEventStream stream = new WriteEventStream() .withDestinationStreamArn(streamArn) .withRoleArn(roleArn); PutEventStreamRequest request = new PutEventStreamRequest() .withApplicationId(appId) .withWriteEventStream(stream); return pinClient.putEventStream(request); }

This example constructs a WriteEventStream object that stores the ARNs of the Kinesis stream and the IAM role. The WriteEventStream object is passed to a PutEventStreamRequest object to configure Amazon Pinpoint to stream events for a specific app. The PutEventStreamRequest object is passed to the putEventStream method of the Amazon Pinpoint client.

You can assign a Kinesis stream to multiple apps. If you do this, Amazon Pinpoint sends event data from each app to the stream, which enables you to analyze the data as a collection. The following example method accepts a list of app IDs, and it uses the previous example method, createEventStream, to assign a stream to each app:

public List<PutEventStreamResult> createEventStreamFromAppList( AmazonPinpoint pinClient, List<String> appIDs, String streamArn, String roleArn) { return appIDs.stream() .map(appId -> createEventStream(pinClient, appId, streamArn, roleArn)) .collect(Collectors.toList()); }

Although you can assign one stream to multiple apps, you can't assign multiple streams to one app.

Disabling Event Streaming

If you assign a Kinesis stream to an app, you can disable event streaming for that app. Amazon Pinpoint stops streaming the events to Kinesis, but you can view event analytics by using the Amazon Pinpoint console.

AWS CLI

Use the delete-event-stream command:

aws pinpoint delete-event-stream --application-id application-id

AWS SDK for Java

Use the deleteEventStream method of the Amazon Pinpoint client:

pinClient.deleteEventStream(new DeleteEventStreamRequest().withApplicationId(appId));