@reservamos/browser-analytics 1.1.7-alpha.0 → 1.1.7
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 +7 -1
- package/README.md +35 -0
- package/dist/browser-analytics.cjs +3 -3
- package/dist/browser-analytics.cjs.map +1 -1
- package/dist/browser-analytics.d.ts +55 -55
- package/dist/browser-analytics.esm.js +1138 -844
- package/dist/browser-analytics.esm.js.map +1 -1
- package/dist/browser-analytics.iife.js +3 -3
- package/dist/browser-analytics.iife.js.map +1 -1
- package/package.json +3 -3
- package/src/events/identify/identify.robustness.test.ts +220 -0
- package/src/events/identify/identify.test.ts +6 -4
- package/src/events/identify/identify.ts +84 -42
- package/src/index.ts +2 -0
- package/src/profiles/createAnonymousProfile/createAnonymousProfile.identify.test.ts +56 -0
- package/src/profiles/createAnonymousProfile/createAnonymousProfile.ts +39 -12
- package/src/services/botDetectionRelay.test.ts +154 -0
- package/src/services/botDetectionRelay.ts +54 -0
- package/src/services/fingerprint.test.ts +250 -35
- package/src/services/fingerprint.ts +89 -12
- package/src/services/mixpanel.test.ts +160 -0
- package/src/services/mixpanel.ts +32 -6
- package/src/track.test.ts +156 -0
- package/src/track.ts +24 -5
- package/src/types/botDetection.ts +16 -0
- package/src/util/identifyAttempt.ts +139 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 1.1.7
|
|
4
4
|
|
|
5
|
+
- 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.
|
|
6
|
+
- Make `await identify()` represent a bounded local attempt, continue after optional enrichment or SDK cache failures, and observe profile callbacks and geolocation request outcomes with sanitized diagnostics and no retries.
|
|
7
|
+
- Treat Fingerprint `visitorFound` as optional metadata, preserving available booleans and omitting `Visitor Found` updates when absent.
|
|
8
|
+
- Register `Reservamos Version` from the SDK package version alongside `Event Source` during Mixpanel initialization, including it in native `$identify` events without changing Mixpanel's library version metadata.
|
|
5
9
|
- Align npm and Yarn lockfiles with Fingerprint Pro SPA 1.3.3 and its compatible JavaScript agent.
|
|
6
10
|
- Avoid identifying with a Fingerprint client before its agent finishes loading.
|
|
11
|
+
- Set the Mixpanel `Visitor Found` profile property after successful Fingerprint identification.
|
|
12
|
+
- Add a Fingerprint Bot Detection relay for `Search`, `Payment Attempt`, and `Purchase Attempt`. The SDK preserves request IDs for the relay without adding them to Mixpanel events, and asynchronously sends identification context to Core API (`/v1/fingerprint/bot-detection`) without consumer event selection or a Fingerprint Server API secret in the browser.
|
|
7
13
|
- Add a reproducible Compound Engineering workflow shared by Codex, Claude Code, and Cursor.
|
|
8
14
|
- Add canonical fast and full validation commands used locally and in CI.
|
|
9
15
|
- Verify generated package entrypoints and align the package's type declaration paths with the generated declaration bundle.
|
package/README.md
CHANGED
|
@@ -46,8 +46,43 @@ window.addEventListener('Tracker Ready', () => {
|
|
|
46
46
|
|
|
47
47
|
`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
48
|
|
|
49
|
+
## Fingerprint Bot Detection relay
|
|
50
|
+
|
|
51
|
+
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
|
+
|
|
53
|
+
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
|
+
|
|
55
|
+
For those events, the SDK requests a fresh Fingerprint identification, bypassing the Fingerprint SPA cache. This adds Fingerprint latency and an identification request before the original Mixpanel event is submitted. All other events keep the existing cache behavior.
|
|
56
|
+
|
|
57
|
+
When identification succeeds, the original event contains:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"User Fingerprint": "visitor-123"
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
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
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"requestId": "request-123",
|
|
70
|
+
"visitorId": "visitor-123",
|
|
71
|
+
"distinctId": "mixpanel-distinct-123",
|
|
72
|
+
"eventName": "Payment Attempt"
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`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
|
+
|
|
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. A failure during an identification that already started follows the SDK's existing tracking error behavior.
|
|
79
|
+
|
|
49
80
|
## Identifying Users
|
|
50
81
|
|
|
82
|
+
`await analytics.identify(...)` waits for the local identification attempt, not confirmed remote delivery. The SDK limits readiness to 5 seconds, anonymous-profile enrichment to 3 seconds, and fingerprint enrichment to 2 seconds. Optional enrichment or SDK cache failures do not block the Mixpanel attempt. Once readiness expires, a later `Tracker Ready` does not reactivate that call.
|
|
83
|
+
|
|
84
|
+
Mixpanel profile callbacks and the existing geolocation request are observed separately for up to 5 seconds. The SDK does not retry requests; a missing callback means its outcome was not observed. Diagnostics use controlled stage/reason values without user identifiers or personal properties. `Visitor Found` is optional metadata: available booleans are preserved, and absent values are not replaced with `false` or inferred from cache state.
|
|
85
|
+
|
|
51
86
|
The `identify` method accepts a main identifier and an object containing user information. The object has four predefined fields: `email`, `firstName`, `lastName`, and `phone`. In addition to these, you can include any custom fields to store additional user-specific information as needed.
|
|
52
87
|
|
|
53
88
|
```typescript
|