@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/commonjs/Adshift.js
CHANGED
|
@@ -11,101 +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
|
-
* Android compares the amount as given; iOS converts it to USD first.
|
|
88
|
-
*/
|
|
28
|
+
/** For the warning only; on iOS it applies to amounts in USD, hence the check. */
|
|
89
29
|
const MAX_AD_REVENUE_PER_IMPRESSION = 10;
|
|
90
30
|
const MEDIATION_NETWORKS = new Set(Object.values(_index.AdshiftMediationNetwork));
|
|
91
|
-
/**
|
|
92
|
-
* Event names the SDK sends on its own. Sending them by hand would mix
|
|
93
|
-
* hand-made records into install and session counts, which cannot be undone
|
|
94
|
-
* once they are reported.
|
|
95
|
-
*/
|
|
31
|
+
/** Sent by the SDK itself. */
|
|
96
32
|
const RESERVED_EVENT_NAMES = new Set(['app_install', 'app_open']);
|
|
97
33
|
|
|
98
|
-
/**
|
|
99
|
-
* Configuration received before `initialize()`. Each entry holds the latest
|
|
100
|
-
* value for one setter, so the memory is bounded by the number of setters.
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
// ============ Internal state ============
|
|
34
|
+
/** Setters called before `initialize()`: each last value, all push paths. */
|
|
104
35
|
|
|
105
36
|
let state = 'uninitialized';
|
|
106
37
|
let frozenConfig = null;
|
|
107
38
|
let startInFlight = null;
|
|
108
|
-
/**
|
|
39
|
+
/** One per start attempt, so a superseded attempt cannot touch the state. */
|
|
109
40
|
let startEpoch = 0;
|
|
110
41
|
let nativeSubscription = null;
|
|
111
42
|
const listeners = new Set();
|
|
@@ -121,9 +52,6 @@ let pendingSettings = {
|
|
|
121
52
|
let errorHandler = null;
|
|
122
53
|
/** Kept so `start()` can answer with the reason `initialize()` was refused. */
|
|
123
54
|
let configError = null;
|
|
124
|
-
|
|
125
|
-
// ============ Logging ============
|
|
126
|
-
|
|
127
55
|
function devWarn(message) {
|
|
128
56
|
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
129
57
|
console.warn(`[AdShift] ${message}`);
|
|
@@ -131,12 +59,8 @@ function devWarn(message) {
|
|
|
131
59
|
}
|
|
132
60
|
|
|
133
61
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* Public methods that return nothing have no channel to answer through, so
|
|
137
|
-
* they never raise: raising would unwind a stack the caller did not choose,
|
|
138
|
-
* and React Native treats an error escaping an event handler or a native
|
|
139
|
-
* 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.
|
|
140
64
|
*/
|
|
141
65
|
function reportDeclined(error) {
|
|
142
66
|
devWarn(`${error.message} (${error.code})`);
|
|
@@ -147,9 +71,6 @@ function reportDeclined(error) {
|
|
|
147
71
|
devWarn('config.onError threw; ignoring it.');
|
|
148
72
|
}
|
|
149
73
|
}
|
|
150
|
-
|
|
151
|
-
// ============ Errors ============
|
|
152
|
-
|
|
153
74
|
function notInitializedError() {
|
|
154
75
|
return (0, _index.createAdshiftError)(_index.AdshiftErrorCode.NotInitialized, 'AdShift SDK is not initialized. Call Adshift.initialize(config) first.');
|
|
155
76
|
}
|
|
@@ -172,11 +93,7 @@ function isStringArray(value) {
|
|
|
172
93
|
return Array.isArray(value) && value.every(isNonEmptyString);
|
|
173
94
|
}
|
|
174
95
|
|
|
175
|
-
/**
|
|
176
|
-
* Plain names a caller is likely to invent, mapped onto the standard constant
|
|
177
|
-
* that carries the same meaning. Built from the constants so there is one list
|
|
178
|
-
* to keep, not two.
|
|
179
|
-
*/
|
|
96
|
+
/** Plain names a caller is likely to use instead of a standard parameter. */
|
|
180
97
|
const STANDARD_PARAM_BY_PLAIN_NAME = (() => {
|
|
181
98
|
const index = new Map();
|
|
182
99
|
const standard = new Set((0, _index.getAllEventParams)());
|
|
@@ -193,10 +110,7 @@ const STANDARD_PARAM_BY_PLAIN_NAME = (() => {
|
|
|
193
110
|
})();
|
|
194
111
|
const reportedPlainParamNames = new Set();
|
|
195
112
|
|
|
196
|
-
/**
|
|
197
|
-
* Warns once per name when a value carries a plain name instead of the
|
|
198
|
-
* standard one. Sending it is allowed — it just stays a custom parameter.
|
|
199
|
-
*/
|
|
113
|
+
/** Warns once per name; the value is still sent, as a custom parameter. */
|
|
200
114
|
function warnAboutPlainParamNames(values) {
|
|
201
115
|
if (values === undefined) return;
|
|
202
116
|
for (const key of Object.keys(values)) {
|
|
@@ -222,15 +136,9 @@ function validateEventValues(values, name) {
|
|
|
222
136
|
}
|
|
223
137
|
}
|
|
224
138
|
|
|
225
|
-
// ============ Configuration received before initialize() ============
|
|
226
|
-
|
|
227
139
|
/**
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
* The config wins for anything it states, because it is the later and more
|
|
231
|
-
* explicit declaration. Push key paths are additive, so they are merged.
|
|
232
|
-
* Settings that reach the SDK through a setter only are applied by
|
|
233
|
-
* `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()`.
|
|
234
142
|
*/
|
|
235
143
|
function withPendingSettings(config) {
|
|
236
144
|
const merged = {
|
|
@@ -282,9 +190,6 @@ function applyPendingSettings() {
|
|
|
282
190
|
}
|
|
283
191
|
}
|
|
284
192
|
}
|
|
285
|
-
|
|
286
|
-
// ============ Deep link delivery ============
|
|
287
|
-
|
|
288
193
|
function ensureNativeSubscription() {
|
|
289
194
|
if (nativeSubscription) return;
|
|
290
195
|
nativeSubscription = _NativeAdShiftReactNativePlugin.default.onDeepLink(payload => {
|
|
@@ -292,9 +197,7 @@ function ensureNativeSubscription() {
|
|
|
292
197
|
});
|
|
293
198
|
}
|
|
294
199
|
function dispatchDeepLink(deepLink) {
|
|
295
|
-
// A result must
|
|
296
|
-
// link delivered after a link tapped later would attribute the install to
|
|
297
|
-
// the wrong click.
|
|
200
|
+
// A result must not overtake one still waiting in the buffer.
|
|
298
201
|
if (listeners.size === 0 || deepLinkBuffer.length > 0) {
|
|
299
202
|
bufferDeepLink(deepLink);
|
|
300
203
|
scheduleReplay();
|
|
@@ -338,9 +241,6 @@ function scheduleReplay() {
|
|
|
338
241
|
}
|
|
339
242
|
});
|
|
340
243
|
}
|
|
341
|
-
|
|
342
|
-
// ============ Automatic URL forwarding (iOS) ============
|
|
343
|
-
|
|
344
244
|
function autoForwardEnabled() {
|
|
345
245
|
return _reactNative.Platform.OS === 'ios' && frozenConfig !== null && frozenConfig.autoHandleDeepLinks !== false;
|
|
346
246
|
}
|
|
@@ -350,16 +250,13 @@ function startLinkingAutoForward() {
|
|
|
350
250
|
url
|
|
351
251
|
}) => {
|
|
352
252
|
if (state === 'uninitialized' || !autoForwardEnabled()) return;
|
|
353
|
-
// An app that
|
|
354
|
-
//
|
|
355
|
-
// short window treats them as one link; a tap that comes later is a
|
|
356
|
-
// 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.
|
|
357
255
|
if (wasAutoForwardedRecently(url)) return;
|
|
358
256
|
forwardUrl(url, false).catch(() => undefined);
|
|
359
257
|
});
|
|
360
|
-
//
|
|
361
|
-
//
|
|
362
|
-
// 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.
|
|
363
260
|
initialUrlForward = _reactNative.Linking.getInitialURL().then(url => url ? forwardUrl(url, true) : undefined).catch(() => undefined).finally(() => {
|
|
364
261
|
initialUrlForward = null;
|
|
365
262
|
});
|
|
@@ -402,9 +299,6 @@ async function waitForInitialUrlForward() {
|
|
|
402
299
|
if (timer !== undefined) clearTimeout(timer);
|
|
403
300
|
}
|
|
404
301
|
}
|
|
405
|
-
|
|
406
|
-
// ============ Start gating ============
|
|
407
|
-
|
|
408
302
|
function runWhenStarted(run) {
|
|
409
303
|
switch (state) {
|
|
410
304
|
case 'uninitialized':
|
|
@@ -445,11 +339,7 @@ function rejectPendingCalls(error) {
|
|
|
445
339
|
}
|
|
446
340
|
}
|
|
447
341
|
|
|
448
|
-
/**
|
|
449
|
-
* Warns when the native SDK on the device is not the one this release was built
|
|
450
|
-
* against. Only iOS reports its version, so on Android the pin is guarded by a
|
|
451
|
-
* build-time test instead.
|
|
452
|
-
*/
|
|
342
|
+
/** Only iOS reports its SDK version; on Android a build test guards the pin. */
|
|
453
343
|
function checkNativeSdkVersion(reported) {
|
|
454
344
|
if (typeof reported !== 'string' || reported.length === 0) return;
|
|
455
345
|
const expected = _reactNative.Platform.OS === 'ios' ? _nativeSdkVersions.NATIVE_SDK_VERSIONS.ios : _reactNative.Platform.OS === 'android' ? _nativeSdkVersions.NATIVE_SDK_VERSIONS.android : null;
|
|
@@ -488,8 +378,7 @@ async function performStart() {
|
|
|
488
378
|
await waitForInitialUrlForward();
|
|
489
379
|
const result = readStartResult(await _NativeAdShiftReactNativePlugin.default.start());
|
|
490
380
|
if (epoch !== startEpoch) {
|
|
491
|
-
// A newer start() owns the
|
|
492
|
-
// leave the state to the newer attempt.
|
|
381
|
+
// A newer start() owns the state now.
|
|
493
382
|
return result;
|
|
494
383
|
}
|
|
495
384
|
if (state !== 'starting') {
|
|
@@ -508,7 +397,6 @@ async function performStart() {
|
|
|
508
397
|
state = 'started';
|
|
509
398
|
flushPendingCalls();
|
|
510
399
|
if (result.apiKeyValidationStatus === 'invalid') {
|
|
511
|
-
// The SDK started locally, but nothing it sends will be accepted.
|
|
512
400
|
reportDeclined((0, _index.createAdshiftError)(_index.AdshiftErrorCode.InvalidApiKey, 'AdShift SDK: the backend rejected this API key; no data will be reported.'));
|
|
513
401
|
}
|
|
514
402
|
return result;
|
|
@@ -530,8 +418,6 @@ async function performStart() {
|
|
|
530
418
|
errorCode: mapped.code,
|
|
531
419
|
errorMessage: mapped.message
|
|
532
420
|
};
|
|
533
|
-
// What the platform said travels with the result, the same way it does
|
|
534
|
-
// when the native side answers with a failure instead of rejecting.
|
|
535
421
|
if (mapped.userInfo.nativeCode !== undefined) {
|
|
536
422
|
result.nativeCode = mapped.userInfo.nativeCode;
|
|
537
423
|
}
|
|
@@ -543,31 +429,17 @@ async function performStart() {
|
|
|
543
429
|
}
|
|
544
430
|
|
|
545
431
|
/**
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
* A rejected key, an excluded device and a missing configuration cannot be
|
|
549
|
-
* fixed by trying again, so the waiting calls are answered. Anything else can
|
|
550
|
-
* be, and holding the calls is worth more than answering them quickly: the
|
|
551
|
-
* 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.
|
|
552
434
|
*/
|
|
553
435
|
function isTerminalStartFailure(code) {
|
|
554
436
|
return code === _index.AdshiftErrorCode.InvalidApiKey || code === _index.AdshiftErrorCode.OptedOut || code === _index.AdshiftErrorCode.NotInitialized;
|
|
555
437
|
}
|
|
556
|
-
|
|
557
|
-
// ============ Main SDK API ============
|
|
558
|
-
|
|
559
438
|
const Adshift = exports.Adshift = {
|
|
560
|
-
// ============ Lifecycle ============
|
|
561
|
-
|
|
562
439
|
/**
|
|
563
|
-
*
|
|
564
|
-
*
|
|
565
|
-
*
|
|
566
|
-
* The configuration is fixed on the first call; later calls are ignored.
|
|
567
|
-
*
|
|
568
|
-
* Never raises, because it is meant to run at module scope, where an error
|
|
569
|
-
* would stop the bundle from evaluating. An unusable config is reported
|
|
570
|
-
* 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()`.
|
|
571
443
|
*/
|
|
572
444
|
initialize(config) {
|
|
573
445
|
if (state !== 'uninitialized') {
|
|
@@ -614,14 +486,9 @@ const Adshift = exports.Adshift = {
|
|
|
614
486
|
}
|
|
615
487
|
},
|
|
616
488
|
/**
|
|
617
|
-
*
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
* `result.success` and `result.errorCode`. Calls to `trackEvent`,
|
|
621
|
-
* `trackPurchase` and `logAdRevenue` made before this resolves are queued
|
|
622
|
-
* and dispatched afterwards. A start that fails with a reason retrying
|
|
623
|
-
* cannot fix rejects them instead; any other failure keeps them waiting for
|
|
624
|
-
* 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.
|
|
625
492
|
*/
|
|
626
493
|
start() {
|
|
627
494
|
if (state === 'uninitialized') {
|
|
@@ -649,11 +516,8 @@ const Adshift = exports.Adshift = {
|
|
|
649
516
|
return attempt;
|
|
650
517
|
},
|
|
651
518
|
/**
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
*
|
|
655
|
-
* Before `initialize()` there is nothing to stop: the call is reported and
|
|
656
|
-
* skipped.
|
|
519
|
+
* Tracking calls reject with `NOT_STARTED` until the next successful
|
|
520
|
+
* `start()`. Before `initialize()` the call is reported and skipped.
|
|
657
521
|
*/
|
|
658
522
|
stop() {
|
|
659
523
|
if (state === 'uninitialized') {
|
|
@@ -673,13 +537,9 @@ const Adshift = exports.Adshift = {
|
|
|
673
537
|
isStarted() {
|
|
674
538
|
return state === 'started';
|
|
675
539
|
},
|
|
676
|
-
// ============ Configuration ============
|
|
677
|
-
|
|
678
540
|
/**
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
* Called before `initialize()`, the value is kept and applied afterwards.
|
|
682
|
-
* 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.
|
|
683
543
|
*/
|
|
684
544
|
setCustomerUserId(userId) {
|
|
685
545
|
if (!isNonEmptyString(userId)) {
|
|
@@ -693,9 +553,8 @@ const Adshift = exports.Adshift = {
|
|
|
693
553
|
_NativeAdShiftReactNativePlugin.default.setCustomerUserId(userId);
|
|
694
554
|
},
|
|
695
555
|
/**
|
|
696
|
-
*
|
|
697
|
-
*
|
|
698
|
-
* Called before `initialize()`, the value is kept and applied afterwards.
|
|
556
|
+
* Verbose SDK logging. Before `initialize()` the value is kept and applied
|
|
557
|
+
* afterwards.
|
|
699
558
|
*/
|
|
700
559
|
setDebugEnabled(enabled) {
|
|
701
560
|
if (state === 'uninitialized') {
|
|
@@ -705,10 +564,9 @@ const Adshift = exports.Adshift = {
|
|
|
705
564
|
_NativeAdShiftReactNativePlugin.default.setDebugEnabled(enabled === true);
|
|
706
565
|
},
|
|
707
566
|
/**
|
|
708
|
-
*
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
* 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.
|
|
712
570
|
*/
|
|
713
571
|
setAppOpenDebounceMs(ms) {
|
|
714
572
|
if (!isFiniteNumber(ms) || ms < 0) {
|
|
@@ -722,10 +580,8 @@ const Adshift = exports.Adshift = {
|
|
|
722
580
|
_NativeAdShiftReactNativePlugin.default.setAppOpenDebounceMs(ms);
|
|
723
581
|
},
|
|
724
582
|
/**
|
|
725
|
-
*
|
|
726
|
-
*
|
|
727
|
-
* Called before `initialize()`, the domains are kept and applied with the
|
|
728
|
-
* 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.
|
|
729
585
|
*/
|
|
730
586
|
setBrandedDomains(domains) {
|
|
731
587
|
if (!isStringArray(domains)) {
|
|
@@ -739,9 +595,8 @@ const Adshift = exports.Adshift = {
|
|
|
739
595
|
_NativeAdShiftReactNativePlugin.default.setBrandedDomains(domains);
|
|
740
596
|
},
|
|
741
597
|
/**
|
|
742
|
-
*
|
|
743
|
-
*
|
|
744
|
-
* 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.
|
|
745
600
|
*/
|
|
746
601
|
setMetaAppId(appId) {
|
|
747
602
|
if (!isNonEmptyString(appId)) {
|
|
@@ -755,11 +610,9 @@ const Adshift = exports.Adshift = {
|
|
|
755
610
|
_NativeAdShiftReactNativePlugin.default.setMetaAppId(appId);
|
|
756
611
|
},
|
|
757
612
|
/**
|
|
758
|
-
*
|
|
759
|
-
*
|
|
760
|
-
*
|
|
761
|
-
*
|
|
762
|
-
* 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.
|
|
763
616
|
*/
|
|
764
617
|
setOaidData(oaid) {
|
|
765
618
|
if (!isNonEmptyString(oaid)) {
|
|
@@ -772,13 +625,9 @@ const Adshift = exports.Adshift = {
|
|
|
772
625
|
}
|
|
773
626
|
_NativeAdShiftReactNativePlugin.default.setOaidData(oaid);
|
|
774
627
|
},
|
|
775
|
-
// ============ Consent (GDPR/DMA) ============
|
|
776
|
-
|
|
777
628
|
/**
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
*
|
|
781
|
-
* 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.
|
|
782
631
|
*/
|
|
783
632
|
setConsentData(consent) {
|
|
784
633
|
if (!isPlainObject(consent) || typeof consent.isUserSubjectToGDPR !== 'boolean') {
|
|
@@ -792,10 +641,8 @@ const Adshift = exports.Adshift = {
|
|
|
792
641
|
_NativeAdShiftReactNativePlugin.default.setConsentData((0, _index.consentToMap)(consent));
|
|
793
642
|
},
|
|
794
643
|
/**
|
|
795
|
-
*
|
|
796
|
-
*
|
|
797
|
-
*
|
|
798
|
-
* 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.
|
|
799
646
|
*/
|
|
800
647
|
enableTCFDataCollection(enabled) {
|
|
801
648
|
if (state === 'uninitialized') {
|
|
@@ -805,14 +652,9 @@ const Adshift = exports.Adshift = {
|
|
|
805
652
|
_NativeAdShiftReactNativePlugin.default.enableTCFDataCollection(enabled === true);
|
|
806
653
|
},
|
|
807
654
|
/**
|
|
808
|
-
*
|
|
809
|
-
*
|
|
810
|
-
*
|
|
811
|
-
* The GPP string rides on its own axis: it is forwarded alongside whatever
|
|
812
|
-
* decides the GDPR axis, including a consent set through `setConsentData()`,
|
|
813
|
-
* and it does not gate the advertising identifier on the device.
|
|
814
|
-
*
|
|
815
|
-
* 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
|
|
816
658
|
* applied afterwards.
|
|
817
659
|
*/
|
|
818
660
|
enableGPPDataCollection(enabled) {
|
|
@@ -823,20 +665,10 @@ const Adshift = exports.Adshift = {
|
|
|
823
665
|
_NativeAdShiftReactNativePlugin.default.enableGPPDataCollection(enabled === true);
|
|
824
666
|
},
|
|
825
667
|
/**
|
|
826
|
-
*
|
|
827
|
-
*
|
|
828
|
-
*
|
|
829
|
-
*
|
|
830
|
-
* This is the answer to a different question than `setConsentData()`, and it
|
|
831
|
-
* has the opposite default: nothing said here means sharing is allowed, so
|
|
832
|
-
* only call it once the user has actually been asked. Setting `allowed()` at
|
|
833
|
-
* startup as a default records a declaration the user never made, and events
|
|
834
|
-
* already sent cannot be recalled when a real answer arrives.
|
|
835
|
-
*
|
|
836
|
-
* Nothing is gated on the device either way — this travels with the events for
|
|
837
|
-
* the backend to act on.
|
|
838
|
-
*
|
|
839
|
-
* 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()`.
|
|
840
672
|
*/
|
|
841
673
|
setThirdPartySharing(sharing) {
|
|
842
674
|
if (!isPlainObject(sharing) || typeof sharing.optOut !== 'boolean') {
|
|
@@ -850,15 +682,9 @@ const Adshift = exports.Adshift = {
|
|
|
850
682
|
_NativeAdShiftReactNativePlugin.default.setThirdPartySharing((0, _index.thirdPartySharingToMap)(sharing));
|
|
851
683
|
},
|
|
852
684
|
/**
|
|
853
|
-
* Withdraws
|
|
854
|
-
*
|
|
855
|
-
*
|
|
856
|
-
* stating that sharing is allowed: the first leaves the decision to your
|
|
857
|
-
* dashboard configuration, the second is the app's own declaration and is
|
|
858
|
-
* recorded as such.
|
|
859
|
-
*
|
|
860
|
-
* Called before `initialize()`, this cancels a `setThirdPartySharing()` that
|
|
861
|
-
* 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()`.
|
|
862
688
|
*/
|
|
863
689
|
clearThirdPartySharing() {
|
|
864
690
|
if (state === 'uninitialized') {
|
|
@@ -884,21 +710,11 @@ const Adshift = exports.Adshift = {
|
|
|
884
710
|
throw (0, _index.toAdshiftError)(error);
|
|
885
711
|
}
|
|
886
712
|
},
|
|
887
|
-
// ============ Event Tracking ============
|
|
888
|
-
|
|
889
713
|
/**
|
|
890
|
-
*
|
|
891
|
-
*
|
|
892
|
-
* `
|
|
893
|
-
*
|
|
894
|
-
*
|
|
895
|
-
* Resolves once the SDK has accepted the event. A call made between
|
|
896
|
-
* `initialize()` and a successful `start()` waits for the start: it is sent
|
|
897
|
-
* when the SDK starts, and rejects when the start fails for a reason
|
|
898
|
-
* retrying cannot fix (rejected key, excluded device) or after `stop()`.
|
|
899
|
-
* A start that failed for any other reason keeps the call waiting for the
|
|
900
|
-
* next attempt, so `start()` belongs on every launch path.
|
|
901
|
-
*
|
|
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).
|
|
902
718
|
* @returns Rejects with `AdshiftError` (`NOT_INITIALIZED`, `NOT_STARTED`,
|
|
903
719
|
* `INVALID_API_KEY`, `OPTED_OUT`, `QUEUE_FULL`, `INVALID_ARGUMENT`).
|
|
904
720
|
*/
|
|
@@ -917,11 +733,7 @@ const Adshift = exports.Adshift = {
|
|
|
917
733
|
warnAboutPlainParamNames(values);
|
|
918
734
|
return runWhenStarted(() => _NativeAdShiftReactNativePlugin.default.trackEvent(eventName, values ?? null));
|
|
919
735
|
},
|
|
920
|
-
/**
|
|
921
|
-
* Tracks a purchase.
|
|
922
|
-
*
|
|
923
|
-
* @returns Rejects with `AdshiftError` (see `trackEvent`).
|
|
924
|
-
*/
|
|
736
|
+
/** Waits for `start()` and rejects like `trackEvent()`. */
|
|
925
737
|
trackPurchase(params) {
|
|
926
738
|
if (!isPlainObject(params)) {
|
|
927
739
|
return Promise.reject(invalidArgument('AdShift SDK: params must be an object'));
|
|
@@ -947,9 +759,8 @@ const Adshift = exports.Adshift = {
|
|
|
947
759
|
return runWhenStarted(() => _NativeAdShiftReactNativePlugin.default.trackPurchase(productId, revenue, currency, transactionId));
|
|
948
760
|
},
|
|
949
761
|
/**
|
|
950
|
-
*
|
|
951
|
-
*
|
|
952
|
-
* @returns Rejects with `AdshiftError` (see `trackEvent`).
|
|
762
|
+
* Revenue of a single impression, not an aggregate. Waits for `start()` and
|
|
763
|
+
* rejects like `trackEvent()`.
|
|
953
764
|
*/
|
|
954
765
|
logAdRevenue(params) {
|
|
955
766
|
if (!isPlainObject(params)) {
|
|
@@ -1007,11 +818,7 @@ const Adshift = exports.Adshift = {
|
|
|
1007
818
|
}
|
|
1008
819
|
return runWhenStarted(() => _NativeAdShiftReactNativePlugin.default.logAdRevenue(data));
|
|
1009
820
|
},
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
/**
|
|
1013
|
-
* Returns the AdShift device id, or `null` before `initialize()`.
|
|
1014
|
-
*/
|
|
821
|
+
/** `null` before `initialize()`. */
|
|
1015
822
|
async getAdShiftDeviceId() {
|
|
1016
823
|
if (state === 'uninitialized') {
|
|
1017
824
|
return null;
|
|
@@ -1023,15 +830,9 @@ const Adshift = exports.Adshift = {
|
|
|
1023
830
|
throw (0, _index.toAdshiftError)(error);
|
|
1024
831
|
}
|
|
1025
832
|
},
|
|
1026
|
-
// ============ Deep Links ============
|
|
1027
|
-
|
|
1028
833
|
/**
|
|
1029
|
-
* Passes a URL to the SDK
|
|
1030
|
-
*
|
|
1031
|
-
* Not needed when `autoHandleDeepLinks` is on (the default). The result is
|
|
1032
|
-
* delivered through `onDeepLink()`; the promise resolves once the SDK has
|
|
1033
|
-
* finished processing the URL.
|
|
1034
|
-
*
|
|
834
|
+
* Passes a URL to the SDK; not needed with `autoHandleDeepLinks` on (the
|
|
835
|
+
* default). The result arrives through `onDeepLink()`.
|
|
1035
836
|
* @returns Rejects with `AdshiftError` (`NOT_INITIALIZED`,
|
|
1036
837
|
* `INVALID_ARGUMENT`).
|
|
1037
838
|
*/
|
|
@@ -1077,11 +878,10 @@ const Adshift = exports.Adshift = {
|
|
|
1077
878
|
_NativeAdShiftReactNativePlugin.default.handlePastedDeepLink(isNonEmptyString(url) ? url : null);
|
|
1078
879
|
},
|
|
1079
880
|
/**
|
|
1080
|
-
*
|
|
1081
|
-
*
|
|
1082
|
-
*
|
|
1083
|
-
*
|
|
1084
|
-
* the SDK reads on its own, so register that key too if you still need it.
|
|
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()`.
|
|
1085
885
|
*/
|
|
1086
886
|
addPushNotificationDeepLinkPath(path) {
|
|
1087
887
|
if (!isStringArray(path) || path.length === 0) {
|
|
@@ -1095,10 +895,8 @@ const Adshift = exports.Adshift = {
|
|
|
1095
895
|
_NativeAdShiftReactNativePlugin.default.addPushNotificationDeepLinkPath(path);
|
|
1096
896
|
},
|
|
1097
897
|
/**
|
|
1098
|
-
*
|
|
1099
|
-
*
|
|
1100
|
-
* through `onDeepLink()`.
|
|
1101
|
-
*
|
|
898
|
+
* Resolves to `true` when the payload carried an AdShift deep link; the
|
|
899
|
+
* result then arrives through `onDeepLink()`.
|
|
1102
900
|
* @returns Rejects with `AdshiftError` (`NOT_INITIALIZED`,
|
|
1103
901
|
* `INVALID_ARGUMENT`).
|
|
1104
902
|
*/
|
|
@@ -1116,12 +914,9 @@ const Adshift = exports.Adshift = {
|
|
|
1116
914
|
}
|
|
1117
915
|
},
|
|
1118
916
|
/**
|
|
1119
|
-
*
|
|
1120
|
-
*
|
|
1121
|
-
*
|
|
1122
|
-
* listener is registered are buffered and delivered to the first listener.
|
|
1123
|
-
* Every link that reaches the SDK (direct, deferred, push) is delivered,
|
|
1124
|
-
* each result once.
|
|
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.
|
|
1125
920
|
*/
|
|
1126
921
|
onDeepLink(callback) {
|
|
1127
922
|
if (typeof callback !== 'function') {
|
|
@@ -1144,8 +939,6 @@ const Adshift = exports.Adshift = {
|
|
|
1144
939
|
}
|
|
1145
940
|
};
|
|
1146
941
|
},
|
|
1147
|
-
// ============ Info ============
|
|
1148
|
-
|
|
1149
942
|
getInfo() {
|
|
1150
943
|
return {
|
|
1151
944
|
platform: _reactNative.Platform.OS,
|