@encorekit/web-sdk 2.2.1 → 2.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.
Files changed (269) hide show
  1. package/README.md +66 -1
  2. package/dist/cjs/index.cjs +1 -1
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs/preview.cjs +2 -0
  5. package/dist/cjs/preview.cjs.map +1 -0
  6. package/dist/cjs/react.cjs +1 -1
  7. package/dist/cjs/react.cjs.map +1 -1
  8. package/dist/esm/chunks/ClaimReminder-DFyrm5bJ.js +2 -0
  9. package/dist/esm/chunks/ClaimReminder-DFyrm5bJ.js.map +1 -0
  10. package/dist/esm/chunks/GiftsButton-B0lVB463.js +2 -0
  11. package/dist/esm/chunks/GiftsButton-B0lVB463.js.map +1 -0
  12. package/dist/esm/chunks/TriggerHost-CNTiNrTH.js +2 -0
  13. package/dist/esm/chunks/TriggerHost-CNTiNrTH.js.map +1 -0
  14. package/dist/esm/chunks/autoPops-CngtK_R0.js +2 -0
  15. package/dist/esm/chunks/autoPops-CngtK_R0.js.map +1 -0
  16. package/dist/esm/chunks/customClaim-B4uj-aOc.js +2 -0
  17. package/dist/esm/chunks/customClaim-B4uj-aOc.js.map +1 -0
  18. package/dist/esm/chunks/eligibility-BY7fL8Ve.js +2 -0
  19. package/dist/esm/chunks/eligibility-BY7fL8Ve.js.map +1 -0
  20. package/dist/esm/chunks/index-CaBSqauy.js +2 -0
  21. package/dist/esm/chunks/index-CaBSqauy.js.map +1 -0
  22. package/dist/esm/chunks/lookValues-B9z2VWpH.js +2 -0
  23. package/dist/esm/chunks/lookValues-B9z2VWpH.js.map +1 -0
  24. package/dist/esm/chunks/sduiView-Ds7QtFId.js +2 -0
  25. package/dist/esm/chunks/sduiView-Ds7QtFId.js.map +1 -0
  26. package/dist/esm/chunks/spot-DkKMLpB-.js +2 -0
  27. package/dist/esm/chunks/spot-DkKMLpB-.js.map +1 -0
  28. package/dist/esm/chunks/template-B9p4CbPD.js +2 -0
  29. package/dist/esm/chunks/template-B9p4CbPD.js.map +1 -0
  30. package/dist/esm/chunks/textSlots-BnwxUg9V.js +2 -0
  31. package/dist/esm/chunks/textSlots-BnwxUg9V.js.map +1 -0
  32. package/dist/esm/chunks/timers-Bva4yoGM.js +2 -0
  33. package/dist/esm/chunks/timers-Bva4yoGM.js.map +1 -0
  34. package/dist/esm/index.js +1 -1
  35. package/dist/esm/index.js.map +1 -1
  36. package/dist/esm/preview.js +2 -0
  37. package/dist/esm/preview.js.map +1 -0
  38. package/dist/esm/react.js +1 -1
  39. package/dist/esm/react.js.map +1 -1
  40. package/dist/umd/encore.min.js +1 -1
  41. package/dist/umd/encore.min.js.map +1 -1
  42. package/package.json +9 -1
  43. package/types/analytics/DiagnosticsOutbox.d.ts +1 -0
  44. package/types/analytics/DiagnosticsOutbox.d.ts.map +1 -1
  45. package/types/analytics/events.d.ts +108 -8
  46. package/types/analytics/events.d.ts.map +1 -1
  47. package/types/analytics/models.d.ts +2 -0
  48. package/types/analytics/models.d.ts.map +1 -1
  49. package/types/analytics/transport.d.ts +6 -0
  50. package/types/analytics/transport.d.ts.map +1 -1
  51. package/types/api/APIClient.d.ts +70 -33
  52. package/types/api/APIClient.d.ts.map +1 -1
  53. package/types/api/contract.d.ts +4 -1
  54. package/types/api/contract.d.ts.map +1 -1
  55. package/types/api/generated/types.d.ts +994 -17
  56. package/types/api/generated/types.d.ts.map +1 -1
  57. package/types/api/models.d.ts +29 -8
  58. package/types/api/models.d.ts.map +1 -1
  59. package/types/api/offerBuilder.d.ts +51 -0
  60. package/types/api/offerBuilder.d.ts.map +1 -0
  61. package/types/core/Configuration.d.ts +9 -0
  62. package/types/core/Configuration.d.ts.map +1 -1
  63. package/types/core/Encore.d.ts +145 -3
  64. package/types/core/Encore.d.ts.map +1 -1
  65. package/types/core/OfferManager.d.ts +27 -5
  66. package/types/core/OfferManager.d.ts.map +1 -1
  67. package/types/core/PlacementBuilder.d.ts +6 -1
  68. package/types/core/PlacementBuilder.d.ts.map +1 -1
  69. package/types/core/SignalManager.d.ts.map +1 -1
  70. package/types/core/StorageManager.d.ts +3 -2
  71. package/types/core/StorageManager.d.ts.map +1 -1
  72. package/types/core/StrictUnlockReconciler.d.ts +1 -1
  73. package/types/core/StrictUnlockReconciler.d.ts.map +1 -1
  74. package/types/core/claimHandle.d.ts +44 -0
  75. package/types/core/claimHandle.d.ts.map +1 -0
  76. package/types/core/claimLog.d.ts +102 -0
  77. package/types/core/claimLog.d.ts.map +1 -0
  78. package/types/core/claimRefusal.d.ts +3 -0
  79. package/types/core/claimRefusal.d.ts.map +1 -0
  80. package/types/core/claimScreenVariant.d.ts +3 -0
  81. package/types/core/claimScreenVariant.d.ts.map +1 -0
  82. package/types/core/claimStatusCheck.d.ts +62 -0
  83. package/types/core/claimStatusCheck.d.ts.map +1 -0
  84. package/types/core/giftVariant.d.ts +5 -0
  85. package/types/core/giftVariant.d.ts.map +1 -1
  86. package/types/core/hostDisplay.d.ts +9 -2
  87. package/types/core/hostDisplay.d.ts.map +1 -1
  88. package/types/core/sduiVariables.d.ts +20 -0
  89. package/types/core/sduiVariables.d.ts.map +1 -0
  90. package/types/core/strings.d.ts +114 -0
  91. package/types/core/strings.d.ts.map +1 -0
  92. package/types/core/unlockCode.d.ts +12 -2
  93. package/types/core/unlockCode.d.ts.map +1 -1
  94. package/types/core/userKeys.d.ts +7 -0
  95. package/types/core/userKeys.d.ts.map +1 -0
  96. package/types/core/version.d.ts +1 -1
  97. package/types/experiments/ExposureOutbox.d.ts +1 -0
  98. package/types/experiments/ExposureOutbox.d.ts.map +1 -1
  99. package/types/preview.d.ts +51 -0
  100. package/types/preview.d.ts.map +1 -0
  101. package/types/react.d.ts +53 -1
  102. package/types/react.d.ts.map +1 -1
  103. package/types/sdui/actions.d.ts +93 -0
  104. package/types/sdui/actions.d.ts.map +1 -0
  105. package/types/sdui/bindings.d.ts +63 -0
  106. package/types/sdui/bindings.d.ts.map +1 -0
  107. package/types/sdui/compile.d.ts +88 -0
  108. package/types/sdui/compile.d.ts.map +1 -0
  109. package/types/sdui/conditions.d.ts +22 -0
  110. package/types/sdui/conditions.d.ts.map +1 -0
  111. package/types/sdui/context.d.ts +132 -0
  112. package/types/sdui/context.d.ts.map +1 -0
  113. package/types/sdui/countdown.d.ts +31 -0
  114. package/types/sdui/countdown.d.ts.map +1 -0
  115. package/types/sdui/decode.d.ts +35 -0
  116. package/types/sdui/decode.d.ts.map +1 -0
  117. package/types/sdui/deps.d.ts +43 -0
  118. package/types/sdui/deps.d.ts.map +1 -0
  119. package/types/sdui/dominantColor.d.ts +24 -0
  120. package/types/sdui/dominantColor.d.ts.map +1 -0
  121. package/types/sdui/elements/confetti.d.ts +38 -0
  122. package/types/sdui/elements/confetti.d.ts.map +1 -0
  123. package/types/sdui/elements/content.d.ts +27 -0
  124. package/types/sdui/elements/content.d.ts.map +1 -0
  125. package/types/sdui/elements/interactive.d.ts +48 -0
  126. package/types/sdui/elements/interactive.d.ts.map +1 -0
  127. package/types/sdui/elements/layout.d.ts +41 -0
  128. package/types/sdui/elements/layout.d.ts.map +1 -0
  129. package/types/sdui/elements/marquee.d.ts +17 -0
  130. package/types/sdui/elements/marquee.d.ts.map +1 -0
  131. package/types/sdui/elements/progress.d.ts +10 -0
  132. package/types/sdui/elements/progress.d.ts.map +1 -0
  133. package/types/sdui/elements/shared.d.ts +138 -0
  134. package/types/sdui/elements/shared.d.ts.map +1 -0
  135. package/types/sdui/elements/symbols.d.ts +22 -0
  136. package/types/sdui/elements/symbols.d.ts.map +1 -0
  137. package/types/sdui/elements/triggerText.d.ts +55 -0
  138. package/types/sdui/elements/triggerText.d.ts.map +1 -0
  139. package/types/sdui/host.d.ts +274 -0
  140. package/types/sdui/host.d.ts.map +1 -0
  141. package/types/sdui/inlineMarkup.d.ts +22 -0
  142. package/types/sdui/inlineMarkup.d.ts.map +1 -0
  143. package/types/sdui/lookValues.d.ts +50 -0
  144. package/types/sdui/lookValues.d.ts.map +1 -0
  145. package/types/sdui/model.d.ts +130 -0
  146. package/types/sdui/model.d.ts.map +1 -0
  147. package/types/sdui/motion.d.ts +37 -0
  148. package/types/sdui/motion.d.ts.map +1 -0
  149. package/types/sdui/precheck.d.ts +94 -0
  150. package/types/sdui/precheck.d.ts.map +1 -0
  151. package/types/sdui/scrollMath.d.ts +32 -0
  152. package/types/sdui/scrollMath.d.ts.map +1 -0
  153. package/types/sdui/style.d.ts +99 -0
  154. package/types/sdui/style.d.ts.map +1 -0
  155. package/types/sdui/triggerKit.d.ts +24 -0
  156. package/types/sdui/triggerKit.d.ts.map +1 -0
  157. package/types/sdui/unrunnable.d.ts +11 -0
  158. package/types/sdui/unrunnable.d.ts.map +1 -0
  159. package/types/sdui/vocabulary.d.ts +119 -0
  160. package/types/sdui/vocabulary.d.ts.map +1 -0
  161. package/types/triggers/claimReminder/ClaimReminder.d.ts +65 -0
  162. package/types/triggers/claimReminder/ClaimReminder.d.ts.map +1 -0
  163. package/types/triggers/claimReminder/bindings.d.ts +40 -0
  164. package/types/triggers/claimReminder/bindings.d.ts.map +1 -0
  165. package/types/triggers/claimReminder/config.d.ts +56 -0
  166. package/types/triggers/claimReminder/config.d.ts.map +1 -0
  167. package/types/triggers/claimReminder/eligibility.d.ts +37 -0
  168. package/types/triggers/claimReminder/eligibility.d.ts.map +1 -0
  169. package/types/triggers/claimReminder/servedWindow.d.ts +15 -0
  170. package/types/triggers/claimReminder/servedWindow.d.ts.map +1 -0
  171. package/types/triggers/claimReminder/source.d.ts +29 -0
  172. package/types/triggers/claimReminder/source.d.ts.map +1 -0
  173. package/types/triggers/giftsButton/GiftsButton.d.ts +60 -0
  174. package/types/triggers/giftsButton/GiftsButton.d.ts.map +1 -0
  175. package/types/triggers/giftsButton/config.d.ts +53 -0
  176. package/types/triggers/giftsButton/config.d.ts.map +1 -0
  177. package/types/triggers/giftsButton/spot.d.ts +54 -0
  178. package/types/triggers/giftsButton/spot.d.ts.map +1 -0
  179. package/types/triggers/host/TriggerHost.d.ts +127 -0
  180. package/types/triggers/host/TriggerHost.d.ts.map +1 -0
  181. package/types/triggers/host/autoPops.d.ts +16 -0
  182. package/types/triggers/host/autoPops.d.ts.map +1 -0
  183. package/types/triggers/host/configCache.d.ts +29 -0
  184. package/types/triggers/host/configCache.d.ts.map +1 -0
  185. package/types/triggers/host/customClaim.d.ts +85 -0
  186. package/types/triggers/host/customClaim.d.ts.map +1 -0
  187. package/types/triggers/host/dismissStore.d.ts +37 -0
  188. package/types/triggers/host/dismissStore.d.ts.map +1 -0
  189. package/types/triggers/host/readThrottle.d.ts +15 -0
  190. package/types/triggers/host/readThrottle.d.ts.map +1 -0
  191. package/types/triggers/host/registry.d.ts +17 -0
  192. package/types/triggers/host/registry.d.ts.map +1 -0
  193. package/types/triggers/host/sduiView.d.ts +31 -0
  194. package/types/triggers/host/sduiView.d.ts.map +1 -0
  195. package/types/triggers/host/template.d.ts +28 -0
  196. package/types/triggers/host/template.d.ts.map +1 -0
  197. package/types/triggers/host/textSlots.d.ts +35 -0
  198. package/types/triggers/host/textSlots.d.ts.map +1 -0
  199. package/types/triggers/host/theme.d.ts +87 -0
  200. package/types/triggers/host/theme.d.ts.map +1 -0
  201. package/types/triggers/host/timers.d.ts +11 -0
  202. package/types/triggers/host/timers.d.ts.map +1 -0
  203. package/types/triggers/host/types.d.ts +278 -0
  204. package/types/triggers/host/types.d.ts.map +1 -0
  205. package/types/triggers/host/wire.d.ts +55 -0
  206. package/types/triggers/host/wire.d.ts.map +1 -0
  207. package/types/triggers/preview.d.ts +78 -0
  208. package/types/triggers/preview.d.ts.map +1 -0
  209. package/types/triggers/request.d.ts +53 -0
  210. package/types/triggers/request.d.ts.map +1 -0
  211. package/types/types.d.ts +420 -4
  212. package/types/types.d.ts.map +1 -1
  213. package/types/ui/ClaimScreen.d.ts +62 -0
  214. package/types/ui/ClaimScreen.d.ts.map +1 -0
  215. package/types/ui/CodeUnlock.d.ts +26 -2
  216. package/types/ui/CodeUnlock.d.ts.map +1 -1
  217. package/types/ui/GiftHero.d.ts.map +1 -1
  218. package/types/ui/GiftList.d.ts.map +1 -1
  219. package/types/ui/GiftPicker.d.ts.map +1 -1
  220. package/types/ui/GiftPickerHero.d.ts.map +1 -1
  221. package/types/ui/GiftReveal.d.ts.map +1 -1
  222. package/types/ui/GiftSheet.d.ts +5 -5
  223. package/types/ui/GiftSheet.d.ts.map +1 -1
  224. package/types/ui/GiftUnwrap.d.ts.map +1 -1
  225. package/types/ui/OfferCard.d.ts.map +1 -1
  226. package/types/ui/OfferCarousel.d.ts.map +1 -1
  227. package/types/ui/OfferModal.d.ts +31 -6
  228. package/types/ui/OfferModal.d.ts.map +1 -1
  229. package/types/ui/PrimerScreen.d.ts +2 -0
  230. package/types/ui/PrimerScreen.d.ts.map +1 -1
  231. package/types/ui/RedemptionScreen.d.ts +5 -0
  232. package/types/ui/RedemptionScreen.d.ts.map +1 -1
  233. package/types/ui/RewardActions.d.ts.map +1 -1
  234. package/types/ui/RewardCard.d.ts.map +1 -1
  235. package/types/ui/SduiRewardSurface.d.ts +145 -0
  236. package/types/ui/SduiRewardSurface.d.ts.map +1 -0
  237. package/types/ui/Tooltip.d.ts.map +1 -1
  238. package/types/ui/brandComponents.d.ts.map +1 -1
  239. package/types/ui/brandTint.d.ts.map +1 -1
  240. package/types/ui/colorScheme.d.ts +15 -0
  241. package/types/ui/colorScheme.d.ts.map +1 -0
  242. package/types/ui/covered.d.ts +12 -0
  243. package/types/ui/covered.d.ts.map +1 -0
  244. package/types/ui/giftCategoryGroups.d.ts +13 -0
  245. package/types/ui/giftCategoryGroups.d.ts.map +1 -1
  246. package/types/ui/giftCopy.d.ts +14 -9
  247. package/types/ui/giftCopy.d.ts.map +1 -1
  248. package/types/ui/giftUnwrapCopy.d.ts.map +1 -1
  249. package/types/ui/imageURL.d.ts +44 -0
  250. package/types/ui/imageURL.d.ts.map +1 -0
  251. package/types/ui/impressionGate.d.ts +9 -0
  252. package/types/ui/impressionGate.d.ts.map +1 -1
  253. package/types/ui/offerBadge.d.ts.map +1 -1
  254. package/types/ui/rewardSurface.d.ts +11 -1
  255. package/types/ui/rewardSurface.d.ts.map +1 -1
  256. package/types/ui/sduiTheme.d.ts +48 -0
  257. package/types/ui/sduiTheme.d.ts.map +1 -0
  258. package/types/ui/sheetDetents.d.ts +28 -0
  259. package/types/ui/sheetDetents.d.ts.map +1 -0
  260. package/types/ui/styles.d.ts +11 -8
  261. package/types/ui/styles.d.ts.map +1 -1
  262. package/types/ui/termsLine.d.ts +3 -3
  263. package/types/ui/termsLine.d.ts.map +1 -1
  264. package/types/ui/toast.d.ts +11 -0
  265. package/types/ui/toast.d.ts.map +1 -0
  266. package/types/utils/logger.d.ts +10 -0
  267. package/types/utils/logger.d.ts.map +1 -1
  268. package/types/utils/text.d.ts +17 -0
  269. package/types/utils/text.d.ts.map +1 -1
package/README.md CHANGED
@@ -231,9 +231,30 @@ react to a claim or a dismissal.
231
231
  | Status | Meaning |
232
232
  |:-------|:--------|
233
233
  | `{ status: 'claimed', offerId, campaignId, advertiserName, transactionId? }` | The user claimed an offer. The advertiser opened in a new tab inside the tap gesture and the SDK renders nothing afterwards — the host owns that moment, so render your own confirmation if you want one. The payload mirrors iOS's and Android's `ClaimedOffer` field-for-field. **`transactionId` carries the attribution** — it is how a completion that lands days later is traced back to this user and app, and it is the argument `didGrant()` and `waitForVerification()` take. It is optional because the transaction write can fail while the claim genuinely happened; the SDK logs a warning when that occurs. |
234
- | `{ status: 'dismissed', reason? }` | The sheet closed without a claim. Failures land here too, carrying `reason.error`. |
234
+ | `{ status: 'dismissed', reason? }` | The sheet closed without a claim. Failures land here too, carrying `reason.error`. `reason: 'alreadyCompleted'` means the server refused the claim because this user already completed the offer; see below. |
235
235
  | `{ status: 'unavailable' }` | Nothing was presented — no eligible offers, or the surface did not resolve. |
236
236
 
237
+ #### When the user already completed the offer
238
+
239
+ If the user taps Claim on an offer they already completed, the server refuses the
240
+ claim. `show()` resolves:
241
+
242
+ ```typescript
243
+ { status: 'dismissed', reason: 'alreadyCompleted' }
244
+ ```
245
+
246
+ It is an expected outcome, not a failure. Nothing is granted, nothing is sent to
247
+ error tracking, and the advertiser tab opened for the claim is closed again.
248
+ `onNotGranted` receives the same `'alreadyCompleted'`, and `presentOffer()`
249
+ resolves `{ granted: false, reason: 'alreadyCompleted' }`. It comes from the
250
+ server's `offerAlreadyCompleted` code. The app-wide trial limit
251
+ (`userAlreadyConverted`) refuses every offer, so it stays an `{ type: 'error' }`
252
+ reason, as does a refusal from a backend that sends no code.
253
+
254
+ For the rest of the session (until the user id changes), the SDK leaves that
255
+ campaign out of the session's offer list, so it is not offered again. A claim
256
+ that started but has not completed does not hide the offer.
257
+
237
258
  `claimed` deliberately makes no assertion about advertiser conversion: that is
238
259
  asynchronous and server-authoritative. Verify entitlements and conversions
239
260
  server-side, by user, never from the client.
@@ -375,6 +396,50 @@ and it has several causes — so do not read it as "not enabled":
375
396
  See [the use-case serving model](https://github.com/EncoreKit/web-sdk/blob/main/docs/architecture/use-case-serving.md)
376
397
  for the full design note.
377
398
 
399
+ ## Language
400
+
401
+ Encore's copy and offers follow one language per session. By default that is the
402
+ browser's `Accept-Language`. To choose one yourself, call `Encore.setLanguage()`
403
+ after `configure()` with a BCP 47 language tag, such as `'fr'` or `'pt-BR'`:
404
+
405
+ ```typescript
406
+ Encore.configure({ apiKey: 'your-api-key-here' });
407
+ Encore.setLanguage('pt-BR');
408
+ ```
409
+
410
+ The same language goes on the config request and the offers request, so the
411
+ sheet's copy and its offers are always in one language, and analytics events carry
412
+ the locale Encore served. Only languages Encore has enabled for your app are
413
+ served; any other language falls back to `Accept-Language`, then your app's
414
+ default. Any case is accepted and stored in BCP 47 case (`'PT-br'` becomes
415
+ `'pt-BR'`), and a deprecated code is replaced (`'iw'` becomes `'he'`). A value that is not a well-formed tag (`'english'`, `'pt_BR'`,
416
+ `' fr'`) is ignored with one console warning, never thrown, and the current
417
+ language stays.
418
+
419
+ The choice is kept on this device until you clear it: a later `configure()`, a
420
+ reload, `reset()` and `identify()` with another user keep it. Changing it drops the cached copy and offers, asks
421
+ for the copy again at once, then fetches the offers again in the new language.
422
+
423
+ To go back to the browser's language, call `Encore.clearLanguage()`. It forgets
424
+ the choice on this device, drops the cached copy and offers, and asks for the copy
425
+ again at once. It does nothing when no language was set.
426
+
427
+ `UserAttributes.language` is deprecated and will be removed in the next major
428
+ version. Until then a `language` passed to `setUserAttributes()` or `identify()`
429
+ is forwarded to `setLanguage()`, with one console warning per page load, and is not
430
+ kept or sent as an attribute. It then behaves like `setLanguage()`, so `reset()`
431
+ keeps it too. There, and only there, a locale identifier reads as its tag
432
+ (`'pt_BR'`, `'de_DE@currency=EUR'`), as the server accepted it. A language an earlier SDK version stored that way is moved into the
433
+ device setting once, on the first `configure()`.
434
+
435
+ The sheet carries `lang` and `dir` for the served language (right to left for
436
+ the same 18 languages as the iOS and Android SDKs, among them Arabic, Hebrew,
437
+ Persian, Urdu, Pashto, Sindhi, Uyghur, Yiddish and Sorani Kurdish) and formats
438
+ dates and numbers in it. Words the
439
+ SDK says itself are served translated where Encore has an approved translation;
440
+ any other string stays in English. A headline or subheadline you pass at runtime
441
+ is shown exactly as you wrote it.
442
+
378
443
  ## Deferred redemption
379
444
 
380
445
  A claim and the advertiser handoff are two moments, and a placement decides