posthog-js-lite 3.4.1 → 3.5.0

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.0 – 2025-04-17
4
+
5
+ ## Added
6
+
7
+ 1. chore: roll out new flag evaluation backend to majority of customers
8
+
9
+ # 3.4.2 - 2025-02-27
10
+
11
+ ## Added
12
+
13
+ 1. Added `captureHistoryEvents` option to automatically capture navigation events in single-page applications using the History API.
14
+
15
+ ## Fixed
16
+
17
+ 1. apiKey cannot be empty.
18
+
19
+ # 3.4.2 - 2025-02-27
20
+
21
+ ## Fixed
22
+
23
+ 1. Supports gracefully handling quotaLimited responses from the PostHog API for feature flags.
24
+
3
25
  # 3.4.1 - 2025-02-20
4
26
 
5
27
  ## Fixed
package/README.md CHANGED
@@ -28,9 +28,9 @@ const posthog = new PostHog('my-api-key', {
28
28
  posthog.capture('my-event', { myProperty: 'foo' })
29
29
 
30
30
  // Identify a user (e.g. on login)
31
- posthog.identify('my-unique-user-id', { email: 'exampke@posthog.com', name: 'Jane Doe' })
31
+ posthog.identify('my-unique-user-id', { email: 'example@posthog.com', name: 'Jane Doe' })
32
32
  // ...or with Set Once additional properties
33
- posthog.identify('my-unique-user-id', { $set: { email: 'exampke@posthog.com', name: 'Jane Doe' }, $set_once: { vip: true } })
33
+ posthog.identify('my-unique-user-id', { $set: { email: 'example@posthog.com', name: 'Jane Doe' }, $set_once: { vip: true } })
34
34
 
35
35
  // Reset a user (e.g. on logout)
36
36
  posthog.reset()
@@ -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.