@tracelog/lib 2.1.1 → 2.1.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.
@@ -688,6 +688,8 @@ interface State {
688
688
  hasStartSession: boolean;
689
689
  suppressNextScroll: boolean;
690
690
  scrollEventCount?: number;
691
+ sessionReferrer?: string;
692
+ sessionUtm?: UTM;
691
693
  }
692
694
 
693
695
  /**
@@ -1613,58 +1615,6 @@ declare class EventManager extends StateManager {
1613
1615
  * @internal
1614
1616
  */
1615
1617
  private cleanupExpiredSessionCounts;
1616
- /**
1617
- * Returns the referrer if it's external, or 'Direct' if internal/empty.
1618
- *
1619
- * **Purpose**: Filter out internal referrers (same domain) to ensure
1620
- * accurate traffic source attribution. Internal referrers occur when:
1621
- * - Session expires and user navigates within the same site
1622
- * - User opens new tab from an internal link
1623
- * - Page refresh after session timeout
1624
- *
1625
- * **Logic**:
1626
- * - Empty referrer → 'Direct'
1627
- * - Referrer from same domain or subdomain → 'Direct' (internal navigation)
1628
- * - External referrer → Returns original referrer
1629
- *
1630
- * **Subdomain Detection**:
1631
- * - `www.example.com` → `example.com` ✓ (internal)
1632
- * - `blog.example.com` → `example.com` ✓ (internal)
1633
- * - `example.com` → `www.example.com` ✓ (internal)
1634
- *
1635
- * @returns External referrer URL or 'Direct'
1636
- *
1637
- * @internal
1638
- */
1639
- private getExternalReferrer;
1640
- /**
1641
- * Checks if two hostnames belong to the same domain (including subdomains).
1642
- * Extracts root domain and compares to handle cross-subdomain navigation.
1643
- *
1644
- * @example
1645
- * isSameDomain('www.example.com', 'example.com') // true
1646
- * isSameDomain('app.example.com', 'www.example.com') // true
1647
- * isSameDomain('example.co.uk', 'app.example.co.uk') // true
1648
- *
1649
- * @param hostname1 - First hostname (e.g., 'www.example.com')
1650
- * @param hostname2 - Second hostname (e.g., 'app.example.com')
1651
- * @returns true if same root domain
1652
- *
1653
- * @internal
1654
- */
1655
- private isSameDomain;
1656
- /**
1657
- * Extracts the root (registrable) domain from a hostname.
1658
- * Handles both standard TLDs (.com, .org) and compound TLDs (.co.uk, .com.br).
1659
- *
1660
- * @example
1661
- * getRootDomain('www.example.com') // 'example.com'
1662
- * getRootDomain('app.blog.example.com') // 'example.com'
1663
- * getRootDomain('shop.example.co.uk') // 'example.co.uk'
1664
- *
1665
- * @internal
1666
- */
1667
- private getRootDomain;
1668
1618
  /**
1669
1619
  * Persists current session event counts to localStorage (debounced).
1670
1620
  *
@@ -688,6 +688,8 @@ interface State {
688
688
  hasStartSession: boolean;
689
689
  suppressNextScroll: boolean;
690
690
  scrollEventCount?: number;
691
+ sessionReferrer?: string;
692
+ sessionUtm?: UTM;
691
693
  }
692
694
 
693
695
  /**
@@ -1613,58 +1615,6 @@ declare class EventManager extends StateManager {
1613
1615
  * @internal
1614
1616
  */
1615
1617
  private cleanupExpiredSessionCounts;
1616
- /**
1617
- * Returns the referrer if it's external, or 'Direct' if internal/empty.
1618
- *
1619
- * **Purpose**: Filter out internal referrers (same domain) to ensure
1620
- * accurate traffic source attribution. Internal referrers occur when:
1621
- * - Session expires and user navigates within the same site
1622
- * - User opens new tab from an internal link
1623
- * - Page refresh after session timeout
1624
- *
1625
- * **Logic**:
1626
- * - Empty referrer → 'Direct'
1627
- * - Referrer from same domain or subdomain → 'Direct' (internal navigation)
1628
- * - External referrer → Returns original referrer
1629
- *
1630
- * **Subdomain Detection**:
1631
- * - `www.example.com` → `example.com` ✓ (internal)
1632
- * - `blog.example.com` → `example.com` ✓ (internal)
1633
- * - `example.com` → `www.example.com` ✓ (internal)
1634
- *
1635
- * @returns External referrer URL or 'Direct'
1636
- *
1637
- * @internal
1638
- */
1639
- private getExternalReferrer;
1640
- /**
1641
- * Checks if two hostnames belong to the same domain (including subdomains).
1642
- * Extracts root domain and compares to handle cross-subdomain navigation.
1643
- *
1644
- * @example
1645
- * isSameDomain('www.example.com', 'example.com') // true
1646
- * isSameDomain('app.example.com', 'www.example.com') // true
1647
- * isSameDomain('example.co.uk', 'app.example.co.uk') // true
1648
- *
1649
- * @param hostname1 - First hostname (e.g., 'www.example.com')
1650
- * @param hostname2 - Second hostname (e.g., 'app.example.com')
1651
- * @returns true if same root domain
1652
- *
1653
- * @internal
1654
- */
1655
- private isSameDomain;
1656
- /**
1657
- * Extracts the root (registrable) domain from a hostname.
1658
- * Handles both standard TLDs (.com, .org) and compound TLDs (.co.uk, .com.br).
1659
- *
1660
- * @example
1661
- * getRootDomain('www.example.com') // 'example.com'
1662
- * getRootDomain('app.blog.example.com') // 'example.com'
1663
- * getRootDomain('shop.example.co.uk') // 'example.co.uk'
1664
- *
1665
- * @internal
1666
- */
1667
- private getRootDomain;
1668
1618
  /**
1669
1619
  * Persists current session event counts to localStorage (debounced).
1670
1620
  *