@reservamos/browser-analytics 1.1.7 → 1.1.8-alpha.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 +8 -0
- package/README.md +12 -10
- package/dist/browser-analytics.cjs +2 -2
- package/dist/browser-analytics.cjs.map +1 -1
- package/dist/browser-analytics.esm.js +113 -53
- package/dist/browser-analytics.esm.js.map +1 -1
- package/dist/browser-analytics.iife.js +2 -2
- package/dist/browser-analytics.iife.js.map +1 -1
- package/package.json +2 -2
- package/src/init.test.ts +287 -0
- package/src/init.ts +34 -12
- package/src/services/fingerprint.test.ts +18 -0
- package/src/services/fingerprint.ts +2 -11
- package/src/services/mixpanel.test.ts +61 -0
- package/src/services/mixpanel.ts +16 -16
- package/src/track.test.ts +315 -71
- package/src/track.ts +88 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
- Add manual alpha and stable publication alongside automatic patch/minor/major releases for PRs merged into main. Alphas also support the temporary alpha-sbx branch; both paths allocate versions from npm, validate fully, and tag the exact source commit without version commits on main.
|
|
6
|
+
- Events called before Mixpanel is ready now wait up to 5 seconds instead of rejecting an unobserved promise. Expired attempts log a controlled diagnostic, release their resources, and do not replay after late readiness.
|
|
7
|
+
- A pending location permission or Fingerprint load no longer holds Tracker Ready. Core API is configured before listeners run; optional initialization waits are bounded to 3 seconds and pre-initialization fingerprint cache reads remain safe.
|
|
8
|
+
- Search, Payment Attempt, and Purchase Attempt are submitted before fresh Fingerprint identification and Bot Detection relay. View Results and other non-bot events continue with an empty fingerprint when retrieval fails.
|
|
9
|
+
- Blocked SDK localStorage no longer discards events or live Mixpanel identity. Cache fallback safely returns null when unavailable, and identify retains its controlled cache diagnostic and people updates.
|
|
10
|
+
|
|
3
11
|
## 1.1.7
|
|
4
12
|
|
|
5
13
|
- Delegate Bot Detection delivery to `js-api-client` 6.28.0's `fingerprint.sendObservation`: preserve SDK triggers and Mixpanel events, send `Fingerprint Requested` with configured Core API authentication, and use the client's bounded timeout instead of fetch keepalive.
|
package/README.md
CHANGED
|
@@ -44,23 +44,21 @@ window.addEventListener('Tracker Ready', () => {
|
|
|
44
44
|
});
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
+
Events called before Mixpanel is ready wait up to 5 seconds. If readiness never arrives, the SDK logs a controlled timeout and discards that attempt; later readiness does not replay it. Submission to Mixpanel does not guarantee remote delivery.
|
|
48
|
+
|
|
49
|
+
`Tracker Ready` means Mixpanel and Core API configuration are ready. Fingerprint and geolocation initialize concurrently afterward and may still be unavailable. `await analytics.init(config)` waits up to 3 seconds for those optional stages after Mixpanel loads; browser permission prompts and late results can outlive that wait.
|
|
50
|
+
|
|
47
51
|
`appName` is optional. When provided, it is sent as the `x-app-name` HTTP header on Datalake identify and anonymous-profile requests so the API can identify the originating client platform.
|
|
48
52
|
|
|
49
53
|
## Fingerprint Bot Detection relay
|
|
50
54
|
|
|
55
|
+
For `Search`, `Payment Attempt`, and `Purchase Attempt`, the original Mixpanel event uses the cached visitor ID or an empty fingerprint. Fresh identification and relay run afterward in the background. A pending or failed identification does not delay that submission. One fresh identification per eligible event remains; navigation may interrupt background work. Other events continue with an empty fingerprint if retrieval rejects.
|
|
56
|
+
|
|
51
57
|
Fingerprint Bot Detection results are retrieved through Fingerprint Server API by Core API. This browser SDK does not call Server API or accept its Secret API Key. It can obtain the request-scoped `requestId` and relay the identification context to Core API.
|
|
52
58
|
|
|
53
59
|
The SDK owns the eligible event list. Consumers do not configure a URL or choose events. Bot Detection currently runs on `Search`, `Payment Attempt`, and `Purchase Attempt`. The destination is built from the Core API `baseUrl`.
|
|
54
60
|
|
|
55
|
-
For those events, the
|
|
56
|
-
|
|
57
|
-
When identification succeeds, the original event contains:
|
|
58
|
-
|
|
59
|
-
```json
|
|
60
|
-
{
|
|
61
|
-
"User Fingerprint": "visitor-123"
|
|
62
|
-
}
|
|
63
|
-
```
|
|
61
|
+
For those events, fresh identification bypasses the Fingerprint SPA cache and runs in the background after the original event has been submitted. Its returned visitor ID and request ID are used for the relay; they do not replace the cached or empty fingerprint already submitted with the original event. Other events retain their existing cache selection and continue with an empty fingerprint if retrieval rejects.
|
|
64
62
|
|
|
65
63
|
After handing the original event to Mixpanel, the SDK sends this JSON payload to `${coreApiBaseUrl}/v1/fingerprint/bot-detection` with `POST`, `Content-Type: application/json`, optional `x-app-name`, and `keepalive: true`. The browser supplies the actual `Origin` header:
|
|
66
64
|
|
|
@@ -75,7 +73,7 @@ After handing the original event to Mixpanel, the SDK sends this JSON payload to
|
|
|
75
73
|
|
|
76
74
|
`distinctId` is omitted when Mixpanel cannot provide one. The Core API response is not used to modify the original event. The SDK sends the generated `requestId` only in the Core API relay payload. Core API owns the Fingerprint Server API lookup and any later enrichment.
|
|
77
75
|
|
|
78
|
-
Relay failures are logged with `console.error` and do not turn an event already submitted to Mixpanel into a tracking failure. If the Fingerprint agent is unavailable, the SDK preserves its existing fingerprint fallback, sends the Mixpanel event, and skips the relay.
|
|
76
|
+
Relay failures are logged with `console.error` and do not turn an event already submitted to Mixpanel into a tracking failure. If the Fingerprint agent is unavailable, the SDK preserves its existing fingerprint fallback, sends the Mixpanel event, and skips the relay. Background identification failures are logged without changing or replacing the already-submitted event.
|
|
79
77
|
|
|
80
78
|
## Identifying Users
|
|
81
79
|
|
|
@@ -127,6 +125,10 @@ The authoritative local checks are:
|
|
|
127
125
|
|
|
128
126
|
Run the full command before a push or pull request. See [the workflow](docs/agents/compound-engineering-workflow.md), [environment setup](docs/agents/setup-and-environments.md), and [review criteria](CODING_STANDARDS.md).
|
|
129
127
|
|
|
128
|
+
### Releases
|
|
129
|
+
|
|
130
|
+
Merging a PR into `main` with exactly one `patch`, `minor`, or `major` release label publishes a stable package automatically. Alphas remain manual: run **Publish to NPM** from `main`, selecting the channel, increment, and source branch. Stable releases require source `main`; alphas also support the temporary `alpha-sbx` integration branch. A lone `alpha` label does not publish on merge. See [the release process](docs/releases.md) for both paths, version allocation, commands, and recovery.
|
|
131
|
+
|
|
130
132
|
### OpenSpec prerequisites
|
|
131
133
|
|
|
132
134
|
### Prerequisites
|