posthog-js-lite 3.4.2 → 3.5.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Next
2
2
 
3
+ # 3.5.1 – 2025-05-06
4
+
5
+ ## Fixed
6
+
7
+ 1. Fix exported file extensions to work with older Node versions
8
+
9
+ # 3.5.0 – 2025-04-17
10
+
11
+ ## Added
12
+
13
+ 1. chore: roll out new flag evaluation backend to majority of customers
14
+
15
+ # 3.4.2 - 2025-02-27
16
+
17
+ ## Added
18
+
19
+ 1. Added `captureHistoryEvents` option to automatically capture navigation events in single-page applications using the History API.
20
+
21
+ ## Fixed
22
+
23
+ 1. apiKey cannot be empty.
24
+
3
25
  # 3.4.2 - 2025-02-27
4
26
 
5
27
  ## Fixed
package/README.md CHANGED
@@ -72,4 +72,23 @@ posthog.onFeatureFlag('my-feature-flag', (value) => {
72
72
  // Opt users in or out, persisting across sessions (default is they are opted in)
73
73
  posthog.optOut() // Will stop tracking
74
74
  posthog.optIn() // Will start tracking
75
+
76
+ ## History API Navigation Tracking
77
+
78
+ Single-page applications (SPAs) typically use the History API (`pushState`, `replaceState`) for navigation instead of full page loads. By default, PostHog only tracks the initial page load.
79
+
80
+ To automatically track navigation events in SPAs, enable the `captureHistoryEvents` option:
81
+
82
+ ```ts
83
+ const posthog = new PostHog('my-api-key', {
84
+ captureHistoryEvents: true
85
+ })
75
86
  ```
87
+
88
+ When enabled, PostHog will:
89
+ - Track calls to `history.pushState()` and `history.replaceState()`
90
+ - Track `popstate` events (browser back/forward navigation)
91
+ - Send these as `$pageview` events with the current URL and pathname
92
+ - Include the navigation type (`pushState`, `replaceState`, or `popstate`) as a property
93
+
94
+ This ensures accurate page tracking in modern web applications without requiring manual pageview capture calls.