The Amazon Kinesis Firehose analytics provider allows you to send analytics data to an [Amazon Kinesis Firehose](https://aws.amazon.com/kinesis/data-firehose) stream for reliably storing data.

## Installation and Configuration

Register the _AWSKinesisFirehoseProvider_ with the Analytics category:

```javascript
import { Analytics, AWSKinesisFirehoseProvider } from 'aws-amplify';
Analytics.addPluggable(new AWSKinesisFirehoseProvider());
```

Ensure you have [setup IAM permissions](https://docs.aws.amazon.com/firehose/latest/dev/controlling-access.html) for `PutRecordBatch`.

Example IAM policy for Amazon Kinesis Firehose:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["firehose:PutRecord", "firehose:PutRecordBatch"],
      "Resource": "*"
    }
  ]
}
```

Configure Kinesis Firehose:

```javascript
// Configure the plugin after adding it to the Analytics module
Analytics.configure({
  AWSKinesisFirehose: {
    // OPTIONAL -  Amazon Kinesis Firehose 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
  }
});
```

## Storing data

You can send a data to a Kinesis Firehose stream with the standard `record` method. Any data is acceptable and `streamName` is required:

```javascript
Analytics.record(
  {
    data: {
      // The data blob to put into the record
    },
    streamName: 'myKinesisStream'
  },
  'AWSKinesisFirehose'
);
```
