Streaming analytics data
The Amazon Kinesis analytics provider allows you to send analytics data to an Amazon Kinesis stream for real-time processing.
Installation and Configuration
Register the AWSKinesisProvider with the Analytics category:
import { Analytics, AWSKinesisProvider } from 'aws-amplify';Analytics.addPluggable(new AWSKinesisProvider());
If you did not use the CLI, ensure you have setup IAM permissions for PutRecords
.
Example IAM policy for Amazon Kinesis:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": ["kinesis:PutRecord", "kinesis:PutRecords"], "Resource": "*" } ]}
For more information visit Amazon Kinesis Developer Documentation.
Configure Kinesis:
// Configure the plugin after adding it to the Analytics moduleAnalytics.configure({ AWSKinesis: { // OPTIONAL - Amazon Kinesis service region region: 'XX-XXXX-X',
// OPTIONAL - The buffer size for events in number of items. bufferSize: 1000,
// OPTIONAL - The number of events to be deleted from the buffer when flushed. flushSize: 100,
// OPTIONAL - The interval in milliseconds to perform a buffer check and flush if necessary. flushInterval: 5000, // 5s
// OPTIONAL - The limit for failed recording retries. resendLimit: 5 }});
Stream data
You can send a data to a Kinesis stream with the standard record()
method:
Analytics.record( { data: { // The data blob to put into the record }, // OPTIONAL partitionKey: 'myPartitionKey', streamName: 'myKinesisStream' }, 'AWSKinesis');