This package is an internal plugin for the AWS Amplify Command Line Interface (CLI) that enables developers to integrate analytics capabilities into their full-stack applications. It simplifies the provisioning and management of AWS analytics services, primarily Amazon Pinpoint and (for the Amplify JavaScript library) Amazon Kinesis, within an Amplify project. As of `npm@4.4.2`, it operates within the larger `@aws-amplify/cli` ecosystem, which is currently at `v14.3.0`. The Amplify CLI project maintains a frequent release cadence, with various component packages receiving updates multiple times per month. Key differentiators include its deep integration with the Amplify ecosystem, providing a streamlined, guided CLI workflow for adding, updating, and removing analytics backend resources, abstracting away direct AWS SDK calls or complex CloudFormation template management for user engagement and tracking services. It leverages Cognito Identity Pools for user identification, supporting both authenticated and unauthenticated analytics data collection.
npm install amplify-category-analyticsNo compatibility data collected yet for this library.
Demonstrates initializing an Amplify project and adding analytics via the CLI.
Upgrade your Node.js environment to version 22 or later. Use `nvm install 22 && nvm use 22` or a similar tool to manage Node.js versions.
Refer to the Amplify JavaScript Library v6 migration guide for Analytics. Update client-side imports and API calls, e.g., use `import { record } from 'aws-amplify/analytics'` and adapt to synchronous `record` calls and the `_session.start` event for session tracking. [25]For new projects, evaluate Kinesis for event collection when adding analytics. For existing Pinpoint users, review AWS migration guidance to transition to recommended services before October 2026. [7, 25]
Inspect the IAM policies attached to your Cognito Identity Pool roles (e.g., `Cognito_YourIdentityPoolNameAuth_Role` and `Cognito_YourIdentityPoolNameUnauth_Role`) via the AWS console. Ensure they grant necessary permissions for `mobiletargeting:PutEvents`, `mobiletargeting:UpdateEndpoints`, or `kinesis:PutRecords` if using Kinesis. [2, 21]
Before major changes or removals, back up your `amplify/backend` folder. If `amplify push` fails, examine the CloudFormation stack events in the AWS console for detailed error messages. In severe cases, manual cleanup of resources in the AWS console might be necessary, followed by re-adding the analytics category locally. [22]
In the AWS IAM console, locate the role associated with your Cognito Identity Pool's unauthenticated users. Add a policy that grants `mobiletargeting:PutEvents` and `mobiletargeting:UpdateEndpoints` permissions to the Pinpoint resource.
Verify the Pinpoint project ID and AWS region in your `amplifyconfiguration.json` (or `aws-exports.js`) match an existing Pinpoint project in the correct region in the AWS Pinpoint console. If deleted, you may need to `amplify remove analytics` and `amplify add analytics` again.
Check the detailed CloudFormation events in the AWS CloudFormation console for the specific Amplify stack (e.g., `amplify-yourappname-dev-xxxxxx-analytics`). The events will provide more specific error messages to diagnose misconfigurations or conflicts. Correct the issues in your local `amplify/backend/analytics` files and try `amplify push` again.
Ensure `Amplify.configure` is called early in your application's lifecycle with the correct configuration object (`amplifyconfiguration.json`). Verify that `record` events are being triggered in your client-side code and check the browser's developer console for any errors or network request failures to Pinpoint endpoints. Confirm the IAM roles have `mobiletargeting:PutEvents` permission. [2, 7]