@amplytools/react-native-amply-sdk 0.4.1 → 0.5.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.
@@ -85,28 +85,47 @@ export type DeepLinkEvent = {
85
85
  };
86
86
 
87
87
  /**
88
- * Terminal result reported by a campaign presenter back to the SDK.
88
+ * Terminal result reported by a gate presenter back to the SDK.
89
89
  *
90
- * - 'Completed': the presenter satisfied the campaign condition (e.g. rewarded ad
91
- * watched to completion). The continuation proceeds.
90
+ * - 'Completed': the presenter satisfied the gate condition (e.g. rewarded ad
91
+ * watched to completion). The gate proceeds with reason `completed`.
92
92
  * - 'Dismissed': a USER-INITIATED dismiss without satisfying the condition. With an
93
- * `onAbort=cancel` action this suppresses the continuation; with `onAbort=proceed`
94
- * it proceeds. Reserved strictly for user intent — never infra failures.
93
+ * `onAbort=cancel` gate this cancels; with `onAbort=proceed` it proceeds. Reserved
94
+ * strictly for user intent — never infra failures.
95
95
  * - 'Unavailable': any non-user failure (no-fill, failed-to-show, not-ready, missing
96
- * precondition). Always fails open and proceeds.
96
+ * precondition). Always fails open and proceeds with reason `failOpen`.
97
97
  *
98
- * NOTE: this raw result is intentionally NOT surfaced to app continuation code —
99
- * the public `trackEvent` continuation only ever sees `onProceed`/`onCancel`.
98
+ * NOTE: this raw result is intentionally NOT surfaced to app gating code — the public
99
+ * `trackGated` surface only ever sees the collapsed {@link GateDecision}.
100
100
  */
101
101
  export type CampaignResult = 'Completed' | 'Dismissed' | 'Unavailable';
102
102
 
103
103
  /**
104
- * Payload delivered to JS when a campaign dispatches a present (blocking) action.
104
+ * Bridge-level gate decision, mirroring the KMP `GateDecision`:
105
+ * - `{ outcome: 'proceed', reason: 'completed' | 'failOpen' }` — the gate cleared.
106
+ * `completed` means the presenter satisfied the condition; `failOpen` means any
107
+ * infra/timeout/not-ready/dismiss-under-proceed path resolved permissively.
108
+ * - `{ outcome: 'cancelled' }` — a deliberate user dismiss under an `onAbort=cancel`
109
+ * gate. The caller should suppress its follow-up action.
110
+ *
111
+ * The raw {@link CampaignResult} is never surfaced here; it is collapsed natively.
112
+ */
113
+ export type GateDecision =
114
+ | {outcome: 'proceed'; reason: 'completed' | 'failOpen'}
115
+ | {outcome: 'cancelled'};
116
+
117
+ /**
118
+ * Payload delivered to JS when a gate dispatches its (blocking) presentation.
105
119
  * The JS handler must eventually report a {@link CampaignResult} for `mediationId`
106
120
  * via `resolveCampaign`.
107
121
  */
108
122
  export type CampaignPresentEvent = {
109
123
  url: string;
124
+ /**
125
+ * Parsed query parameters from the gate action URL — a flat string map decoded
126
+ * from the URL query string (e.g. `{ adUnit: 'rewarded_main', placement: 'home' }`).
127
+ */
128
+ params: JsonMap;
110
129
  /**
111
130
  * Enriched, decoupled action info:
112
131
  * `{ url, campaignId, campaignName, triggeringEvent, triggeringProperties, content }`.
@@ -120,31 +139,36 @@ export interface Spec extends TurboModule {
120
139
  isInitialized(): boolean;
121
140
  track(payload: TrackEventPayload): Promise<void>;
122
141
  /**
123
- * Gated form of track: records the event, evaluates campaigns, and — if a
124
- * blocking action matches and a presenter is registered — dispatches the campaign
125
- * present and awaits its result. Resolves with the continuation decision:
126
- * - 'complete': the continuation should proceed (onProceed).
127
- * - 'cancel': the continuation should be suppressed (onCancel) — only ever
128
- * returned for a user `Dismissed` against an `onAbort=cancel` action.
142
+ * Gated form of track: records the event, evaluates campaigns, and — if a gate
143
+ * action matches and a presenter is registered — dispatches the gate presentation
144
+ * and awaits its outcome. Resolves with the collapsed {@link GateDecision} as a
145
+ * plain map:
146
+ * - `{ outcome: 'proceed', reason: 'completed' }` — gate satisfied.
147
+ * - `{ outcome: 'proceed', reason: 'failOpen' }` — any permissive path (no gate,
148
+ * not initialized, timeout, unavailable, dismiss under `onAbort=proceed`, infra
149
+ * failure).
150
+ * - `{ outcome: 'cancelled' }` — user dismiss under an `onAbort=cancel` gate.
129
151
  *
130
- * The raw {@link CampaignResult} is never returned to JS; it is collapsed natively
131
- * into this 'complete' | 'cancel' decision so app code can't branch on results.
132
- * Every failure path fails open to 'complete'.
152
+ * The raw {@link CampaignResult} is never returned to JS; it is collapsed natively.
153
+ * This promise MUST NOT reject — every failure path resolves to a `proceed`/failOpen.
133
154
  */
134
- trackEventGated(event: string, properties: JsonMap): Promise<string>;
155
+ trackGated(event: string, properties: JsonMap): Promise<JsonMap>;
135
156
  /**
136
- * Report the terminal result of a campaign present dispatched to JS via the
157
+ * Report the terminal result of a gate presentation dispatched to JS via the
137
158
  * `onCampaignPresent` event. Idempotent natively — late/duplicate calls are ignored.
138
159
  * @param mediationId The id carried by the matching `onCampaignPresent` event.
139
160
  * @param result One of {@link CampaignResult} ('Completed' | 'Dismissed' | 'Unavailable').
140
161
  */
141
162
  resolveCampaign(mediationId: string, result: string): void;
142
163
  /**
143
- * Register the JS side as the recipient of campaign present dispatches. Wiring of
144
- * the actual per-URL-pattern routing happens natively; JS receives every dispatch
145
- * via the `onCampaignPresent` event and replies through `resolveCampaign`.
164
+ * Register the JS side as the recipient of gate presentation dispatches for the
165
+ * given `baseUrl`. The native side wires the gate; JS receives each dispatch via
166
+ * the `onCampaignPresent` event and replies through `resolveCampaign`.
167
+ * @param baseUrl The gate action base URL this presenter handles.
168
+ * @param onAbort Abort policy: 'cancel' (user dismiss cancels) or 'proceed'.
169
+ * @param timeoutMs Max time the gate waits for a presenter result before failing open.
146
170
  */
147
- registerCampaignPresenter(): void;
171
+ registerGate(baseUrl: string, onAbort: string, timeoutMs: number): void;
148
172
  getRecentEvents(limit: number): Promise<EventRecord[]>;
149
173
  getDataSetSnapshot(type: DataSetType): Promise<DataSetSnapshot>;
150
174
  registerDeepLinkListener(): void;