api/internal/gamification/chance_events library

Extensions

EngageEventEmitterChanceEvents on EngageEventEmitter
Sends chance events to Digia analytics only — never the CEP. A live test never reports chance events: the emitter's live-test sink drops Digia signals, and this skips them before that, so no live-test payload ever reaches even the real sink. Port of iOS forwardChanceEvents.
PlayDecisionChanceEvents on PlayDecision
The events a grant answer carried, whatever the decision it led to.

Functions

chanceEventsOf(Object? raw, {String? campaignKey}) → List<ChanceAnalyticsEvent>
The events the gamification server returns in an answer's data.response (the grantChance answer, or the body of a proxied http play answer). Port of iOS ChanceEvents.swift.
chanceEventsOfAnswer(Object? body, {String? campaignKey}) → List<ChanceAnalyticsEvent>
The events in a proxied http answer body ({isSuccess, data: {response: {events}}}).
grantEventsOf(Map<String, dynamic> answer, {required bool granted, required String? chanceId, required String userId, required String triggerId, required String? testInvocationId}) → List<ChanceAnalyticsEvent>
The chance events a grantChance answer's facts call for:
isLiveTestGamePayload(CEPTriggerPayload payload) → bool
Whether payload belongs to a live test. Chance events never report for one — factored so the game funnel shares the rule with the emitter.
playEventsOf(Map<String, dynamic>? request, Map<String, dynamic>? body, {required String campaignId, required int playNumber, String? entry}) → List<ChanceAnalyticsEvent>
The chance events a proxied play answer's facts call for: Digia Game Played iff the answer is isNew (the play it made, never a replay of an earlier answer), plus Digia Chance Granted (source extraPlay) when it carries an extraChance. request is the skin's /play body (its chanceId); body is {isSuccess, data: {response}}. playNumber is this play's 1-based number in the window; entry is where the window opened. The caller gates live tests. Never throws.
playResponseOf(Map<String, dynamic>? body) → Map<String, dynamic>?
The data.response object of an answered skin http body ({isSuccess, data: {response}}), or null when the body has none. Never throws.