Overview
2.x reduces the public API to a single dimension: why a placement presents. The composition, the copy slots, and the claim flow all follow from that, or are gone. Coming from 1.x, four things change:- The use case decides when the advertiser opens.
redemptionModeis removed. A'reduceChurn'claim is saved forredeem(), as 1.x’s default was; a'rewardUsers'claim opens the advertiser at once. PlacementOptionsis one flat shape.headlineandsubheadlinereplace the nestedheaderobject.layoutis gone, along with the'thankYou'composition and everything that dressed it. A newuseCaseoption names the use case, which decides the sheet.- The builder’s
show()takes no arguments, and a claimed result now carriesofferId,campaignId,advertiserName, andtransactionId.
Step 1: Update the package
Install the current 2.x release:Use 2.0.6 or later.
2.0.0 still carries the 1.x API, and 2.0.1 to 2.0.4 have no
redeem(). Check what you resolved to with npm view @encorekit/web-sdk version before
pinning.Step 2: Remove redemptionMode
redemptionMode is removed from configure()
and from placement options, and getConfiguration() no longer returns it. The use case now
decides when the advertiser opens (The Claim Flow):
redeem(), placement(id).redeem() and getPendingTransaction() stay, with two changes:
RedeemResult returns 'unavailable' where 1.x returned 'none' or 'expired', and a
Transaction carries useCase in place of claimLayout. A branch on 'none' or
'expired' never matches on 2.x. Contract: redeem().
Step 3: Flatten the placement options
The nestedheader object is replaced by flat fields:
.onNotGranted() and .onLoadingStateChange() on the builder are unchanged.
Step 4: Replace the retired compositions
layout is removed. The new useCase option
names the use case, which decides the sheet, and it defaults to 'reduceChurn', whose built-in sheet is the
offer carousel your 1.x 'list' placements already showed.
A placement that named no layout needs no change here. Drop the layout: 'list' option
if you passed it explicitly; the default covers you.
The 'thankYou' composition is retired, and with it the payment-status sheet a
post-purchase surface could compose. If you presented one, the closest equivalent is the
'rewardUsers' composition:
Because
display is gone, so is the display pre-flight that could resolve a deferred
show() to dismissed with a CONFIGURATION_ERROR before anything rendered.
Step 5: Read the new claim result
A claimed result is no longer bare:transactionId is what carries attribution: it is how a completion landing days later is
traced back to this user and app. Persist it when it is present. In 1.x the claimed
result was bare, and the id lived only on the transaction record from
getPendingTransaction().
It is optional because the transaction write can fail while the claim genuinely happened, in
which case the SDK logs a warning rather than fabricating a placeholder id, and the result
still resolves claimed.
dismissed and unavailable are unchanged. show() still never rejects.
New in 2.x: reward a user, not just save one
1.x could only intervene when a user was about to leave. 2.x adds a second use case for the opposite moment, a user who just accomplished something:useCase unset keeps every placement on
'reduceChurn', which is the behavior your 1.x integration already had. See
Post-Purchase Placements for the full
walkthrough.
The values you type (
'reduceChurn', 'rewardUsers') match the native SDKs. The values
Encore sends and stores over the wire are separate frozen labels, so anything you have built
on the use_case analytics property is unaffected.Removed APIs at a glance
Verify the migration
- Your project type-checks, or (in JavaScript) no call site still references
redemptionMode,layout,header,offerContext,footer,receipt, ordisplay. - A
'reduceChurn'claim reaches the advertiser through yourredeem()call, and a'rewardUsers'claim opens it at once. - Your
claimedbranch reads and persiststransactionId. - Your analytics still report against the same use-case values they always did, because the wire did not change.
Related
- The Claim Flow: the single-step flow in full.
placement(): the currentPlacementOptionscontract.show(): the currentShowResultcontract.configure(): the currentEncoreConfigcontract.