@encorekit/web-sdk 1.1.21 → 2.0.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/README.md +135 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/umd/encore.min.js +1 -1
- package/dist/umd/encore.min.js.map +1 -1
- package/package.json +4 -3
- package/types/analytics/AnalyticsClient.d.ts +11 -1
- package/types/analytics/AnalyticsClient.d.ts.map +1 -1
- package/types/analytics/events.d.ts +197 -3
- package/types/analytics/events.d.ts.map +1 -1
- package/types/analytics/transport.d.ts.map +1 -1
- package/types/api/APIClient.d.ts +32 -7
- package/types/api/APIClient.d.ts.map +1 -1
- package/types/api/generated/types.d.ts +548 -1
- package/types/api/generated/types.d.ts.map +1 -1
- package/types/core/Encore.d.ts.map +1 -1
- package/types/core/OfferManager.d.ts +50 -9
- package/types/core/OfferManager.d.ts.map +1 -1
- package/types/core/PlacementBuilder.d.ts +24 -1
- package/types/core/PlacementBuilder.d.ts.map +1 -1
- package/types/core/useCase.d.ts +21 -0
- package/types/core/useCase.d.ts.map +1 -0
- package/types/core/version.d.ts +1 -1
- package/types/core/version.d.ts.map +1 -1
- package/types/types.d.ts +56 -0
- package/types/types.d.ts.map +1 -1
- package/types/ui/OfferCarousel.d.ts +23 -0
- package/types/ui/OfferCarousel.d.ts.map +1 -1
- package/types/ui/ThankYouLayout.d.ts +11 -0
- package/types/ui/ThankYouLayout.d.ts.map +1 -1
- package/types/ui/styles.d.ts.map +1 -1
- package/examples/react/.env +0 -1
|
@@ -3,11 +3,65 @@
|
|
|
3
3
|
* Event definitions matching cross-platform analytics spec
|
|
4
4
|
*/
|
|
5
5
|
import type { AnalyticsEvent } from './models';
|
|
6
|
+
import type { UseCase } from '../types';
|
|
7
|
+
/**
|
|
8
|
+
* `properties.reason` on `sdk_offer_presentation_failed`. These strings are the
|
|
9
|
+
* cross-SDK vocabulary, not local names: the backend pins them in
|
|
10
|
+
* `packages/core/src/canonical/analytics/index.ts`
|
|
11
|
+
* (`SDKPresentationFailedReason`), iOS produces them from
|
|
12
|
+
* `NotPresentedReason.wireValue`, and Android from `OfferPresentationFailedEvent`.
|
|
13
|
+
*
|
|
14
|
+
* `NO_OFFER_AVAILABLE` is the one this SDK used to get wrong — web emitted
|
|
15
|
+
* camelCase `noOffersAvailable` for the identical condition iOS reports as
|
|
16
|
+
* `no_offer_available`, so every dashboard grouping by reason split one
|
|
17
|
+
* condition across two buckets. The backend registry documents the split
|
|
18
|
+
* explicitly and matches BOTH spellings as a workaround; this constant is the
|
|
19
|
+
* emitter-side fix that lets it eventually match one.
|
|
20
|
+
*
|
|
21
|
+
* `NO_TEMPLATE` deliberately keeps web's existing spelling: `no_template` is the
|
|
22
|
+
* name the BACKEND registry canonicalises (`SDKPresentationFailedReason.NoTemplate`),
|
|
23
|
+
* so web is already correct here and Android's `use_case_unavailable` is the
|
|
24
|
+
* outlier. Aligning that one is an Android change, not a web change.
|
|
25
|
+
*/
|
|
26
|
+
export declare const PresentationFailedReason: {
|
|
27
|
+
readonly NO_OFFER_AVAILABLE: "no_offer_available";
|
|
28
|
+
readonly EXPERIMENT_CONTROL: "experiment_control";
|
|
29
|
+
readonly NO_TEMPLATE: "no_template";
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* `properties.reason` on `sdk_offer_claim_failed` — the failure twin of
|
|
33
|
+
* `sdk_offer_claimed`. Values match iOS's `ClaimFailureReason`, plus one
|
|
34
|
+
* browser-only member: `POPUP_BLOCKED` has no native analogue because only a
|
|
35
|
+
* browser can refuse to open the destination the user just asked for. It is the
|
|
36
|
+
* single most common way a web claim dies and today it only produces a
|
|
37
|
+
* `logger.warn` nobody reads.
|
|
38
|
+
*/
|
|
39
|
+
export declare const ClaimFailureReason: {
|
|
40
|
+
readonly MANAGER_UNAVAILABLE: "manager_unavailable";
|
|
41
|
+
readonly TRANSACTION_START_FAILED: "transaction_start_failed";
|
|
42
|
+
readonly MISSING_DESTINATION_URL: "missing_destination_url";
|
|
43
|
+
readonly INVALID_DESTINATION_URL: "invalid_destination_url";
|
|
44
|
+
readonly POPUP_BLOCKED: "popup_blocked";
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Translate an SDK-internal decline reason to its wire value.
|
|
48
|
+
*
|
|
49
|
+
* Takes the STRING form only. `NotGrantedReason`'s `{type:'error'}` member
|
|
50
|
+
* is a public RESULT shape that never reaches an analytics call site — the flow
|
|
51
|
+
* passes the literal `'error'` for that case (see `endPresentation('error', …)`
|
|
52
|
+
* in Encore.ts) — so accepting the object here would be dead code pretending to
|
|
53
|
+
* be defensive.
|
|
54
|
+
*
|
|
55
|
+
* A reason with no mapping falls back to its raw value rather than being
|
|
56
|
+
* dropped: an unmapped bucket is visible in the warehouse and can be fixed; a
|
|
57
|
+
* missing one is invisible.
|
|
58
|
+
*/
|
|
59
|
+
export declare function declineReasonWireValue(reason: string | undefined): string | undefined;
|
|
6
60
|
export declare function sdkInitialized(distinctId: string, sdkVersion: string, appBundleId: string): AnalyticsEvent;
|
|
7
61
|
export declare function userIdentified(distinctId: string, userId: string, appBundleId: string, attributes?: Record<string, unknown>): AnalyticsEvent;
|
|
8
|
-
export declare function offerPresentationTriggered(distinctId: string, presentationId: string, variantId?: string): AnalyticsEvent;
|
|
9
|
-
export declare function offerPresentationFailed(distinctId: string, reason: string, presentationId: string, variantId?: string): AnalyticsEvent;
|
|
10
|
-
export declare function offerPresentationSuccess(distinctId: string, presentationId: string, offerCount: number, variantId?: string): AnalyticsEvent;
|
|
62
|
+
export declare function offerPresentationTriggered(distinctId: string, presentationId: string, variantId?: string, useCase?: UseCase): AnalyticsEvent;
|
|
63
|
+
export declare function offerPresentationFailed(distinctId: string, reason: string, presentationId: string, variantId?: string, useCase?: UseCase): AnalyticsEvent;
|
|
64
|
+
export declare function offerPresentationSuccess(distinctId: string, presentationId: string, offerCount: number, variantId?: string, useCase?: UseCase): AnalyticsEvent;
|
|
11
65
|
export declare function offerPresented(distinctId: string, params: {
|
|
12
66
|
campaignId: string;
|
|
13
67
|
creativeId: string;
|
|
@@ -18,6 +72,7 @@ export declare function offerPresented(distinctId: string, params: {
|
|
|
18
72
|
presentationTrigger?: string;
|
|
19
73
|
presentationId: string;
|
|
20
74
|
variantId?: string;
|
|
75
|
+
useCase?: UseCase;
|
|
21
76
|
}): AnalyticsEvent;
|
|
22
77
|
export declare function offerClaimed(distinctId: string, params: {
|
|
23
78
|
campaignId: string;
|
|
@@ -29,6 +84,7 @@ export declare function offerClaimed(distinctId: string, params: {
|
|
|
29
84
|
totalOffers: number;
|
|
30
85
|
presentationId: string;
|
|
31
86
|
variantId?: string;
|
|
87
|
+
useCase?: UseCase;
|
|
32
88
|
}): AnalyticsEvent;
|
|
33
89
|
export declare function offerDeclined(distinctId: string, params: {
|
|
34
90
|
campaignId: string;
|
|
@@ -40,6 +96,7 @@ export declare function offerDeclined(distinctId: string, params: {
|
|
|
40
96
|
declineReason?: string;
|
|
41
97
|
presentationId: string;
|
|
42
98
|
variantId?: string;
|
|
99
|
+
useCase?: UseCase;
|
|
43
100
|
}): AnalyticsEvent;
|
|
44
101
|
export declare function offerSheetDismissed(distinctId: string, params: {
|
|
45
102
|
presentationId: string;
|
|
@@ -48,6 +105,7 @@ export declare function offerSheetDismissed(distinctId: string, params: {
|
|
|
48
105
|
offersViewed: number;
|
|
49
106
|
declineReason?: string;
|
|
50
107
|
variantId?: string;
|
|
108
|
+
useCase?: UseCase;
|
|
51
109
|
}): AnalyticsEvent;
|
|
52
110
|
/**
|
|
53
111
|
* Primer-screen (post-claim activation handoff) outcomes. The two events are what
|
|
@@ -60,12 +118,14 @@ export declare function offerActivationContinue(distinctId: string, params: {
|
|
|
60
118
|
campaignId: string;
|
|
61
119
|
presentationId: string;
|
|
62
120
|
variantId?: string;
|
|
121
|
+
useCase?: UseCase;
|
|
63
122
|
}): AnalyticsEvent;
|
|
64
123
|
export declare function offerActivationDismissed(distinctId: string, params: {
|
|
65
124
|
transactionId: string;
|
|
66
125
|
campaignId: string;
|
|
67
126
|
presentationId: string;
|
|
68
127
|
variantId?: string;
|
|
128
|
+
useCase?: UseCase;
|
|
69
129
|
}): AnalyticsEvent;
|
|
70
130
|
export declare function offerTimeSpent(distinctId: string, params: {
|
|
71
131
|
campaignId: string;
|
|
@@ -75,6 +135,140 @@ export declare function offerTimeSpent(distinctId: string, params: {
|
|
|
75
135
|
totalOffers: number;
|
|
76
136
|
presentationId: string;
|
|
77
137
|
variantId?: string;
|
|
138
|
+
useCase?: UseCase;
|
|
139
|
+
}): AnalyticsEvent;
|
|
140
|
+
/**
|
|
141
|
+
* The offer identity every claim-funnel and advertiser-handoff event carries —
|
|
142
|
+
* the same field set iOS threads as `OfferAnalyticsContext`, so a row from web
|
|
143
|
+
* joins a row from iOS on identical keys.
|
|
144
|
+
*
|
|
145
|
+
* Only `campaignId` is required. The presentation-scoped fields are optional
|
|
146
|
+
* because `redeem()` legitimately runs on a LATER page load, with only the
|
|
147
|
+
* stored transaction in hand and no live presentation: there is no impression or
|
|
148
|
+
* presentation id to report, and minting one would be worse than omitting it —
|
|
149
|
+
* `impression_id` is the warehouse's primary claim↔completion join key, so a
|
|
150
|
+
* fabricated value joins against nothing while looking like real coverage.
|
|
151
|
+
* Those rows join on `transaction_id` instead, the documented fallback. Same
|
|
152
|
+
* rule iOS applies to its cross-launch `OfferVerifiedEvent`: absent context
|
|
153
|
+
* fields stay absent, never fabricated.
|
|
154
|
+
*/
|
|
155
|
+
export interface OfferEventContext {
|
|
156
|
+
campaignId: string;
|
|
157
|
+
creativeId?: string;
|
|
158
|
+
advertiserName?: string;
|
|
159
|
+
impressionId?: string;
|
|
160
|
+
offerIndex?: number;
|
|
161
|
+
totalOffers?: number;
|
|
162
|
+
presentationId?: string;
|
|
163
|
+
variantId?: string;
|
|
164
|
+
useCase?: UseCase;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* The claim TAP, emitted before any guard can fail — the advertiser funnel's
|
|
168
|
+
* true denominator. `sdk_offer_claimed` fires only once a transaction exists, so
|
|
169
|
+
* on its own it cannot distinguish "nobody tapped Claim" from "everybody tapped
|
|
170
|
+
* and the transaction call failed". Mirrors iOS `OfferClaimTappedEvent`.
|
|
171
|
+
*/
|
|
172
|
+
export declare function offerClaimTapped(distinctId: string, ctx: OfferEventContext): AnalyticsEvent;
|
|
173
|
+
/**
|
|
174
|
+
* A claim tap that never reached the advertiser — the failure twin of
|
|
175
|
+
* `sdk_offer_claimed`. Together they make every claim outcome observable, so a
|
|
176
|
+
* regression like a silently-rejected transaction shows up as a failure rather
|
|
177
|
+
* than as users who simply didn't tap. Mirrors iOS `OfferClaimFailedEvent`.
|
|
178
|
+
*
|
|
179
|
+
* `errorDescription` is the caught error's message, included only for
|
|
180
|
+
* `transaction_start_failed` to separate network from server-side reject. It is
|
|
181
|
+
* an SDK-produced message, never publisher data.
|
|
182
|
+
*/
|
|
183
|
+
export declare function offerClaimFailed(distinctId: string, ctx: OfferEventContext, params: {
|
|
184
|
+
reason: string;
|
|
185
|
+
errorDescription?: string;
|
|
186
|
+
transactionId?: string;
|
|
187
|
+
}): AnalyticsEvent;
|
|
188
|
+
/**
|
|
189
|
+
* The user came back to the host page from the advertiser. iOS reads this off
|
|
190
|
+
* the in-app Safari dismissal; web reads the equivalent moment — the host
|
|
191
|
+
* document regaining focus/visibility after the advertiser tab was opened. It is
|
|
192
|
+
* the one signal that separates "we handed the user off" from "the user actually
|
|
193
|
+
* engaged and returned". Mirrors iOS `OfferClaimReturnedEvent`.
|
|
194
|
+
*/
|
|
195
|
+
export declare function offerClaimReturned(distinctId: string, ctx: OfferEventContext, params: {
|
|
196
|
+
transactionId?: string;
|
|
197
|
+
}): AnalyticsEvent;
|
|
198
|
+
/**
|
|
199
|
+
* Web's advertiser handoff is a browser tab, not an embedded webview, so these
|
|
200
|
+
* keep iOS's event NAMES (the warehouse funnel is keyed on them) while reporting
|
|
201
|
+
* only what a browser can actually observe. `docs/architecture/analytics-events.md`
|
|
202
|
+
* lists the two members of the iOS funnel this SDK deliberately does NOT emit
|
|
203
|
+
* (`_load_success` and `_initial_redirect` — both need to see inside the
|
|
204
|
+
* cross-origin advertiser context).
|
|
205
|
+
*
|
|
206
|
+
* `url` / `urlHost` describe the ADVERTISER destination the SDK itself composed —
|
|
207
|
+
* never the host page's own URL, which can carry publisher query data.
|
|
208
|
+
*/
|
|
209
|
+
export declare function offerWebviewAttemptingOpen(distinctId: string, ctx: OfferEventContext, params: {
|
|
210
|
+
url: string;
|
|
211
|
+
urlHost: string;
|
|
212
|
+
}): AnalyticsEvent;
|
|
213
|
+
/** The advertiser window handle was obtained and navigated to the destination. */
|
|
214
|
+
export declare function offerWebviewOpened(distinctId: string, ctx: OfferEventContext, params: {
|
|
215
|
+
url: string;
|
|
216
|
+
urlHost: string;
|
|
217
|
+
openedAt: string;
|
|
218
|
+
}): AnalyticsEvent;
|
|
219
|
+
/**
|
|
220
|
+
* The handoff failed — on web this is overwhelmingly a blocked popup. Carries
|
|
221
|
+
* `loadSuccess: false` for wire-shape parity with iOS's load_failed row.
|
|
222
|
+
*/
|
|
223
|
+
export declare function offerWebviewLoadFailed(distinctId: string, ctx: OfferEventContext, params: {
|
|
224
|
+
url: string;
|
|
225
|
+
urlHost: string;
|
|
226
|
+
reason: string;
|
|
227
|
+
}): AnalyticsEvent;
|
|
228
|
+
/** Dwell at the advertiser, measured from handoff to the host page regaining focus. */
|
|
229
|
+
export declare function offerWebviewDismissed(distinctId: string, ctx: OfferEventContext, params: {
|
|
230
|
+
timeSpentSeconds: number;
|
|
231
|
+
}): AnalyticsEvent;
|
|
232
|
+
/**
|
|
233
|
+
* The server-assigned variant landed and the sheet will render it.
|
|
234
|
+
*
|
|
235
|
+
* Web has no server-driven-UI RENDERER (see `UseCase` in types.ts), but it is
|
|
236
|
+
* served by the same variant assignment as iOS/Android: `/config` returns
|
|
237
|
+
* `ui.variantId` plus the variant's copy. So the variant dimension is real here
|
|
238
|
+
* and this event is the one that makes it readable — without it, a web row's
|
|
239
|
+
* `variant_id` has no denominator saying how many users the variant reached.
|
|
240
|
+
*
|
|
241
|
+
* `loadSource` is the cross-SDK frozen vocabulary; web can only ever report
|
|
242
|
+
* `'remote'` (config resolved) or `'fallback'` (it did not, and the bundled copy
|
|
243
|
+
* rendered). It never reports `'cache'` — web persists no variant/template pair,
|
|
244
|
+
* so claiming a cache tier would describe a mechanism this SDK does not have.
|
|
245
|
+
*/
|
|
246
|
+
export declare function sduiConfigLoaded(distinctId: string, params: {
|
|
247
|
+
variantId?: string;
|
|
248
|
+
loadSource: 'remote' | 'fallback';
|
|
249
|
+
loadDurationMs: number;
|
|
250
|
+
presentationId?: string;
|
|
251
|
+
}): AnalyticsEvent;
|
|
252
|
+
/**
|
|
253
|
+
* A control in the offer sheet was activated. `actionType` uses iOS's action
|
|
254
|
+
* vocabulary so the same query reads both platforms.
|
|
255
|
+
*/
|
|
256
|
+
export declare function sduiButtonTapped(distinctId: string, params: {
|
|
257
|
+
variantId?: string;
|
|
258
|
+
actionType: 'close' | 'claimOffer' | 'openUrl' | 'next' | 'previous';
|
|
259
|
+
presentationId: string;
|
|
260
|
+
currentState: string;
|
|
261
|
+
}): AnalyticsEvent;
|
|
262
|
+
/**
|
|
263
|
+
* The user moved through the offer carousel. `scrollAxis` is genuinely
|
|
264
|
+
* bi-modal on web: the carousel is horizontal on desktop and a vertical list on
|
|
265
|
+
* mobile, and which one a user got is a real analysis dimension iOS does not have.
|
|
266
|
+
*/
|
|
267
|
+
export declare function sduiScroll(distinctId: string, params: {
|
|
268
|
+
variantId?: string;
|
|
269
|
+
scrollAxis: 'horizontal' | 'vertical';
|
|
270
|
+
scrollPosition: number;
|
|
271
|
+
presentationId: string;
|
|
78
272
|
}): AnalyticsEvent;
|
|
79
273
|
/**
|
|
80
274
|
* Exposure at the offer trigger — logged for BOTH treatment and control to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/analytics/events.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/analytics/events.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAMxC;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,wBAAwB;;;;CAI3B,CAAC;AAEX;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB;;;;;;CAMrB,CAAC;AA+BX;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAGrF;AAMD,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,cAAc,CAMhB;AAED,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,cAAc,CAMhB;AAkCD,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EACtB,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,OAAO,GAChB,cAAc,CAMhB;AAED,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,EACtB,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,OAAO,GAChB,cAAc,CAMhB;AAED,wBAAgB,wBA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AG,UAAU,CAAC;IACtC,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB,GACA,cAAc,CAWhB;AAMD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,GACxE,cAAc,CAWhB;AAMD,wBAAgB,QAAQ,CACtB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,MAAM,EACxB,OAAO,CAAC,EAAE,MAAM,GACf,cAAc,CAMhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/analytics/transport.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/analytics/transport.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAiD9D;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,GAAE,MAAuB,GAAG,aAAa,CAcpG;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAChC,OAAO,CAAC,QAAQ,CAAC,CAWnB"}
|
package/types/api/APIClient.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Low-level HTTP client using native fetch with retries, timeout, and deduplication
|
|
4
4
|
* Also provides high-level methods for specific API endpoints
|
|
5
5
|
*/
|
|
6
|
-
import type { UserAttributes, Entitlement, VerificationStatus } from '../types';
|
|
6
|
+
import type { UserAttributes, Entitlement, VerificationStatus, UseCase } from '../types';
|
|
7
7
|
import type { StartTransactionResponse, InitUserResponse, IdentifyUserResponse, RemoteConfigResponse, OfferModel, BackendVerificationStatus } from './models';
|
|
8
8
|
interface RequestOptions {
|
|
9
9
|
method: 'GET' | 'POST' | 'PATCH';
|
|
@@ -36,15 +36,26 @@ export declare class APIClient {
|
|
|
36
36
|
*/
|
|
37
37
|
patch<T>(endpoint: string, body?: unknown, options?: Partial<RequestOptions>): Promise<T>;
|
|
38
38
|
/**
|
|
39
|
-
* Fetch offers for a user
|
|
39
|
+
* Fetch offers for a user. `placementId` is best-effort analytics context (max 64
|
|
40
|
+
* chars per contract) — stamped server-side onto sdk_offer_requested; omitted for
|
|
41
|
+
* an auto-generated/absent placement id (buckets as '(unlabeled)' server-side).
|
|
42
|
+
*
|
|
43
|
+
* Truncated client-side to the contract's own limit (`z.string().max(64)` on
|
|
44
|
+
* `/offers/search` — see backend `offers/dto.ts`) rather than sent verbatim: the
|
|
45
|
+
* backend rejects the WHOLE request with a 400 on an oversized value, which would
|
|
46
|
+
* turn this best-effort label into a hard failure of the entire offers fetch for
|
|
47
|
+
* a publisher who simply named their placement something long. Truncating keeps
|
|
48
|
+
* the analytics label degraded-but-present instead of losing the offer entirely.
|
|
40
49
|
*/
|
|
41
|
-
fetchOffers(userId: string, attributes: UserAttributes): Promise<{
|
|
50
|
+
fetchOffers(userId: string, attributes: UserAttributes, placementId?: string): Promise<{
|
|
42
51
|
offers: OfferModel[];
|
|
43
52
|
}>;
|
|
44
53
|
/**
|
|
45
|
-
* Start a transaction for an offer
|
|
54
|
+
* Start a transaction for an offer. `useCase` is omitted for 'churn-intervention' (the
|
|
55
|
+
* contract's own default) rather than sent explicitly, keeping the wire payload
|
|
56
|
+
* byte-identical to before this dimension existed for every existing caller.
|
|
46
57
|
*/
|
|
47
|
-
startTransaction(campaignId: string, userId: string): Promise<StartTransactionResponse>;
|
|
58
|
+
startTransaction(campaignId: string, userId: string, useCase?: UseCase): Promise<StartTransactionResponse>;
|
|
48
59
|
/**
|
|
49
60
|
* Send grant signal (provisional or final)
|
|
50
61
|
*/
|
|
@@ -75,9 +86,23 @@ export declare class APIClient {
|
|
|
75
86
|
name?: string;
|
|
76
87
|
}): Promise<IdentifyUserResponse>;
|
|
77
88
|
/**
|
|
78
|
-
* Fetch remote config
|
|
89
|
+
* Fetch remote config.
|
|
90
|
+
*
|
|
91
|
+
* `useCase` selects which SURFACE the response's `ui` block resolves, and the
|
|
92
|
+
* response echoes it back as `ui.useCase`. It is deliberately OMITTED for both
|
|
93
|
+
* `undefined` and an explicit `'churn-intervention'`, so the eager
|
|
94
|
+
* configure()-time fetch stays byte-identical to every pre-use-case SDK — the
|
|
95
|
+
* same convention `startTransaction` already uses for this dimension.
|
|
96
|
+
*
|
|
97
|
+
* Two callers, two very different requests:
|
|
98
|
+
* - The EAGER fetch (once, at configure()) passes no use case. Its response
|
|
99
|
+
* carries churn-intervention in `ui` PLUS the `useCases` prefetch block.
|
|
100
|
+
* - The LAZY fetch (at most once per use case, only when the block did not
|
|
101
|
+
* carry it) passes one. Its response resolves that surface in `ui`
|
|
102
|
+
* INCLUDING experiments — which the prefetch block, carrying only default
|
|
103
|
+
* variants, cannot do.
|
|
79
104
|
*/
|
|
80
|
-
fetchConfig(userId: string, sdkVersion: string): Promise<RemoteConfigResponse>;
|
|
105
|
+
fetchConfig(userId: string, sdkVersion: string, useCase?: UseCase): Promise<RemoteConfigResponse>;
|
|
81
106
|
/**
|
|
82
107
|
* Report a client error (fire-and-forget)
|
|
83
108
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"APIClient.d.ts","sourceRoot":"","sources":["../../src/api/APIClient.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAe,cAAc,EAAE,WAA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