@grainql/analytics-web 3.0.3 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1557,10 +1557,23 @@ class GrainAnalytics {
1557
1557
  const userId = options.userId || this.getEffectiveUserIdInternal();
1558
1558
  const immediateKeys = options.immediateKeys || [];
1559
1559
  const properties = options.properties || {};
1560
+ // Include currentUrl from options, or automatically get it from window.location if available
1561
+ // Strip query parameters and hash to match backend normalization
1562
+ let currentUrl = options.currentUrl ?? (typeof window !== 'undefined' ? window.location.href : undefined);
1563
+ if (currentUrl) {
1564
+ try {
1565
+ const urlObj = new URL(currentUrl);
1566
+ currentUrl = `${urlObj.protocol}//${urlObj.host}${urlObj.pathname}`;
1567
+ }
1568
+ catch {
1569
+ // If URL parsing fails, use as-is
1570
+ }
1571
+ }
1560
1572
  const request = {
1561
1573
  userId,
1562
1574
  immediateKeys,
1563
1575
  properties,
1576
+ currentUrl,
1564
1577
  };
1565
1578
  let lastError;
1566
1579
  for (let attempt = 0; attempt <= this.config.retryAttempts; attempt++) {
package/dist/index.mjs CHANGED
@@ -1516,10 +1516,23 @@ export class GrainAnalytics {
1516
1516
  const userId = options.userId || this.getEffectiveUserIdInternal();
1517
1517
  const immediateKeys = options.immediateKeys || [];
1518
1518
  const properties = options.properties || {};
1519
+ // Include currentUrl from options, or automatically get it from window.location if available
1520
+ // Strip query parameters and hash to match backend normalization
1521
+ let currentUrl = options.currentUrl ?? (typeof window !== 'undefined' ? window.location.href : undefined);
1522
+ if (currentUrl) {
1523
+ try {
1524
+ const urlObj = new URL(currentUrl);
1525
+ currentUrl = `${urlObj.protocol}//${urlObj.host}${urlObj.pathname}`;
1526
+ }
1527
+ catch {
1528
+ // If URL parsing fails, use as-is
1529
+ }
1530
+ }
1519
1531
  const request = {
1520
1532
  userId,
1521
1533
  immediateKeys,
1522
1534
  properties,
1535
+ currentUrl,
1523
1536
  };
1524
1537
  let lastError;
1525
1538
  for (let attempt = 0; attempt <= this.config.retryAttempts; attempt++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grainql/analytics-web",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "description": "Lightweight TypeScript SDK for sending analytics events and managing remote configurations via Grain's REST API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",