@affiliateo/web 4.3.0 → 4.4.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/dist/bot-detect.d.ts +3 -3
- package/dist/bot-detect.js +3 -3
- package/dist/provider.js +11 -11
- package/dist/queue.d.ts +2 -2
- package/dist/queue.js +2 -2
- package/package.json +1 -1
package/dist/bot-detect.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Client-side bot detection. Mirrors
|
|
2
|
+
* Client-side bot detection. Mirrors PostHog / Plausible's
|
|
3
3
|
* approach: catch the obvious automation tools at SDK init so they
|
|
4
4
|
* never fire a single network request.
|
|
5
5
|
*
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
* layer 3 (kicks in on the request), then layer 2 (server checks before
|
|
21
21
|
* writing). If any one layer rejects, the event drops.
|
|
22
22
|
*
|
|
23
|
-
* Patterns sourced from
|
|
24
|
-
* inspectable). We include
|
|
23
|
+
* Patterns sourced from widely-used analytics SDKs (publicly
|
|
24
|
+
* inspectable). We include a comprehensive list because it represents years
|
|
25
25
|
* of accumulated bot-shape knowledge that's expensive to reproduce.
|
|
26
26
|
*/
|
|
27
27
|
/**
|
package/dist/bot-detect.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Client-side bot detection. Mirrors
|
|
2
|
+
* Client-side bot detection. Mirrors PostHog / Plausible's
|
|
3
3
|
* approach: catch the obvious automation tools at SDK init so they
|
|
4
4
|
* never fire a single network request.
|
|
5
5
|
*
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
* layer 3 (kicks in on the request), then layer 2 (server checks before
|
|
21
21
|
* writing). If any one layer rejects, the event drops.
|
|
22
22
|
*
|
|
23
|
-
* Patterns sourced from
|
|
24
|
-
* inspectable). We include
|
|
23
|
+
* Patterns sourced from widely-used analytics SDKs (publicly
|
|
24
|
+
* inspectable). We include a comprehensive list because it represents years
|
|
25
25
|
* of accumulated bot-shape knowledge that's expensive to reproduce.
|
|
26
26
|
*/
|
|
27
27
|
// Selenium/WebDriver/headless flags set on window or navigator. Modern
|
package/dist/provider.js
CHANGED
|
@@ -8,12 +8,12 @@ const DEFAULT_API_URL = 'https://affiliateo.com';
|
|
|
8
8
|
const LS_VISITOR_ID = 'affiliateo_visitor_id';
|
|
9
9
|
const LS_REF = 'affiliateo_ref';
|
|
10
10
|
const LS_CAMPAIGN_ID = 'affiliateo_campaign_id';
|
|
11
|
-
// Persistent opt-out flag
|
|
11
|
+
// Persistent opt-out flag (affiliateo_opt_out) —
|
|
12
12
|
// when set to "true" the SDK silently noops every outbound call. Survives
|
|
13
13
|
// page reloads. removed by optIn(). Checked at init time so a previously
|
|
14
14
|
// opted-out visitor never re-fires auto-pageviews after a refresh.
|
|
15
15
|
const LS_OPT_OUT = 'affiliateo_opt_out';
|
|
16
|
-
// Client-owned session id
|
|
16
|
+
// Client-owned session id. The BROWSER owns the session,
|
|
17
17
|
// not the server. One id is reused for every event within a sliding
|
|
18
18
|
// 10-minute activity window, then a fresh one is minted. Because the id is
|
|
19
19
|
// generated here and sent on each event, a burst of pageviews (a redirect
|
|
@@ -26,7 +26,7 @@ const SESSION_WINDOW_MS = 10 * 60 * 1000;
|
|
|
26
26
|
// Same-URL pageview throttle, persisted in sessionStorage so it survives
|
|
27
27
|
// hard navigations / redirect bounces (the old in-memory throttle reset on
|
|
28
28
|
// every fresh page context, which let a 3-hop bounce fire 3 pageviews).
|
|
29
|
-
// Different URLs are never throttled against each other
|
|
29
|
+
// Different URLs are never throttled against each other, with a
|
|
30
30
|
// 60s same-URL suppression.
|
|
31
31
|
const SS_PV_THROTTLE = 'affiliateo_pv_throttle';
|
|
32
32
|
const PV_THROTTLE_MS = 60 * 1000;
|
|
@@ -88,7 +88,7 @@ function uuid() {
|
|
|
88
88
|
// Get-or-create the current session id with a sliding 10-minute window.
|
|
89
89
|
// Stored in localStorage so every tab and every page load in the same
|
|
90
90
|
// browser shares one session. Each call slides the window forward (the same
|
|
91
|
-
// way
|
|
91
|
+
// way a session cookie is refreshed on each event), so an actively
|
|
92
92
|
// browsing visitor keeps one id and a returning visitor past the window
|
|
93
93
|
// gets a fresh one. Returns a UUID string the server stamps onto the event.
|
|
94
94
|
function getSessionId() {
|
|
@@ -169,7 +169,7 @@ export function AffiliateoProvider({ campaignId, apiUrl, allowedHostnames, allow
|
|
|
169
169
|
// Normalize autoCapturePageviews. Three shapes:
|
|
170
170
|
// - undefined / true / object → auto-capture ON (with object overrides)
|
|
171
171
|
// - false → auto-capture OFF entirely (host must call trackPageview)
|
|
172
|
-
//
|
|
172
|
+
// Sensible defaults: captureInitialPageview true, trackHashChanges
|
|
173
173
|
// false, debounceMs 100.
|
|
174
174
|
const autoCfg = autoCapturePageviews === false
|
|
175
175
|
? { enabled: false, captureInitialPageview: false, trackHashChanges: false, debounceMs: 100 }
|
|
@@ -299,7 +299,7 @@ export function AffiliateoProvider({ campaignId, apiUrl, allowedHostnames, allow
|
|
|
299
299
|
}
|
|
300
300
|
catch { /* swallow */ }
|
|
301
301
|
}, [apiBase, log]);
|
|
302
|
-
// Manual pageview
|
|
302
|
+
// Manual pageview via trackPageview(path?). Same payload
|
|
303
303
|
// shape the auto-fired pageview uses (see sendPageview inside the route
|
|
304
304
|
// effect below) so server-side routing / dedup / IP+UA enrichment behave
|
|
305
305
|
// identically for both code paths.
|
|
@@ -370,13 +370,13 @@ export function AffiliateoProvider({ campaignId, apiUrl, allowedHostnames, allow
|
|
|
370
370
|
// affiliate ref so the next pageview is a brand-new anonymous visitor.
|
|
371
371
|
// The campaign_id stays (it's a property of the site, not the visitor).
|
|
372
372
|
//
|
|
373
|
-
//
|
|
373
|
+
// reset() semantics for non-cookieless mode: new
|
|
374
374
|
// visitor, no event fired, caller handles "tell the server about it"
|
|
375
375
|
// by triggering whatever pageview / navigation comes next.
|
|
376
376
|
//
|
|
377
377
|
// Returns a Promise so callers can `await reset()` before navigating
|
|
378
378
|
// (the localStorage writes are sync but the Promise lets the API stay
|
|
379
|
-
//
|
|
379
|
+
// an async signature, future-proofing for
|
|
380
380
|
// server-minted IDs in cookieless mode).
|
|
381
381
|
const reset = useCallback(async () => {
|
|
382
382
|
try {
|
|
@@ -766,8 +766,8 @@ export function AffiliateoProvider({ campaignId, apiUrl, allowedHostnames, allow
|
|
|
766
766
|
// Debouncing collapses back-to-back navigation events into one. Some
|
|
767
767
|
// frameworks (Next.js, certain Vue routers) fire pushState then
|
|
768
768
|
// replaceState in the same tick to canonicalize the URL; without
|
|
769
|
-
// debouncing that's two pageviews per real navigation. Default 100ms
|
|
770
|
-
//
|
|
769
|
+
// debouncing that's two pageviews per real navigation. Default 100ms;
|
|
770
|
+
// set debounceMs to 0 to disable.
|
|
771
771
|
let lastPath = window.location.pathname;
|
|
772
772
|
let lastHash = window.location.hash;
|
|
773
773
|
let pendingPageviewTimer = null;
|
|
@@ -812,7 +812,7 @@ export function AffiliateoProvider({ campaignId, apiUrl, allowedHostnames, allow
|
|
|
812
812
|
};
|
|
813
813
|
// HTML-attribute goal scanning (`data-affiliateo-goal`,
|
|
814
814
|
// `data-affiliateo-scroll`) and the IntersectionObserver that drove
|
|
815
|
-
// them were removed in 3.0.0 to
|
|
815
|
+
// them were removed in 3.0.0 to streamline the npm SDK ergonomics:
|
|
816
816
|
// SDK does pageview + track() + identify(); merchants fire goals
|
|
817
817
|
// themselves via onClick={() => track('signup_clicked')} or by
|
|
818
818
|
// wiring their own IntersectionObserver and calling track() from it.
|
package/dist/queue.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* networks (train wifi, subway transitions, dropping 4G) merchants saw
|
|
10
10
|
* ~10-15% fewer events than they should have.
|
|
11
11
|
*
|
|
12
|
-
* This queue mirrors the pattern PostHog / Segment / Amplitude
|
|
12
|
+
* This queue mirrors the pattern PostHog / Segment / Amplitude
|
|
13
13
|
* all converged on: in-memory queue, localStorage persistence so events
|
|
14
14
|
* survive page reload, periodic auto-flush, retry on failure up to N
|
|
15
15
|
* times, drop after N tries to bound memory.
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* - MAX_QUEUE_SIZE hard cap so a long network outage can't fill
|
|
38
38
|
* localStorage and break the host app. Events
|
|
39
39
|
* beyond the cap are dropped FIFO (oldest first).
|
|
40
|
-
* - FLUSH_INTERVAL_MS = 5_000
|
|
40
|
+
* - FLUSH_INTERVAL_MS = 5_000 a sensible web SDK default
|
|
41
41
|
* - SIZE_FLUSH_THRESHOLD = 10 triggers a flush when queue grows
|
|
42
42
|
* past this even before the timer fires
|
|
43
43
|
*/
|
package/dist/queue.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* networks (train wifi, subway transitions, dropping 4G) merchants saw
|
|
10
10
|
* ~10-15% fewer events than they should have.
|
|
11
11
|
*
|
|
12
|
-
* This queue mirrors the pattern PostHog / Segment / Amplitude
|
|
12
|
+
* This queue mirrors the pattern PostHog / Segment / Amplitude
|
|
13
13
|
* all converged on: in-memory queue, localStorage persistence so events
|
|
14
14
|
* survive page reload, periodic auto-flush, retry on failure up to N
|
|
15
15
|
* times, drop after N tries to bound memory.
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* - MAX_QUEUE_SIZE hard cap so a long network outage can't fill
|
|
38
38
|
* localStorage and break the host app. Events
|
|
39
39
|
* beyond the cap are dropped FIFO (oldest first).
|
|
40
|
-
* - FLUSH_INTERVAL_MS = 5_000
|
|
40
|
+
* - FLUSH_INTERVAL_MS = 5_000 a sensible web SDK default
|
|
41
41
|
* - SIZE_FLUSH_THRESHOLD = 10 triggers a flush when queue grows
|
|
42
42
|
* past this even before the timer fires
|
|
43
43
|
*/
|