@adshift/react-native-plugin 3.0.0 → 3.1.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/AdShiftReactNativePlugin.podspec +20 -4
- package/CHANGELOG.md +30 -17
- package/README.md +55 -47
- package/android/build.gradle +2 -3
- package/android/consumer-rules.pro +2 -21
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/adshift/reactnativeplugin/ActivityIntents.kt +307 -0
- package/android/src/main/java/com/adshift/reactnativeplugin/AdShiftReactNativePluginModule.kt +83 -157
- package/android/src/test/java/com/adshift/reactnativeplugin/ConsentSnapshotTest.kt +0 -20
- package/android/src/test/java/com/adshift/reactnativeplugin/DeepLinkDeliveryTest.kt +0 -4
- package/android/src/test/java/com/adshift/reactnativeplugin/InitializeOrderingTest.kt +37 -5
- package/android/src/test/java/com/adshift/reactnativeplugin/IntentLinkDedupTest.kt +0 -5
- package/android/src/test/java/com/adshift/reactnativeplugin/LaunchIntentForwardingTest.kt +7 -26
- package/android/src/test/java/com/adshift/reactnativeplugin/LaunchLinkRecordTest.kt +420 -0
- package/android/src/test/java/com/adshift/reactnativeplugin/ModuleTestSupport.kt +93 -34
- package/android/src/test/java/com/adshift/reactnativeplugin/StartVerdictTest.kt +0 -4
- package/ios/AdShiftReactNativePlugin.h +0 -12
- package/ios/AdShiftReactNativePlugin.mm +2 -14
- package/ios/AdShiftReactNativePluginHelper.swift +14 -73
- package/ios/Core/BridgeRules.swift +24 -29
- package/lib/commonjs/Adshift.js +78 -285
- package/lib/commonjs/Adshift.js.map +1 -1
- package/lib/commonjs/NativeAdShiftReactNativePlugin.js +2 -11
- package/lib/commonjs/NativeAdShiftReactNativePlugin.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/jest/index.js +4 -18
- package/lib/commonjs/jest/index.js.map +1 -1
- package/lib/commonjs/nativeSdkVersions.js +4 -6
- package/lib/commonjs/nativeSdkVersions.js.map +1 -1
- package/lib/commonjs/types/AdshiftAdRevenue.js +0 -24
- package/lib/commonjs/types/AdshiftAdRevenue.js.map +1 -1
- package/lib/commonjs/types/AdshiftConfig.js +3 -24
- package/lib/commonjs/types/AdshiftConfig.js.map +1 -1
- package/lib/commonjs/types/AdshiftConsent.js +9 -45
- package/lib/commonjs/types/AdshiftConsent.js.map +1 -1
- package/lib/commonjs/types/AdshiftConsentSnapshot.js +5 -24
- package/lib/commonjs/types/AdshiftConsentSnapshot.js.map +1 -1
- package/lib/commonjs/types/AdshiftDeepLink.js +3 -30
- package/lib/commonjs/types/AdshiftDeepLink.js.map +1 -1
- package/lib/commonjs/types/AdshiftError.js +7 -27
- package/lib/commonjs/types/AdshiftError.js.map +1 -1
- package/lib/commonjs/types/AdshiftEventParam.js +4 -38
- package/lib/commonjs/types/AdshiftEventParam.js.map +1 -1
- package/lib/commonjs/types/AdshiftEventType.js +1 -39
- package/lib/commonjs/types/AdshiftEventType.js.map +1 -1
- package/lib/commonjs/types/AdshiftThirdPartySharing.js +7 -38
- package/lib/commonjs/types/AdshiftThirdPartySharing.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/Adshift.js +78 -285
- package/lib/module/Adshift.js.map +1 -1
- package/lib/module/NativeAdShiftReactNativePlugin.js +2 -12
- package/lib/module/NativeAdShiftReactNativePlugin.js.map +1 -1
- package/lib/module/index.js +1 -46
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest/index.js +4 -18
- package/lib/module/jest/index.js.map +1 -1
- package/lib/module/nativeSdkVersions.js +4 -6
- package/lib/module/nativeSdkVersions.js.map +1 -1
- package/lib/module/types/AdshiftAdRevenue.js +0 -24
- package/lib/module/types/AdshiftAdRevenue.js.map +1 -1
- package/lib/module/types/AdshiftConfig.js +3 -24
- package/lib/module/types/AdshiftConfig.js.map +1 -1
- package/lib/module/types/AdshiftConsent.js +9 -45
- package/lib/module/types/AdshiftConsent.js.map +1 -1
- package/lib/module/types/AdshiftConsentSnapshot.js +5 -24
- package/lib/module/types/AdshiftConsentSnapshot.js.map +1 -1
- package/lib/module/types/AdshiftDeepLink.js +3 -31
- package/lib/module/types/AdshiftDeepLink.js.map +1 -1
- package/lib/module/types/AdshiftError.js +7 -28
- package/lib/module/types/AdshiftError.js.map +1 -1
- package/lib/module/types/AdshiftEventParam.js +4 -38
- package/lib/module/types/AdshiftEventParam.js.map +1 -1
- package/lib/module/types/AdshiftEventType.js +1 -39
- package/lib/module/types/AdshiftEventType.js.map +1 -1
- package/lib/module/types/AdshiftThirdPartySharing.js +7 -38
- package/lib/module/types/AdshiftThirdPartySharing.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/commonjs/src/Adshift.d.ts +61 -185
- package/lib/typescript/commonjs/src/Adshift.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts +10 -36
- package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +0 -32
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/jest/index.d.ts +6 -20
- package/lib/typescript/commonjs/src/jest/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts +4 -6
- package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftAdRevenue.d.ts +0 -24
- package/lib/typescript/commonjs/src/types/AdshiftAdRevenue.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts +10 -37
- package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftConsent.d.ts +9 -49
- package/lib/typescript/commonjs/src/types/AdshiftConsent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftConsentSnapshot.d.ts +10 -28
- package/lib/typescript/commonjs/src/types/AdshiftConsentSnapshot.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts +6 -34
- package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftError.d.ts +7 -26
- package/lib/typescript/commonjs/src/types/AdshiftError.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftEventParam.d.ts +3 -19
- package/lib/typescript/commonjs/src/types/AdshiftEventParam.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftEventType.d.ts +1 -23
- package/lib/typescript/commonjs/src/types/AdshiftEventType.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdshiftThirdPartySharing.d.ts +7 -38
- package/lib/typescript/commonjs/src/types/AdshiftThirdPartySharing.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/version.d.ts +1 -1
- package/lib/typescript/module/src/Adshift.d.ts +61 -185
- package/lib/typescript/module/src/Adshift.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts +10 -36
- package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +0 -32
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/jest/index.d.ts +6 -20
- package/lib/typescript/module/src/jest/index.d.ts.map +1 -1
- package/lib/typescript/module/src/nativeSdkVersions.d.ts +4 -6
- package/lib/typescript/module/src/nativeSdkVersions.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftAdRevenue.d.ts +0 -24
- package/lib/typescript/module/src/types/AdshiftAdRevenue.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftConfig.d.ts +10 -37
- package/lib/typescript/module/src/types/AdshiftConfig.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftConsent.d.ts +9 -49
- package/lib/typescript/module/src/types/AdshiftConsent.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftConsentSnapshot.d.ts +10 -28
- package/lib/typescript/module/src/types/AdshiftConsentSnapshot.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts +6 -34
- package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftError.d.ts +7 -26
- package/lib/typescript/module/src/types/AdshiftError.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftEventParam.d.ts +3 -19
- package/lib/typescript/module/src/types/AdshiftEventParam.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftEventType.d.ts +1 -23
- package/lib/typescript/module/src/types/AdshiftEventType.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdshiftThirdPartySharing.d.ts +7 -38
- package/lib/typescript/module/src/types/AdshiftThirdPartySharing.d.ts.map +1 -1
- package/lib/typescript/module/src/version.d.ts +1 -1
- package/package.json +11 -1
- package/src/Adshift.ts +82 -286
- package/src/NativeAdShiftReactNativePlugin.ts +10 -48
- package/src/index.tsx +1 -44
- package/src/jest/index.ts +6 -20
- package/src/nativeSdkVersions.ts +4 -6
- package/src/types/AdshiftAdRevenue.ts +0 -24
- package/src/types/AdshiftConfig.ts +11 -54
- package/src/types/AdshiftConsent.ts +9 -49
- package/src/types/AdshiftConsentSnapshot.ts +11 -38
- package/src/types/AdshiftDeepLink.ts +6 -34
- package/src/types/AdshiftError.ts +7 -26
- package/src/types/AdshiftEventParam.ts +4 -38
- package/src/types/AdshiftEventType.ts +1 -39
- package/src/types/AdshiftThirdPartySharing.ts +7 -38
- package/src/version.ts +1 -1
- package/vendor/ios/AdshiftSDK.files.json +30 -0
- package/vendor/ios/AdshiftSDK.xcframework/Info.plist +44 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/AdshiftSDK +0 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Headers/AdshiftSDK-Swift.h +315 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Info.plist +0 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.abi.json +18729 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +414 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios.swiftinterface +414 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/Modules/module.modulemap +4 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64/AdshiftSDK.framework/PrivacyInfo.xcprivacy +132 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/AdshiftSDK +0 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Headers/AdshiftSDK-Swift.h +626 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Info.plist +0 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +18729 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +414 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +414 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +18729 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +414 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/AdshiftSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +414 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/Modules/module.modulemap +4 -0
- package/vendor/ios/AdshiftSDK.xcframework/ios-arm64_x86_64-simulator/AdshiftSDK.framework/PrivacyInfo.xcprivacy +132 -0
- package/android/src/main/java/com/adshift/reactnativeplugin/RestoredIntents.kt +0 -64
package/lib/module/Adshift.js
CHANGED
|
@@ -1,107 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* AdShift SDK for React Native.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* import {
|
|
9
|
-
* Adshift,
|
|
10
|
-
* AdshiftEventParam,
|
|
11
|
-
* AdshiftEventType,
|
|
12
|
-
* } from '@adshift/react-native-plugin';
|
|
13
|
-
*
|
|
14
|
-
* // 1. Register the deep link listener (safe to do before initialize)
|
|
15
|
-
* const subscription = Adshift.onDeepLink((deepLink) => {
|
|
16
|
-
* // route on deepLink.deepLinkValue / deepLink.params
|
|
17
|
-
* });
|
|
18
|
-
*
|
|
19
|
-
* // 2. Initialize
|
|
20
|
-
* Adshift.initialize({ apiKey: 'your-api-key', isDebug: __DEV__ });
|
|
21
|
-
*
|
|
22
|
-
* // 3. Start
|
|
23
|
-
* const result = await Adshift.start();
|
|
24
|
-
*
|
|
25
|
-
* // 4. Track
|
|
26
|
-
* await Adshift.trackEvent(AdshiftEventType.Purchase, {
|
|
27
|
-
* [AdshiftEventParam.Revenue]: 9.99,
|
|
28
|
-
* [AdshiftEventParam.Currency]: 'USD',
|
|
29
|
-
* });
|
|
30
|
-
*
|
|
31
|
-
* // Later: subscription.remove();
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
3
|
import { Linking, Platform } from 'react-native';
|
|
36
4
|
import NativeAdShiftReactNativePlugin from "./NativeAdShiftReactNativePlugin.js";
|
|
37
5
|
import { NATIVE_SDK_VERSIONS } from "./nativeSdkVersions.js";
|
|
38
6
|
import { AdshiftDeepLink as AdshiftDeepLinkHelpers, AdshiftErrorCode, AdshiftEventParam, AdshiftMediationNetwork, configToMap, DEFERRED_DEEP_LINK_CLIPBOARD_MODES, getAllEventParams, consentSnapshotFromMap, consentToMap, createAdshiftError, thirdPartySharingToMap, toAdshiftError } from "./types/index.js";
|
|
39
7
|
import { PLUGIN_VERSION } from "./version.js";
|
|
40
8
|
|
|
41
|
-
// ============ Public types ============
|
|
42
|
-
|
|
43
9
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* `
|
|
47
|
-
*
|
|
48
|
-
* at the time `start()` resolved, and `config.onError` reports
|
|
49
|
-
* `INVALID_API_KEY` when that verdict is `invalid`. On iOS the verdict usually
|
|
50
|
-
* arrives after `start()` resolved and is reported by the next `start()`; on
|
|
51
|
-
* Android `start()` waits up to 5 s for it.
|
|
10
|
+
* `success` says whether the SDK started on the device. The API key is checked
|
|
11
|
+
* in the background; an `invalid` verdict is also reported through
|
|
12
|
+
* `config.onError` as `INVALID_API_KEY`. Android waits up to 5 s for the
|
|
13
|
+
* verdict; on iOS it usually arrives later and shows in a later `start()`.
|
|
52
14
|
*/
|
|
53
15
|
|
|
54
16
|
/** How far the API key check had got when `start()` resolved. */
|
|
55
17
|
|
|
56
|
-
/**
|
|
57
|
-
* Parameters for `Adshift.trackPurchase()`.
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Subscription returned by `Adshift.onDeepLink()`.
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Native SDK versions bundled with this plugin release.
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Plugin information returned by `Adshift.getInfo()`.
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
// ============ Constants ============
|
|
73
|
-
|
|
74
18
|
const DEEP_LINK_BUFFER_LIMIT = 20;
|
|
75
19
|
const PENDING_CALL_LIMIT = 100;
|
|
76
20
|
/** Bounds how long `start()` waits for the URL the app was opened with. */
|
|
77
21
|
const INITIAL_URL_WAIT_MS = 3000;
|
|
78
22
|
/** How long one URL counts as the same link, whoever passed it in first. */
|
|
79
23
|
const AUTO_FORWARD_DEDUP_MS = 2000;
|
|
80
|
-
/**
|
|
81
|
-
* Mirrors a limit the SDK applies, so the warning below can name it. Raising it
|
|
82
|
-
* there without raising it here makes the warning wrong, not the behaviour.
|
|
83
|
-
* Android compares the amount as given; iOS converts it to USD first.
|
|
84
|
-
*/
|
|
24
|
+
/** For the warning only; on iOS it applies to amounts in USD, hence the check. */
|
|
85
25
|
const MAX_AD_REVENUE_PER_IMPRESSION = 10;
|
|
86
26
|
const MEDIATION_NETWORKS = new Set(Object.values(AdshiftMediationNetwork));
|
|
87
|
-
/**
|
|
88
|
-
* Event names the SDK sends on its own. Sending them by hand would mix
|
|
89
|
-
* hand-made records into install and session counts, which cannot be undone
|
|
90
|
-
* once they are reported.
|
|
91
|
-
*/
|
|
27
|
+
/** Sent by the SDK itself. */
|
|
92
28
|
const RESERVED_EVENT_NAMES = new Set(['app_install', 'app_open']);
|
|
93
29
|
|
|
94
|
-
/**
|
|
95
|
-
* Configuration received before `initialize()`. Each entry holds the latest
|
|
96
|
-
* value for one setter, so the memory is bounded by the number of setters.
|
|
97
|
-
*/
|
|
98
|
-
|
|
99
|
-
// ============ Internal state ============
|
|
30
|
+
/** Setters called before `initialize()`: each last value, all push paths. */
|
|
100
31
|
|
|
101
32
|
let state = 'uninitialized';
|
|
102
33
|
let frozenConfig = null;
|
|
103
34
|
let startInFlight = null;
|
|
104
|
-
/**
|
|
35
|
+
/** One per start attempt, so a superseded attempt cannot touch the state. */
|
|
105
36
|
let startEpoch = 0;
|
|
106
37
|
let nativeSubscription = null;
|
|
107
38
|
const listeners = new Set();
|
|
@@ -117,9 +48,6 @@ let pendingSettings = {
|
|
|
117
48
|
let errorHandler = null;
|
|
118
49
|
/** Kept so `start()` can answer with the reason `initialize()` was refused. */
|
|
119
50
|
let configError = null;
|
|
120
|
-
|
|
121
|
-
// ============ Logging ============
|
|
122
|
-
|
|
123
51
|
function devWarn(message) {
|
|
124
52
|
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
125
53
|
console.warn(`[AdShift] ${message}`);
|
|
@@ -127,12 +55,8 @@ function devWarn(message) {
|
|
|
127
55
|
}
|
|
128
56
|
|
|
129
57
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* Public methods that return nothing have no channel to answer through, so
|
|
133
|
-
* they never raise: raising would unwind a stack the caller did not choose,
|
|
134
|
-
* and React Native treats an error escaping an event handler or a native
|
|
135
|
-
* callback as fatal. The call is skipped and reported here instead.
|
|
58
|
+
* Methods that return nothing report a declined call here instead of raising:
|
|
59
|
+
* React Native treats an error escaping an event handler as fatal.
|
|
136
60
|
*/
|
|
137
61
|
function reportDeclined(error) {
|
|
138
62
|
devWarn(`${error.message} (${error.code})`);
|
|
@@ -143,9 +67,6 @@ function reportDeclined(error) {
|
|
|
143
67
|
devWarn('config.onError threw; ignoring it.');
|
|
144
68
|
}
|
|
145
69
|
}
|
|
146
|
-
|
|
147
|
-
// ============ Errors ============
|
|
148
|
-
|
|
149
70
|
function notInitializedError() {
|
|
150
71
|
return createAdshiftError(AdshiftErrorCode.NotInitialized, 'AdShift SDK is not initialized. Call Adshift.initialize(config) first.');
|
|
151
72
|
}
|
|
@@ -168,11 +89,7 @@ function isStringArray(value) {
|
|
|
168
89
|
return Array.isArray(value) && value.every(isNonEmptyString);
|
|
169
90
|
}
|
|
170
91
|
|
|
171
|
-
/**
|
|
172
|
-
* Plain names a caller is likely to invent, mapped onto the standard constant
|
|
173
|
-
* that carries the same meaning. Built from the constants so there is one list
|
|
174
|
-
* to keep, not two.
|
|
175
|
-
*/
|
|
92
|
+
/** Plain names a caller is likely to use instead of a standard parameter. */
|
|
176
93
|
const STANDARD_PARAM_BY_PLAIN_NAME = (() => {
|
|
177
94
|
const index = new Map();
|
|
178
95
|
const standard = new Set(getAllEventParams());
|
|
@@ -189,10 +106,7 @@ const STANDARD_PARAM_BY_PLAIN_NAME = (() => {
|
|
|
189
106
|
})();
|
|
190
107
|
const reportedPlainParamNames = new Set();
|
|
191
108
|
|
|
192
|
-
/**
|
|
193
|
-
* Warns once per name when a value carries a plain name instead of the
|
|
194
|
-
* standard one. Sending it is allowed — it just stays a custom parameter.
|
|
195
|
-
*/
|
|
109
|
+
/** Warns once per name; the value is still sent, as a custom parameter. */
|
|
196
110
|
function warnAboutPlainParamNames(values) {
|
|
197
111
|
if (values === undefined) return;
|
|
198
112
|
for (const key of Object.keys(values)) {
|
|
@@ -218,15 +132,9 @@ function validateEventValues(values, name) {
|
|
|
218
132
|
}
|
|
219
133
|
}
|
|
220
134
|
|
|
221
|
-
// ============ Configuration received before initialize() ============
|
|
222
|
-
|
|
223
135
|
/**
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
* The config wins for anything it states, because it is the later and more
|
|
227
|
-
* explicit declaration. Push key paths are additive, so they are merged.
|
|
228
|
-
* Settings that reach the SDK through a setter only are applied by
|
|
229
|
-
* `applyPendingSettings()` right after the native module is initialized.
|
|
136
|
+
* The config wins over a value set before `initialize()`; push paths from both
|
|
137
|
+
* are kept. Values without a config option go through `applyPendingSettings()`.
|
|
230
138
|
*/
|
|
231
139
|
function withPendingSettings(config) {
|
|
232
140
|
const merged = {
|
|
@@ -278,9 +186,6 @@ function applyPendingSettings() {
|
|
|
278
186
|
}
|
|
279
187
|
}
|
|
280
188
|
}
|
|
281
|
-
|
|
282
|
-
// ============ Deep link delivery ============
|
|
283
|
-
|
|
284
189
|
function ensureNativeSubscription() {
|
|
285
190
|
if (nativeSubscription) return;
|
|
286
191
|
nativeSubscription = NativeAdShiftReactNativePlugin.onDeepLink(payload => {
|
|
@@ -288,9 +193,7 @@ function ensureNativeSubscription() {
|
|
|
288
193
|
});
|
|
289
194
|
}
|
|
290
195
|
function dispatchDeepLink(deepLink) {
|
|
291
|
-
// A result must
|
|
292
|
-
// link delivered after a link tapped later would attribute the install to
|
|
293
|
-
// the wrong click.
|
|
196
|
+
// A result must not overtake one still waiting in the buffer.
|
|
294
197
|
if (listeners.size === 0 || deepLinkBuffer.length > 0) {
|
|
295
198
|
bufferDeepLink(deepLink);
|
|
296
199
|
scheduleReplay();
|
|
@@ -334,9 +237,6 @@ function scheduleReplay() {
|
|
|
334
237
|
}
|
|
335
238
|
});
|
|
336
239
|
}
|
|
337
|
-
|
|
338
|
-
// ============ Automatic URL forwarding (iOS) ============
|
|
339
|
-
|
|
340
240
|
function autoForwardEnabled() {
|
|
341
241
|
return Platform.OS === 'ios' && frozenConfig !== null && frozenConfig.autoHandleDeepLinks !== false;
|
|
342
242
|
}
|
|
@@ -346,16 +246,13 @@ function startLinkingAutoForward() {
|
|
|
346
246
|
url
|
|
347
247
|
}) => {
|
|
348
248
|
if (state === 'uninitialized' || !autoForwardEnabled()) return;
|
|
349
|
-
// An app that
|
|
350
|
-
//
|
|
351
|
-
// short window treats them as one link; a tap that comes later is a
|
|
352
|
-
// separate click and is forwarded.
|
|
249
|
+
// An app that also passes this event to handleDeepLink() must not count the
|
|
250
|
+
// link twice; a tap after the short window is a new click.
|
|
353
251
|
if (wasAutoForwardedRecently(url)) return;
|
|
354
252
|
forwardUrl(url, false).catch(() => undefined);
|
|
355
253
|
});
|
|
356
|
-
//
|
|
357
|
-
//
|
|
358
|
-
// it for the lifetime of the process, so the link is booked once.
|
|
254
|
+
// getInitialURL() returns the launch URL again after a JavaScript reload;
|
|
255
|
+
// marked as the launch URL, native forwards it once per process.
|
|
359
256
|
initialUrlForward = Linking.getInitialURL().then(url => url ? forwardUrl(url, true) : undefined).catch(() => undefined).finally(() => {
|
|
360
257
|
initialUrlForward = null;
|
|
361
258
|
});
|
|
@@ -398,9 +295,6 @@ async function waitForInitialUrlForward() {
|
|
|
398
295
|
if (timer !== undefined) clearTimeout(timer);
|
|
399
296
|
}
|
|
400
297
|
}
|
|
401
|
-
|
|
402
|
-
// ============ Start gating ============
|
|
403
|
-
|
|
404
298
|
function runWhenStarted(run) {
|
|
405
299
|
switch (state) {
|
|
406
300
|
case 'uninitialized':
|
|
@@ -441,11 +335,7 @@ function rejectPendingCalls(error) {
|
|
|
441
335
|
}
|
|
442
336
|
}
|
|
443
337
|
|
|
444
|
-
/**
|
|
445
|
-
* Warns when the native SDK on the device is not the one this release was built
|
|
446
|
-
* against. Only iOS reports its version, so on Android the pin is guarded by a
|
|
447
|
-
* build-time test instead.
|
|
448
|
-
*/
|
|
338
|
+
/** Only iOS reports its SDK version; on Android a build test guards the pin. */
|
|
449
339
|
function checkNativeSdkVersion(reported) {
|
|
450
340
|
if (typeof reported !== 'string' || reported.length === 0) return;
|
|
451
341
|
const expected = Platform.OS === 'ios' ? NATIVE_SDK_VERSIONS.ios : Platform.OS === 'android' ? NATIVE_SDK_VERSIONS.android : null;
|
|
@@ -484,8 +374,7 @@ async function performStart() {
|
|
|
484
374
|
await waitForInitialUrlForward();
|
|
485
375
|
const result = readStartResult(await NativeAdShiftReactNativePlugin.start());
|
|
486
376
|
if (epoch !== startEpoch) {
|
|
487
|
-
// A newer start() owns the
|
|
488
|
-
// leave the state to the newer attempt.
|
|
377
|
+
// A newer start() owns the state now.
|
|
489
378
|
return result;
|
|
490
379
|
}
|
|
491
380
|
if (state !== 'starting') {
|
|
@@ -504,7 +393,6 @@ async function performStart() {
|
|
|
504
393
|
state = 'started';
|
|
505
394
|
flushPendingCalls();
|
|
506
395
|
if (result.apiKeyValidationStatus === 'invalid') {
|
|
507
|
-
// The SDK started locally, but nothing it sends will be accepted.
|
|
508
396
|
reportDeclined(createAdshiftError(AdshiftErrorCode.InvalidApiKey, 'AdShift SDK: the backend rejected this API key; no data will be reported.'));
|
|
509
397
|
}
|
|
510
398
|
return result;
|
|
@@ -526,8 +414,6 @@ async function performStart() {
|
|
|
526
414
|
errorCode: mapped.code,
|
|
527
415
|
errorMessage: mapped.message
|
|
528
416
|
};
|
|
529
|
-
// What the platform said travels with the result, the same way it does
|
|
530
|
-
// when the native side answers with a failure instead of rejecting.
|
|
531
417
|
if (mapped.userInfo.nativeCode !== undefined) {
|
|
532
418
|
result.nativeCode = mapped.userInfo.nativeCode;
|
|
533
419
|
}
|
|
@@ -539,31 +425,17 @@ async function performStart() {
|
|
|
539
425
|
}
|
|
540
426
|
|
|
541
427
|
/**
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
* A rejected key, an excluded device and a missing configuration cannot be
|
|
545
|
-
* fixed by trying again, so the waiting calls are answered. Anything else can
|
|
546
|
-
* be, and holding the calls is worth more than answering them quickly: the
|
|
547
|
-
* data survives until the app starts the SDK again.
|
|
428
|
+
* Failures a retry cannot fix, which reject the calls waiting for `start()`.
|
|
429
|
+
* After any other failure they wait for the next attempt.
|
|
548
430
|
*/
|
|
549
431
|
function isTerminalStartFailure(code) {
|
|
550
432
|
return code === AdshiftErrorCode.InvalidApiKey || code === AdshiftErrorCode.OptedOut || code === AdshiftErrorCode.NotInitialized;
|
|
551
433
|
}
|
|
552
|
-
|
|
553
|
-
// ============ Main SDK API ============
|
|
554
|
-
|
|
555
434
|
export const Adshift = {
|
|
556
|
-
// ============ Lifecycle ============
|
|
557
|
-
|
|
558
435
|
/**
|
|
559
|
-
*
|
|
560
|
-
*
|
|
561
|
-
*
|
|
562
|
-
* The configuration is fixed on the first call; later calls are ignored.
|
|
563
|
-
*
|
|
564
|
-
* Never raises, because it is meant to run at module scope, where an error
|
|
565
|
-
* would stop the bundle from evaluating. An unusable config is reported
|
|
566
|
-
* through `config.onError` and answered by `start()`.
|
|
436
|
+
* Call once, as early as possible, for example at module scope. The first
|
|
437
|
+
* config is kept; later calls are ignored. Never raises: an unusable config
|
|
438
|
+
* is reported through `config.onError` and returned by `start()`.
|
|
567
439
|
*/
|
|
568
440
|
initialize(config) {
|
|
569
441
|
if (state !== 'uninitialized') {
|
|
@@ -610,14 +482,9 @@ export const Adshift = {
|
|
|
610
482
|
}
|
|
611
483
|
},
|
|
612
484
|
/**
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
*
|
|
616
|
-
* `result.success` and `result.errorCode`. Calls to `trackEvent`,
|
|
617
|
-
* `trackPurchase` and `logAdRevenue` made before this resolves are queued
|
|
618
|
-
* and dispatched afterwards. A start that fails with a reason retrying
|
|
619
|
-
* cannot fix rejects them instead; any other failure keeps them waiting for
|
|
620
|
-
* the next attempt.
|
|
485
|
+
* Never rejects; check `result.success`. `trackEvent`, `trackPurchase` and
|
|
486
|
+
* `logAdRevenue` calls made before it succeeds wait for it. A failure that
|
|
487
|
+
* retrying cannot fix rejects them; otherwise they wait for the next try.
|
|
621
488
|
*/
|
|
622
489
|
start() {
|
|
623
490
|
if (state === 'uninitialized') {
|
|
@@ -645,11 +512,8 @@ export const Adshift = {
|
|
|
645
512
|
return attempt;
|
|
646
513
|
},
|
|
647
514
|
/**
|
|
648
|
-
*
|
|
649
|
-
*
|
|
650
|
-
*
|
|
651
|
-
* Before `initialize()` there is nothing to stop: the call is reported and
|
|
652
|
-
* skipped.
|
|
515
|
+
* Tracking calls reject with `NOT_STARTED` until the next successful
|
|
516
|
+
* `start()`. Before `initialize()` the call is reported and skipped.
|
|
653
517
|
*/
|
|
654
518
|
stop() {
|
|
655
519
|
if (state === 'uninitialized') {
|
|
@@ -669,13 +533,9 @@ export const Adshift = {
|
|
|
669
533
|
isStarted() {
|
|
670
534
|
return state === 'started';
|
|
671
535
|
},
|
|
672
|
-
// ============ Configuration ============
|
|
673
|
-
|
|
674
536
|
/**
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
* Called before `initialize()`, the value is kept and applied afterwards.
|
|
678
|
-
* An empty identifier is reported and skipped; nothing is raised.
|
|
537
|
+
* Your own user id; may be set at any time. Before `initialize()` it is kept
|
|
538
|
+
* and applied afterwards. An empty id is reported and skipped.
|
|
679
539
|
*/
|
|
680
540
|
setCustomerUserId(userId) {
|
|
681
541
|
if (!isNonEmptyString(userId)) {
|
|
@@ -689,9 +549,8 @@ export const Adshift = {
|
|
|
689
549
|
NativeAdShiftReactNativePlugin.setCustomerUserId(userId);
|
|
690
550
|
},
|
|
691
551
|
/**
|
|
692
|
-
*
|
|
693
|
-
*
|
|
694
|
-
* Called before `initialize()`, the value is kept and applied afterwards.
|
|
552
|
+
* Verbose SDK logging. Before `initialize()` the value is kept and applied
|
|
553
|
+
* afterwards.
|
|
695
554
|
*/
|
|
696
555
|
setDebugEnabled(enabled) {
|
|
697
556
|
if (state === 'uninitialized') {
|
|
@@ -701,10 +560,9 @@ export const Adshift = {
|
|
|
701
560
|
NativeAdShiftReactNativePlugin.setDebugEnabled(enabled === true);
|
|
702
561
|
},
|
|
703
562
|
/**
|
|
704
|
-
*
|
|
705
|
-
*
|
|
706
|
-
*
|
|
707
|
-
* A negative interval is reported and skipped; nothing is raised.
|
|
563
|
+
* Debounce interval for automatic `app_open` events. Before `initialize()`
|
|
564
|
+
* the value is kept and applied afterwards. A negative value is reported and
|
|
565
|
+
* skipped.
|
|
708
566
|
*/
|
|
709
567
|
setAppOpenDebounceMs(ms) {
|
|
710
568
|
if (!isFiniteNumber(ms) || ms < 0) {
|
|
@@ -718,10 +576,8 @@ export const Adshift = {
|
|
|
718
576
|
NativeAdShiftReactNativePlugin.setAppOpenDebounceMs(ms);
|
|
719
577
|
},
|
|
720
578
|
/**
|
|
721
|
-
*
|
|
722
|
-
*
|
|
723
|
-
* Called before `initialize()`, the domains are kept and applied with the
|
|
724
|
-
* config, so they are in place before the first link is processed.
|
|
579
|
+
* Your own link domains; set them before `start()`. Before `initialize()`
|
|
580
|
+
* they are kept and passed with the config.
|
|
725
581
|
*/
|
|
726
582
|
setBrandedDomains(domains) {
|
|
727
583
|
if (!isStringArray(domains)) {
|
|
@@ -735,9 +591,8 @@ export const Adshift = {
|
|
|
735
591
|
NativeAdShiftReactNativePlugin.setBrandedDomains(domains);
|
|
736
592
|
},
|
|
737
593
|
/**
|
|
738
|
-
*
|
|
739
|
-
*
|
|
740
|
-
* Called before `initialize()`, the value is kept and applied afterwards.
|
|
594
|
+
* Meta app id used to parse Meta App Links; no-op on iOS. Before
|
|
595
|
+
* `initialize()` the value is kept and applied afterwards.
|
|
741
596
|
*/
|
|
742
597
|
setMetaAppId(appId) {
|
|
743
598
|
if (!isNonEmptyString(appId)) {
|
|
@@ -751,11 +606,9 @@ export const Adshift = {
|
|
|
751
606
|
NativeAdShiftReactNativePlugin.setMetaAppId(appId);
|
|
752
607
|
},
|
|
753
608
|
/**
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
757
|
-
*
|
|
758
|
-
* Called before `initialize()`, the value is kept and applied afterwards.
|
|
609
|
+
* An OAID the app obtained itself, for Android devices without Google Play
|
|
610
|
+
* services; set `collectOaid: false` as well. No-op on iOS. Before
|
|
611
|
+
* `initialize()` the value is kept and applied afterwards.
|
|
759
612
|
*/
|
|
760
613
|
setOaidData(oaid) {
|
|
761
614
|
if (!isNonEmptyString(oaid)) {
|
|
@@ -768,13 +621,9 @@ export const Adshift = {
|
|
|
768
621
|
}
|
|
769
622
|
NativeAdShiftReactNativePlugin.setOaidData(oaid);
|
|
770
623
|
},
|
|
771
|
-
// ============ Consent (GDPR/DMA) ============
|
|
772
|
-
|
|
773
624
|
/**
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
* Called before `initialize()`, the consent is kept and applied afterwards.
|
|
625
|
+
* Consent collected by your own UI: `AdshiftConsent.forGDPRUser()` or
|
|
626
|
+
* `forNonGDPRUser()`. Before `initialize()` it is kept and applied later.
|
|
778
627
|
*/
|
|
779
628
|
setConsentData(consent) {
|
|
780
629
|
if (!isPlainObject(consent) || typeof consent.isUserSubjectToGDPR !== 'boolean') {
|
|
@@ -788,10 +637,8 @@ export const Adshift = {
|
|
|
788
637
|
NativeAdShiftReactNativePlugin.setConsentData(consentToMap(consent));
|
|
789
638
|
},
|
|
790
639
|
/**
|
|
791
|
-
*
|
|
792
|
-
*
|
|
793
|
-
*
|
|
794
|
-
* Called before `initialize()`, the value is kept and applied afterwards.
|
|
640
|
+
* Reading IAB TCF v2.2 consent from the CMP on the device. Call before
|
|
641
|
+
* `start()`; before `initialize()` the value is kept and applied afterwards.
|
|
795
642
|
*/
|
|
796
643
|
enableTCFDataCollection(enabled) {
|
|
797
644
|
if (state === 'uninitialized') {
|
|
@@ -801,14 +648,9 @@ export const Adshift = {
|
|
|
801
648
|
NativeAdShiftReactNativePlugin.enableTCFDataCollection(enabled === true);
|
|
802
649
|
},
|
|
803
650
|
/**
|
|
804
|
-
*
|
|
805
|
-
*
|
|
806
|
-
*
|
|
807
|
-
* The GPP string rides on its own axis: it is forwarded alongside whatever
|
|
808
|
-
* decides the GDPR axis, including a consent set through `setConsentData()`,
|
|
809
|
-
* and it does not gate the advertising identifier on the device.
|
|
810
|
-
*
|
|
811
|
-
* Call before `start()`. Called before `initialize()`, the value is kept and
|
|
651
|
+
* Reading an IAB GPP string written by the CMP, for US state privacy
|
|
652
|
+
* signals; off until called with `true`. It does not gate the advertising
|
|
653
|
+
* id. Call before `start()`; before `initialize()` the value is kept and
|
|
812
654
|
* applied afterwards.
|
|
813
655
|
*/
|
|
814
656
|
enableGPPDataCollection(enabled) {
|
|
@@ -819,20 +661,10 @@ export const Adshift = {
|
|
|
819
661
|
NativeAdShiftReactNativePlugin.enableGPPDataCollection(enabled === true);
|
|
820
662
|
},
|
|
821
663
|
/**
|
|
822
|
-
*
|
|
823
|
-
*
|
|
824
|
-
*
|
|
825
|
-
*
|
|
826
|
-
* This is the answer to a different question than `setConsentData()`, and it
|
|
827
|
-
* has the opposite default: nothing said here means sharing is allowed, so
|
|
828
|
-
* only call it once the user has actually been asked. Setting `allowed()` at
|
|
829
|
-
* startup as a default records a declaration the user never made, and events
|
|
830
|
-
* already sent cannot be recalled when a real answer arrives.
|
|
831
|
-
*
|
|
832
|
-
* Nothing is gated on the device either way — this travels with the events for
|
|
833
|
-
* the backend to act on.
|
|
834
|
-
*
|
|
835
|
-
* Called before `initialize()`, the answer is kept and applied afterwards.
|
|
664
|
+
* The user's answer on sharing their data with advertising partners:
|
|
665
|
+
* `AdshiftThirdPartySharing.optedOut()` or `allowed()`. Unlike consent,
|
|
666
|
+
* saying nothing means allowed, so call it only once the user was asked;
|
|
667
|
+
* events already sent are not recalled. Kept if called before `initialize()`.
|
|
836
668
|
*/
|
|
837
669
|
setThirdPartySharing(sharing) {
|
|
838
670
|
if (!isPlainObject(sharing) || typeof sharing.optOut !== 'boolean') {
|
|
@@ -846,15 +678,9 @@ export const Adshift = {
|
|
|
846
678
|
NativeAdShiftReactNativePlugin.setThirdPartySharing(thirdPartySharingToMap(sharing));
|
|
847
679
|
},
|
|
848
680
|
/**
|
|
849
|
-
* Withdraws
|
|
850
|
-
*
|
|
851
|
-
*
|
|
852
|
-
* stating that sharing is allowed: the first leaves the decision to your
|
|
853
|
-
* dashboard configuration, the second is the app's own declaration and is
|
|
854
|
-
* recorded as such.
|
|
855
|
-
*
|
|
856
|
-
* Called before `initialize()`, this cancels a `setThirdPartySharing()` that
|
|
857
|
-
* was also queued.
|
|
681
|
+
* Withdraws `setThirdPartySharing()`: later events say nothing about sharing,
|
|
682
|
+
* which is not the same as `allowed()`. Before `initialize()` it cancels a
|
|
683
|
+
* queued `setThirdPartySharing()`.
|
|
858
684
|
*/
|
|
859
685
|
clearThirdPartySharing() {
|
|
860
686
|
if (state === 'uninitialized') {
|
|
@@ -880,21 +706,11 @@ export const Adshift = {
|
|
|
880
706
|
throw toAdshiftError(error);
|
|
881
707
|
}
|
|
882
708
|
},
|
|
883
|
-
// ============ Event Tracking ============
|
|
884
|
-
|
|
885
709
|
/**
|
|
886
|
-
*
|
|
887
|
-
*
|
|
888
|
-
* `
|
|
889
|
-
*
|
|
890
|
-
*
|
|
891
|
-
* Resolves once the SDK has accepted the event. A call made between
|
|
892
|
-
* `initialize()` and a successful `start()` waits for the start: it is sent
|
|
893
|
-
* when the SDK starts, and rejects when the start fails for a reason
|
|
894
|
-
* retrying cannot fix (rejected key, excluded device) or after `stop()`.
|
|
895
|
-
* A start that failed for any other reason keeps the call waiting for the
|
|
896
|
-
* next attempt, so `start()` belongs on every launch path.
|
|
897
|
-
*
|
|
710
|
+
* `app_install` and `app_open` are reserved. A call made before a successful
|
|
711
|
+
* `start()` waits for it, so call `start()` on every launch path; it rejects
|
|
712
|
+
* after `stop()` or a start failure retrying cannot fix (rejected key,
|
|
713
|
+
* excluded device).
|
|
898
714
|
* @returns Rejects with `AdshiftError` (`NOT_INITIALIZED`, `NOT_STARTED`,
|
|
899
715
|
* `INVALID_API_KEY`, `OPTED_OUT`, `QUEUE_FULL`, `INVALID_ARGUMENT`).
|
|
900
716
|
*/
|
|
@@ -913,11 +729,7 @@ export const Adshift = {
|
|
|
913
729
|
warnAboutPlainParamNames(values);
|
|
914
730
|
return runWhenStarted(() => NativeAdShiftReactNativePlugin.trackEvent(eventName, values ?? null));
|
|
915
731
|
},
|
|
916
|
-
/**
|
|
917
|
-
* Tracks a purchase.
|
|
918
|
-
*
|
|
919
|
-
* @returns Rejects with `AdshiftError` (see `trackEvent`).
|
|
920
|
-
*/
|
|
732
|
+
/** Waits for `start()` and rejects like `trackEvent()`. */
|
|
921
733
|
trackPurchase(params) {
|
|
922
734
|
if (!isPlainObject(params)) {
|
|
923
735
|
return Promise.reject(invalidArgument('AdShift SDK: params must be an object'));
|
|
@@ -943,9 +755,8 @@ export const Adshift = {
|
|
|
943
755
|
return runWhenStarted(() => NativeAdShiftReactNativePlugin.trackPurchase(productId, revenue, currency, transactionId));
|
|
944
756
|
},
|
|
945
757
|
/**
|
|
946
|
-
*
|
|
947
|
-
*
|
|
948
|
-
* @returns Rejects with `AdshiftError` (see `trackEvent`).
|
|
758
|
+
* Revenue of a single impression, not an aggregate. Waits for `start()` and
|
|
759
|
+
* rejects like `trackEvent()`.
|
|
949
760
|
*/
|
|
950
761
|
logAdRevenue(params) {
|
|
951
762
|
if (!isPlainObject(params)) {
|
|
@@ -1003,11 +814,7 @@ export const Adshift = {
|
|
|
1003
814
|
}
|
|
1004
815
|
return runWhenStarted(() => NativeAdShiftReactNativePlugin.logAdRevenue(data));
|
|
1005
816
|
},
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
/**
|
|
1009
|
-
* Returns the AdShift device id, or `null` before `initialize()`.
|
|
1010
|
-
*/
|
|
817
|
+
/** `null` before `initialize()`. */
|
|
1011
818
|
async getAdShiftDeviceId() {
|
|
1012
819
|
if (state === 'uninitialized') {
|
|
1013
820
|
return null;
|
|
@@ -1019,15 +826,9 @@ export const Adshift = {
|
|
|
1019
826
|
throw toAdshiftError(error);
|
|
1020
827
|
}
|
|
1021
828
|
},
|
|
1022
|
-
// ============ Deep Links ============
|
|
1023
|
-
|
|
1024
829
|
/**
|
|
1025
|
-
* Passes a URL to the SDK
|
|
1026
|
-
*
|
|
1027
|
-
* Not needed when `autoHandleDeepLinks` is on (the default). The result is
|
|
1028
|
-
* delivered through `onDeepLink()`; the promise resolves once the SDK has
|
|
1029
|
-
* finished processing the URL.
|
|
1030
|
-
*
|
|
830
|
+
* Passes a URL to the SDK; not needed with `autoHandleDeepLinks` on (the
|
|
831
|
+
* default). The result arrives through `onDeepLink()`.
|
|
1031
832
|
* @returns Rejects with `AdshiftError` (`NOT_INITIALIZED`,
|
|
1032
833
|
* `INVALID_ARGUMENT`).
|
|
1033
834
|
*/
|
|
@@ -1073,11 +874,10 @@ export const Adshift = {
|
|
|
1073
874
|
NativeAdShiftReactNativePlugin.handlePastedDeepLink(isNonEmptyString(url) ? url : null);
|
|
1074
875
|
},
|
|
1075
876
|
/**
|
|
1076
|
-
*
|
|
1077
|
-
*
|
|
1078
|
-
*
|
|
1079
|
-
*
|
|
1080
|
-
* the SDK reads on its own, so register that key too if you still need it.
|
|
877
|
+
* A key path inside push payloads that carries an AdShift deep link. The
|
|
878
|
+
* first path replaces the top-level `as_push_link` the SDK reads by default,
|
|
879
|
+
* so add that one too if you still use it. Kept if called before
|
|
880
|
+
* `initialize()`.
|
|
1081
881
|
*/
|
|
1082
882
|
addPushNotificationDeepLinkPath(path) {
|
|
1083
883
|
if (!isStringArray(path) || path.length === 0) {
|
|
@@ -1091,10 +891,8 @@ export const Adshift = {
|
|
|
1091
891
|
NativeAdShiftReactNativePlugin.addPushNotificationDeepLinkPath(path);
|
|
1092
892
|
},
|
|
1093
893
|
/**
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1096
|
-
* through `onDeepLink()`.
|
|
1097
|
-
*
|
|
894
|
+
* Resolves to `true` when the payload carried an AdShift deep link; the
|
|
895
|
+
* result then arrives through `onDeepLink()`.
|
|
1098
896
|
* @returns Rejects with `AdshiftError` (`NOT_INITIALIZED`,
|
|
1099
897
|
* `INVALID_ARGUMENT`).
|
|
1100
898
|
*/
|
|
@@ -1112,12 +910,9 @@ export const Adshift = {
|
|
|
1112
910
|
}
|
|
1113
911
|
},
|
|
1114
912
|
/**
|
|
1115
|
-
*
|
|
1116
|
-
*
|
|
1117
|
-
*
|
|
1118
|
-
* listener is registered are buffered and delivered to the first listener.
|
|
1119
|
-
* Every link that reaches the SDK (direct, deferred, push) is delivered,
|
|
1120
|
-
* each result once.
|
|
913
|
+
* Safe to call before `initialize()`. Results that arrive while no listener
|
|
914
|
+
* is registered are buffered for the first one. Every link that reaches the
|
|
915
|
+
* SDK (direct, deferred, push) is delivered once.
|
|
1121
916
|
*/
|
|
1122
917
|
onDeepLink(callback) {
|
|
1123
918
|
if (typeof callback !== 'function') {
|
|
@@ -1140,8 +935,6 @@ export const Adshift = {
|
|
|
1140
935
|
}
|
|
1141
936
|
};
|
|
1142
937
|
},
|
|
1143
|
-
// ============ Info ============
|
|
1144
|
-
|
|
1145
938
|
getInfo() {
|
|
1146
939
|
return {
|
|
1147
940
|
platform: Platform.OS,
|