@amplytools/react-native-amply-sdk 0.14.0 → 0.15.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.
- package/AmplyReactNative.podspec +1 -1
- package/README.md +41 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/tools/amply/sdk/reactnative/AmplyModule.kt +22 -0
- package/android/src/main/java/tools/amply/sdk/reactnative/core/AmplyClient.kt +11 -0
- package/android/src/main/java/tools/amply/sdk/reactnative/core/DefaultAmplyClient.kt +29 -0
- package/android/src/main/java/tools/amply/sdk/reactnative/model/CampaignTouchPayload.kt +12 -0
- package/android/src/newarch/java/tools/amply/sdk/reactnative/NativeAmplyModuleSpec.java +8 -0
- package/android/src/newarch/jni/AmplyReactNative-generated.cpp +12 -0
- package/dist/src/__tests__/appLanguage.test.d.ts +1 -42
- package/dist/src/__tests__/appLanguage.test.d.ts.map +1 -1
- package/dist/src/__tests__/appLanguage.test.js +1 -1
- package/dist/src/__tests__/handleUrl.test.d.ts +2 -0
- package/dist/src/__tests__/handleUrl.test.d.ts.map +1 -0
- package/dist/src/__tests__/handleUrl.test.js +114 -0
- package/dist/src/__tests__/lastCampaignTouch.test.d.ts +2 -0
- package/dist/src/__tests__/lastCampaignTouch.test.d.ts.map +1 -0
- package/dist/src/__tests__/lastCampaignTouch.test.js +119 -0
- package/dist/src/__tests__/systemEventUtils.test.js +16 -0
- package/dist/src/campaignTouch.d.ts +36 -0
- package/dist/src/campaignTouch.d.ts.map +1 -0
- package/dist/src/campaignTouch.js +39 -0
- package/dist/src/index.d.ts +35 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +120 -0
- package/dist/src/nativeSpecs/NativeAmplyModule.d.ts +28 -0
- package/dist/src/nativeSpecs/NativeAmplyModule.d.ts.map +1 -1
- package/dist/src/systemEventUtils.d.ts.map +1 -1
- package/dist/src/systemEventUtils.js +3 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/ARCHITECTURE.md +2 -0
- package/docs/DEVELOPMENT.md +2 -1
- package/ios/Sources/AmplyReactNative/AmplyModule.mm +56 -0
- package/ios/Sources/AmplyReactNative/AmplyReactNative/AmplyReactNative-generated.mm +14 -0
- package/ios/Sources/AmplyReactNative/AmplyReactNative/AmplyReactNative.h +4 -0
- package/package.json +1 -1
- package/src/__tests__/appLanguage.test.ts +2 -0
- package/src/__tests__/handleUrl.test.ts +155 -0
- package/src/__tests__/lastCampaignTouch.test.ts +151 -0
- package/src/__tests__/systemEventUtils.test.ts +22 -0
- package/src/campaignTouch.ts +74 -0
- package/src/index.ts +124 -0
- package/src/nativeSpecs/NativeAmplyModule.ts +29 -0
- package/src/systemEventUtils.ts +3 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { CampaignTouchPayload } from './nativeSpecs/NativeAmplyModule';
|
|
2
|
+
/**
|
|
3
|
+
* - `'shown'`: the campaign was shown (`CampaignShown`).
|
|
4
|
+
* - `'engaged'`: the campaign resolved `Completed` (`CampaignResolved` with `result: 'Completed'`).
|
|
5
|
+
*/
|
|
6
|
+
export type CampaignTouchKind = 'shown' | 'engaged';
|
|
7
|
+
/**
|
|
8
|
+
* The most recent moment a campaign reached the user, as answered by `getLastCampaignTouch`.
|
|
9
|
+
*
|
|
10
|
+
* Meant for your own analytics: attach `campaignId` / `campaignName` to a purchase (or any
|
|
11
|
+
* conversion) that happens shortly after a campaign, even when it did not start from the
|
|
12
|
+
* campaign's own link.
|
|
13
|
+
*/
|
|
14
|
+
export type CampaignTouch = {
|
|
15
|
+
/**
|
|
16
|
+
* The id the SDK reports in `CampaignShown`. Inside an experiment that is the arm's own id —
|
|
17
|
+
* the same value `{@campaign.id}` resolves to, so it is also the right value for an explicit
|
|
18
|
+
* `amply_campaign_id` mark.
|
|
19
|
+
*/
|
|
20
|
+
campaignId: string;
|
|
21
|
+
/** The campaign's name when the touch was recorded. Empty if the event carried no name. */
|
|
22
|
+
campaignName: string;
|
|
23
|
+
/** One touch per campaign: the newer of a show and a completion wins. */
|
|
24
|
+
kind: CampaignTouchKind;
|
|
25
|
+
/** When it happened, epoch milliseconds in the SDK's server-corrected clock. */
|
|
26
|
+
atMs: number;
|
|
27
|
+
};
|
|
28
|
+
/** Thrown (as a rejection) by `getLastCampaignTouch` for a window that is not a usable number. */
|
|
29
|
+
export declare function assertValidWithinMs(withinMs: unknown): asserts withinMs is number;
|
|
30
|
+
/**
|
|
31
|
+
* Narrows what the native bridge resolved to the public type. Anything it cannot read as a
|
|
32
|
+
* touch becomes null with a warning: the caller asked "was there a campaign", and a payload this
|
|
33
|
+
* bridge does not understand is not one it can vouch for.
|
|
34
|
+
*/
|
|
35
|
+
export declare function toCampaignTouch(payload: CampaignTouchPayload | null | undefined): CampaignTouch | null;
|
|
36
|
+
//# sourceMappingURL=campaignTouch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"campaignTouch.d.ts","sourceRoot":"","sources":["../../src/campaignTouch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAC;AAE1E;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,SAAS,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,2FAA2F;IAC3F,YAAY,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,IAAI,EAAE,iBAAiB,CAAC;IACxB,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,kGAAkG;AAClG,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,IAAI,MAAM,CAMjF;AAUD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,GAAG,SAAS,GAAG,aAAa,GAAG,IAAI,CAqBtG"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Thrown (as a rejection) by `getLastCampaignTouch` for a window that is not a usable number. */
|
|
2
|
+
export function assertValidWithinMs(withinMs) {
|
|
3
|
+
if (typeof withinMs !== 'number' || !Number.isFinite(withinMs) || withinMs < 0) {
|
|
4
|
+
throw new RangeError(`[Amply] getLastCampaignTouch: withinMs must be a finite number >= 0, got ${String(withinMs)}`);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
function toKind(raw) {
|
|
8
|
+
if (typeof raw !== 'string') {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const lowered = raw.toLowerCase();
|
|
12
|
+
return lowered === 'shown' || lowered === 'engaged' ? lowered : null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Narrows what the native bridge resolved to the public type. Anything it cannot read as a
|
|
16
|
+
* touch becomes null with a warning: the caller asked "was there a campaign", and a payload this
|
|
17
|
+
* bridge does not understand is not one it can vouch for.
|
|
18
|
+
*/
|
|
19
|
+
export function toCampaignTouch(payload) {
|
|
20
|
+
if (payload == null) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const kind = toKind(payload.kind);
|
|
24
|
+
const isReadable = kind !== null &&
|
|
25
|
+
typeof payload.campaignId === 'string' &&
|
|
26
|
+
payload.campaignId.length > 0 &&
|
|
27
|
+
typeof payload.atMs === 'number' &&
|
|
28
|
+
Number.isFinite(payload.atMs);
|
|
29
|
+
if (!isReadable) {
|
|
30
|
+
console.warn('[Amply] getLastCampaignTouch: ignoring an unreadable native payload', payload);
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
campaignId: payload.campaignId,
|
|
35
|
+
campaignName: typeof payload.campaignName === 'string' ? payload.campaignName : '',
|
|
36
|
+
kind,
|
|
37
|
+
atMs: payload.atMs,
|
|
38
|
+
};
|
|
39
|
+
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { useAmplySystemEvents } from './hooks/useAmplySystemEvents';
|
|
2
2
|
export { formatSystemEventLabel } from './systemEventUtils';
|
|
3
3
|
export type { FormatOptions } from './systemEventUtils';
|
|
4
|
+
import type { CampaignTouch } from './campaignTouch';
|
|
5
|
+
export type { CampaignTouch, CampaignTouchKind } from './campaignTouch';
|
|
4
6
|
import type { CampaignResult, GateDecision, AmplyInitializationConfig as NativeInitializationConfig, DataSetSnapshot, DataSetType, DeepLinkEvent, EventRecord, LogLevel, CampaignPresentEvent, TrackEventPayload } from './nativeSpecs/NativeAmplyModule';
|
|
5
7
|
/**
|
|
6
8
|
* The keys from your application's page in Amply. All three are required: the SDK signs every
|
|
@@ -31,6 +33,19 @@ export declare function initialize(config: AmplyInitializationConfig): Promise<v
|
|
|
31
33
|
* @param tag The language tag, or null to clear
|
|
32
34
|
*/
|
|
33
35
|
export declare function setAppLanguage(tag: string | null): void;
|
|
36
|
+
/**
|
|
37
|
+
* Hand an incoming URL to Amply. Call it for every link your app is opened with — cold start
|
|
38
|
+
* and while running — before your own routing; when it returns `true` Amply recognised the
|
|
39
|
+
* link as its own and took it over, so your app should not route it.
|
|
40
|
+
*
|
|
41
|
+
* Safe to call before {@link initialize}, which is how a cold-start link arrives: an Amply debug
|
|
42
|
+
* link is held (the newest one) and opened once initialization succeeds, and `true` is returned.
|
|
43
|
+
*
|
|
44
|
+
* Synchronous. Returns `false` for any other URL, for a non-string, and when the installed
|
|
45
|
+
* native SDK predates this method; it never throws.
|
|
46
|
+
* @param url The full incoming URL
|
|
47
|
+
*/
|
|
48
|
+
export declare function handleUrl(url: string): boolean;
|
|
34
49
|
/**
|
|
35
50
|
* Set the user ID for analytics. Pass null to clear.
|
|
36
51
|
* @param userId The user ID to set, or null to clear
|
|
@@ -145,6 +160,24 @@ export declare function trackGated(event: string, properties?: Record<string, un
|
|
|
145
160
|
*/
|
|
146
161
|
export declare function registerGate(baseUrl: string, presenter: GatePresenter, opts?: RegisterGateOptions): Promise<() => void>;
|
|
147
162
|
export declare function getRecentEvents(limit: number): Promise<EventRecord[]>;
|
|
163
|
+
/**
|
|
164
|
+
* The campaign the user was most recently touched by — shown, or completed — at most `withinMs`
|
|
165
|
+
* ago, or `null` if there was none.
|
|
166
|
+
*
|
|
167
|
+
* Use it to attribute a purchase (or any conversion) in your own analytics to the campaign that
|
|
168
|
+
* preceded it, including one made from somewhere other than the campaign's link:
|
|
169
|
+
*
|
|
170
|
+
* ```ts
|
|
171
|
+
* const touch = await Amply.getLastCampaignTouch(30 * 60 * 1000);
|
|
172
|
+
* analytics.track('Purchase', {sku, amply_campaign_id: touch?.campaignId});
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* One touch per campaign, the newer of a show and a completion. `withinMs` is inclusive and
|
|
176
|
+
* capped at 30 days by the SDK. Resolves `null` before {@link initialize}, while the SDK's storage
|
|
177
|
+
* is off, and if the native call fails — it rejects only for a `withinMs` that is not a finite
|
|
178
|
+
* number >= 0, which is a bug at the call site.
|
|
179
|
+
*/
|
|
180
|
+
export declare function getLastCampaignTouch(withinMs: number): Promise<CampaignTouch | null>;
|
|
148
181
|
export declare function getDataSetSnapshot(type: DataSetType): Promise<DataSetSnapshot>;
|
|
149
182
|
export declare function addDeepLinkListener(listener: (event: DeepLinkEvent) => void): Promise<() => void>;
|
|
150
183
|
export declare function addSystemEventListener(listener: (event: EventRecord) => void): Promise<() => void>;
|
|
@@ -192,6 +225,7 @@ declare const _default: {
|
|
|
192
225
|
trackGated: typeof trackGated;
|
|
193
226
|
registerGate: typeof registerGate;
|
|
194
227
|
getRecentEvents: typeof getRecentEvents;
|
|
228
|
+
getLastCampaignTouch: typeof getLastCampaignTouch;
|
|
195
229
|
getDataSetSnapshot: typeof getDataSetSnapshot;
|
|
196
230
|
addDeepLinkListener: typeof addDeepLinkListener;
|
|
197
231
|
addSystemEventListener: typeof addSystemEventListener;
|
|
@@ -199,6 +233,7 @@ declare const _default: {
|
|
|
199
233
|
removeAllListeners: typeof removeAllListeners;
|
|
200
234
|
setUserId: typeof setUserId;
|
|
201
235
|
setAppLanguage: typeof setAppLanguage;
|
|
236
|
+
handleUrl: typeof handleUrl;
|
|
202
237
|
setLogLevel: typeof setLogLevel;
|
|
203
238
|
getLogLevel: typeof getLogLevel;
|
|
204
239
|
setCustomProperty: typeof setCustomProperty;
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,oBAAoB,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAC,sBAAsB,EAAC,MAAM,oBAAoB,CAAC;AAC1D,YAAY,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,oBAAoB,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAC,sBAAsB,EAAC,MAAM,oBAAoB,CAAC;AAC1D,YAAY,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAC,aAAa,EAAE,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,yBAAyB,IAAI,0BAA0B,EACvD,eAAe,EACf,WAAW,EACX,aAAa,EACb,WAAW,EACX,QAAQ,EACR,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,iCAAiC,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,0BAA0B,EAAE,cAAc,CAAC,GAAG;IACzF,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAIF,qFAAqF;AACrF,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAA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,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5D;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAE/E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,IAAI,CAEzF;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAIxF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEtD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAyBzC;AAED,YAAY,EACV,eAAe,EACf,WAAW,EACX,aAAa,EACb,WAAW,EACX,QAAQ,EACR,oBAAoB,EACpB,iBAAiB,GAClB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GACrC,OAAO,CAAC,MAAM,IAAI,CAAC,CAErB;AAED,eAAO,MAAM,YAAY;;CAExB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,wBAyBE"}
|
package/dist/src/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import getNativeModule from './nativeModule';
|
|
|
2
2
|
import { addSystemEventListenerRaw, addSystemEventListener as addSystemEventListenerInternal } from './systemEvents';
|
|
3
3
|
export { useAmplySystemEvents } from './hooks/useAmplySystemEvents';
|
|
4
4
|
export { formatSystemEventLabel } from './systemEventUtils';
|
|
5
|
+
import { assertValidWithinMs, toCampaignTouch } from './campaignTouch';
|
|
5
6
|
const REQUIRED_KEYS = ['appId', 'apiKeyPublic', 'apiKeySecret'];
|
|
6
7
|
/** Rejection raised by {@link initialize} for a config the SDK cannot start with. */
|
|
7
8
|
export class AmplyConfigError extends Error {
|
|
@@ -193,6 +194,9 @@ export async function initialize(config) {
|
|
|
193
194
|
await getNativeModule().initialize(withParkedAppLanguage(config, parked));
|
|
194
195
|
}
|
|
195
196
|
catch (error) {
|
|
197
|
+
// A debug link parked for a failed start has nothing to open; replaying it later would
|
|
198
|
+
// surprise a retry that the user did not scan for.
|
|
199
|
+
parkedDebugUrl = null;
|
|
196
200
|
// Nothing reached the SDK, so the call still has to — unless a newer one replaced it.
|
|
197
201
|
if (parkedAppLanguage == null && isLatestLanguageWrite(parked)) {
|
|
198
202
|
parkedAppLanguage = parked;
|
|
@@ -206,6 +210,7 @@ export async function initialize(config) {
|
|
|
206
210
|
getNativeModule().setAppLanguage(null);
|
|
207
211
|
}
|
|
208
212
|
flushParkedAppLanguage();
|
|
213
|
+
flushParkedDebugUrl();
|
|
209
214
|
// Anything the host registered before this point was parked rather than lost.
|
|
210
215
|
replayPendingRegistrations();
|
|
211
216
|
}
|
|
@@ -266,6 +271,90 @@ export function setAppLanguage(tag) {
|
|
|
266
271
|
}
|
|
267
272
|
parkedAppLanguage = { tag, seq: languageWriteSeq };
|
|
268
273
|
}
|
|
274
|
+
/** A debug link that arrived before the SDK was up. At most one: a newer link replaces it. */
|
|
275
|
+
let parkedDebugUrl = null;
|
|
276
|
+
const URL_SCHEME_PREFIX = /^[A-Za-z][A-Za-z0-9+.-]*:\/\//;
|
|
277
|
+
const DEBUG_LINK_HOST = 'amply-debug';
|
|
278
|
+
const DEBUG_LINK_PATH = '/campaign';
|
|
279
|
+
const DEBUG_LINK_TOKEN_PARAM = 't';
|
|
280
|
+
/**
|
|
281
|
+
* True for `<any scheme>://amply-debug/campaign?t=<non-empty>`. Parsed by hand, without decoding,
|
|
282
|
+
* so a malformed string is just "not a debug link" and can never throw.
|
|
283
|
+
*/
|
|
284
|
+
function isDebugLink(url) {
|
|
285
|
+
const scheme = URL_SCHEME_PREFIX.exec(url);
|
|
286
|
+
if (scheme == null) {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
const rest = url.slice(scheme[0].length).split('#')[0];
|
|
290
|
+
const queryStart = rest.indexOf('?');
|
|
291
|
+
if (queryStart < 0) {
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
const target = rest.slice(0, queryStart);
|
|
295
|
+
const slash = target.indexOf('/');
|
|
296
|
+
if (slash < 0 || target.slice(0, slash) !== DEBUG_LINK_HOST) {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
299
|
+
if (target.slice(slash).replace(/\/+$/, '') !== DEBUG_LINK_PATH) {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
return rest
|
|
303
|
+
.slice(queryStart + 1)
|
|
304
|
+
.split('&')
|
|
305
|
+
.some(pair => {
|
|
306
|
+
const eq = pair.indexOf('=');
|
|
307
|
+
return eq > 0 && pair.slice(0, eq) === DEBUG_LINK_TOKEN_PARAM && eq < pair.length - 1;
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
function flushParkedDebugUrl() {
|
|
311
|
+
var _a, _b;
|
|
312
|
+
const url = parkedDebugUrl;
|
|
313
|
+
parkedDebugUrl = null;
|
|
314
|
+
if (url == null) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
try {
|
|
318
|
+
(_b = (_a = getNativeModule()).handleUrl) === null || _b === void 0 ? void 0 : _b.call(_a, url);
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
console.warn('[Amply] Failed to replay a debug link parked until initialize', error);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Hand an incoming URL to Amply. Call it for every link your app is opened with — cold start
|
|
326
|
+
* and while running — before your own routing; when it returns `true` Amply recognised the
|
|
327
|
+
* link as its own and took it over, so your app should not route it.
|
|
328
|
+
*
|
|
329
|
+
* Safe to call before {@link initialize}, which is how a cold-start link arrives: an Amply debug
|
|
330
|
+
* link is held (the newest one) and opened once initialization succeeds, and `true` is returned.
|
|
331
|
+
*
|
|
332
|
+
* Synchronous. Returns `false` for any other URL, for a non-string, and when the installed
|
|
333
|
+
* native SDK predates this method; it never throws.
|
|
334
|
+
* @param url The full incoming URL
|
|
335
|
+
*/
|
|
336
|
+
export function handleUrl(url) {
|
|
337
|
+
if (typeof url !== 'string') {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
try {
|
|
341
|
+
if (!isSdkUp()) {
|
|
342
|
+
if (!isDebugLink(url)) {
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
parkedDebugUrl = url;
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
const nativeModule = getNativeModule();
|
|
349
|
+
if (typeof nativeModule.handleUrl !== 'function') {
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
return nativeModule.handleUrl(url) === true;
|
|
353
|
+
}
|
|
354
|
+
catch {
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
269
358
|
/**
|
|
270
359
|
* Set the user ID for analytics. Pass null to clear.
|
|
271
360
|
* @param userId The user ID to set, or null to clear
|
|
@@ -462,6 +551,35 @@ export async function registerGate(baseUrl, presenter, opts) {
|
|
|
462
551
|
export async function getRecentEvents(limit) {
|
|
463
552
|
return getNativeModule().getRecentEvents(limit);
|
|
464
553
|
}
|
|
554
|
+
/**
|
|
555
|
+
* The campaign the user was most recently touched by — shown, or completed — at most `withinMs`
|
|
556
|
+
* ago, or `null` if there was none.
|
|
557
|
+
*
|
|
558
|
+
* Use it to attribute a purchase (or any conversion) in your own analytics to the campaign that
|
|
559
|
+
* preceded it, including one made from somewhere other than the campaign's link:
|
|
560
|
+
*
|
|
561
|
+
* ```ts
|
|
562
|
+
* const touch = await Amply.getLastCampaignTouch(30 * 60 * 1000);
|
|
563
|
+
* analytics.track('Purchase', {sku, amply_campaign_id: touch?.campaignId});
|
|
564
|
+
* ```
|
|
565
|
+
*
|
|
566
|
+
* One touch per campaign, the newer of a show and a completion. `withinMs` is inclusive and
|
|
567
|
+
* capped at 30 days by the SDK. Resolves `null` before {@link initialize}, while the SDK's storage
|
|
568
|
+
* is off, and if the native call fails — it rejects only for a `withinMs` that is not a finite
|
|
569
|
+
* number >= 0, which is a bug at the call site.
|
|
570
|
+
*/
|
|
571
|
+
export async function getLastCampaignTouch(withinMs) {
|
|
572
|
+
assertValidWithinMs(withinMs);
|
|
573
|
+
try {
|
|
574
|
+
return toCampaignTouch(await getNativeModule().getLastCampaignTouch(withinMs));
|
|
575
|
+
}
|
|
576
|
+
catch (error) {
|
|
577
|
+
// The SDK answers null for every state it can be in; a rejection here is the bridge itself
|
|
578
|
+
// failing, and an analytics lookup must never break the purchase flow that asked.
|
|
579
|
+
console.warn('[Amply] getLastCampaignTouch failed; resolving null', error);
|
|
580
|
+
return null;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
465
583
|
export async function getDataSetSnapshot(type) {
|
|
466
584
|
return getNativeModule().getDataSetSnapshot(type);
|
|
467
585
|
}
|
|
@@ -552,6 +670,7 @@ export default {
|
|
|
552
670
|
trackGated,
|
|
553
671
|
registerGate,
|
|
554
672
|
getRecentEvents,
|
|
673
|
+
getLastCampaignTouch,
|
|
555
674
|
getDataSetSnapshot,
|
|
556
675
|
addDeepLinkListener,
|
|
557
676
|
addSystemEventListener,
|
|
@@ -559,6 +678,7 @@ export default {
|
|
|
559
678
|
removeAllListeners,
|
|
560
679
|
setUserId,
|
|
561
680
|
setAppLanguage,
|
|
681
|
+
handleUrl,
|
|
562
682
|
setLogLevel,
|
|
563
683
|
getLogLevel,
|
|
564
684
|
setCustomProperty,
|
|
@@ -63,7 +63,22 @@ export type EventRecord = {
|
|
|
63
63
|
timestamp: number;
|
|
64
64
|
properties: JsonMap;
|
|
65
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* A system event from the SDK. `CampaignShown` and `CampaignResolved` carry `campaignId` and,
|
|
68
|
+
* from SDK 0.15.0, `campaignName` in `properties`.
|
|
69
|
+
*/
|
|
66
70
|
export type SystemEventPayload = EventRecord;
|
|
71
|
+
/**
|
|
72
|
+
* Wire shape of a campaign touch as the native bridges send it. `kind` is `'shown'` or
|
|
73
|
+
* `'engaged'`; the public `CampaignTouch` type narrows it. Kept a plain string here so the
|
|
74
|
+
* codegen contract does not change if the SDK ever adds a kind.
|
|
75
|
+
*/
|
|
76
|
+
export type CampaignTouchPayload = {
|
|
77
|
+
campaignId: string;
|
|
78
|
+
campaignName: string;
|
|
79
|
+
kind: string;
|
|
80
|
+
atMs: number;
|
|
81
|
+
};
|
|
67
82
|
export type TriggeredEventCountStrategy = 'global' | 'session';
|
|
68
83
|
export type TriggeredEventParam = {
|
|
69
84
|
name: string;
|
|
@@ -195,6 +210,12 @@ export interface Spec extends TurboModule {
|
|
|
195
210
|
*/
|
|
196
211
|
unregisterGate(baseUrl: string): void;
|
|
197
212
|
getRecentEvents(limit: number): Promise<EventRecord[]>;
|
|
213
|
+
/**
|
|
214
|
+
* The campaign the user was most recently touched by (shown, or completed) at most `withinMs`
|
|
215
|
+
* ago, or null. Never rejects for "not initialised" — that resolves null, as in the SDK.
|
|
216
|
+
* `withinMs` is clamped natively to [0, 30 days].
|
|
217
|
+
*/
|
|
218
|
+
getLastCampaignTouch(withinMs: number): Promise<CampaignTouchPayload | null>;
|
|
198
219
|
getDataSetSnapshot(type: DataSetType): Promise<DataSetSnapshot>;
|
|
199
220
|
registerDeepLinkListener(): void;
|
|
200
221
|
/**
|
|
@@ -208,6 +229,13 @@ export interface Spec extends TurboModule {
|
|
|
208
229
|
* @param tag The language tag, or null to clear
|
|
209
230
|
*/
|
|
210
231
|
setAppLanguage(tag: string | null): void;
|
|
232
|
+
/**
|
|
233
|
+
* Hand an incoming URL to the SDK. Returns true when the SDK recognised it as its own
|
|
234
|
+
* (a test-launch link) and took it over; false for any other URL, or when the SDK is not
|
|
235
|
+
* initialized.
|
|
236
|
+
* @param url The full incoming URL
|
|
237
|
+
*/
|
|
238
|
+
handleUrl(url: string): boolean;
|
|
211
239
|
/**
|
|
212
240
|
* Set the log level at runtime.
|
|
213
241
|
* @param level The log level to set
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeAmplyModule.d.ts","sourceRoot":"","sources":["../../../src/nativeSpecs/NativeAmplyModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,2CAA2C,CAAC;AAE5E,KAAK,OAAO,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAC,CAAC;AAExC;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpE,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,0EAA0E;IAC1E,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3B;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE5C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MA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E,MAAM,WAAW,aAAa;IAC5B,wEAAwE;IACxE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,aAAkB,GAC1B,MAAM,
|
|
1
|
+
{"version":3,"file":"systemEventUtils.d.ts","sourceRoot":"","sources":["../../src/systemEventUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,iCAAiC,CAAC;AAYjE,MAAM,WAAW,aAAa;IAC5B,wEAAwE;IACxE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,aAAkB,GAC1B,MAAM,CAuCR"}
|
|
@@ -16,8 +16,10 @@ export function formatSystemEventLabel(event, options = {}) {
|
|
|
16
16
|
}
|
|
17
17
|
if (event.name === 'CampaignShown') {
|
|
18
18
|
const campaignId = event.properties.campaignId;
|
|
19
|
+
// Sent by SDK 0.15.0 and later (on CampaignShown and CampaignResolved alike).
|
|
20
|
+
const campaignName = event.properties.campaignName;
|
|
19
21
|
const source = event.properties.source;
|
|
20
|
-
return `Campaign shown${campaignId ? ` (${campaignId})` : ''}${source ? ` via ${source}` : ''}`;
|
|
22
|
+
return `Campaign shown${campaignName ? ` "${campaignName}"` : ''}${campaignId ? ` (${campaignId})` : ''}${source ? ` via ${source}` : ''}`;
|
|
21
23
|
}
|
|
22
24
|
if (event.name === 'EventTriggered') {
|
|
23
25
|
const source = event.properties.sourceEvent;
|