@rakutenanalytics/ral
v1.11.0
Published
Rakuten Analytics JavaScript SDK.
Readme
@rakutenanalytics/ral
🚀 Modern ES Module version of Rakuten Analytics Library (RAL)
✨ What's New
This is the ES Module version of the Rakuten Analytics Library, designed to solve version conflicts and modernize your analytics implementation. Unlike the traditional global variable approach, this package allows you to import RAL as a module, giving you better control and avoiding conflicts when multiple versions are used on the same page.
🎯 Why This Package Exists
The Problem We Solved
Previously, ral.js was loaded as a global variable (window.RAL), which caused conflicts when:
- Multiple teams used different versions of RAL on the same page
- Different parts of an application required different RAL versions
- Updating RAL versions required extensive regression testing across all teams
Our Solution
✅ ES Module Version: Import RAL as a module for better isolation
✅ Version Independence: Each team can use their preferred RAL version
✅ Zero Global Conflicts: No more window.RAL overwrites
✅ Backward Compatibility: Global variable version still available via CDN
📦 Installation
npm install @rakutenanalytics/ral🔄 Migration Guide
From Global Variable to ES Module
Before (Global Variable):
// Old way
window.RAL = window.RAL || {};
window.RAL.callQueue = window.RAL.callQueue || [];
window.RAL.callQueue.push(['setAccountId', 999]);
window.RAL.callQueue.push(['setServiceId', 999]);
window.RAL.callQueue.push(['setEvent', 'pv']);After (ES Module):
// New way
import { createRAL } from '@rakutenanalytics/ral';
const RAL = createRAL();
RAL.callQueue.push(['setAccountId', 999]);
RAL.callQueue.push(['setServiceId', 999]);
RAL.callQueue.push(['setEvent', 'pv']);