<script>
// The UMD global exposes the SDK instance on .default
var EncoreSDK = Encore.default || Encore;
EncoreSDK.configure({ apiKey: 'pk_live_yourpublishablekey' });
// After login:
EncoreSDK.identify('user-123'); // replaces the auto-generated anonymous UUID
document.getElementById('finish-lesson-btn').addEventListener('click', async function () {
await saveLessonProgress();
const result = await EncoreSDK.placement('milestone_reached', {
useCase: 'rewardUsers',
}).show(); // never rejects
if (result.status === 'claimed') {
// The SDK has opened the advertiser. transactionId is absent if its write failed.
if (result.transactionId) await persistClaim(result.transactionId);
}
goToNextLesson(); // whatever the result, continue your flow
});
</script>