Registry / communication / rudder-sdk-js

rudder-sdk-js

JSON →
library2.52.11jsnpmunverified

The `rudder-sdk-js` package is the original JavaScript SDK for RudderStack, a customer data platform. It enables tracking of customer event data from websites and sending it to various destinations via the RudderStack platform. The current stable version observed in the npm metadata is `2.52.11`. However, this specific package is explicitly marked as *deprecated* and is no longer actively maintained. Users are strongly recommended to migrate to the newer `@rudderstack/analytics-js` package for continued support, enhanced features, and security updates. This SDK allowed for identifying users, tracking actions, and managing event readiness through a global `rudderanalytics` object. Its primary differentiator was providing a unified API for sending data to multiple analytics and marketing tools, acting as a server-side customer data router.

npm install rudder-sdk-js
INSTALL
IMPORT
SIG · RUDDER-SDK-JS
R
rudder-sdk-js
communicationjavascriptv2.52.11
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

rudderanalytics
window.rudderanalytics.load('YOUR_WRITE_KEY', 'YOUR_DATAPLANE_URL');
import { rudderanalytics } from 'rudder-sdk-js';
This deprecated package is typically loaded via a script tag, creating a global `window.rudderanalytics` object. Direct ESM/CJS module imports are not the primary or recommended way to interact with this SDK.
track
window.rudderanalytics.track('Event Name', { property: 'value' });
import { track } from 'rudder-sdk-js';
`track` is a method available on the global `rudderanalytics` object after successful initialization. This pattern is for the deprecated SDK.
Analytics (new package)
import { Analytics } from '@rudderstack/analytics-js';
import { Analytics } from 'rudder-sdk-js';
This import is for the *recommended migration target*, `@rudderstack/analytics-js`, which replaces `rudder-sdk-js`.

Demonstrates how to initialize the deprecated RudderStack JavaScript SDK via a script tag and track a product view event after it's ready, along with user identification.

<html> <head> <title>RudderStack Deprecated SDK Quickstart</title> <script type="text/javascript"> !function(){var e=window.rudderanalytics=window.rudderanalytics||[];e.methods=["load","page","track","identify","alias","group","ready","reset","getAnonymousId","setAnonymousId"],e.factory=function(t){return function(){var n=Array.prototype.slice.call(arguments);n.unshift(t);e.push(n);return e}};for(var t=0;t<e.methods.length;t++){var n=e.methods[t];e[n]=e.factory(n)}e.load=function(t,n){var r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src="https://cdn.rudderlabs.com/rudder-analytics.min.js";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(r,a);e._writeKey=t;e._options=n};}(); // Initialize RudderStack (replace with your actual keys) rudderanalytics.load('YOUR_WRITE_KEY', 'YOUR_DATAPLANE_URL'); rudderanalytics.ready(function() { console.log('RudderStack SDK is ready!'); rudderanalytics.track('Product Viewed', { productId: 'RS-123', productName: 'Example Product', category: 'Electronics' }); rudderanalytics.identify('user-123', { email: 'test@example.com', plan: 'premium' }); }); </script> </head> <body> <h1>Welcome to the website!</h1> <button onclick="rudderanalytics.track('Button Clicked', { buttonName: 'Test' })">Click Me</button> <p>Check your browser console and network requests for RudderStack events.</p> </body> </html>
Debug
Known issues
breakingThis `rudder-sdk-js` package is officially deprecated and is no longer maintained. Continued use is not recommended due to lack of security updates, bug fixes, and new features.
fix
Migrate your integration to the actively supported `@rudderstack/analytics-js` package following the official migration guide available on RudderStack's documentation site.
affects: >=2.0.0
deprecatedThe service worker export has been moved from `rudder-sdk-js` to a separate, dedicated package, `@rudderstack/analytics-js-service-worker`. Attempting to use service worker features from `rudder-sdk-js` may result in errors or outdated behavior.
fix
If your project utilizes RudderStack's service worker capabilities, switch to using the `@rudderstack/analytics-js-service-worker` package explicitly.
affects: >=2.52.0
Errors
Common errors & fixes
ReferenceError: rudderanalytics is not defined
The SDK script has not loaded or executed correctly, or `rudderanalytics` is being accessed before it is globally available or before the `rudderanalytics.ready()` callback fires.
fix
Ensure the SDK script tag is correctly placed in the `<head>` section of your HTML and that all RudderStack API calls are made within the `rudderanalytics.ready()` callback or explicitly after the script has fully loaded.
This package is deprecated and no longer maintained.
This message (or similar warnings during installation/build) indicates that you are using the `rudder-sdk-js` package, which has been officially deprecated by RudderStack.
fix
Migrate your project to use the `@rudderstack/analytics-js` package. This new package offers enhanced features, ongoing maintenance, and critical security updates.
Upgrade
Version history
2.52.11latest on npm
Audit
Dependencies
@rudderstack/analytics-jsrequiredThis package is deprecated; migration to `@rudderstack/analytics-js` is strongly recommended for ongoing support and features.
Agent activity
49 hits · last 30 days
node
48
OpenAI (training)
1
Resources
rudder-sdk-js — npm install rudder-sdk-js · libregistry