<script lang="ts">
import Encore from '@encorekit/web-sdk';
// After login:
Encore.identify(user.id); // replaces the auto-generated anonymous UUID
async function onFinishClicked() {
await saveLessonProgress();
const result = await Encore.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>
<button on:click={onFinishClicked}>Finish lesson</button>