@amplytools/react-native-amply-sdk 0.4.1 → 0.5.1
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.
- package/AmplyReactNative.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/tools/amply/sdk/reactnative/AmplyModule.kt +38 -27
- package/android/src/main/java/tools/amply/sdk/reactnative/core/AmplyClient.kt +13 -12
- package/android/src/main/java/tools/amply/sdk/reactnative/core/DefaultAmplyClient.kt +195 -65
- package/android/src/main/java/tools/amply/sdk/reactnative/core/GateDecision.kt +23 -0
- package/android/src/main/java/tools/amply/sdk/reactnative/model/CampaignPresentPayload.kt +4 -2
- package/android/src/newarch/java/tools/amply/sdk/reactnative/NativeAmplyModuleSpec.java +2 -2
- package/android/src/newarch/jni/AmplyReactNative-generated.cpp +6 -6
- package/dist/src/__tests__/campaignResolved.test.js +115 -56
- package/dist/src/index.d.ts +61 -37
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +79 -43
- package/dist/src/nativeSpecs/NativeAmplyModule.d.ts +50 -24
- package/dist/src/nativeSpecs/NativeAmplyModule.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/ios/Sources/AmplyReactNative/AmplyModule.mm +277 -83
- package/ios/Sources/AmplyReactNative/AmplyReactNative/AmplyReactNative-generated.mm +6 -6
- package/ios/Sources/AmplyReactNative/AmplyReactNative/AmplyReactNative.h +7 -5
- package/package.json +1 -1
- package/src/__tests__/campaignResolved.test.ts +169 -73
- package/src/index.ts +133 -92
- package/src/nativeSpecs/NativeAmplyModule.ts +48 -24
|
@@ -85,28 +85,47 @@ export type DeepLinkEvent = {
|
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
|
-
* Terminal result reported by a
|
|
88
|
+
* Terminal result reported by a gate presenter back to the SDK.
|
|
89
89
|
*
|
|
90
|
-
* - 'Completed': the presenter satisfied the
|
|
91
|
-
* watched to completion). The
|
|
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`
|
|
94
|
-
*
|
|
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
|
|
99
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* - '
|
|
128
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
155
|
+
trackGated(event: string, properties: JsonMap): Promise<JsonMap>;
|
|
135
156
|
/**
|
|
136
|
-
* Report the terminal result of a
|
|
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
|
|
144
|
-
*
|
|
145
|
-
*
|
|
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
|
-
|
|
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;
|