@ops-ai/react-router-toggly 1.0.1 → 1.1.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,24 @@
1
1
  # Changelog
2
2
 
3
+
4
+ ## [1.1.0] - 2026-09-18
5
+
6
+ ### Added
7
+ - Default browser telemetry with independent collector URL, configurable flush interval and explicit opt-out.
8
+ - Public usage, view, app-level counter, latest-value gauge and awaitable flush methods on the provider context.
9
+
10
+ ### Fixed
11
+ - Synchronize changed provider groups/claims before passive refresh consumers without replacing the telemetry owner or overriding explicit identity context on equivalent props.
12
+ - Snapshot only selected definitions and applicable local gates for each check while preserving immutable callback capture and short-circuit counts.
13
+ - Preserve immutable selected definitions through entity/local callbacks and keep only the newest overlapping refresh and asynchronous hook completion.
14
+ - Count effective local/entity-gated browser checks once per evaluated leaf, preserving short circuit and negation without duplicate component evaluation.
15
+ - Isolate telemetry and hydrated snapshots when app/environment changes; release browser resources on real unmount while preserving StrictMode replay.
16
+ - Capture original flag and attribution snapshots before reentrant callbacks; isolate failed/new contexts and late responses.
17
+ - Prevent delayed refresh/identity completion from updating a disposed provider and discard pending telemetry on incompatible transport replacement.
18
+
19
+ ### Changed
20
+ - Browser definitions and telemetry support host-minted instance tokens with precedence over client targeting, plus client identity fallback. Trusted server telemetry and loader/action behavior remain unchanged.
21
+
3
22
  ## 1.0.1
4
23
 
5
24
  2026-09-17
package/README.md CHANGED
@@ -7,6 +7,56 @@ in-source (not published as a separate package).
7
7
  > Migrating from `@ops-ai/remix-toggly-*`? Those packages are deprecated. Install
8
8
  > `@ops-ai/react-router-toggly` and import from `/client` and `/server`.
9
9
 
10
+
11
+ ## Browser telemetry
12
+
13
+ `TogglyProvider` and `RouterTogglyProvider` each own one compact browser reporter.
14
+ With an app key, telemetry is enabled by default. Access explicit events through
15
+ `useToggly()` or `useTogglyContext()`:
16
+
17
+ ```tsx
18
+ const toggly = useToggly()
19
+ // Call these from application actions or an explicit view event.
20
+ toggly.recordUsage('Checkout')
21
+ toggly.recordView('Checkout', 'control')
22
+ toggly.incrementCounter('orders', 2)
23
+ toggly.setGauge('cartSize', 3)
24
+ await toggly.flushTelemetry()
25
+ ```
26
+
27
+ Usage and view variants default to `enabled`; labels contain 1–64 ASCII letters,
28
+ digits, underscores or hyphens. Counters sum nonnegative integer deltas, and gauges
29
+ retain the latest finite nonnegative value. A single value cannot exceed 1,000,000.
30
+ Metrics are app-level and contain no feature attribution.
31
+
32
+ Automatic checks record each evaluated feature after local and entity gates,
33
+ before negation. Short-circuited keys do not count. Direct cached reads, hooks and
34
+ components count actual evaluations; hydration and refresh snapshots alone do
35
+ not. Rendering never implicitly records usage or views. Boolean A/B helpers use
36
+ enabled/disabled check labels; explicit events may specify a variant label.
37
+
38
+ Provider `config` accepts `enableTelemetry` (default true), `metricsBaseUrl`
39
+ (default `https://metrics.toggly.io`), and `telemetryFlushIntervalMs` (30000–60000 ms,
40
+ default 45000). Set `enableTelemetry: false` to disable browser telemetry.
41
+ `enableUsageTracking: false` disables checks/usage/views, and `enableMetrics: false`
42
+ disables business metrics. Invalid intervals use the default. Invalid collector
43
+ URLs disable telemetry without changing feature results; use absolute HTTP(S)
44
+ URLs without credentials, query or fragment.
45
+
46
+ SSR/build, keyless and opted-out providers create no frontend reporter resources.
47
+ Payloads contain app/environment, optional `i` (host-minted instance token) or `u` (client identity), feature/variant counts and numeric metrics. Claims, groups, entity data and timestamps are excluded. Requests omit
48
+ credentials, use native gzip when available, and have bounded buffers, timeout
49
+ and retries. Page hiding and unmount trigger a bounded best-effort flush; await
50
+ `flushTelemetry()` to wait for the current best-effort attempt before navigation; it does not guarantee server acknowledgement.
51
+
52
+ Set `config.instanceId` to a token minted by your trusted host. It takes precedence over client identity/groups/claims in browser definition requests and telemetry. Rotate it with `await context.identify(identity, {instanceId})`; `identify(identity)` clears the token and uses client targeting. `reset()` clears identity and token. Groups/claims can be updated through the existing identify context. Changed provider groups/claims commit to the same owner, clear prior results to defaults, and become active on the next existing refresh trigger; they do not start an extra request. Omitted groups/claims clear those fields. Equivalent props preserve context explicitly set by `identify`. Failed context refreshes retain the new targeting scope with configured defaults; old results and pending responses cannot cross that boundary. Context changes preserve already queued events under their original attribution.
53
+
54
+ Each mounted provider is independent. App/environment replacement releases the
55
+ old reporter without relabeling its queue (incompatible collector/transport or opt-out replacement discards pending old data), and ignores loader snapshots explicitly
56
+ labeled for another owner. StrictMode effect replay preserves the committed owner;
57
+ real unmount releases it and remount creates a fresh one. Browser telemetry does
58
+ not change trusted server loader/action metrics or their existing APIs.
59
+
10
60
  ## Install
11
61
 
12
62
  ```bash