The `amplitude-js` library is the original JavaScript SDK for integrating web applications with Amplitude Analytics, enabling developers to track user events, user properties, and revenue data. Currently at version 8.21.10, this SDK primarily receives maintenance updates, with new feature development and a TypeScript-first approach now concentrated in the newer `@amplitude/analytics-browser` package. While `amplitude-js` continues to be functional for existing projects, it is no longer recommended for new browser-based instrumentations and has deprecated support for React Native since version 8.0.0, advising migration to `@amplitude/react-native` for cross-platform applications and `@amplitude/node` for server-side environments. Its release cadence has slowed significantly, focusing on bug fixes and dependency upgrades. It differentiates itself as the foundational Amplitude SDK before the introduction of more specialized and modern alternatives.
npm install amplitude-jsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the Amplitude SDK, set a user ID and properties, and log two different events with associated properties. It showcases basic event tracking functionality in a browser context.
Upgrade all instances of `amplitude-js` to version 6.0.0 or higher across all related applications concurrently. Consider using the `cookieForceUpgrade` option if necessary to force all browsers to upgrade and delete old cookies.
Migrate your React Native projects to the dedicated `@amplitude/react-native` SDK. Refer to the official Amplitude migration guide for detailed steps.
For all new browser-based Amplitude instrumentations, use the `@amplitude/analytics-browser` SDK. If you are starting a new React Native project, use `@amplitude/react-native`. For Node.js environments, use `@amplitude/node`.
Upgrade to `amplitude-js` version 8.21.9 or higher to ensure `flushIntervalMillis=0` correctly disables the flush interval and allows for immediate event processing.
Avoid calling `amplitude.init()` directly in `_app.js` when using `getServerSideProps`. Instead, initialize the SDK client-side or consider dynamic imports and conditional initialization to ensure it only runs in the browser context for such pages. The `@amplitude/analytics-browser` SDK may offer more robust SSR solutions.
Verify your API key is correct during `amplitude.getInstance().init()`. Ensure events are being sent (e.g., `uploadIntervalMillis` configuration or `flushQueueSize`). Check browser console for errors or network requests to Amplitude. Use Amplitude's Chrome extension for real-time debugging.
Ensure the Amplitude SDK script tag is placed correctly in your HTML (ideally at the end of `<body>` or using `defer`). If using modules, verify `import amplitude from 'amplitude-js';` or `const amplitude = require('amplitude-js');` is at the top of your file and the module resolution is correct.Check for multiple Amplitude snippets loaded on the page. Ensure the Amplitude snippet is loaded only once and initialized correctly. If using the snippet, ensure it's not being overridden. Consider consolidating to a single, consistent loading mechanism (e.g., npm package) if possible.
Upgrade all client-side applications that share the same Amplitude API key to `amplitude-js` v6.0.0 or newer at the same time to ensure consistent cookie handling. Refer to the migration guide for additional options like `cookieForceUpgrade`.
No dependency data recorded yet.