@adshift/react-native-plugin 2.1.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 +57 -8
- package/README.md +131 -74
- package/android/build.gradle +3 -2
- package/android/consumer-rules.pro +2 -21
- package/android/src/main/AndroidManifest.xml +14 -1
- package/android/src/main/java/com/adshift/reactnativeplugin/ActivityIntents.kt +307 -0
- package/android/src/main/java/com/adshift/reactnativeplugin/AdShiftReactNativePluginModule.kt +90 -153
- package/android/src/test/java/com/adshift/reactnativeplugin/ConsentSnapshotTest.kt +0 -20
- package/android/src/test/java/com/adshift/reactnativeplugin/DeepLinkDeliveryTest.kt +40 -7
- package/android/src/test/java/com/adshift/reactnativeplugin/InitializeOrderingTest.kt +51 -5
- package/android/src/test/java/com/adshift/reactnativeplugin/IntentLinkDedupTest.kt +0 -5
- package/android/src/test/java/com/adshift/reactnativeplugin/LaunchIntentForwardingTest.kt +21 -11
- package/android/src/test/java/com/adshift/reactnativeplugin/LaunchLinkRecordTest.kt +420 -0
- package/android/src/test/java/com/adshift/reactnativeplugin/ModuleTestSupport.kt +97 -25
- package/android/src/test/java/com/adshift/reactnativeplugin/StartVerdictTest.kt +0 -4
- package/ios/AdShiftReactNativePlugin.h +0 -12
- package/ios/AdShiftReactNativePlugin.mm +7 -14
- package/ios/AdShiftReactNativePluginHelper.swift +38 -73
- package/ios/Core/BridgeRules.swift +42 -30
- package/lib/commonjs/Adshift.js +100 -284
- 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 +6 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/jest/index.js +6 -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 +11 -23
- 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 +50 -33
- 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/types/index.js +12 -0
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/Adshift.js +101 -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 +2 -47
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest/index.js +7 -19
- 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 +10 -23
- 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 +49 -32
- 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/types/index.js +2 -2
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/commonjs/src/Adshift.d.ts +68 -184
- package/lib/typescript/commonjs/src/Adshift.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts +18 -35
- package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +2 -34
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/jest/index.d.ts +9 -21
- 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 +35 -39
- 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 +55 -39
- 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/types/index.d.ts +3 -3
- package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/version.d.ts +1 -1
- package/lib/typescript/module/src/Adshift.d.ts +68 -184
- package/lib/typescript/module/src/Adshift.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts +18 -35
- package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +2 -34
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/jest/index.d.ts +9 -21
- 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 +35 -39
- 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 +55 -39
- 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/types/index.d.ts +3 -3
- package/lib/typescript/module/src/types/index.d.ts.map +1 -1
- package/lib/typescript/module/src/version.d.ts +1 -1
- package/package.json +11 -1
- package/src/Adshift.ts +118 -285
- package/src/NativeAdShiftReactNativePlugin.ts +19 -47
- package/src/index.tsx +7 -46
- package/src/jest/index.ts +11 -20
- package/src/nativeSdkVersions.ts +4 -6
- package/src/types/AdshiftAdRevenue.ts +0 -24
- package/src/types/AdshiftConfig.ts +48 -55
- package/src/types/AdshiftConsent.ts +9 -49
- package/src/types/AdshiftConsentSnapshot.ts +11 -38
- package/src/types/AdshiftDeepLink.ts +87 -39
- 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/types/index.ts +9 -2
- 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/lib/commonjs/Adshift.js
CHANGED
|
@@ -11,100 +11,32 @@ var _index = require("./types/index.js");
|
|
|
11
11
|
var _version = require("./version.js");
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* import {
|
|
19
|
-
* Adshift,
|
|
20
|
-
* AdshiftEventParam,
|
|
21
|
-
* AdshiftEventType,
|
|
22
|
-
* } from '@adshift/react-native-plugin';
|
|
23
|
-
*
|
|
24
|
-
* // 1. Register the deep link listener (safe to do before initialize)
|
|
25
|
-
* const subscription = Adshift.onDeepLink((deepLink) => {
|
|
26
|
-
* // route on deepLink.deepLinkValue / deepLink.params
|
|
27
|
-
* });
|
|
28
|
-
*
|
|
29
|
-
* // 2. Initialize
|
|
30
|
-
* Adshift.initialize({ apiKey: 'your-api-key', isDebug: __DEV__ });
|
|
31
|
-
*
|
|
32
|
-
* // 3. Start
|
|
33
|
-
* const result = await Adshift.start();
|
|
34
|
-
*
|
|
35
|
-
* // 4. Track
|
|
36
|
-
* await Adshift.trackEvent(AdshiftEventType.Purchase, {
|
|
37
|
-
* [AdshiftEventParam.Revenue]: 9.99,
|
|
38
|
-
* [AdshiftEventParam.Currency]: 'USD',
|
|
39
|
-
* });
|
|
40
|
-
*
|
|
41
|
-
* // Later: subscription.remove();
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
// ============ Public types ============
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Result of `Adshift.start()`.
|
|
49
|
-
*
|
|
50
|
-
* `success` reports whether the SDK started locally. The API key is checked
|
|
51
|
-
* with the backend in the background: `apiKeyValidationStatus` is the verdict
|
|
52
|
-
* at the time `start()` resolved, and `config.onError` reports
|
|
53
|
-
* `INVALID_API_KEY` when that verdict is `invalid`. On iOS the verdict usually
|
|
54
|
-
* arrives after `start()` resolved and is reported by the next `start()`; on
|
|
55
|
-
* Android `start()` waits up to 5 s for it.
|
|
14
|
+
* `success` says whether the SDK started on the device. The API key is checked
|
|
15
|
+
* in the background; an `invalid` verdict is also reported through
|
|
16
|
+
* `config.onError` as `INVALID_API_KEY`. Android waits up to 5 s for the
|
|
17
|
+
* verdict; on iOS it usually arrives later and shows in a later `start()`.
|
|
56
18
|
*/
|
|
57
19
|
|
|
58
20
|
/** How far the API key check had got when `start()` resolved. */
|
|
59
21
|
|
|
60
|
-
/**
|
|
61
|
-
* Parameters for `Adshift.trackPurchase()`.
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Subscription returned by `Adshift.onDeepLink()`.
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Native SDK versions bundled with this plugin release.
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Plugin information returned by `Adshift.getInfo()`.
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
// ============ Constants ============
|
|
77
|
-
|
|
78
22
|
const DEEP_LINK_BUFFER_LIMIT = 20;
|
|
79
23
|
const PENDING_CALL_LIMIT = 100;
|
|
80
24
|
/** Bounds how long `start()` waits for the URL the app was opened with. */
|
|
81
25
|
const INITIAL_URL_WAIT_MS = 3000;
|
|
82
26
|
/** How long one URL counts as the same link, whoever passed it in first. */
|
|
83
27
|
const AUTO_FORWARD_DEDUP_MS = 2000;
|
|
84
|
-
/**
|
|
85
|
-
* Mirrors a limit the SDK applies, so the warning below can name it. Raising it
|
|
86
|
-
* there without raising it here makes the warning wrong, not the behaviour.
|
|
87
|
-
*/
|
|
28
|
+
/** For the warning only; on iOS it applies to amounts in USD, hence the check. */
|
|
88
29
|
const MAX_AD_REVENUE_PER_IMPRESSION = 10;
|
|
89
30
|
const MEDIATION_NETWORKS = new Set(Object.values(_index.AdshiftMediationNetwork));
|
|
90
|
-
/**
|
|
91
|
-
* Event names the SDK sends on its own. Sending them by hand would mix
|
|
92
|
-
* hand-made records into install and session counts, which cannot be undone
|
|
93
|
-
* once they are reported.
|
|
94
|
-
*/
|
|
31
|
+
/** Sent by the SDK itself. */
|
|
95
32
|
const RESERVED_EVENT_NAMES = new Set(['app_install', 'app_open']);
|
|
96
33
|
|
|
97
|
-
/**
|
|
98
|
-
* Configuration received before `initialize()`. Each entry holds the latest
|
|
99
|
-
* value for one setter, so the memory is bounded by the number of setters.
|
|
100
|
-
*/
|
|
101
|
-
|
|
102
|
-
// ============ Internal state ============
|
|
34
|
+
/** Setters called before `initialize()`: each last value, all push paths. */
|
|
103
35
|
|
|
104
36
|
let state = 'uninitialized';
|
|
105
37
|
let frozenConfig = null;
|
|
106
38
|
let startInFlight = null;
|
|
107
|
-
/**
|
|
39
|
+
/** One per start attempt, so a superseded attempt cannot touch the state. */
|
|
108
40
|
let startEpoch = 0;
|
|
109
41
|
let nativeSubscription = null;
|
|
110
42
|
const listeners = new Set();
|
|
@@ -120,9 +52,6 @@ let pendingSettings = {
|
|
|
120
52
|
let errorHandler = null;
|
|
121
53
|
/** Kept so `start()` can answer with the reason `initialize()` was refused. */
|
|
122
54
|
let configError = null;
|
|
123
|
-
|
|
124
|
-
// ============ Logging ============
|
|
125
|
-
|
|
126
55
|
function devWarn(message) {
|
|
127
56
|
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
128
57
|
console.warn(`[AdShift] ${message}`);
|
|
@@ -130,12 +59,8 @@ function devWarn(message) {
|
|
|
130
59
|
}
|
|
131
60
|
|
|
132
61
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* Public methods that return nothing have no channel to answer through, so
|
|
136
|
-
* they never raise: raising would unwind a stack the caller did not choose,
|
|
137
|
-
* and React Native treats an error escaping an event handler or a native
|
|
138
|
-
* callback as fatal. The call is skipped and reported here instead.
|
|
62
|
+
* Methods that return nothing report a declined call here instead of raising:
|
|
63
|
+
* React Native treats an error escaping an event handler as fatal.
|
|
139
64
|
*/
|
|
140
65
|
function reportDeclined(error) {
|
|
141
66
|
devWarn(`${error.message} (${error.code})`);
|
|
@@ -146,9 +71,6 @@ function reportDeclined(error) {
|
|
|
146
71
|
devWarn('config.onError threw; ignoring it.');
|
|
147
72
|
}
|
|
148
73
|
}
|
|
149
|
-
|
|
150
|
-
// ============ Errors ============
|
|
151
|
-
|
|
152
74
|
function notInitializedError() {
|
|
153
75
|
return (0, _index.createAdshiftError)(_index.AdshiftErrorCode.NotInitialized, 'AdShift SDK is not initialized. Call Adshift.initialize(config) first.');
|
|
154
76
|
}
|
|
@@ -171,11 +93,7 @@ function isStringArray(value) {
|
|
|
171
93
|
return Array.isArray(value) && value.every(isNonEmptyString);
|
|
172
94
|
}
|
|
173
95
|
|
|
174
|
-
/**
|
|
175
|
-
* Plain names a caller is likely to invent, mapped onto the standard constant
|
|
176
|
-
* that carries the same meaning. Built from the constants so there is one list
|
|
177
|
-
* to keep, not two.
|
|
178
|
-
*/
|
|
96
|
+
/** Plain names a caller is likely to use instead of a standard parameter. */
|
|
179
97
|
const STANDARD_PARAM_BY_PLAIN_NAME = (() => {
|
|
180
98
|
const index = new Map();
|
|
181
99
|
const standard = new Set((0, _index.getAllEventParams)());
|
|
@@ -192,10 +110,7 @@ const STANDARD_PARAM_BY_PLAIN_NAME = (() => {
|
|
|
192
110
|
})();
|
|
193
111
|
const reportedPlainParamNames = new Set();
|
|
194
112
|
|
|
195
|
-
/**
|
|
196
|
-
* Warns once per name when a value carries a plain name instead of the
|
|
197
|
-
* standard one. Sending it is allowed — it just stays a custom parameter.
|
|
198
|
-
*/
|
|
113
|
+
/** Warns once per name; the value is still sent, as a custom parameter. */
|
|
199
114
|
function warnAboutPlainParamNames(values) {
|
|
200
115
|
if (values === undefined) return;
|
|
201
116
|
for (const key of Object.keys(values)) {
|
|
@@ -221,15 +136,9 @@ function validateEventValues(values, name) {
|
|
|
221
136
|
}
|
|
222
137
|
}
|
|
223
138
|
|
|
224
|
-
// ============ Configuration received before initialize() ============
|
|
225
|
-
|
|
226
139
|
/**
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
* The config wins for anything it states, because it is the later and more
|
|
230
|
-
* explicit declaration. Push key paths are additive, so they are merged.
|
|
231
|
-
* Settings that reach the SDK through a setter only are applied by
|
|
232
|
-
* `applyPendingSettings()` right after the native module is initialized.
|
|
140
|
+
* The config wins over a value set before `initialize()`; push paths from both
|
|
141
|
+
* are kept. Values without a config option go through `applyPendingSettings()`.
|
|
233
142
|
*/
|
|
234
143
|
function withPendingSettings(config) {
|
|
235
144
|
const merged = {
|
|
@@ -281,9 +190,6 @@ function applyPendingSettings() {
|
|
|
281
190
|
}
|
|
282
191
|
}
|
|
283
192
|
}
|
|
284
|
-
|
|
285
|
-
// ============ Deep link delivery ============
|
|
286
|
-
|
|
287
193
|
function ensureNativeSubscription() {
|
|
288
194
|
if (nativeSubscription) return;
|
|
289
195
|
nativeSubscription = _NativeAdShiftReactNativePlugin.default.onDeepLink(payload => {
|
|
@@ -291,9 +197,7 @@ function ensureNativeSubscription() {
|
|
|
291
197
|
});
|
|
292
198
|
}
|
|
293
199
|
function dispatchDeepLink(deepLink) {
|
|
294
|
-
// A result must
|
|
295
|
-
// link delivered after a link tapped later would attribute the install to
|
|
296
|
-
// the wrong click.
|
|
200
|
+
// A result must not overtake one still waiting in the buffer.
|
|
297
201
|
if (listeners.size === 0 || deepLinkBuffer.length > 0) {
|
|
298
202
|
bufferDeepLink(deepLink);
|
|
299
203
|
scheduleReplay();
|
|
@@ -337,9 +241,6 @@ function scheduleReplay() {
|
|
|
337
241
|
}
|
|
338
242
|
});
|
|
339
243
|
}
|
|
340
|
-
|
|
341
|
-
// ============ Automatic URL forwarding (iOS) ============
|
|
342
|
-
|
|
343
244
|
function autoForwardEnabled() {
|
|
344
245
|
return _reactNative.Platform.OS === 'ios' && frozenConfig !== null && frozenConfig.autoHandleDeepLinks !== false;
|
|
345
246
|
}
|
|
@@ -349,16 +250,13 @@ function startLinkingAutoForward() {
|
|
|
349
250
|
url
|
|
350
251
|
}) => {
|
|
351
252
|
if (state === 'uninitialized' || !autoForwardEnabled()) return;
|
|
352
|
-
// An app that
|
|
353
|
-
//
|
|
354
|
-
// short window treats them as one link; a tap that comes later is a
|
|
355
|
-
// separate click and is forwarded.
|
|
253
|
+
// An app that also passes this event to handleDeepLink() must not count the
|
|
254
|
+
// link twice; a tap after the short window is a new click.
|
|
356
255
|
if (wasAutoForwardedRecently(url)) return;
|
|
357
256
|
forwardUrl(url, false).catch(() => undefined);
|
|
358
257
|
});
|
|
359
|
-
//
|
|
360
|
-
//
|
|
361
|
-
// it for the lifetime of the process, so the link is booked once.
|
|
258
|
+
// getInitialURL() returns the launch URL again after a JavaScript reload;
|
|
259
|
+
// marked as the launch URL, native forwards it once per process.
|
|
362
260
|
initialUrlForward = _reactNative.Linking.getInitialURL().then(url => url ? forwardUrl(url, true) : undefined).catch(() => undefined).finally(() => {
|
|
363
261
|
initialUrlForward = null;
|
|
364
262
|
});
|
|
@@ -401,9 +299,6 @@ async function waitForInitialUrlForward() {
|
|
|
401
299
|
if (timer !== undefined) clearTimeout(timer);
|
|
402
300
|
}
|
|
403
301
|
}
|
|
404
|
-
|
|
405
|
-
// ============ Start gating ============
|
|
406
|
-
|
|
407
302
|
function runWhenStarted(run) {
|
|
408
303
|
switch (state) {
|
|
409
304
|
case 'uninitialized':
|
|
@@ -444,11 +339,7 @@ function rejectPendingCalls(error) {
|
|
|
444
339
|
}
|
|
445
340
|
}
|
|
446
341
|
|
|
447
|
-
/**
|
|
448
|
-
* Warns when the native SDK on the device is not the one this release was built
|
|
449
|
-
* against. Only iOS reports its version, so on Android the pin is guarded by a
|
|
450
|
-
* build-time test instead.
|
|
451
|
-
*/
|
|
342
|
+
/** Only iOS reports its SDK version; on Android a build test guards the pin. */
|
|
452
343
|
function checkNativeSdkVersion(reported) {
|
|
453
344
|
if (typeof reported !== 'string' || reported.length === 0) return;
|
|
454
345
|
const expected = _reactNative.Platform.OS === 'ios' ? _nativeSdkVersions.NATIVE_SDK_VERSIONS.ios : _reactNative.Platform.OS === 'android' ? _nativeSdkVersions.NATIVE_SDK_VERSIONS.android : null;
|
|
@@ -487,8 +378,7 @@ async function performStart() {
|
|
|
487
378
|
await waitForInitialUrlForward();
|
|
488
379
|
const result = readStartResult(await _NativeAdShiftReactNativePlugin.default.start());
|
|
489
380
|
if (epoch !== startEpoch) {
|
|
490
|
-
// A newer start() owns the
|
|
491
|
-
// leave the state to the newer attempt.
|
|
381
|
+
// A newer start() owns the state now.
|
|
492
382
|
return result;
|
|
493
383
|
}
|
|
494
384
|
if (state !== 'starting') {
|
|
@@ -507,7 +397,6 @@ async function performStart() {
|
|
|
507
397
|
state = 'started';
|
|
508
398
|
flushPendingCalls();
|
|
509
399
|
if (result.apiKeyValidationStatus === 'invalid') {
|
|
510
|
-
// The SDK started locally, but nothing it sends will be accepted.
|
|
511
400
|
reportDeclined((0, _index.createAdshiftError)(_index.AdshiftErrorCode.InvalidApiKey, 'AdShift SDK: the backend rejected this API key; no data will be reported.'));
|
|
512
401
|
}
|
|
513
402
|
return result;
|
|
@@ -529,8 +418,6 @@ async function performStart() {
|
|
|
529
418
|
errorCode: mapped.code,
|
|
530
419
|
errorMessage: mapped.message
|
|
531
420
|
};
|
|
532
|
-
// What the platform said travels with the result, the same way it does
|
|
533
|
-
// when the native side answers with a failure instead of rejecting.
|
|
534
421
|
if (mapped.userInfo.nativeCode !== undefined) {
|
|
535
422
|
result.nativeCode = mapped.userInfo.nativeCode;
|
|
536
423
|
}
|
|
@@ -542,31 +429,17 @@ async function performStart() {
|
|
|
542
429
|
}
|
|
543
430
|
|
|
544
431
|
/**
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
* A rejected key, an excluded device and a missing configuration cannot be
|
|
548
|
-
* fixed by trying again, so the waiting calls are answered. Anything else can
|
|
549
|
-
* be, and holding the calls is worth more than answering them quickly: the
|
|
550
|
-
* data survives until the app starts the SDK again.
|
|
432
|
+
* Failures a retry cannot fix, which reject the calls waiting for `start()`.
|
|
433
|
+
* After any other failure they wait for the next attempt.
|
|
551
434
|
*/
|
|
552
435
|
function isTerminalStartFailure(code) {
|
|
553
436
|
return code === _index.AdshiftErrorCode.InvalidApiKey || code === _index.AdshiftErrorCode.OptedOut || code === _index.AdshiftErrorCode.NotInitialized;
|
|
554
437
|
}
|
|
555
|
-
|
|
556
|
-
// ============ Main SDK API ============
|
|
557
|
-
|
|
558
438
|
const Adshift = exports.Adshift = {
|
|
559
|
-
// ============ Lifecycle ============
|
|
560
|
-
|
|
561
439
|
/**
|
|
562
|
-
*
|
|
563
|
-
*
|
|
564
|
-
*
|
|
565
|
-
* The configuration is fixed on the first call; later calls are ignored.
|
|
566
|
-
*
|
|
567
|
-
* Never raises, because it is meant to run at module scope, where an error
|
|
568
|
-
* would stop the bundle from evaluating. An unusable config is reported
|
|
569
|
-
* through `config.onError` and answered by `start()`.
|
|
440
|
+
* Call once, as early as possible, for example at module scope. The first
|
|
441
|
+
* config is kept; later calls are ignored. Never raises: an unusable config
|
|
442
|
+
* is reported through `config.onError` and returned by `start()`.
|
|
570
443
|
*/
|
|
571
444
|
initialize(config) {
|
|
572
445
|
if (state !== 'uninitialized') {
|
|
@@ -590,6 +463,10 @@ const Adshift = exports.Adshift = {
|
|
|
590
463
|
refuse('AdShift SDK: pushDeepLinkPaths must be an array of string arrays');
|
|
591
464
|
return;
|
|
592
465
|
}
|
|
466
|
+
if (config.deferredDeepLinkClipboard !== undefined && !_index.DEFERRED_DEEP_LINK_CLIPBOARD_MODES.has(config.deferredDeepLinkClipboard)) {
|
|
467
|
+
refuse("AdShift SDK: deferredDeepLinkClipboard must be 'disabled', 'prompt' or 'pasteControl'");
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
593
470
|
configError = null;
|
|
594
471
|
frozenConfig = Object.freeze(withPendingSettings(config));
|
|
595
472
|
try {
|
|
@@ -609,14 +486,9 @@ const Adshift = exports.Adshift = {
|
|
|
609
486
|
}
|
|
610
487
|
},
|
|
611
488
|
/**
|
|
612
|
-
*
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
* `result.success` and `result.errorCode`. Calls to `trackEvent`,
|
|
616
|
-
* `trackPurchase` and `logAdRevenue` made before this resolves are queued
|
|
617
|
-
* and dispatched afterwards. A start that fails with a reason retrying
|
|
618
|
-
* cannot fix rejects them instead; any other failure keeps them waiting for
|
|
619
|
-
* the next attempt.
|
|
489
|
+
* Never rejects; check `result.success`. `trackEvent`, `trackPurchase` and
|
|
490
|
+
* `logAdRevenue` calls made before it succeeds wait for it. A failure that
|
|
491
|
+
* retrying cannot fix rejects them; otherwise they wait for the next try.
|
|
620
492
|
*/
|
|
621
493
|
start() {
|
|
622
494
|
if (state === 'uninitialized') {
|
|
@@ -644,11 +516,8 @@ const Adshift = exports.Adshift = {
|
|
|
644
516
|
return attempt;
|
|
645
517
|
},
|
|
646
518
|
/**
|
|
647
|
-
*
|
|
648
|
-
*
|
|
649
|
-
*
|
|
650
|
-
* Before `initialize()` there is nothing to stop: the call is reported and
|
|
651
|
-
* skipped.
|
|
519
|
+
* Tracking calls reject with `NOT_STARTED` until the next successful
|
|
520
|
+
* `start()`. Before `initialize()` the call is reported and skipped.
|
|
652
521
|
*/
|
|
653
522
|
stop() {
|
|
654
523
|
if (state === 'uninitialized') {
|
|
@@ -668,13 +537,9 @@ const Adshift = exports.Adshift = {
|
|
|
668
537
|
isStarted() {
|
|
669
538
|
return state === 'started';
|
|
670
539
|
},
|
|
671
|
-
// ============ Configuration ============
|
|
672
|
-
|
|
673
540
|
/**
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
* Called before `initialize()`, the value is kept and applied afterwards.
|
|
677
|
-
* An empty identifier is reported and skipped; nothing is raised.
|
|
541
|
+
* Your own user id; may be set at any time. Before `initialize()` it is kept
|
|
542
|
+
* and applied afterwards. An empty id is reported and skipped.
|
|
678
543
|
*/
|
|
679
544
|
setCustomerUserId(userId) {
|
|
680
545
|
if (!isNonEmptyString(userId)) {
|
|
@@ -688,9 +553,8 @@ const Adshift = exports.Adshift = {
|
|
|
688
553
|
_NativeAdShiftReactNativePlugin.default.setCustomerUserId(userId);
|
|
689
554
|
},
|
|
690
555
|
/**
|
|
691
|
-
*
|
|
692
|
-
*
|
|
693
|
-
* Called before `initialize()`, the value is kept and applied afterwards.
|
|
556
|
+
* Verbose SDK logging. Before `initialize()` the value is kept and applied
|
|
557
|
+
* afterwards.
|
|
694
558
|
*/
|
|
695
559
|
setDebugEnabled(enabled) {
|
|
696
560
|
if (state === 'uninitialized') {
|
|
@@ -700,10 +564,9 @@ const Adshift = exports.Adshift = {
|
|
|
700
564
|
_NativeAdShiftReactNativePlugin.default.setDebugEnabled(enabled === true);
|
|
701
565
|
},
|
|
702
566
|
/**
|
|
703
|
-
*
|
|
704
|
-
*
|
|
705
|
-
*
|
|
706
|
-
* A negative interval is reported and skipped; nothing is raised.
|
|
567
|
+
* Debounce interval for automatic `app_open` events. Before `initialize()`
|
|
568
|
+
* the value is kept and applied afterwards. A negative value is reported and
|
|
569
|
+
* skipped.
|
|
707
570
|
*/
|
|
708
571
|
setAppOpenDebounceMs(ms) {
|
|
709
572
|
if (!isFiniteNumber(ms) || ms < 0) {
|
|
@@ -717,10 +580,8 @@ const Adshift = exports.Adshift = {
|
|
|
717
580
|
_NativeAdShiftReactNativePlugin.default.setAppOpenDebounceMs(ms);
|
|
718
581
|
},
|
|
719
582
|
/**
|
|
720
|
-
*
|
|
721
|
-
*
|
|
722
|
-
* Called before `initialize()`, the domains are kept and applied with the
|
|
723
|
-
* config, so they are in place before the first link is processed.
|
|
583
|
+
* Your own link domains; set them before `start()`. Before `initialize()`
|
|
584
|
+
* they are kept and passed with the config.
|
|
724
585
|
*/
|
|
725
586
|
setBrandedDomains(domains) {
|
|
726
587
|
if (!isStringArray(domains)) {
|
|
@@ -734,9 +595,8 @@ const Adshift = exports.Adshift = {
|
|
|
734
595
|
_NativeAdShiftReactNativePlugin.default.setBrandedDomains(domains);
|
|
735
596
|
},
|
|
736
597
|
/**
|
|
737
|
-
*
|
|
738
|
-
*
|
|
739
|
-
* Called before `initialize()`, the value is kept and applied afterwards.
|
|
598
|
+
* Meta app id used to parse Meta App Links; no-op on iOS. Before
|
|
599
|
+
* `initialize()` the value is kept and applied afterwards.
|
|
740
600
|
*/
|
|
741
601
|
setMetaAppId(appId) {
|
|
742
602
|
if (!isNonEmptyString(appId)) {
|
|
@@ -750,11 +610,9 @@ const Adshift = exports.Adshift = {
|
|
|
750
610
|
_NativeAdShiftReactNativePlugin.default.setMetaAppId(appId);
|
|
751
611
|
},
|
|
752
612
|
/**
|
|
753
|
-
*
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
757
|
-
* Called before `initialize()`, the value is kept and applied afterwards.
|
|
613
|
+
* An OAID the app obtained itself, for Android devices without Google Play
|
|
614
|
+
* services; set `collectOaid: false` as well. No-op on iOS. Before
|
|
615
|
+
* `initialize()` the value is kept and applied afterwards.
|
|
758
616
|
*/
|
|
759
617
|
setOaidData(oaid) {
|
|
760
618
|
if (!isNonEmptyString(oaid)) {
|
|
@@ -767,13 +625,9 @@ const Adshift = exports.Adshift = {
|
|
|
767
625
|
}
|
|
768
626
|
_NativeAdShiftReactNativePlugin.default.setOaidData(oaid);
|
|
769
627
|
},
|
|
770
|
-
// ============ Consent (GDPR/DMA) ============
|
|
771
|
-
|
|
772
628
|
/**
|
|
773
|
-
*
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
* Called before `initialize()`, the consent is kept and applied afterwards.
|
|
629
|
+
* Consent collected by your own UI: `AdshiftConsent.forGDPRUser()` or
|
|
630
|
+
* `forNonGDPRUser()`. Before `initialize()` it is kept and applied later.
|
|
777
631
|
*/
|
|
778
632
|
setConsentData(consent) {
|
|
779
633
|
if (!isPlainObject(consent) || typeof consent.isUserSubjectToGDPR !== 'boolean') {
|
|
@@ -787,10 +641,8 @@ const Adshift = exports.Adshift = {
|
|
|
787
641
|
_NativeAdShiftReactNativePlugin.default.setConsentData((0, _index.consentToMap)(consent));
|
|
788
642
|
},
|
|
789
643
|
/**
|
|
790
|
-
*
|
|
791
|
-
*
|
|
792
|
-
*
|
|
793
|
-
* Called before `initialize()`, the value is kept and applied afterwards.
|
|
644
|
+
* Reading IAB TCF v2.2 consent from the CMP on the device. Call before
|
|
645
|
+
* `start()`; before `initialize()` the value is kept and applied afterwards.
|
|
794
646
|
*/
|
|
795
647
|
enableTCFDataCollection(enabled) {
|
|
796
648
|
if (state === 'uninitialized') {
|
|
@@ -800,14 +652,9 @@ const Adshift = exports.Adshift = {
|
|
|
800
652
|
_NativeAdShiftReactNativePlugin.default.enableTCFDataCollection(enabled === true);
|
|
801
653
|
},
|
|
802
654
|
/**
|
|
803
|
-
*
|
|
804
|
-
*
|
|
805
|
-
*
|
|
806
|
-
* The GPP string rides on its own axis: it is forwarded alongside whatever
|
|
807
|
-
* decides the GDPR axis, including a consent set through `setConsentData()`,
|
|
808
|
-
* and it does not gate the advertising identifier on the device.
|
|
809
|
-
*
|
|
810
|
-
* Call before `start()`. Called before `initialize()`, the value is kept and
|
|
655
|
+
* Reading an IAB GPP string written by the CMP, for US state privacy
|
|
656
|
+
* signals; off until called with `true`. It does not gate the advertising
|
|
657
|
+
* id. Call before `start()`; before `initialize()` the value is kept and
|
|
811
658
|
* applied afterwards.
|
|
812
659
|
*/
|
|
813
660
|
enableGPPDataCollection(enabled) {
|
|
@@ -818,20 +665,10 @@ const Adshift = exports.Adshift = {
|
|
|
818
665
|
_NativeAdShiftReactNativePlugin.default.enableGPPDataCollection(enabled === true);
|
|
819
666
|
},
|
|
820
667
|
/**
|
|
821
|
-
*
|
|
822
|
-
*
|
|
823
|
-
*
|
|
824
|
-
*
|
|
825
|
-
* This is the answer to a different question than `setConsentData()`, and it
|
|
826
|
-
* has the opposite default: nothing said here means sharing is allowed, so
|
|
827
|
-
* only call it once the user has actually been asked. Setting `allowed()` at
|
|
828
|
-
* startup as a default records a declaration the user never made, and events
|
|
829
|
-
* already sent cannot be recalled when a real answer arrives.
|
|
830
|
-
*
|
|
831
|
-
* Nothing is gated on the device either way — this travels with the events for
|
|
832
|
-
* the backend to act on.
|
|
833
|
-
*
|
|
834
|
-
* Called before `initialize()`, the answer is kept and applied afterwards.
|
|
668
|
+
* The user's answer on sharing their data with advertising partners:
|
|
669
|
+
* `AdshiftThirdPartySharing.optedOut()` or `allowed()`. Unlike consent,
|
|
670
|
+
* saying nothing means allowed, so call it only once the user was asked;
|
|
671
|
+
* events already sent are not recalled. Kept if called before `initialize()`.
|
|
835
672
|
*/
|
|
836
673
|
setThirdPartySharing(sharing) {
|
|
837
674
|
if (!isPlainObject(sharing) || typeof sharing.optOut !== 'boolean') {
|
|
@@ -845,15 +682,9 @@ const Adshift = exports.Adshift = {
|
|
|
845
682
|
_NativeAdShiftReactNativePlugin.default.setThirdPartySharing((0, _index.thirdPartySharingToMap)(sharing));
|
|
846
683
|
},
|
|
847
684
|
/**
|
|
848
|
-
* Withdraws
|
|
849
|
-
*
|
|
850
|
-
*
|
|
851
|
-
* stating that sharing is allowed: the first leaves the decision to your
|
|
852
|
-
* dashboard configuration, the second is the app's own declaration and is
|
|
853
|
-
* recorded as such.
|
|
854
|
-
*
|
|
855
|
-
* Called before `initialize()`, this cancels a `setThirdPartySharing()` that
|
|
856
|
-
* was also queued.
|
|
685
|
+
* Withdraws `setThirdPartySharing()`: later events say nothing about sharing,
|
|
686
|
+
* which is not the same as `allowed()`. Before `initialize()` it cancels a
|
|
687
|
+
* queued `setThirdPartySharing()`.
|
|
857
688
|
*/
|
|
858
689
|
clearThirdPartySharing() {
|
|
859
690
|
if (state === 'uninitialized') {
|
|
@@ -879,21 +710,11 @@ const Adshift = exports.Adshift = {
|
|
|
879
710
|
throw (0, _index.toAdshiftError)(error);
|
|
880
711
|
}
|
|
881
712
|
},
|
|
882
|
-
// ============ Event Tracking ============
|
|
883
|
-
|
|
884
713
|
/**
|
|
885
|
-
*
|
|
886
|
-
*
|
|
887
|
-
* `
|
|
888
|
-
*
|
|
889
|
-
*
|
|
890
|
-
* Resolves once the SDK has accepted the event. A call made between
|
|
891
|
-
* `initialize()` and a successful `start()` waits for the start: it is sent
|
|
892
|
-
* when the SDK starts, and rejects when the start fails for a reason
|
|
893
|
-
* retrying cannot fix (rejected key, excluded device) or after `stop()`.
|
|
894
|
-
* A start that failed for any other reason keeps the call waiting for the
|
|
895
|
-
* next attempt, so `start()` belongs on every launch path.
|
|
896
|
-
*
|
|
714
|
+
* `app_install` and `app_open` are reserved. A call made before a successful
|
|
715
|
+
* `start()` waits for it, so call `start()` on every launch path; it rejects
|
|
716
|
+
* after `stop()` or a start failure retrying cannot fix (rejected key,
|
|
717
|
+
* excluded device).
|
|
897
718
|
* @returns Rejects with `AdshiftError` (`NOT_INITIALIZED`, `NOT_STARTED`,
|
|
898
719
|
* `INVALID_API_KEY`, `OPTED_OUT`, `QUEUE_FULL`, `INVALID_ARGUMENT`).
|
|
899
720
|
*/
|
|
@@ -912,11 +733,7 @@ const Adshift = exports.Adshift = {
|
|
|
912
733
|
warnAboutPlainParamNames(values);
|
|
913
734
|
return runWhenStarted(() => _NativeAdShiftReactNativePlugin.default.trackEvent(eventName, values ?? null));
|
|
914
735
|
},
|
|
915
|
-
/**
|
|
916
|
-
* Tracks a purchase.
|
|
917
|
-
*
|
|
918
|
-
* @returns Rejects with `AdshiftError` (see `trackEvent`).
|
|
919
|
-
*/
|
|
736
|
+
/** Waits for `start()` and rejects like `trackEvent()`. */
|
|
920
737
|
trackPurchase(params) {
|
|
921
738
|
if (!isPlainObject(params)) {
|
|
922
739
|
return Promise.reject(invalidArgument('AdShift SDK: params must be an object'));
|
|
@@ -942,9 +759,8 @@ const Adshift = exports.Adshift = {
|
|
|
942
759
|
return runWhenStarted(() => _NativeAdShiftReactNativePlugin.default.trackPurchase(productId, revenue, currency, transactionId));
|
|
943
760
|
},
|
|
944
761
|
/**
|
|
945
|
-
*
|
|
946
|
-
*
|
|
947
|
-
* @returns Rejects with `AdshiftError` (see `trackEvent`).
|
|
762
|
+
* Revenue of a single impression, not an aggregate. Waits for `start()` and
|
|
763
|
+
* rejects like `trackEvent()`.
|
|
948
764
|
*/
|
|
949
765
|
logAdRevenue(params) {
|
|
950
766
|
if (!isPlainObject(params)) {
|
|
@@ -974,7 +790,7 @@ const Adshift = exports.Adshift = {
|
|
|
974
790
|
if (!isFiniteNumber(revenue) || revenue <= 0) {
|
|
975
791
|
return Promise.reject(invalidArgument('AdShift SDK: revenue must be a positive number'));
|
|
976
792
|
}
|
|
977
|
-
if (revenue > MAX_AD_REVENUE_PER_IMPRESSION) {
|
|
793
|
+
if (revenue > MAX_AD_REVENUE_PER_IMPRESSION && (_reactNative.Platform.OS === 'android' || currency.toUpperCase() === 'USD')) {
|
|
978
794
|
devWarn(`logAdRevenue: revenue above ${MAX_AD_REVENUE_PER_IMPRESSION} is not recorded. ` + 'Pass the revenue of a single impression, not an aggregate.');
|
|
979
795
|
}
|
|
980
796
|
if (adUnitId !== undefined && typeof adUnitId !== 'string') {
|
|
@@ -1002,11 +818,7 @@ const Adshift = exports.Adshift = {
|
|
|
1002
818
|
}
|
|
1003
819
|
return runWhenStarted(() => _NativeAdShiftReactNativePlugin.default.logAdRevenue(data));
|
|
1004
820
|
},
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
/**
|
|
1008
|
-
* Returns the AdShift device id, or `null` before `initialize()`.
|
|
1009
|
-
*/
|
|
821
|
+
/** `null` before `initialize()`. */
|
|
1010
822
|
async getAdShiftDeviceId() {
|
|
1011
823
|
if (state === 'uninitialized') {
|
|
1012
824
|
return null;
|
|
@@ -1018,15 +830,9 @@ const Adshift = exports.Adshift = {
|
|
|
1018
830
|
throw (0, _index.toAdshiftError)(error);
|
|
1019
831
|
}
|
|
1020
832
|
},
|
|
1021
|
-
// ============ Deep Links ============
|
|
1022
|
-
|
|
1023
833
|
/**
|
|
1024
|
-
* Passes a URL to the SDK
|
|
1025
|
-
*
|
|
1026
|
-
* Not needed when `autoHandleDeepLinks` is on (the default). The result is
|
|
1027
|
-
* delivered through `onDeepLink()`; the promise resolves once the SDK has
|
|
1028
|
-
* finished processing the URL.
|
|
1029
|
-
*
|
|
834
|
+
* Passes a URL to the SDK; not needed with `autoHandleDeepLinks` on (the
|
|
835
|
+
* default). The result arrives through `onDeepLink()`.
|
|
1030
836
|
* @returns Rejects with `AdshiftError` (`NOT_INITIALIZED`,
|
|
1031
837
|
* `INVALID_ARGUMENT`).
|
|
1032
838
|
*/
|
|
@@ -1055,11 +861,27 @@ const Adshift = exports.Adshift = {
|
|
|
1055
861
|
}
|
|
1056
862
|
},
|
|
1057
863
|
/**
|
|
1058
|
-
*
|
|
1059
|
-
*
|
|
1060
|
-
*
|
|
1061
|
-
*
|
|
1062
|
-
|
|
864
|
+
* With `deferredDeepLinkClipboard: 'pasteControl'`, passes what the user
|
|
865
|
+
* pasted with `UIPasteControl`, or `null` when they skipped it. Call it on
|
|
866
|
+
* every way out of onboarding: the first launch's deferred deep link waits
|
|
867
|
+
* for it. No-op on Android.
|
|
868
|
+
*/
|
|
869
|
+
handlePastedDeepLink(url) {
|
|
870
|
+
if (url !== null && typeof url !== 'string') {
|
|
871
|
+
reportDeclined(invalidArgument('AdShift SDK: url must be a string or null'));
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
if (state === 'uninitialized') {
|
|
875
|
+
reportDeclined(notInitializedError());
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
_NativeAdShiftReactNativePlugin.default.handlePastedDeepLink(isNonEmptyString(url) ? url : null);
|
|
879
|
+
},
|
|
880
|
+
/**
|
|
881
|
+
* A key path inside push payloads that carries an AdShift deep link. The
|
|
882
|
+
* first path replaces the top-level `as_push_link` the SDK reads by default,
|
|
883
|
+
* so add that one too if you still use it. Kept if called before
|
|
884
|
+
* `initialize()`.
|
|
1063
885
|
*/
|
|
1064
886
|
addPushNotificationDeepLinkPath(path) {
|
|
1065
887
|
if (!isStringArray(path) || path.length === 0) {
|
|
@@ -1073,10 +895,8 @@ const Adshift = exports.Adshift = {
|
|
|
1073
895
|
_NativeAdShiftReactNativePlugin.default.addPushNotificationDeepLinkPath(path);
|
|
1074
896
|
},
|
|
1075
897
|
/**
|
|
1076
|
-
*
|
|
1077
|
-
*
|
|
1078
|
-
* through `onDeepLink()`.
|
|
1079
|
-
*
|
|
898
|
+
* Resolves to `true` when the payload carried an AdShift deep link; the
|
|
899
|
+
* result then arrives through `onDeepLink()`.
|
|
1080
900
|
* @returns Rejects with `AdshiftError` (`NOT_INITIALIZED`,
|
|
1081
901
|
* `INVALID_ARGUMENT`).
|
|
1082
902
|
*/
|
|
@@ -1094,11 +914,9 @@ const Adshift = exports.Adshift = {
|
|
|
1094
914
|
}
|
|
1095
915
|
},
|
|
1096
916
|
/**
|
|
1097
|
-
*
|
|
1098
|
-
*
|
|
1099
|
-
*
|
|
1100
|
-
* listener is registered are buffered and delivered to the first listener.
|
|
1101
|
-
* Every link that reaches the SDK (direct, deferred, push) is delivered.
|
|
917
|
+
* Safe to call before `initialize()`. Results that arrive while no listener
|
|
918
|
+
* is registered are buffered for the first one. Every link that reaches the
|
|
919
|
+
* SDK (direct, deferred, push) is delivered once.
|
|
1102
920
|
*/
|
|
1103
921
|
onDeepLink(callback) {
|
|
1104
922
|
if (typeof callback !== 'function') {
|
|
@@ -1121,8 +939,6 @@ const Adshift = exports.Adshift = {
|
|
|
1121
939
|
}
|
|
1122
940
|
};
|
|
1123
941
|
},
|
|
1124
|
-
// ============ Info ============
|
|
1125
|
-
|
|
1126
942
|
getInfo() {
|
|
1127
943
|
return {
|
|
1128
944
|
platform: _reactNative.Platform.OS,
|