@active-reach/web-sdk 1.48.0 → 1.49.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/aegis.min.js +1 -1
- package/dist/aegis.min.js.map +1 -1
- package/dist/{analytics-zA6ckfKP.mjs → analytics-DMY0Q0rI.mjs} +911 -312
- package/dist/analytics-DMY0Q0rI.mjs.map +1 -0
- package/dist/chat/AegisChat.d.ts +20 -0
- package/dist/chat/AegisChat.d.ts.map +1 -1
- package/dist/chat/index.d.ts +1 -1
- package/dist/chat/index.d.ts.map +1 -1
- package/dist/core/analytics.d.ts.map +1 -1
- package/dist/core/bootstrap.d.ts +2 -1
- package/dist/core/bootstrap.d.ts.map +1 -1
- package/dist/core/prefetch-bundle-client.d.ts.map +1 -1
- package/dist/core/purchase-backlog.d.ts +141 -0
- package/dist/core/purchase-backlog.d.ts.map +1 -0
- package/dist/core/purchase-events.d.ts +25 -0
- package/dist/core/purchase-events.d.ts.map +1 -0
- package/dist/core/queue.d.ts +39 -0
- package/dist/core/queue.d.ts.map +1 -1
- package/dist/core/sdk-config-poller.d.ts.map +1 -1
- package/dist/core/transport.d.ts +74 -1
- package/dist/core/transport.d.ts.map +1 -1
- package/dist/ecommerce/index.d.ts +1 -1
- package/dist/ecommerce/index.d.ts.map +1 -1
- package/dist/ecommerce/types.d.ts +10 -0
- package/dist/ecommerce/types.d.ts.map +1 -1
- package/dist/governance/trait-governor.d.ts +13 -6
- package/dist/governance/trait-governor.d.ts.map +1 -1
- package/dist/inapp/AegisInAppManager.d.ts +94 -6
- package/dist/inapp/AegisInAppManager.d.ts.map +1 -1
- package/dist/inapp/anon-claim.d.ts +36 -0
- package/dist/inapp/anon-claim.d.ts.map +1 -0
- package/dist/inapp/index.d.ts +1 -1
- package/dist/inapp/index.d.ts.map +1 -1
- package/dist/inapp/prize-retry.d.ts +51 -0
- package/dist/inapp/prize-retry.d.ts.map +1 -0
- package/dist/inapp/rail-fallback.d.ts +83 -0
- package/dist/inapp/rail-fallback.d.ts.map +1 -0
- package/dist/inapp/renderers/games.d.ts.map +1 -1
- package/dist/inapp/renderers/types.d.ts +12 -0
- package/dist/inapp/renderers/types.d.ts.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +936 -144
- package/dist/index.js.map +1 -1
- package/dist/integrations/react.d.ts.map +1 -1
- package/dist/react.js +1 -1
- package/dist/runtime/AegisMessageRuntime.d.ts +17 -0
- package/dist/runtime/AegisMessageRuntime.d.ts.map +1 -1
- package/dist/triggers/IntentRuleEvaluator.d.ts.map +1 -1
- package/dist/utils/fetch-abort.d.ts +23 -0
- package/dist/utils/fetch-abort.d.ts.map +1 -0
- package/dist/utils/preview-as-of.d.ts +21 -0
- package/dist/utils/preview-as-of.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/analytics-zA6ckfKP.mjs.map +0 -1
package/dist/chat/AegisChat.d.ts
CHANGED
|
@@ -103,6 +103,10 @@ export declare function chatScrollTarget(m: {
|
|
|
103
103
|
}): number;
|
|
104
104
|
/** The single mounted launcher, or null if chat isn't active on this page. */
|
|
105
105
|
export declare function getCurrentLauncher(): AegisChat | null;
|
|
106
|
+
/** Subscribe to the launcher mounting or unmounting (a host "Chat with us" link
|
|
107
|
+
* shows only while one is live, however late the chat initialises). Returns
|
|
108
|
+
* the unsubscribe function. */
|
|
109
|
+
export declare function onLauncherChange(listener: (launcher: AegisChat | null) => void): () => void;
|
|
106
110
|
/** Open the chat panel (no-op if no launcher is mounted). */
|
|
107
111
|
export declare function openChat(prefill?: string): void;
|
|
108
112
|
/** Close the chat panel. */
|
|
@@ -154,6 +158,9 @@ export declare class AegisChat {
|
|
|
154
158
|
/** True once a resume attempt ran this page-load (one /session call max). */
|
|
155
159
|
private sessionResumed;
|
|
156
160
|
private open;
|
|
161
|
+
/** Set by destroy(): a late retry or response must not POST or reopen SSE. */
|
|
162
|
+
private destroyed;
|
|
163
|
+
private retryWaits;
|
|
157
164
|
private initialized;
|
|
158
165
|
private root?;
|
|
159
166
|
private bubble?;
|
|
@@ -183,6 +190,19 @@ export declare class AegisChat {
|
|
|
183
190
|
closePanel(): void;
|
|
184
191
|
destroy(): void;
|
|
185
192
|
private send;
|
|
193
|
+
/** Statuses where the server may have already accepted the message (the
|
|
194
|
+
* gateway times out after the cell produced) or asked us to come back. */
|
|
195
|
+
private static readonly RETRYABLE_STATUS;
|
|
196
|
+
private static readonly RETRY_DELAYS_MS;
|
|
197
|
+
private static readonly RETRY_AFTER_CAP_MS;
|
|
198
|
+
private static retryAfterMs;
|
|
199
|
+
/** POST one message with bounded automatic retries on the SAME id. On a final
|
|
200
|
+
* failure, leave a Retry action that re-sends the stored id and text. */
|
|
201
|
+
private deliver;
|
|
202
|
+
/** The failed-message notice with a Retry button. Retry re-sends the stored
|
|
203
|
+
* client id + text, so a message the server did accept is absorbed, not
|
|
204
|
+
* answered twice, and the customer never has to retype. */
|
|
205
|
+
private appendDeliveryFailed;
|
|
186
206
|
/** Validate + upload a picked file, then send it as a media message. */
|
|
187
207
|
private handleFile;
|
|
188
208
|
/** Read a File as bare base64 (strip the `data:…;base64,` prefix). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AegisChat.d.ts","sourceRoot":"","sources":["../../src/chat/AegisChat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;
|
|
1
|
+
{"version":3,"file":"AegisChat.d.ts","sourceRoot":"","sources":["../../src/chat/AegisChat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAcH,OAAO,EAQL,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;4EAGwE;IACxE,WAAW,CAA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,UAAU;IAclB,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,GAAG;IAIX,OAAO,CAAC,YAAY;CAOrB"}
|
package/dist/chat/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AegisChat, openChat, closeChat, getCurrentLauncher } from './AegisChat';
|
|
1
|
+
export { AegisChat, openChat, closeChat, getCurrentLauncher, onLauncherChange } from './AegisChat';
|
|
2
2
|
export type { AegisChatConfig } from './AegisChat';
|
|
3
3
|
export { setChatContext, getChatContext } from './whatsapp-launcher';
|
|
4
4
|
export type { ChatContext, ChatWhatsappPayload } from './whatsapp-launcher';
|
package/dist/chat/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/chat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/chat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACnG,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrE,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../src/core/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAGX,YAAY,EACb,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,C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AC,QAAQ,EAAE,eAAe,GAAG,OAAO;IAQ9C,qBAAqB,IAAI,kBAAkB,GAAG,IAAI;IAQlD,eAAe,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,kBAAkB,KAAK,IAAI,GAAG,MAAM,IAAI;IAShF,OAAO,CAAC,iBAAiB;IAQzB,IAAI,SAAS,IAAI,gBAAgB,CAKhC;IAED,IAAI,IAAI,IAAI,aAAa,CAKxB;IAED,OAAO,IAAI,IAAI;CAwBhB"}
|
package/dist/core/bootstrap.d.ts
CHANGED
|
@@ -83,7 +83,8 @@ export declare function writeFirstPartyCookie(cookieId: string): void;
|
|
|
83
83
|
* Perform the bootstrap handshake.
|
|
84
84
|
*
|
|
85
85
|
* @throws BootstrapError on 4xx — the SDK should stop init and surface the
|
|
86
|
-
* error to the console. 5xx are retried once
|
|
86
|
+
* error to the console. 5xx and an 800 ms abort are retried once; two
|
|
87
|
+
* aborts raise BootstrapError(0).
|
|
87
88
|
*/
|
|
88
89
|
export declare function bootstrap(apiHost: string, req: BootstrapRequest): Promise<BootstrapResult>;
|
|
89
90
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/core/bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/core/bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,MAAM,WAAW,gBAAgB;IAC/B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B,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAyBzF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefetch-bundle-client.d.ts","sourceRoot":"","sources":["../../src/core/prefetch-bundle-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;
|
|
1
|
+
{"version":3,"file":"prefetch-bundle-client.d.ts","sourceRoot":"","sources":["../../src/core/prefetch-bundle-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAOH,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,CAAC,EAAE;QACV,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,uBAAuB,CAAC,EAAE,MAAM,CAAC;QACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;IACF,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,cAAc,CAAC,EAAE;QACf,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAClC,CAAC;IACF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,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,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAU/C;iFAC6E;IAC7E,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,GAAG,MAAM,IAAI;IAQtD;;;;OAIG;IACH,cAAc,CAAC,OAAO,EAAE;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,IAAI;IAoCR;8EAC0E;IAC1E,gBAAgB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAI3D;;;;;;;;;;;;;;OAcG;IACH,sBAAsB,CAAC,UAAU,EAAE;QACjC,SAAS,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;SAAE,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;KAC5F,GAAG,MAAM,IAAI;YAkBA,KAAK;CAiGpB"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PURCHASE BACKLOG (Aman 11-02, Q13 / WP19 SDK half): the SDK never drops a
|
|
3
|
+
* purchase event except under the bounds below, each one logged and counted.
|
|
4
|
+
*
|
|
5
|
+
* Durable first. A purchase (purchase-events.ts) is written to localStorage
|
|
6
|
+
* BEFORE the first send, so a reload, a closed tab or a crash mid-send loses
|
|
7
|
+
* nothing; the next page load re-sends it.
|
|
8
|
+
*
|
|
9
|
+
* Sending.
|
|
10
|
+
* - A live page drains with a NON-keepalive fetch (a keepalive body over
|
|
11
|
+
* 64 KB is refused by the browser), at most PURCHASE_SEND_CHUNK events a
|
|
12
|
+
* request, and never via `sendBeacon` (that only says "queued").
|
|
13
|
+
* - On unload (`flushOnUnload`, called synchronously from pagehide /
|
|
14
|
+
* visibilitychange / beforeunload) one keepalive fetch starts before the
|
|
15
|
+
* handler returns, carrying only the purchases that fit in
|
|
16
|
+
* KEEPALIVE_BODY_MAX_BYTES. The rest stay on disk for the next load.
|
|
17
|
+
* - Re-tried until a 2xx: 1 s to 60 s jittered backoff, never sooner than the
|
|
18
|
+
* gateway's `Retry-After` (the per-visitor 429), an immediate try on
|
|
19
|
+
* `online` and on every page load. A 429 is never the end of a purchase.
|
|
20
|
+
* - The transport halves a request on 413, on 400 (`splitOnBadRequest`) and
|
|
21
|
+
* on an oversize keepalive body; only events without a 2xx are kept.
|
|
22
|
+
*
|
|
23
|
+
* Several tabs. Every write re-reads localStorage and merges by messageId:
|
|
24
|
+
* the union of the stored and in-memory purchases, minus every id any tab has
|
|
25
|
+
* SETTLED (got a 2xx for, or terminally refused). Settled ids are kept for
|
|
26
|
+
* SETTLED_RETENTION_MS so a slower tab never writes a sent purchase back.
|
|
27
|
+
*
|
|
28
|
+
* Re-sends are at-least-once by design. The cell consumer claims each
|
|
29
|
+
* purchase once (event_engine/consumer.py `order_dedup_key(ENGINE_TXN, ...)`):
|
|
30
|
+
* on its order natural key for 24 h, and, when the event names no order, on
|
|
31
|
+
* the SDK messageId (gateway -> `external_event_id`) for 8 days, longer than
|
|
32
|
+
* MAX_PURCHASE_AGE_MS, so a re-sent purchase is dropped there, not counted
|
|
33
|
+
* twice.
|
|
34
|
+
*
|
|
35
|
+
* THE BOUNDS (each eviction is `logger.error` + a counter, never silent):
|
|
36
|
+
* - COUNT: MAX_PURCHASE_BACKLOG (200) per tenant per browser. A shopper places
|
|
37
|
+
* about one order a visit; 200 unsent in ONE browser is a host loop or a key
|
|
38
|
+
* refused for days. At ~2-4 KB an event that is 0.4-0.8 MB of the origin's
|
|
39
|
+
* ~5 MB localStorage. The oldest goes first (`droppedOverBound`).
|
|
40
|
+
* - AGE: MAX_PURCHASE_AGE_MS (7 days) from the event's own timestamp
|
|
41
|
+
* (`droppedExpired`).
|
|
42
|
+
* - TERMINAL: one event the gateway refuses on its own (400, or 413 at a
|
|
43
|
+
* single event): resending cannot succeed, and it must not block the rest
|
|
44
|
+
* (`droppedTerminal`).
|
|
45
|
+
*
|
|
46
|
+
* A REFUSED KEY (401/403) is a key-level problem, not an event-level one, so
|
|
47
|
+
* it evicts NOTHING (Aman: purchases are never dropped). Drains for this
|
|
48
|
+
* write key pause for AUTH_PAUSE_BASE_MS (5 min), doubling per refusal up to
|
|
49
|
+
* AUTH_PAUSE_MAX_MS (1 h); the pause is persisted, so a reload honours it.
|
|
50
|
+
* Each refusal is a warning and is counted (`authPaused`). The next 2xx
|
|
51
|
+
* clears the pause. During a pause two sends still get ONE try each: the
|
|
52
|
+
* unload send and the first send after a NEW purchase is added. A 2xx clears
|
|
53
|
+
* the pause; a refusal keeps it as it is.
|
|
54
|
+
*
|
|
55
|
+
* A gateway answering 400 to everything must not empty the backlog through
|
|
56
|
+
* the terminal path: after MAX_TERMINAL_STREAK (3) single-event refusals in a
|
|
57
|
+
* row with no 2xx between, no further event is evicted; drains pause instead
|
|
58
|
+
* (the same persisted pause) and an error is logged.
|
|
59
|
+
*
|
|
60
|
+
* A changed write key. The backlog is scoped by a hash of the write key, so a
|
|
61
|
+
* purchase is never sent with another tenant's key. A backlog left under a
|
|
62
|
+
* DIFFERENT key on this origin is not adopted (it could be another brand);
|
|
63
|
+
* it stays on disk, is sent if that key loads again, and is counted at load
|
|
64
|
+
* (`orphaned`) with a warning.
|
|
65
|
+
*/
|
|
66
|
+
import type { AegisEvent } from '../types/events';
|
|
67
|
+
import type { Transport } from './transport';
|
|
68
|
+
export declare const MAX_PURCHASE_BACKLOG = 200;
|
|
69
|
+
export declare const MAX_PURCHASE_AGE_MS: number;
|
|
70
|
+
/** Purchases per request while a live page drains the backlog. */
|
|
71
|
+
export declare const PURCHASE_SEND_CHUNK = 50;
|
|
72
|
+
export declare const PURCHASE_RETRY_BASE_MS = 1000;
|
|
73
|
+
export declare const PURCHASE_RETRY_MAX_MS = 60000;
|
|
74
|
+
/** Settled ids are remembered this long (past MAX_PURCHASE_AGE_MS). */
|
|
75
|
+
export declare const SETTLED_RETENTION_MS: number;
|
|
76
|
+
export declare const PURCHASE_BACKLOG_PREFIX = "aegis_purchase_backlog:v1:";
|
|
77
|
+
export declare const AUTH_PAUSE_BASE_MS: number;
|
|
78
|
+
export declare const AUTH_PAUSE_MAX_MS: number;
|
|
79
|
+
/** Terminal (single-event 400/413) evictions in a row before evicting stops. */
|
|
80
|
+
export declare const MAX_TERMINAL_STREAK = 3;
|
|
81
|
+
/** Short stable hash so the write key itself is not spelled into a storage key. */
|
|
82
|
+
export declare function fnv1a(input: string): string;
|
|
83
|
+
export declare function purchaseBacklogKey(namespace?: string): string;
|
|
84
|
+
export interface PurchaseDropCounts {
|
|
85
|
+
overBound: number;
|
|
86
|
+
expired: number;
|
|
87
|
+
terminal: number;
|
|
88
|
+
}
|
|
89
|
+
export declare class PurchaseBacklog {
|
|
90
|
+
private readonly transport;
|
|
91
|
+
private events;
|
|
92
|
+
private settled;
|
|
93
|
+
private inFlight;
|
|
94
|
+
private attempt;
|
|
95
|
+
private timer;
|
|
96
|
+
private destroyed;
|
|
97
|
+
private readonly key;
|
|
98
|
+
readonly dropped: PurchaseDropCounts;
|
|
99
|
+
/** Purchases found under another write key's backlog on this origin at load. */
|
|
100
|
+
orphaned: number;
|
|
101
|
+
/** 401/403 refusals of a purchase drain (each paused drains; nothing evicted). */
|
|
102
|
+
authPaused: number;
|
|
103
|
+
/** Single-event refusals in a row with no 2xx between (MAX_TERMINAL_STREAK). */
|
|
104
|
+
private terminalStreak;
|
|
105
|
+
/** A purchase was added: its first send may try once through a pause. */
|
|
106
|
+
private bypassPauseOnce;
|
|
107
|
+
constructor(transport: Transport, namespace?: string);
|
|
108
|
+
size(): number;
|
|
109
|
+
totalDropped(): number;
|
|
110
|
+
add(event: AegisEvent): void;
|
|
111
|
+
/** Cancel any pending backoff and try on the next tick (live page). */
|
|
112
|
+
retryNow(): void;
|
|
113
|
+
/**
|
|
114
|
+
* Called SYNCHRONOUSLY from an unload handler: the keepalive fetch starts
|
|
115
|
+
* before this returns (timers do not run after pagehide). Sends only what
|
|
116
|
+
* fits in one keepalive body; the rest stay on disk for the next load.
|
|
117
|
+
*/
|
|
118
|
+
flushOnUnload(): void;
|
|
119
|
+
/** Forget every held purchase (an explicit embedder wipe). */
|
|
120
|
+
clear(): void;
|
|
121
|
+
destroy(): void;
|
|
122
|
+
static retryDelayMs(attempt: number, retryAfterMs?: number, jitter?: number): number;
|
|
123
|
+
/** Send one request's worth; keep every purchase until a 2xx accepts it. */
|
|
124
|
+
drain(unloading?: boolean): Promise<void>;
|
|
125
|
+
/** The oldest purchases whose batch body fits one keepalive request. */
|
|
126
|
+
private unloadChunk;
|
|
127
|
+
private readAuthPause;
|
|
128
|
+
private writeAuthPause;
|
|
129
|
+
private clearAuthPause;
|
|
130
|
+
private schedule;
|
|
131
|
+
private clearTimer;
|
|
132
|
+
private settle;
|
|
133
|
+
private read;
|
|
134
|
+
/**
|
|
135
|
+
* Merge with what other tabs wrote, apply the bounds, write back. The
|
|
136
|
+
* union of events by messageId, minus every id any tab has settled.
|
|
137
|
+
*/
|
|
138
|
+
private persist;
|
|
139
|
+
private countOrphans;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=purchase-backlog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purchase-backlog.d.ts","sourceRoot":"","sources":["../../src/core/purchase-backlog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAK7C,eAAO,MAAM,oBAAoB,MAAM,CAAC;AACxC,eAAO,MAAM,mBAAmB,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AAY,IAAI,MAAM;IAItB,GAAG,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAS5B,uEAAuE;IACvE,QAAQ,IAAI,IAAI;IAOhB;;;;OAIG;IACH,aAAa,IAAI,IAAI;IAOrB,8DAA8D;IAC9D,KAAK,IAAI,IAAI;IAOb,OAAO,IAAI,IAAI;IAMf,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,MAAM,GAAE,MAAsB,GAAG,MAAM;IAKnG,4EAA4E;IACtE,KAAK,CAAC,SAAS,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IA6GtD,wEAAwE;IACxE,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,IAAI;IAkBZ;;;OAGG;IACH,OAAO,CAAC,OAAO;IAoEf,OAAO,CAAC,YAAY;CAqBrB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which SDK events are PURCHASES (Aman 11-02, Q13 / WP19 SDK half): a purchase
|
|
3
|
+
* event is never dropped by the SDK. The queue keeps purchases in their own
|
|
4
|
+
* persisted backlog and retries them until the gateway accepts them; the
|
|
5
|
+
* client rate limiter and the event-name governor let them through.
|
|
6
|
+
*
|
|
7
|
+
* A purchase is any track event whose name the gateway canonicalises to
|
|
8
|
+
* `transaction.purchase` (libs/gateway-core/src/canonical-event.ts, the ONE
|
|
9
|
+
* name mapper; docs/agent-rules/EVENT_VOCABULARY.md). The SDK cannot import
|
|
10
|
+
* gateway-core (a Node lib, not part of the browser bundle), so the spellings
|
|
11
|
+
* are listed here and `tests/drift-purchase-never-dropped.test.ts` fails the
|
|
12
|
+
* build when the mapper gains a purchase spelling this list lacks.
|
|
13
|
+
*
|
|
14
|
+
* Matching mirrors the mapper: the exact lower-cased name, then the
|
|
15
|
+
* normalised form (`.`, `/`, `-` and spaces → `_`), so `Order Completed`,
|
|
16
|
+
* `Purchase` and `order.completed` all count.
|
|
17
|
+
*/
|
|
18
|
+
import type { AegisEvent } from '../types/events';
|
|
19
|
+
/** Every spelling the gateway maps to `transaction.purchase`, plus the canonical name itself. */
|
|
20
|
+
export declare const PURCHASE_EVENT_NAMES: ReadonlySet<string>;
|
|
21
|
+
/** True when `name` is a purchase event name (see the module doc). */
|
|
22
|
+
export declare function isPurchaseEventName(name: unknown): boolean;
|
|
23
|
+
/** True when `event` is a track event carrying a purchase name. */
|
|
24
|
+
export declare function isPurchaseEvent(event: AegisEvent | null | undefined): boolean;
|
|
25
|
+
//# sourceMappingURL=purchase-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purchase-events.d.ts","sourceRoot":"","sources":["../../src/core/purchase-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,iBAAiB,CAAC;AAE9D,iGAAiG;AACjG,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAwBnD,CAAC;AAWH,sEAAsE;AACtE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAI1D;AAED,mEAAmE;AACnE,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAG7E"}
|
package/dist/core/queue.d.ts
CHANGED
|
@@ -6,7 +6,25 @@ export interface QueueConfig {
|
|
|
6
6
|
batchInterval: number;
|
|
7
7
|
enableOfflineMode: boolean;
|
|
8
8
|
maxOfflineEvents: number;
|
|
9
|
+
/**
|
|
10
|
+
* Scopes the persisted purchase backlog to one tenant (the write key): a
|
|
11
|
+
* purchase saved under one key is never sent with another. Optional so an
|
|
12
|
+
* embedder that builds the queue directly keeps working (one shared slot).
|
|
13
|
+
*/
|
|
14
|
+
persistNamespace?: string;
|
|
9
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Purchases never enter this queue's drop-oldest offline list: they go to the
|
|
18
|
+
* PurchaseBacklog (purchase-backlog.ts), which holds them durably and re-tries
|
|
19
|
+
* until the gateway accepts them. When the offline list is full it still
|
|
20
|
+
* drops its oldest event, and it only ever holds NON-purchase events.
|
|
21
|
+
*
|
|
22
|
+
* No request carries more than 100 events (transport.ts MAX_BATCH_EVENTS, the
|
|
23
|
+
* gateway's 413 cap) on any flush path. A 413 halves the request and is never
|
|
24
|
+
* a failure that ends in drop-oldest; after a partial send only the events
|
|
25
|
+
* without a 2xx (`SendResult.rejected`, client-side bookkeeping) are kept.
|
|
26
|
+
*/
|
|
27
|
+
export { MAX_PURCHASE_BACKLOG, MAX_PURCHASE_AGE_MS, PURCHASE_SEND_CHUNK, PURCHASE_RETRY_BASE_MS, PURCHASE_RETRY_MAX_MS, } from './purchase-backlog';
|
|
10
28
|
export declare class EventQueue {
|
|
11
29
|
private buffer;
|
|
12
30
|
private config;
|
|
@@ -16,6 +34,8 @@ export declare class EventQueue {
|
|
|
16
34
|
private isFlushing;
|
|
17
35
|
private offlineQueue;
|
|
18
36
|
private isOnline;
|
|
37
|
+
/** Purchases not yet accepted by the gateway (purchase-backlog.ts). */
|
|
38
|
+
private purchases;
|
|
19
39
|
constructor(config: QueueConfig, transport: Transport, storage: Storage);
|
|
20
40
|
private loadOfflineQueue;
|
|
21
41
|
private saveOfflineQueue;
|
|
@@ -27,8 +47,27 @@ export declare class EventQueue {
|
|
|
27
47
|
private startFlushTimer;
|
|
28
48
|
private setupUnloadHandlers;
|
|
29
49
|
private persistBufferToOfflineQueue;
|
|
50
|
+
/** Move every purchase in `events` to the backlog; return the rest. */
|
|
51
|
+
private takePurchases;
|
|
52
|
+
private setupPurchaseOnlineListener;
|
|
53
|
+
/** Send the backlog now (one request's worth; re-tries are scheduled). */
|
|
54
|
+
flushPurchases(): Promise<void>;
|
|
55
|
+
/** Backoff before purchase try `attempt` (1-based), honouring Retry-After. */
|
|
56
|
+
static purchaseRetryDelayMs(attempt: number, retryAfterMs?: number, jitter?: number): number;
|
|
57
|
+
getPurchaseBacklogSize(): number;
|
|
58
|
+
/** Purchases evicted under a bound this page life (0 in normal use). */
|
|
59
|
+
getDroppedPurchaseCount(): number;
|
|
60
|
+
/** 401/403 refusals that paused purchase drains (nothing is evicted for them). */
|
|
61
|
+
getAuthPausedCount(): number;
|
|
62
|
+
/** Purchases held under another write key's backlog on this origin. */
|
|
63
|
+
getOrphanedPurchaseCount(): number;
|
|
30
64
|
getQueueSize(): number;
|
|
31
65
|
getOfflineQueueSize(): number;
|
|
66
|
+
/**
|
|
67
|
+
* Forget everything queued, purchases included. An explicit wipe by the
|
|
68
|
+
* embedder (no SDK path calls it): the only way a held purchase is removed
|
|
69
|
+
* without a 2xx, besides the MAX_PURCHASE_BACKLOG eviction.
|
|
70
|
+
*/
|
|
32
71
|
clear(): void;
|
|
33
72
|
destroy(): void;
|
|
34
73
|
}
|
package/dist/core/queue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/core/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/core/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAM3C,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE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M,GAAE,MAAsB,GAAG,MAAM;IAI3G,sBAAsB,IAAI,MAAM;IAIhC,wEAAwE;IACxE,uBAAuB,IAAI,MAAM;IAIjC,kFAAkF;IAClF,kBAAkB,IAAI,MAAM;IAI5B,uEAAuE;IACvE,wBAAwB,IAAI,MAAM;IAIlC,YAAY,IAAI,MAAM;IAItB,mBAAmB,IAAI,MAAM;IAI7B;;;;OAIG;IACH,KAAK,IAAI,IAAI;IAQb,OAAO,IAAI,IAAI;CAWhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-config-poller.d.ts","sourceRoot":"","sources":["../../src/core/sdk-config-poller.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"sdk-config-poller.d.ts","sourceRoot":"","sources":["../../src/core/sdk-config-poller.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE;QACJ,OAAO,EAAE,OAAO,CAAC;QACjB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;QAChC,SAAS,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;IACF,MAAM,EAAE;QACN,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,OAAO,EAAE;QACP,yBAAyB,EAAE,MAAM,EAAE,CAAC;KACrC,CAAC;CACH;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI,CAAC;AAE/D,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAyF;IACxG,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,aAAa,CAA0B;IAC/C,OAAO,CAAC,SAAS,CAA+C;IAChE,OAAO,CAAC,SAAS,CAA8B;gBAEnC,OAAO,EAAE,sBAAsB;IAO3C;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAYxC;;OAEG;IACH,IAAI,IAAI,IAAI;IAOZ;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,IAAI;IAQpD;;OAEG;IACH,SAAS,IAAI,SAAS,GAAG,IAAI;IAI7B;;OAEG;YACW,WAAW;CA4D1B"}
|
package/dist/core/transport.d.ts
CHANGED
|
@@ -17,7 +17,68 @@ export interface SendResult {
|
|
|
17
17
|
response?: BatchResponse;
|
|
18
18
|
error?: Error;
|
|
19
19
|
endpoint?: string;
|
|
20
|
+
/** HTTP status of the last attempt (0 = network error / abort). */
|
|
21
|
+
status?: number;
|
|
22
|
+
/** Server-asked wait before the next try (a 429/503 `Retry-After`), ms. */
|
|
23
|
+
retryAfterMs?: number;
|
|
24
|
+
/**
|
|
25
|
+
* CLIENT-SIDE bookkeeping, not a gateway contract: when this send went out
|
|
26
|
+
* as several requests (chunks of MAX_BATCH_EVENTS, halves after a 413 / an
|
|
27
|
+
* oversize keepalive body / a 400 on a purchase drain), the events whose
|
|
28
|
+
* request did not get a 2xx (or was not tried after a refusal). The caller
|
|
29
|
+
* keeps exactly these, so a chunk that got a 2xx is never re-sent. Absent
|
|
30
|
+
* on a single-request failure: then every event is unaccepted.
|
|
31
|
+
*/
|
|
32
|
+
rejected?: AegisEvent[];
|
|
33
|
+
/**
|
|
34
|
+
* A single event the gateway refused on its own (400, or 413 at one event):
|
|
35
|
+
* re-sending it can never succeed. Set only when `splitOnBadRequest` let the
|
|
36
|
+
* transport narrow a refusal down to one event.
|
|
37
|
+
*/
|
|
38
|
+
terminalEvent?: AegisEvent;
|
|
20
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Browsers refuse a `keepalive` fetch (and `sendBeacon`) whose body is over
|
|
42
|
+
* 64 KB, with a TypeError that looks like status 0. A keepalive body is kept
|
|
43
|
+
* under this many bytes: a larger multi-event request is split before it is
|
|
44
|
+
* sent; a single event over it goes without keepalive.
|
|
45
|
+
*/
|
|
46
|
+
export declare const KEEPALIVE_BODY_MAX_BYTES = 60000;
|
|
47
|
+
/** UTF-8 byte length (the browser's 64 KB limit counts bytes, not chars). */
|
|
48
|
+
export declare function utf8Bytes(text: string): number;
|
|
49
|
+
/**
|
|
50
|
+
* The most events one `/v1/batch` request carries. The gateway answers 413
|
|
51
|
+
* above `SDK_BATCH_MAX_EVENTS` (default 100, docs/architecture/
|
|
52
|
+
* GATEWAY_SDK_RATE_LIMITS.md), so EVERY send — a normal batch, an offline
|
|
53
|
+
* flush, a purchase drain, a beacon — is cut into requests of at most this
|
|
54
|
+
* many. A 413 anyway (an org set a lower cap) splits the request in half and
|
|
55
|
+
* sends each half; a 413 never drops an event.
|
|
56
|
+
*/
|
|
57
|
+
export declare const MAX_BATCH_EVENTS = 100;
|
|
58
|
+
export interface SendOptions {
|
|
59
|
+
/**
|
|
60
|
+
* The caller owns retries and needs to know the server ACCEPTED the batch:
|
|
61
|
+
* never use `sendBeacon` (it reports "queued by the browser", not
|
|
62
|
+
* "accepted"), and make one attempt — the caller re-tries on its own
|
|
63
|
+
* backoff. The purchase backlog (queue.ts) sends this way so a 429 is never
|
|
64
|
+
* the end of a purchase.
|
|
65
|
+
*/
|
|
66
|
+
confirmDelivery?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Send with `keepalive` (default true: the request survives the page
|
|
69
|
+
* unloading, but its body must stay under 64 KB). The purchase drain of a
|
|
70
|
+
* live page passes false so a large chunk is never refused by the browser.
|
|
71
|
+
*/
|
|
72
|
+
keepalive?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Halve a request the gateway answers 400 and narrow the refusal down to
|
|
75
|
+
* the one event it is about (`SendResult.terminalEvent`). The purchase
|
|
76
|
+
* drain uses it so one bad event cannot block the backlog.
|
|
77
|
+
*/
|
|
78
|
+
splitOnBadRequest?: boolean;
|
|
79
|
+
}
|
|
80
|
+
/** Parse a `Retry-After` header (seconds or an HTTP date) into ms, capped at 5 min. */
|
|
81
|
+
export declare function parseRetryAfterMs(value: string | null | undefined, now?: number): number | undefined;
|
|
21
82
|
export declare class Transport {
|
|
22
83
|
private config;
|
|
23
84
|
private storage;
|
|
@@ -36,7 +97,19 @@ export declare class Transport {
|
|
|
36
97
|
private startHealthChecks;
|
|
37
98
|
private performHealthChecks;
|
|
38
99
|
private checkCellHealth;
|
|
39
|
-
send(events: AegisEvent[]): Promise<SendResult>;
|
|
100
|
+
send(events: AegisEvent[], options?: SendOptions): Promise<SendResult>;
|
|
101
|
+
/**
|
|
102
|
+
* One request (<= MAX_BATCH_EVENTS). Halved, never dropped, when:
|
|
103
|
+
* - it is a keepalive request whose body is over KEEPALIVE_BODY_MAX_BYTES
|
|
104
|
+
* (split before sending; the browser would refuse it);
|
|
105
|
+
* - the gateway answers 413;
|
|
106
|
+
* - a keepalive request over KEEPALIVE_SPLIT_ON_ZERO_BYTES fails with
|
|
107
|
+
* status 0 (a browser quota refusal looks like a network error);
|
|
108
|
+
* - the gateway answers 400 and `splitOnBadRequest` is set.
|
|
109
|
+
*/
|
|
110
|
+
private sendChunk;
|
|
111
|
+
private sendHalves;
|
|
112
|
+
private sendOne;
|
|
40
113
|
private getActiveEndpoint;
|
|
41
114
|
private buildPayload;
|
|
42
115
|
private sendViaBeacon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/core/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,WAAW,eAAe;IAC9B,Q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AU,EAAE,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IAyBhF;;;;;;;;OAQG;YACW,SAAS;YA+BT,UAAU;YAqBV,OAAO;IA4BrB,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,aAAa;YAyBP,YAAY;IAqE1B,OAAO,CAAC,WAAW;YAgBL,YAAY;IAqB1B,aAAa,IAAI,YAAY,GAAG,IAAI;IAIpC,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAIzC,OAAO,IAAI,IAAI;CAMhB"}
|
|
@@ -90,5 +90,5 @@ export declare class EcommerceTracker {
|
|
|
90
90
|
promotionViewed(promo: EcommercePromotion): void;
|
|
91
91
|
promotionClicked(promo: EcommercePromotion): void;
|
|
92
92
|
}
|
|
93
|
-
export type { EcommerceProduct, EcommerceCart, EcommerceCheckout, EcommerceOrder, EcommerceCoupon, EcommerceSearch, EcommerceProductList, EcommerceWishlist, EcommerceWaitlist, EcommercePromotion, } from './types';
|
|
93
|
+
export type { EcommerceProduct, EcommerceCart, EcommerceCheckout, EcommerceOrder, EcommerceFulfillmentMode, EcommerceCoupon, EcommerceSearch, EcommerceProductList, EcommerceWishlist, EcommerceWaitlist, EcommercePromotion, } from './types';
|
|
94
94
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ecommerce/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ecommerce/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;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AAE,iBAAiB,GAAG,IAAI;IAkB7D,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAapD,eAAe,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI;IAIhD,gBAAgB,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI;CAGlD;AAED,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,SAAS,CAAC"}
|
|
@@ -49,7 +49,17 @@ export interface EcommerceOrder {
|
|
|
49
49
|
tax?: number;
|
|
50
50
|
discount?: number;
|
|
51
51
|
payment_method?: string;
|
|
52
|
+
/**
|
|
53
|
+
* How the order reaches the customer: `pickup` or `delivery`. The order
|
|
54
|
+
* journey reads it to pick the ready-for-pickup or out-for-delivery step.
|
|
55
|
+
* When omitted, an order with a positive `shipping` charge is sent as
|
|
56
|
+
* `delivery`; otherwise no mode is sent and the order journey still
|
|
57
|
+
* confirms the order and waits for whichever step the order reports.
|
|
58
|
+
* Any other value is dropped (dine-in orders belong to the in-store bill).
|
|
59
|
+
*/
|
|
60
|
+
fulfillment_mode?: EcommerceFulfillmentMode;
|
|
52
61
|
}
|
|
62
|
+
export type EcommerceFulfillmentMode = 'pickup' | 'delivery';
|
|
53
63
|
export interface EcommerceCoupon {
|
|
54
64
|
coupon_id?: string;
|
|
55
65
|
coupon_code: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ecommerce/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,E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Aa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC,UAAU,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC,CAAC;CACzD;AAED,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TraitGovernor — client-side guards for trait writes (P10.5).
|
|
3
3
|
*
|
|
4
|
-
* Runs
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Runs, client-side, stage 1 of the trait-key rule the cell-plane backend
|
|
5
|
+
* applies at EVERY write of `contacts.attributes`
|
|
6
|
+
* (`data_governance.trait_keys.govern_trait_payload`; docs/agent-rules/
|
|
7
|
+
* TRAIT_VOCABULARY.md), plus the value guards, so the SDK can warn developers
|
|
8
|
+
* about problematic keys/values BEFORE network send.
|
|
7
9
|
*
|
|
8
10
|
* Why two chokepoints:
|
|
9
|
-
* - **Backend** (`
|
|
10
|
-
* payloads that bypass the SDK (direct HTTP, CSV import,
|
|
11
|
-
* workers)
|
|
11
|
+
* - **Backend** (`govern_trait_payload` → DLQ): authoritative; it decides the
|
|
12
|
+
* stored key for payloads that bypass the SDK (direct HTTP, CSV import,
|
|
13
|
+
* integration workers) and for older SDKs, and adds stage 2 (ASCII only,
|
|
14
|
+
* accent fold, <= 64 chars). Operators see refused keys, with their value,
|
|
15
|
+
* in the Validation tab.
|
|
16
|
+
* - Key-rule parity: libs/mobile-sdk/tests/drift/trait-governor-verdicts.json
|
|
17
|
+
* (`key_vectors`) is read by tests/trait-governor-vectors.test.ts and the
|
|
18
|
+
* Python guard test_drift_guard_trait_key_rule_parity.py.
|
|
12
19
|
* - **SDK** (this file): developer-facing; warns in console.warn at dev
|
|
13
20
|
* time so the issue is caught BEFORE the bad data hits production. We
|
|
14
21
|
* normalize what we can (key casing, value truncation, date format)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trait-governor.d.ts","sourceRoot":"","sources":["../../src/governance/trait-governor.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"trait-governor.d.ts","sourceRoot":"","sources":["../../src/governance/trait-governor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,MAAM,MAAM,YAAY,GACpB,gBAAgB,GAChB,gBAAgB,GAChB,iBAAiB,GACjB,eAAe,GACf,iBAAiB,CAAC;AAEtB,MAAM,WAAW,SAAS;IACxB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,OAAO,EAAE,YAAY,CAAC;IACtB,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,+DAA+D;IAC/D,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB;AA+FD,qBAAa,aAAa;IACxB,iEAAiE;IACjE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAK;IACrC,4DAA4D;IAC5D,OAAO,CAAC,UAAU,CAAqD;IAEvE;;;;;;;OAOG;IACH,OAAO,CACL,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,EAClD,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAC3B,WAAW;IA+Fd,OAAO,CAAC,SAAS;CAgBlB"}
|