@usermaven/nextjs 1.3.0 → 1.3.2

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.
Files changed (2) hide show
  1. package/lib/index.es.js +16 -5
  2. package/package.json +1 -1
package/lib/index.es.js CHANGED
@@ -788,6 +788,13 @@ function _copyAndTruncateStrings(object, maxStringLength) {
788
788
  return value;
789
789
  });
790
790
  }
791
+ // Function to find the closest link element
792
+ function _findClosestLink(element) {
793
+ while (element && element.tagName && element.tagName.toLowerCase() !== 'a') {
794
+ element = element.parentNode;
795
+ }
796
+ return element;
797
+ }
791
798
 
792
799
  /*
793
800
  * Get the className of an element, accounting for edge cases where element.className is an object
@@ -1399,8 +1406,8 @@ _safewrap_instance_methods(autocapture);
1399
1406
 
1400
1407
  var VERSION_INFO = {
1401
1408
  env: 'production',
1402
- date: '2024-01-31T10:00:47.158Z',
1403
- version: '1.3.0'
1409
+ date: '2024-02-20T05:52:39.092Z',
1410
+ version: '1.3.2'
1404
1411
  };
1405
1412
  var USERMAVEN_VERSION = VERSION_INFO.version + "/" + VERSION_INFO.env + "@" + VERSION_INFO.date;
1406
1413
  var MAX_AGE_TEN_YEARS = 31622400 * 10;
@@ -2305,14 +2312,18 @@ var UsermavenClientImpl = /** @class */ (function () {
2305
2312
  var domains = options.domains || [];
2306
2313
  // Listen for all clicks on the page
2307
2314
  document.addEventListener('click', function (event) {
2308
- // Check if the clicked element is a link
2309
- var target = event.target;
2310
- if (target.tagName.toLowerCase() === 'a') {
2315
+ // Find the closest link
2316
+ var target = _findClosestLink(event.target);
2317
+ if (target) {
2311
2318
  // Check if the link is pointing to a different domain
2312
2319
  var href = target.getAttribute('href');
2313
2320
  if (href && href.startsWith('http')) {
2314
2321
  var url = new URL(href);
2315
2322
  var cookie = getCookie(cookieName);
2323
+ // Skip the link if it's pointing to the current domain
2324
+ if (url.hostname === window.location.hostname) {
2325
+ return;
2326
+ }
2316
2327
  if (domains.includes(url.hostname) && cookie) {
2317
2328
  // Add the '_um' parameter to the URL
2318
2329
  url.searchParams.append('_um', cookie);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usermaven/nextjs",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Usermaven JavaScript SDK for NextJS",
5
5
  "author": "Usermaven <hello@usermaven.com>",
6
6
  "license": "MIT",