@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/src/Adshift.ts
CHANGED
|
@@ -1,35 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AdShift SDK for React Native.
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* ```typescript
|
|
6
|
-
* import {
|
|
7
|
-
* Adshift,
|
|
8
|
-
* AdshiftEventParam,
|
|
9
|
-
* AdshiftEventType,
|
|
10
|
-
* } from '@adshift/react-native-plugin';
|
|
11
|
-
*
|
|
12
|
-
* // 1. Register the deep link listener (safe to do before initialize)
|
|
13
|
-
* const subscription = Adshift.onDeepLink((deepLink) => {
|
|
14
|
-
* // route on deepLink.deepLinkValue / deepLink.params
|
|
15
|
-
* });
|
|
16
|
-
*
|
|
17
|
-
* // 2. Initialize
|
|
18
|
-
* Adshift.initialize({ apiKey: 'your-api-key', isDebug: __DEV__ });
|
|
19
|
-
*
|
|
20
|
-
* // 3. Start
|
|
21
|
-
* const result = await Adshift.start();
|
|
22
|
-
*
|
|
23
|
-
* // 4. Track
|
|
24
|
-
* await Adshift.trackEvent(AdshiftEventType.Purchase, {
|
|
25
|
-
* [AdshiftEventParam.Revenue]: 9.99,
|
|
26
|
-
* [AdshiftEventParam.Currency]: 'USD',
|
|
27
|
-
* });
|
|
28
|
-
*
|
|
29
|
-
* // Later: subscription.remove();
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
1
|
import { Linking, Platform } from 'react-native';
|
|
34
2
|
import type { EventSubscription } from 'react-native';
|
|
35
3
|
import NativeAdShiftReactNativePlugin from './NativeAdShiftReactNativePlugin';
|
|
@@ -61,25 +29,15 @@ import {
|
|
|
61
29
|
} from './types';
|
|
62
30
|
import { PLUGIN_VERSION } from './version';
|
|
63
31
|
|
|
64
|
-
// ============ Public types ============
|
|
65
|
-
|
|
66
32
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* `
|
|
70
|
-
*
|
|
71
|
-
* at the time `start()` resolved, and `config.onError` reports
|
|
72
|
-
* `INVALID_API_KEY` when that verdict is `invalid`. On iOS the verdict usually
|
|
73
|
-
* arrives after `start()` resolved and is reported by the next `start()`; on
|
|
74
|
-
* Android `start()` waits up to 5 s for it.
|
|
33
|
+
* `success` says whether the SDK started on the device. The API key is checked
|
|
34
|
+
* in the background; an `invalid` verdict is also reported through
|
|
35
|
+
* `config.onError` as `INVALID_API_KEY`. Android waits up to 5 s for the
|
|
36
|
+
* verdict; on iOS it usually arrives later and shows in a later `start()`.
|
|
75
37
|
*/
|
|
76
38
|
export interface StartResult {
|
|
77
39
|
success: boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Outcome of the API key check at the time `start()` resolved; `pending`
|
|
80
|
-
* means the answer had not arrived yet. It changes nothing you have to do:
|
|
81
|
-
* events tracked meanwhile stay queued on the device by the native SDK.
|
|
82
|
-
*/
|
|
40
|
+
/** The API key check when `start()` resolved; `pending` needs no action. */
|
|
83
41
|
apiKeyValidationStatus?: ApiKeyValidationStatus;
|
|
84
42
|
/** Platform error number behind `errorCode`, for support requests. */
|
|
85
43
|
nativeCode?: number | string;
|
|
@@ -96,11 +54,7 @@ export type ApiKeyValidationStatus = 'pending' | 'valid' | 'invalid';
|
|
|
96
54
|
|
|
97
55
|
export type EventValues = Record<string, string | number | boolean>;
|
|
98
56
|
|
|
99
|
-
/**
|
|
100
|
-
* Parameters for `Adshift.trackPurchase()`.
|
|
101
|
-
*/
|
|
102
57
|
export interface PurchaseParams {
|
|
103
|
-
/** Product identifier. */
|
|
104
58
|
productId: string;
|
|
105
59
|
/** Purchase amount in `currency`. */
|
|
106
60
|
revenue: number;
|
|
@@ -110,27 +64,18 @@ export interface PurchaseParams {
|
|
|
110
64
|
transactionId: string;
|
|
111
65
|
}
|
|
112
66
|
|
|
113
|
-
/**
|
|
114
|
-
* Subscription returned by `Adshift.onDeepLink()`.
|
|
115
|
-
*/
|
|
116
67
|
export interface DeepLinkSubscription {
|
|
117
|
-
/** Removes the listener
|
|
68
|
+
/** Removes the listener; safe to call more than once. */
|
|
118
69
|
remove(): void;
|
|
119
70
|
}
|
|
120
71
|
|
|
121
72
|
export type DeepLinkCallback = (deepLink: AdshiftDeepLink) => void;
|
|
122
73
|
|
|
123
|
-
/**
|
|
124
|
-
* Native SDK versions bundled with this plugin release.
|
|
125
|
-
*/
|
|
126
74
|
export interface NativeSdkVersions {
|
|
127
75
|
android: string;
|
|
128
76
|
ios: string;
|
|
129
77
|
}
|
|
130
78
|
|
|
131
|
-
/**
|
|
132
|
-
* Plugin information returned by `Adshift.getInfo()`.
|
|
133
|
-
*/
|
|
134
79
|
export interface AdshiftInfo {
|
|
135
80
|
/** `Platform.OS`; the SDK only supports `ios` and `android`. */
|
|
136
81
|
platform: 'ios' | 'android' | (string & {});
|
|
@@ -140,28 +85,18 @@ export interface AdshiftInfo {
|
|
|
140
85
|
nativeSdkVersions: NativeSdkVersions;
|
|
141
86
|
}
|
|
142
87
|
|
|
143
|
-
// ============ Constants ============
|
|
144
|
-
|
|
145
88
|
const DEEP_LINK_BUFFER_LIMIT = 20;
|
|
146
89
|
const PENDING_CALL_LIMIT = 100;
|
|
147
90
|
/** Bounds how long `start()` waits for the URL the app was opened with. */
|
|
148
91
|
const INITIAL_URL_WAIT_MS = 3000;
|
|
149
92
|
/** How long one URL counts as the same link, whoever passed it in first. */
|
|
150
93
|
const AUTO_FORWARD_DEDUP_MS = 2000;
|
|
151
|
-
/**
|
|
152
|
-
* Mirrors a limit the SDK applies, so the warning below can name it. Raising it
|
|
153
|
-
* there without raising it here makes the warning wrong, not the behaviour.
|
|
154
|
-
* Android compares the amount as given; iOS converts it to USD first.
|
|
155
|
-
*/
|
|
94
|
+
/** For the warning only; on iOS it applies to amounts in USD, hence the check. */
|
|
156
95
|
const MAX_AD_REVENUE_PER_IMPRESSION = 10;
|
|
157
96
|
const MEDIATION_NETWORKS: ReadonlySet<string> = new Set(
|
|
158
97
|
Object.values(AdshiftMediationNetwork)
|
|
159
98
|
);
|
|
160
|
-
/**
|
|
161
|
-
* Event names the SDK sends on its own. Sending them by hand would mix
|
|
162
|
-
* hand-made records into install and session counts, which cannot be undone
|
|
163
|
-
* once they are reported.
|
|
164
|
-
*/
|
|
99
|
+
/** Sent by the SDK itself. */
|
|
165
100
|
const RESERVED_EVENT_NAMES: ReadonlySet<string> = new Set([
|
|
166
101
|
'app_install',
|
|
167
102
|
'app_open',
|
|
@@ -184,10 +119,7 @@ interface PendingCall {
|
|
|
184
119
|
reject: (error: AdshiftError) => void;
|
|
185
120
|
}
|
|
186
121
|
|
|
187
|
-
/**
|
|
188
|
-
* Configuration received before `initialize()`. Each entry holds the latest
|
|
189
|
-
* value for one setter, so the memory is bounded by the number of setters.
|
|
190
|
-
*/
|
|
122
|
+
/** Setters called before `initialize()`: each last value, all push paths. */
|
|
191
123
|
interface PendingSettings {
|
|
192
124
|
customerUserId?: string;
|
|
193
125
|
debugEnabled?: boolean;
|
|
@@ -199,21 +131,17 @@ interface PendingSettings {
|
|
|
199
131
|
tcfEnabled?: boolean;
|
|
200
132
|
gppEnabled?: boolean;
|
|
201
133
|
/**
|
|
202
|
-
* Absent
|
|
203
|
-
* `clearThirdPartySharing()
|
|
204
|
-
* has to survive here or a clear before `initialize()` would be dropped and
|
|
205
|
-
* the set it was meant to undo would still be applied.
|
|
134
|
+
* Absent: neither sharing call was made. `null`: the last one was
|
|
135
|
+
* `clearThirdPartySharing()`, which must still cancel an earlier set.
|
|
206
136
|
*/
|
|
207
137
|
thirdPartySharing?: AdshiftThirdPartySharing | null;
|
|
208
138
|
pushDeepLinkPaths: string[][];
|
|
209
139
|
}
|
|
210
140
|
|
|
211
|
-
// ============ Internal state ============
|
|
212
|
-
|
|
213
141
|
let state: LifecycleState = 'uninitialized';
|
|
214
142
|
let frozenConfig: Readonly<AdshiftConfig> | null = null;
|
|
215
143
|
let startInFlight: Promise<StartResult> | null = null;
|
|
216
|
-
/**
|
|
144
|
+
/** One per start attempt, so a superseded attempt cannot touch the state. */
|
|
217
145
|
let startEpoch = 0;
|
|
218
146
|
|
|
219
147
|
let nativeSubscription: EventSubscription | null = null;
|
|
@@ -232,8 +160,6 @@ let errorHandler: ((error: AdshiftError) => void) | null = null;
|
|
|
232
160
|
/** Kept so `start()` can answer with the reason `initialize()` was refused. */
|
|
233
161
|
let configError: AdshiftError | null = null;
|
|
234
162
|
|
|
235
|
-
// ============ Logging ============
|
|
236
|
-
|
|
237
163
|
function devWarn(message: string): void {
|
|
238
164
|
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
239
165
|
console.warn(`[AdShift] ${message}`);
|
|
@@ -241,12 +167,8 @@ function devWarn(message: string): void {
|
|
|
241
167
|
}
|
|
242
168
|
|
|
243
169
|
/**
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
* Public methods that return nothing have no channel to answer through, so
|
|
247
|
-
* they never raise: raising would unwind a stack the caller did not choose,
|
|
248
|
-
* and React Native treats an error escaping an event handler or a native
|
|
249
|
-
* callback as fatal. The call is skipped and reported here instead.
|
|
170
|
+
* Methods that return nothing report a declined call here instead of raising:
|
|
171
|
+
* React Native treats an error escaping an event handler as fatal.
|
|
250
172
|
*/
|
|
251
173
|
function reportDeclined(error: AdshiftError): void {
|
|
252
174
|
devWarn(`${error.message} (${error.code})`);
|
|
@@ -258,8 +180,6 @@ function reportDeclined(error: AdshiftError): void {
|
|
|
258
180
|
}
|
|
259
181
|
}
|
|
260
182
|
|
|
261
|
-
// ============ Errors ============
|
|
262
|
-
|
|
263
183
|
function notInitializedError(): AdshiftError {
|
|
264
184
|
return createAdshiftError(
|
|
265
185
|
AdshiftErrorCode.NotInitialized,
|
|
@@ -294,11 +214,7 @@ function isStringArray(value: unknown): value is string[] {
|
|
|
294
214
|
return Array.isArray(value) && value.every(isNonEmptyString);
|
|
295
215
|
}
|
|
296
216
|
|
|
297
|
-
/**
|
|
298
|
-
* Plain names a caller is likely to invent, mapped onto the standard constant
|
|
299
|
-
* that carries the same meaning. Built from the constants so there is one list
|
|
300
|
-
* to keep, not two.
|
|
301
|
-
*/
|
|
217
|
+
/** Plain names a caller is likely to use instead of a standard parameter. */
|
|
302
218
|
const STANDARD_PARAM_BY_PLAIN_NAME: ReadonlyMap<
|
|
303
219
|
string,
|
|
304
220
|
keyof typeof AdshiftEventParam
|
|
@@ -325,10 +241,7 @@ const STANDARD_PARAM_BY_PLAIN_NAME: ReadonlyMap<
|
|
|
325
241
|
|
|
326
242
|
const reportedPlainParamNames = new Set<string>();
|
|
327
243
|
|
|
328
|
-
/**
|
|
329
|
-
* Warns once per name when a value carries a plain name instead of the
|
|
330
|
-
* standard one. Sending it is allowed — it just stays a custom parameter.
|
|
331
|
-
*/
|
|
244
|
+
/** Warns once per name; the value is still sent, as a custom parameter. */
|
|
332
245
|
function warnAboutPlainParamNames(values: EventValues | undefined): void {
|
|
333
246
|
if (values === undefined) return;
|
|
334
247
|
for (const key of Object.keys(values)) {
|
|
@@ -360,15 +273,9 @@ function validateEventValues(values: unknown, name: string): void {
|
|
|
360
273
|
}
|
|
361
274
|
}
|
|
362
275
|
|
|
363
|
-
// ============ Configuration received before initialize() ============
|
|
364
|
-
|
|
365
276
|
/**
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
* The config wins for anything it states, because it is the later and more
|
|
369
|
-
* explicit declaration. Push key paths are additive, so they are merged.
|
|
370
|
-
* Settings that reach the SDK through a setter only are applied by
|
|
371
|
-
* `applyPendingSettings()` right after the native module is initialized.
|
|
277
|
+
* The config wins over a value set before `initialize()`; push paths from both
|
|
278
|
+
* are kept. Values without a config option go through `applyPendingSettings()`.
|
|
372
279
|
*/
|
|
373
280
|
function withPendingSettings(config: AdshiftConfig): AdshiftConfig {
|
|
374
281
|
const merged: AdshiftConfig = { ...config };
|
|
@@ -428,8 +335,6 @@ function applyPendingSettings(): void {
|
|
|
428
335
|
}
|
|
429
336
|
}
|
|
430
337
|
|
|
431
|
-
// ============ Deep link delivery ============
|
|
432
|
-
|
|
433
338
|
function ensureNativeSubscription(): void {
|
|
434
339
|
if (nativeSubscription) return;
|
|
435
340
|
nativeSubscription = NativeAdShiftReactNativePlugin.onDeepLink(
|
|
@@ -442,9 +347,7 @@ function ensureNativeSubscription(): void {
|
|
|
442
347
|
}
|
|
443
348
|
|
|
444
349
|
function dispatchDeepLink(deepLink: AdshiftDeepLink): void {
|
|
445
|
-
// A result must
|
|
446
|
-
// link delivered after a link tapped later would attribute the install to
|
|
447
|
-
// the wrong click.
|
|
350
|
+
// A result must not overtake one still waiting in the buffer.
|
|
448
351
|
if (listeners.size === 0 || deepLinkBuffer.length > 0) {
|
|
449
352
|
bufferDeepLink(deepLink);
|
|
450
353
|
scheduleReplay();
|
|
@@ -496,8 +399,6 @@ function scheduleReplay(): void {
|
|
|
496
399
|
});
|
|
497
400
|
}
|
|
498
401
|
|
|
499
|
-
// ============ Automatic URL forwarding (iOS) ============
|
|
500
|
-
|
|
501
402
|
function autoForwardEnabled(): boolean {
|
|
502
403
|
return (
|
|
503
404
|
Platform.OS === 'ios' &&
|
|
@@ -510,16 +411,13 @@ function startLinkingAutoForward(): void {
|
|
|
510
411
|
if (linkingSubscription) return;
|
|
511
412
|
linkingSubscription = Linking.addEventListener('url', ({ url }) => {
|
|
512
413
|
if (state === 'uninitialized' || !autoForwardEnabled()) return;
|
|
513
|
-
// An app that
|
|
514
|
-
//
|
|
515
|
-
// short window treats them as one link; a tap that comes later is a
|
|
516
|
-
// separate click and is forwarded.
|
|
414
|
+
// An app that also passes this event to handleDeepLink() must not count the
|
|
415
|
+
// link twice; a tap after the short window is a new click.
|
|
517
416
|
if (wasAutoForwardedRecently(url)) return;
|
|
518
417
|
forwardUrl(url, false).catch(() => undefined);
|
|
519
418
|
});
|
|
520
|
-
//
|
|
521
|
-
//
|
|
522
|
-
// it for the lifetime of the process, so the link is booked once.
|
|
419
|
+
// getInitialURL() returns the launch URL again after a JavaScript reload;
|
|
420
|
+
// marked as the launch URL, native forwards it once per process.
|
|
523
421
|
initialUrlForward = Linking.getInitialURL()
|
|
524
422
|
.then((url) => (url ? forwardUrl(url, true) : undefined))
|
|
525
423
|
.catch(() => undefined)
|
|
@@ -570,8 +468,6 @@ async function waitForInitialUrlForward(): Promise<void> {
|
|
|
570
468
|
}
|
|
571
469
|
}
|
|
572
470
|
|
|
573
|
-
// ============ Start gating ============
|
|
574
|
-
|
|
575
471
|
function runWhenStarted<T>(run: () => Promise<T>): Promise<T> {
|
|
576
472
|
switch (state) {
|
|
577
473
|
case 'uninitialized':
|
|
@@ -624,11 +520,7 @@ function rejectPendingCalls(error: AdshiftError): void {
|
|
|
624
520
|
}
|
|
625
521
|
}
|
|
626
522
|
|
|
627
|
-
/**
|
|
628
|
-
* Warns when the native SDK on the device is not the one this release was built
|
|
629
|
-
* against. Only iOS reports its version, so on Android the pin is guarded by a
|
|
630
|
-
* build-time test instead.
|
|
631
|
-
*/
|
|
523
|
+
/** Only iOS reports its SDK version; on Android a build test guards the pin. */
|
|
632
524
|
function checkNativeSdkVersion(reported: unknown): void {
|
|
633
525
|
if (typeof reported !== 'string' || reported.length === 0) return;
|
|
634
526
|
const expected =
|
|
@@ -690,8 +582,7 @@ async function performStart(): Promise<StartResult> {
|
|
|
690
582
|
await NativeAdShiftReactNativePlugin.start()
|
|
691
583
|
);
|
|
692
584
|
if (epoch !== startEpoch) {
|
|
693
|
-
// A newer start() owns the
|
|
694
|
-
// leave the state to the newer attempt.
|
|
585
|
+
// A newer start() owns the state now.
|
|
695
586
|
return result;
|
|
696
587
|
}
|
|
697
588
|
if (state !== 'starting') {
|
|
@@ -710,7 +601,6 @@ async function performStart(): Promise<StartResult> {
|
|
|
710
601
|
state = 'started';
|
|
711
602
|
flushPendingCalls();
|
|
712
603
|
if (result.apiKeyValidationStatus === 'invalid') {
|
|
713
|
-
// The SDK started locally, but nothing it sends will be accepted.
|
|
714
604
|
reportDeclined(
|
|
715
605
|
createAdshiftError(
|
|
716
606
|
AdshiftErrorCode.InvalidApiKey,
|
|
@@ -740,8 +630,6 @@ async function performStart(): Promise<StartResult> {
|
|
|
740
630
|
errorCode: mapped.code,
|
|
741
631
|
errorMessage: mapped.message,
|
|
742
632
|
};
|
|
743
|
-
// What the platform said travels with the result, the same way it does
|
|
744
|
-
// when the native side answers with a failure instead of rejecting.
|
|
745
633
|
if (mapped.userInfo.nativeCode !== undefined) {
|
|
746
634
|
result.nativeCode = mapped.userInfo.nativeCode;
|
|
747
635
|
}
|
|
@@ -753,12 +641,8 @@ async function performStart(): Promise<StartResult> {
|
|
|
753
641
|
}
|
|
754
642
|
|
|
755
643
|
/**
|
|
756
|
-
*
|
|
757
|
-
*
|
|
758
|
-
* A rejected key, an excluded device and a missing configuration cannot be
|
|
759
|
-
* fixed by trying again, so the waiting calls are answered. Anything else can
|
|
760
|
-
* be, and holding the calls is worth more than answering them quickly: the
|
|
761
|
-
* data survives until the app starts the SDK again.
|
|
644
|
+
* Failures a retry cannot fix, which reject the calls waiting for `start()`.
|
|
645
|
+
* After any other failure they wait for the next attempt.
|
|
762
646
|
*/
|
|
763
647
|
function isTerminalStartFailure(code: AdshiftErrorCode): boolean {
|
|
764
648
|
return (
|
|
@@ -768,20 +652,11 @@ function isTerminalStartFailure(code: AdshiftErrorCode): boolean {
|
|
|
768
652
|
);
|
|
769
653
|
}
|
|
770
654
|
|
|
771
|
-
// ============ Main SDK API ============
|
|
772
|
-
|
|
773
655
|
export const Adshift = {
|
|
774
|
-
// ============ Lifecycle ============
|
|
775
|
-
|
|
776
656
|
/**
|
|
777
|
-
*
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
* The configuration is fixed on the first call; later calls are ignored.
|
|
781
|
-
*
|
|
782
|
-
* Never raises, because it is meant to run at module scope, where an error
|
|
783
|
-
* would stop the bundle from evaluating. An unusable config is reported
|
|
784
|
-
* through `config.onError` and answered by `start()`.
|
|
657
|
+
* Call once, as early as possible, for example at module scope. The first
|
|
658
|
+
* config is kept; later calls are ignored. Never raises: an unusable config
|
|
659
|
+
* is reported through `config.onError` and returned by `start()`.
|
|
785
660
|
*/
|
|
786
661
|
initialize(config: AdshiftConfig): void {
|
|
787
662
|
if (state !== 'uninitialized') {
|
|
@@ -853,14 +728,9 @@ export const Adshift = {
|
|
|
853
728
|
},
|
|
854
729
|
|
|
855
730
|
/**
|
|
856
|
-
*
|
|
857
|
-
*
|
|
858
|
-
*
|
|
859
|
-
* `result.success` and `result.errorCode`. Calls to `trackEvent`,
|
|
860
|
-
* `trackPurchase` and `logAdRevenue` made before this resolves are queued
|
|
861
|
-
* and dispatched afterwards. A start that fails with a reason retrying
|
|
862
|
-
* cannot fix rejects them instead; any other failure keeps them waiting for
|
|
863
|
-
* the next attempt.
|
|
731
|
+
* Never rejects; check `result.success`. `trackEvent`, `trackPurchase` and
|
|
732
|
+
* `logAdRevenue` calls made before it succeeds wait for it. A failure that
|
|
733
|
+
* retrying cannot fix rejects them; otherwise they wait for the next try.
|
|
864
734
|
*/
|
|
865
735
|
start(): Promise<StartResult> {
|
|
866
736
|
if (state === 'uninitialized') {
|
|
@@ -887,11 +757,8 @@ export const Adshift = {
|
|
|
887
757
|
},
|
|
888
758
|
|
|
889
759
|
/**
|
|
890
|
-
*
|
|
891
|
-
*
|
|
892
|
-
*
|
|
893
|
-
* Before `initialize()` there is nothing to stop: the call is reported and
|
|
894
|
-
* skipped.
|
|
760
|
+
* Tracking calls reject with `NOT_STARTED` until the next successful
|
|
761
|
+
* `start()`. Before `initialize()` the call is reported and skipped.
|
|
895
762
|
*/
|
|
896
763
|
stop(): void {
|
|
897
764
|
if (state === 'uninitialized') {
|
|
@@ -913,13 +780,9 @@ export const Adshift = {
|
|
|
913
780
|
return state === 'started';
|
|
914
781
|
},
|
|
915
782
|
|
|
916
|
-
// ============ Configuration ============
|
|
917
|
-
|
|
918
783
|
/**
|
|
919
|
-
*
|
|
920
|
-
*
|
|
921
|
-
* Called before `initialize()`, the value is kept and applied afterwards.
|
|
922
|
-
* An empty identifier is reported and skipped; nothing is raised.
|
|
784
|
+
* Your own user id; may be set at any time. Before `initialize()` it is kept
|
|
785
|
+
* and applied afterwards. An empty id is reported and skipped.
|
|
923
786
|
*/
|
|
924
787
|
setCustomerUserId(userId: string): void {
|
|
925
788
|
if (!isNonEmptyString(userId)) {
|
|
@@ -936,9 +799,8 @@ export const Adshift = {
|
|
|
936
799
|
},
|
|
937
800
|
|
|
938
801
|
/**
|
|
939
|
-
*
|
|
940
|
-
*
|
|
941
|
-
* Called before `initialize()`, the value is kept and applied afterwards.
|
|
802
|
+
* Verbose SDK logging. Before `initialize()` the value is kept and applied
|
|
803
|
+
* afterwards.
|
|
942
804
|
*/
|
|
943
805
|
setDebugEnabled(enabled: boolean): void {
|
|
944
806
|
if (state === 'uninitialized') {
|
|
@@ -949,10 +811,9 @@ export const Adshift = {
|
|
|
949
811
|
},
|
|
950
812
|
|
|
951
813
|
/**
|
|
952
|
-
*
|
|
953
|
-
*
|
|
954
|
-
*
|
|
955
|
-
* A negative interval is reported and skipped; nothing is raised.
|
|
814
|
+
* Debounce interval for automatic `app_open` events. Before `initialize()`
|
|
815
|
+
* the value is kept and applied afterwards. A negative value is reported and
|
|
816
|
+
* skipped.
|
|
956
817
|
*/
|
|
957
818
|
setAppOpenDebounceMs(ms: number): void {
|
|
958
819
|
if (!isFiniteNumber(ms) || ms < 0) {
|
|
@@ -969,10 +830,8 @@ export const Adshift = {
|
|
|
969
830
|
},
|
|
970
831
|
|
|
971
832
|
/**
|
|
972
|
-
*
|
|
973
|
-
*
|
|
974
|
-
* Called before `initialize()`, the domains are kept and applied with the
|
|
975
|
-
* config, so they are in place before the first link is processed.
|
|
833
|
+
* Your own link domains; set them before `start()`. Before `initialize()`
|
|
834
|
+
* they are kept and passed with the config.
|
|
976
835
|
*/
|
|
977
836
|
setBrandedDomains(domains: string[]): void {
|
|
978
837
|
if (!isStringArray(domains)) {
|
|
@@ -991,9 +850,8 @@ export const Adshift = {
|
|
|
991
850
|
},
|
|
992
851
|
|
|
993
852
|
/**
|
|
994
|
-
*
|
|
995
|
-
*
|
|
996
|
-
* Called before `initialize()`, the value is kept and applied afterwards.
|
|
853
|
+
* Meta app id used to parse Meta App Links; no-op on iOS. Before
|
|
854
|
+
* `initialize()` the value is kept and applied afterwards.
|
|
997
855
|
*/
|
|
998
856
|
setMetaAppId(appId: string): void {
|
|
999
857
|
if (!isNonEmptyString(appId)) {
|
|
@@ -1010,11 +868,9 @@ export const Adshift = {
|
|
|
1010
868
|
},
|
|
1011
869
|
|
|
1012
870
|
/**
|
|
1013
|
-
*
|
|
1014
|
-
*
|
|
1015
|
-
*
|
|
1016
|
-
*
|
|
1017
|
-
* Called before `initialize()`, the value is kept and applied afterwards.
|
|
871
|
+
* An OAID the app obtained itself, for Android devices without Google Play
|
|
872
|
+
* services; set `collectOaid: false` as well. No-op on iOS. Before
|
|
873
|
+
* `initialize()` the value is kept and applied afterwards.
|
|
1018
874
|
*/
|
|
1019
875
|
setOaidData(oaid: string): void {
|
|
1020
876
|
if (!isNonEmptyString(oaid)) {
|
|
@@ -1030,13 +886,9 @@ export const Adshift = {
|
|
|
1030
886
|
NativeAdShiftReactNativePlugin.setOaidData(oaid);
|
|
1031
887
|
},
|
|
1032
888
|
|
|
1033
|
-
// ============ Consent (GDPR/DMA) ============
|
|
1034
|
-
|
|
1035
889
|
/**
|
|
1036
|
-
*
|
|
1037
|
-
*
|
|
1038
|
-
*
|
|
1039
|
-
* Called before `initialize()`, the consent is kept and applied afterwards.
|
|
890
|
+
* Consent collected by your own UI: `AdshiftConsent.forGDPRUser()` or
|
|
891
|
+
* `forNonGDPRUser()`. Before `initialize()` it is kept and applied later.
|
|
1040
892
|
*/
|
|
1041
893
|
setConsentData(consent: AdshiftConsent): void {
|
|
1042
894
|
if (
|
|
@@ -1058,10 +910,8 @@ export const Adshift = {
|
|
|
1058
910
|
},
|
|
1059
911
|
|
|
1060
912
|
/**
|
|
1061
|
-
*
|
|
1062
|
-
*
|
|
1063
|
-
*
|
|
1064
|
-
* Called before `initialize()`, the value is kept and applied afterwards.
|
|
913
|
+
* Reading IAB TCF v2.2 consent from the CMP on the device. Call before
|
|
914
|
+
* `start()`; before `initialize()` the value is kept and applied afterwards.
|
|
1065
915
|
*/
|
|
1066
916
|
enableTCFDataCollection(enabled: boolean): void {
|
|
1067
917
|
if (state === 'uninitialized') {
|
|
@@ -1072,14 +922,9 @@ export const Adshift = {
|
|
|
1072
922
|
},
|
|
1073
923
|
|
|
1074
924
|
/**
|
|
1075
|
-
*
|
|
1076
|
-
*
|
|
1077
|
-
*
|
|
1078
|
-
* The GPP string rides on its own axis: it is forwarded alongside whatever
|
|
1079
|
-
* decides the GDPR axis, including a consent set through `setConsentData()`,
|
|
1080
|
-
* and it does not gate the advertising identifier on the device.
|
|
1081
|
-
*
|
|
1082
|
-
* Call before `start()`. Called before `initialize()`, the value is kept and
|
|
925
|
+
* Reading an IAB GPP string written by the CMP, for US state privacy
|
|
926
|
+
* signals; off until called with `true`. It does not gate the advertising
|
|
927
|
+
* id. Call before `start()`; before `initialize()` the value is kept and
|
|
1083
928
|
* applied afterwards.
|
|
1084
929
|
*/
|
|
1085
930
|
enableGPPDataCollection(enabled: boolean): void {
|
|
@@ -1091,20 +936,10 @@ export const Adshift = {
|
|
|
1091
936
|
},
|
|
1092
937
|
|
|
1093
938
|
/**
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1096
|
-
*
|
|
1097
|
-
*
|
|
1098
|
-
* This is the answer to a different question than `setConsentData()`, and it
|
|
1099
|
-
* has the opposite default: nothing said here means sharing is allowed, so
|
|
1100
|
-
* only call it once the user has actually been asked. Setting `allowed()` at
|
|
1101
|
-
* startup as a default records a declaration the user never made, and events
|
|
1102
|
-
* already sent cannot be recalled when a real answer arrives.
|
|
1103
|
-
*
|
|
1104
|
-
* Nothing is gated on the device either way — this travels with the events for
|
|
1105
|
-
* the backend to act on.
|
|
1106
|
-
*
|
|
1107
|
-
* Called before `initialize()`, the answer is kept and applied afterwards.
|
|
939
|
+
* The user's answer on sharing their data with advertising partners:
|
|
940
|
+
* `AdshiftThirdPartySharing.optedOut()` or `allowed()`. Unlike consent,
|
|
941
|
+
* saying nothing means allowed, so call it only once the user was asked;
|
|
942
|
+
* events already sent are not recalled. Kept if called before `initialize()`.
|
|
1108
943
|
*/
|
|
1109
944
|
setThirdPartySharing(sharing: AdshiftThirdPartySharing): void {
|
|
1110
945
|
if (!isPlainObject(sharing) || typeof sharing.optOut !== 'boolean') {
|
|
@@ -1123,15 +958,9 @@ export const Adshift = {
|
|
|
1123
958
|
},
|
|
1124
959
|
|
|
1125
960
|
/**
|
|
1126
|
-
* Withdraws
|
|
1127
|
-
*
|
|
1128
|
-
*
|
|
1129
|
-
* stating that sharing is allowed: the first leaves the decision to your
|
|
1130
|
-
* dashboard configuration, the second is the app's own declaration and is
|
|
1131
|
-
* recorded as such.
|
|
1132
|
-
*
|
|
1133
|
-
* Called before `initialize()`, this cancels a `setThirdPartySharing()` that
|
|
1134
|
-
* was also queued.
|
|
961
|
+
* Withdraws `setThirdPartySharing()`: later events say nothing about sharing,
|
|
962
|
+
* which is not the same as `allowed()`. Before `initialize()` it cancels a
|
|
963
|
+
* queued `setThirdPartySharing()`.
|
|
1135
964
|
*/
|
|
1136
965
|
clearThirdPartySharing(): void {
|
|
1137
966
|
if (state === 'uninitialized') {
|
|
@@ -1159,21 +988,11 @@ export const Adshift = {
|
|
|
1159
988
|
}
|
|
1160
989
|
},
|
|
1161
990
|
|
|
1162
|
-
// ============ Event Tracking ============
|
|
1163
|
-
|
|
1164
991
|
/**
|
|
1165
|
-
*
|
|
1166
|
-
*
|
|
1167
|
-
* `
|
|
1168
|
-
*
|
|
1169
|
-
*
|
|
1170
|
-
* Resolves once the SDK has accepted the event. A call made between
|
|
1171
|
-
* `initialize()` and a successful `start()` waits for the start: it is sent
|
|
1172
|
-
* when the SDK starts, and rejects when the start fails for a reason
|
|
1173
|
-
* retrying cannot fix (rejected key, excluded device) or after `stop()`.
|
|
1174
|
-
* A start that failed for any other reason keeps the call waiting for the
|
|
1175
|
-
* next attempt, so `start()` belongs on every launch path.
|
|
1176
|
-
*
|
|
992
|
+
* `app_install` and `app_open` are reserved. A call made before a successful
|
|
993
|
+
* `start()` waits for it, so call `start()` on every launch path; it rejects
|
|
994
|
+
* after `stop()` or a start failure retrying cannot fix (rejected key,
|
|
995
|
+
* excluded device).
|
|
1177
996
|
* @returns Rejects with `AdshiftError` (`NOT_INITIALIZED`, `NOT_STARTED`,
|
|
1178
997
|
* `INVALID_API_KEY`, `OPTED_OUT`, `QUEUE_FULL`, `INVALID_ARGUMENT`).
|
|
1179
998
|
*/
|
|
@@ -1204,11 +1023,7 @@ export const Adshift = {
|
|
|
1204
1023
|
);
|
|
1205
1024
|
},
|
|
1206
1025
|
|
|
1207
|
-
/**
|
|
1208
|
-
* Tracks a purchase.
|
|
1209
|
-
*
|
|
1210
|
-
* @returns Rejects with `AdshiftError` (see `trackEvent`).
|
|
1211
|
-
*/
|
|
1026
|
+
/** Waits for `start()` and rejects like `trackEvent()`. */
|
|
1212
1027
|
trackPurchase(params: PurchaseParams): Promise<void> {
|
|
1213
1028
|
if (!isPlainObject(params)) {
|
|
1214
1029
|
return Promise.reject(
|
|
@@ -1247,9 +1062,8 @@ export const Adshift = {
|
|
|
1247
1062
|
},
|
|
1248
1063
|
|
|
1249
1064
|
/**
|
|
1250
|
-
*
|
|
1251
|
-
*
|
|
1252
|
-
* @returns Rejects with `AdshiftError` (see `trackEvent`).
|
|
1065
|
+
* Revenue of a single impression, not an aggregate. Waits for `start()` and
|
|
1066
|
+
* rejects like `trackEvent()`.
|
|
1253
1067
|
*/
|
|
1254
1068
|
logAdRevenue(params: AdRevenueParams): Promise<void> {
|
|
1255
1069
|
if (!isPlainObject(params)) {
|
|
@@ -1339,11 +1153,7 @@ export const Adshift = {
|
|
|
1339
1153
|
);
|
|
1340
1154
|
},
|
|
1341
1155
|
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
/**
|
|
1345
|
-
* Returns the AdShift device id, or `null` before `initialize()`.
|
|
1346
|
-
*/
|
|
1156
|
+
/** `null` before `initialize()`. */
|
|
1347
1157
|
async getAdShiftDeviceId(): Promise<string | null> {
|
|
1348
1158
|
if (state === 'uninitialized') {
|
|
1349
1159
|
return null;
|
|
@@ -1356,15 +1166,9 @@ export const Adshift = {
|
|
|
1356
1166
|
}
|
|
1357
1167
|
},
|
|
1358
1168
|
|
|
1359
|
-
// ============ Deep Links ============
|
|
1360
|
-
|
|
1361
1169
|
/**
|
|
1362
|
-
* Passes a URL to the SDK
|
|
1363
|
-
*
|
|
1364
|
-
* Not needed when `autoHandleDeepLinks` is on (the default). The result is
|
|
1365
|
-
* delivered through `onDeepLink()`; the promise resolves once the SDK has
|
|
1366
|
-
* finished processing the URL.
|
|
1367
|
-
*
|
|
1170
|
+
* Passes a URL to the SDK; not needed with `autoHandleDeepLinks` on (the
|
|
1171
|
+
* default). The result arrives through `onDeepLink()`.
|
|
1368
1172
|
* @returns Rejects with `AdshiftError` (`NOT_INITIALIZED`,
|
|
1369
1173
|
* `INVALID_ARGUMENT`).
|
|
1370
1174
|
*/
|
|
@@ -1416,11 +1220,10 @@ export const Adshift = {
|
|
|
1416
1220
|
},
|
|
1417
1221
|
|
|
1418
1222
|
/**
|
|
1419
|
-
*
|
|
1420
|
-
*
|
|
1421
|
-
*
|
|
1422
|
-
*
|
|
1423
|
-
* the SDK reads on its own, so register that key too if you still need it.
|
|
1223
|
+
* A key path inside push payloads that carries an AdShift deep link. The
|
|
1224
|
+
* first path replaces the top-level `as_push_link` the SDK reads by default,
|
|
1225
|
+
* so add that one too if you still use it. Kept if called before
|
|
1226
|
+
* `initialize()`.
|
|
1424
1227
|
*/
|
|
1425
1228
|
addPushNotificationDeepLinkPath(path: string[]): void {
|
|
1426
1229
|
if (!isStringArray(path) || path.length === 0) {
|
|
@@ -1439,10 +1242,8 @@ export const Adshift = {
|
|
|
1439
1242
|
},
|
|
1440
1243
|
|
|
1441
1244
|
/**
|
|
1442
|
-
*
|
|
1443
|
-
*
|
|
1444
|
-
* through `onDeepLink()`.
|
|
1445
|
-
*
|
|
1245
|
+
* Resolves to `true` when the payload carried an AdShift deep link; the
|
|
1246
|
+
* result then arrives through `onDeepLink()`.
|
|
1446
1247
|
* @returns Rejects with `AdshiftError` (`NOT_INITIALIZED`,
|
|
1447
1248
|
* `INVALID_ARGUMENT`).
|
|
1448
1249
|
*/
|
|
@@ -1467,12 +1268,9 @@ export const Adshift = {
|
|
|
1467
1268
|
},
|
|
1468
1269
|
|
|
1469
1270
|
/**
|
|
1470
|
-
*
|
|
1471
|
-
*
|
|
1472
|
-
*
|
|
1473
|
-
* listener is registered are buffered and delivered to the first listener.
|
|
1474
|
-
* Every link that reaches the SDK (direct, deferred, push) is delivered,
|
|
1475
|
-
* each result once.
|
|
1271
|
+
* Safe to call before `initialize()`. Results that arrive while no listener
|
|
1272
|
+
* is registered are buffered for the first one. Every link that reaches the
|
|
1273
|
+
* SDK (direct, deferred, push) is delivered once.
|
|
1476
1274
|
*/
|
|
1477
1275
|
onDeepLink(callback: DeepLinkCallback): DeepLinkSubscription {
|
|
1478
1276
|
if (typeof callback !== 'function') {
|
|
@@ -1494,8 +1292,6 @@ export const Adshift = {
|
|
|
1494
1292
|
};
|
|
1495
1293
|
},
|
|
1496
1294
|
|
|
1497
|
-
// ============ Info ============
|
|
1498
|
-
|
|
1499
1295
|
getInfo(): AdshiftInfo {
|
|
1500
1296
|
return {
|
|
1501
1297
|
platform: Platform.OS,
|