@adshift/react-native-plugin 2.0.0 → 3.0.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.
Files changed (86) hide show
  1. package/AdShiftReactNativePlugin.podspec +1 -1
  2. package/CHANGELOG.md +53 -1
  3. package/README.md +106 -50
  4. package/android/build.gradle +3 -1
  5. package/android/src/main/AndroidManifest.xml +14 -1
  6. package/android/src/main/java/com/adshift/reactnativeplugin/AdShiftReactNativePluginModule.kt +12 -1
  7. package/android/src/main/java/com/adshift/reactnativeplugin/RestoredIntents.kt +64 -0
  8. package/android/src/test/java/com/adshift/reactnativeplugin/DeepLinkDeliveryTest.kt +40 -3
  9. package/android/src/test/java/com/adshift/reactnativeplugin/InitializeOrderingTest.kt +14 -0
  10. package/android/src/test/java/com/adshift/reactnativeplugin/LaunchIntentForwardingTest.kt +30 -1
  11. package/android/src/test/java/com/adshift/reactnativeplugin/ModuleTestSupport.kt +13 -0
  12. package/ios/AdShiftReactNativePlugin.mm +5 -0
  13. package/ios/AdShiftReactNativePluginHelper.swift +25 -1
  14. package/ios/Core/BridgeRules.swift +18 -1
  15. package/lib/commonjs/Adshift.js +31 -5
  16. package/lib/commonjs/Adshift.js.map +1 -1
  17. package/lib/commonjs/NativeAdShiftReactNativePlugin.js.map +1 -1
  18. package/lib/commonjs/index.js +6 -0
  19. package/lib/commonjs/index.js.map +1 -1
  20. package/lib/commonjs/jest/index.js +2 -0
  21. package/lib/commonjs/jest/index.js.map +1 -1
  22. package/lib/commonjs/nativeSdkVersions.js +2 -2
  23. package/lib/commonjs/types/AdshiftConfig.js +10 -1
  24. package/lib/commonjs/types/AdshiftConfig.js.map +1 -1
  25. package/lib/commonjs/types/AdshiftDeepLink.js +50 -6
  26. package/lib/commonjs/types/AdshiftDeepLink.js.map +1 -1
  27. package/lib/commonjs/types/index.js +12 -0
  28. package/lib/commonjs/types/index.js.map +1 -1
  29. package/lib/commonjs/version.js +1 -1
  30. package/lib/module/Adshift.js +32 -6
  31. package/lib/module/Adshift.js.map +1 -1
  32. package/lib/module/NativeAdShiftReactNativePlugin.js.map +1 -1
  33. package/lib/module/index.js +1 -1
  34. package/lib/module/index.js.map +1 -1
  35. package/lib/module/jest/index.js +3 -1
  36. package/lib/module/jest/index.js.map +1 -1
  37. package/lib/module/nativeSdkVersions.js +2 -2
  38. package/lib/module/types/AdshiftConfig.js +9 -1
  39. package/lib/module/types/AdshiftConfig.js.map +1 -1
  40. package/lib/module/types/AdshiftDeepLink.js +50 -5
  41. package/lib/module/types/AdshiftDeepLink.js.map +1 -1
  42. package/lib/module/types/index.js +2 -2
  43. package/lib/module/types/index.js.map +1 -1
  44. package/lib/module/version.js +1 -1
  45. package/lib/typescript/commonjs/src/Adshift.d.ts +18 -7
  46. package/lib/typescript/commonjs/src/Adshift.d.ts.map +1 -1
  47. package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts +13 -4
  48. package/lib/typescript/commonjs/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -1
  49. package/lib/typescript/commonjs/src/index.d.ts +2 -2
  50. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  51. package/lib/typescript/commonjs/src/jest/index.d.ts +3 -1
  52. package/lib/typescript/commonjs/src/jest/index.d.ts.map +1 -1
  53. package/lib/typescript/commonjs/src/nativeSdkVersions.d.ts +2 -2
  54. package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts +25 -2
  55. package/lib/typescript/commonjs/src/types/AdshiftConfig.d.ts.map +1 -1
  56. package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts +55 -11
  57. package/lib/typescript/commonjs/src/types/AdshiftDeepLink.d.ts.map +1 -1
  58. package/lib/typescript/commonjs/src/types/index.d.ts +3 -3
  59. package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -1
  60. package/lib/typescript/commonjs/src/version.d.ts +1 -1
  61. package/lib/typescript/module/src/Adshift.d.ts +18 -7
  62. package/lib/typescript/module/src/Adshift.d.ts.map +1 -1
  63. package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts +13 -4
  64. package/lib/typescript/module/src/NativeAdShiftReactNativePlugin.d.ts.map +1 -1
  65. package/lib/typescript/module/src/index.d.ts +2 -2
  66. package/lib/typescript/module/src/index.d.ts.map +1 -1
  67. package/lib/typescript/module/src/jest/index.d.ts +3 -1
  68. package/lib/typescript/module/src/jest/index.d.ts.map +1 -1
  69. package/lib/typescript/module/src/nativeSdkVersions.d.ts +2 -2
  70. package/lib/typescript/module/src/types/AdshiftConfig.d.ts +25 -2
  71. package/lib/typescript/module/src/types/AdshiftConfig.d.ts.map +1 -1
  72. package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts +55 -11
  73. package/lib/typescript/module/src/types/AdshiftDeepLink.d.ts.map +1 -1
  74. package/lib/typescript/module/src/types/index.d.ts +3 -3
  75. package/lib/typescript/module/src/types/index.d.ts.map +1 -1
  76. package/lib/typescript/module/src/version.d.ts +1 -1
  77. package/package.json +2 -2
  78. package/src/Adshift.ts +48 -8
  79. package/src/NativeAdShiftReactNativePlugin.ts +14 -4
  80. package/src/index.tsx +6 -2
  81. package/src/jest/index.ts +5 -0
  82. package/src/nativeSdkVersions.ts +2 -2
  83. package/src/types/AdshiftConfig.ts +38 -2
  84. package/src/types/AdshiftDeepLink.ts +87 -11
  85. package/src/types/index.ts +9 -2
  86. package/src/version.ts +1 -1
@@ -1,5 +1,21 @@
1
1
  import type { AdshiftError } from './AdshiftError';
2
2
 
3
+ /**
4
+ * Whether the first launch on iOS reads the deferred deep link a RightLink
5
+ * page copied to the clipboard.
6
+ */
7
+ export type AdshiftDeferredDeepLinkClipboard =
8
+ | 'disabled'
9
+ | 'prompt'
10
+ | 'pasteControl';
11
+
12
+ /** @internal */
13
+ export const DEFERRED_DEEP_LINK_CLIPBOARD_MODES: ReadonlySet<string> = new Set([
14
+ 'disabled',
15
+ 'prompt',
16
+ 'pasteControl',
17
+ ]);
18
+
3
19
  /**
4
20
  * Configuration for initializing the AdShift SDK.
5
21
  *
@@ -34,11 +50,18 @@ export interface AdshiftConfig {
34
50
  appOpenDebounceMs?: number;
35
51
 
36
52
  /**
37
- * Branded (custom) attribution domains, e.g. `links.example.com`.
38
- * Links on these hosts are treated as attribution links.
53
+ * Your own link domains, e.g. `links.example.com`. Without this a link on
54
+ * such a domain comes back `notFound` and is not counted as a click.
39
55
  */
40
56
  brandedDomains?: string[];
41
57
 
58
+ /**
59
+ * Mark every click and event as test traffic, which is kept out of
60
+ * reports, postbacks and billing. A debug build does not turn it on.
61
+ * @default false
62
+ */
63
+ testMode?: boolean;
64
+
42
65
  /**
43
66
  * Meta app id used to parse Meta App Links.
44
67
  * @platform android
@@ -88,6 +111,17 @@ export interface AdshiftConfig {
88
111
  */
89
112
  attTimeoutMs?: number;
90
113
 
114
+ /**
115
+ * Read the deferred deep link from the clipboard on the first launch, for
116
+ * RightLink templates with the clipboard option. `prompt`: iOS asks the
117
+ * user to allow the paste, once per install. `pasteControl`: your
118
+ * onboarding shows `UIPasteControl` and passes the result to
119
+ * `Adshift.handlePastedDeepLink()`.
120
+ * @default 'disabled'
121
+ * @platform ios
122
+ */
123
+ deferredDeepLinkClipboard?: AdshiftDeferredDeepLinkClipboard;
124
+
91
125
  // ============ Android-only options ============
92
126
 
93
127
  /**
@@ -135,12 +169,14 @@ const BRIDGED_KEYS = [
135
169
  'isDebug',
136
170
  'appOpenDebounceMs',
137
171
  'brandedDomains',
172
+ 'testMode',
138
173
  'metaAppId',
139
174
  'pushDeepLinkPaths',
140
175
  'autoHandleDeepLinks',
141
176
  'disableSKAN',
142
177
  'waitForATTBeforeStart',
143
178
  'attTimeoutMs',
179
+ 'deferredDeepLinkClipboard',
144
180
  'collectOaid',
145
181
  ] as const satisfies ReadonlyArray<keyof AdshiftConfig>;
146
182
 
@@ -2,21 +2,54 @@
2
2
  * Status of a deep link result.
3
3
  */
4
4
  export enum AdshiftDeepLinkStatus {
5
- /** The link was processed and delivered. */
5
+ /** A RightLink link, or a deferred deep link with a value. Navigate on this. */
6
6
  Found = 'found',
7
7
 
8
- /** No deep link was found (e.g. organic install, deferred lookup empty). */
8
+ /** Not a RightLink link, a deleted one, or no deferred deep link. */
9
9
  NotFound = 'notFound',
10
10
 
11
- /** An error occurred while resolving the deep link. */
11
+ /** Not resolved yet; the same link can still arrive as `found`. */
12
12
  Error = 'error',
13
13
  }
14
14
 
15
+ /**
16
+ * How the link of a result reached the app.
17
+ */
18
+ export enum AdshiftDeepLinkSource {
19
+ /** A Universal Link, or a link the app passed in itself. iOS. */
20
+ UniversalLink = 'ul',
21
+
22
+ /** An App Link, or a link the app passed in itself. Android. */
23
+ AppLink = 'app_link',
24
+
25
+ /** The app's own scheme; `found` only when it wraps a RightLink link in `as_rl`. */
26
+ Scheme = 'scheme',
27
+
28
+ /** The open-in-app button of a RightLink page. */
29
+ Cta = 'cta',
30
+
31
+ /** A push notification. */
32
+ Push = 'push',
33
+
34
+ /** An AdAttributionKit re-engagement open. iOS. */
35
+ AdAttributionKit = 'aak',
36
+
37
+ /** A link opened by a Meta app that is not a RightLink link. Android. */
38
+ MetaAppLink = 'meta_applink',
39
+
40
+ /** The lookup on the first launch after install. */
41
+ Deferred = 'deferred',
42
+
43
+ /** A web link that is not a RightLink link. */
44
+ Foreign = 'foreign',
45
+ }
46
+
15
47
  /**
16
48
  * Deep link delivered through `Adshift.onDeepLink()`.
17
49
  *
18
- * Every link that enters the app and reaches the SDK produces a result with
19
- * `status: 'found'`. Route on `deepLinkValue`, `params` or the URL itself.
50
+ * Navigate only on `status: 'found'`, and validate `deepLinkValue` first:
51
+ * anyone can write a link. Any other URL comes back `notFound` with the URL
52
+ * in `deepLink`. Treat `error` as "not yet".
20
53
  *
21
54
  * @example
22
55
  * ```typescript
@@ -28,15 +61,18 @@ export enum AdshiftDeepLinkStatus {
28
61
  * ```
29
62
  */
30
63
  export interface AdshiftDeepLink {
64
+ /**
65
+ * The link as opened, a short link expanded. On iOS a deferred result has
66
+ * none: route on `deepLinkValue`.
67
+ */
31
68
  deepLink?: string;
32
69
 
33
70
  /** Standardized routing value (`deep_link_value`). */
34
71
  deepLinkValue?: string;
35
72
 
36
73
  /**
37
- * Query parameters of the link. On Android `deep_link_sub1` … `sub5` also
38
- * appear here; on iOS they are only available as the `deepLinkSubN` fields
39
- * below, which both platforms fill.
74
+ * Query parameters of a RightLink link, your own keys included. Absent for
75
+ * any other URL.
40
76
  */
41
77
  params?: Record<string, string>;
42
78
 
@@ -45,12 +81,29 @@ export interface AdshiftDeepLink {
45
81
 
46
82
  status: AdshiftDeepLinkStatus;
47
83
 
48
- /** Error message when `status` is `error`. */
84
+ /** Error message when `status` is `error`; wording differs per platform. */
49
85
  errorMessage?: string;
50
86
 
87
+ /** How the link reached the app. */
88
+ source?: AdshiftDeepLinkSource;
89
+
90
+ /**
91
+ * Id of the click this open was attributed to. Absent for a deferred result
92
+ * and when no click was recorded.
93
+ */
94
+ clickId?: string;
95
+
96
+ /**
97
+ * `false` for a deferred result matched without a clipboard token or an
98
+ * advertising identifier: route the user, but do not sign them in or grant
99
+ * a reward because of it.
100
+ * @platform ios
101
+ */
102
+ matchGuaranteed?: boolean;
103
+
51
104
  /**
52
- * Whether the result belongs to the first session after install. Android
53
- * reports it for every result, deferred or not; undefined on iOS.
105
+ * Whether the result came in the first session after install. `isDeferred`
106
+ * alone does not mean a new user.
54
107
  */
55
108
  isFirstSession?: boolean;
56
109
 
@@ -70,6 +123,8 @@ export interface AdshiftDeepLink {
70
123
  deepLinkSub5?: string;
71
124
  }
72
125
 
126
+ const SOURCES = new Set<string>(Object.values(AdshiftDeepLinkSource));
127
+
73
128
  const SUB_KEYS = [
74
129
  'deepLinkSub1',
75
130
  'deepLinkSub2',
@@ -88,6 +143,9 @@ export const AdshiftDeepLink = {
88
143
  params?: Record<string, string>;
89
144
  isDeferred?: boolean;
90
145
  isFirstSession?: boolean;
146
+ source?: AdshiftDeepLinkSource;
147
+ clickId?: string;
148
+ matchGuaranteed?: boolean;
91
149
  deepLinkSub1?: string;
92
150
  deepLinkSub2?: string;
93
151
  deepLinkSub3?: string;
@@ -108,6 +166,15 @@ export const AdshiftDeepLink = {
108
166
  if (options.isFirstSession !== undefined) {
109
167
  result.isFirstSession = options.isFirstSession;
110
168
  }
169
+ if (options.source !== undefined) {
170
+ result.source = options.source;
171
+ }
172
+ if (options.clickId !== undefined) {
173
+ result.clickId = options.clickId;
174
+ }
175
+ if (options.matchGuaranteed !== undefined) {
176
+ result.matchGuaranteed = options.matchGuaranteed;
177
+ }
111
178
  for (const key of SUB_KEYS) {
112
179
  const value = options[key];
113
180
  if (value !== undefined) {
@@ -159,6 +226,15 @@ export const AdshiftDeepLink = {
159
226
  if (typeof map.isFirstSession === 'boolean') {
160
227
  result.isFirstSession = map.isFirstSession;
161
228
  }
229
+ if (typeof map.source === 'string' && SOURCES.has(map.source)) {
230
+ result.source = map.source as AdshiftDeepLinkSource;
231
+ }
232
+ if (typeof map.clickId === 'string' && map.clickId.length > 0) {
233
+ result.clickId = map.clickId;
234
+ }
235
+ if (typeof map.matchGuaranteed === 'boolean') {
236
+ result.matchGuaranteed = map.matchGuaranteed;
237
+ }
162
238
  SUB_KEYS.forEach((key, index) => {
163
239
  const sub = map[key] ?? params?.[`deep_link_sub${index + 1}`];
164
240
  if (typeof sub === 'string') {
@@ -1,5 +1,11 @@
1
- export type { AdshiftConfig } from './AdshiftConfig';
2
- export { configToMap } from './AdshiftConfig';
1
+ export type {
2
+ AdshiftConfig,
3
+ AdshiftDeferredDeepLinkClipboard,
4
+ } from './AdshiftConfig';
5
+ export {
6
+ configToMap,
7
+ DEFERRED_DEEP_LINK_CLIPBOARD_MODES,
8
+ } from './AdshiftConfig';
3
9
 
4
10
  export type { ConsentFlag } from './AdshiftConsent';
5
11
  export { AdshiftConsent, consentToMap } from './AdshiftConsent';
@@ -14,6 +20,7 @@ export {
14
20
 
15
21
  export {
16
22
  AdshiftDeepLinkStatus,
23
+ AdshiftDeepLinkSource,
17
24
  AdshiftDeepLink,
18
25
  deepLinkToMap,
19
26
  } from './AdshiftDeepLink';
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by scripts/write-version.js from package.json. Do not edit.
2
- export const PLUGIN_VERSION = '2.0.0';
2
+ export const PLUGIN_VERSION = '3.0.0';