react-native-mparticle 3.0.0 → 3.1.1
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/README.md +51 -4
- package/android/build.gradle +4 -2
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/mparticle/react/rokt/MPRoktModuleImpl.kt +18 -0
- package/android/src/newarch/java/com/mparticle/react/rokt/MPRoktModule.kt +19 -0
- package/android/src/oldarch/java/com/mparticle/react/NativeMPRoktSpec.kt +10 -0
- package/android/src/oldarch/java/com/mparticle/react/rokt/MPRoktModule.kt +19 -0
- package/ios/RNMParticle/RNMPRokt.mm +58 -0
- package/js/codegenSpecs/NativeMParticle.ts +1 -4
- package/js/codegenSpecs/rokt/NativeMPRokt.ts +6 -0
- package/js/rokt/rokt.ts +12 -0
- package/lib/codegenSpecs/NativeMParticle.js.map +1 -1
- package/lib/codegenSpecs/rokt/NativeMPRokt.d.ts +3 -0
- package/lib/codegenSpecs/rokt/NativeMPRokt.js.map +1 -1
- package/lib/rokt/rokt.d.ts +3 -0
- package/lib/rokt/rokt.js +9 -0
- package/lib/rokt/rokt.js.map +1 -1
- package/package.json +1 -1
- package/plugin/build/customBaseUrl.d.ts +4 -0
- package/plugin/build/customBaseUrl.js +22 -0
- package/plugin/build/withMParticle.d.ts +6 -0
- package/plugin/build/withMParticleAndroid.js +39 -10
- package/plugin/build/withMParticleIOS.js +23 -1
- package/plugin/src/customBaseUrl.ts +31 -0
- package/plugin/src/withMParticle.ts +7 -0
- package/plugin/src/withMParticleAndroid.ts +49 -10
- package/plugin/src/withMParticleIOS.ts +37 -1
- package/react-native-mparticle.podspec +2 -2
package/README.md
CHANGED
|
@@ -82,6 +82,7 @@ npx expo run:android
|
|
|
82
82
|
| `dataPlanId` | string | No | Data plan ID for validation |
|
|
83
83
|
| `dataPlanVersion` | number | No | Data plan version |
|
|
84
84
|
| `iosKits` | string[] | No | iOS kit pod names (e.g., `['mParticle-Rokt']`) |
|
|
85
|
+
| `customBaseUrl` | string | No | Custom base URL for global CNAME setup on iOS and Android |
|
|
85
86
|
| `androidKits` | string[] | No | Android kit artifact names (e.g., `['android-rokt-kit']`) |
|
|
86
87
|
| `useEmptyIdentifyRequest` | boolean | No | Use empty user identify request at init (default: `true`) |
|
|
87
88
|
|
|
@@ -109,17 +110,27 @@ npx expo run:android
|
|
|
109
110
|
}
|
|
110
111
|
```
|
|
111
112
|
|
|
113
|
+
For global CNAME setup, add the optional shared `customBaseUrl` setting:
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"customBaseUrl": "https://cname.example.com"
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
112
121
|
### What the Plugin Does
|
|
113
122
|
|
|
114
123
|
**iOS:**
|
|
115
124
|
|
|
116
125
|
- Adds mParticle SDK initialization to `AppDelegate` (supports both Swift and Objective-C)
|
|
126
|
+
- Sets `MPNetworkOptions.customBaseURL` before startup when `customBaseUrl` is configured
|
|
117
127
|
- Configures `pre_install` hook in Podfile for dynamic framework linking
|
|
118
128
|
- Adds specified kit pod dependencies
|
|
119
129
|
|
|
120
130
|
**Android:**
|
|
121
131
|
|
|
122
132
|
- Adds mParticle SDK initialization to `MainApplication` (supports both Kotlin and Java)
|
|
133
|
+
- Sets `NetworkOptions.setCustomBaseURL` before startup when `customBaseUrl` is configured
|
|
123
134
|
- Adds specified kit Maven dependencies to `build.gradle`
|
|
124
135
|
|
|
125
136
|
### Version Support
|
|
@@ -219,6 +230,12 @@ func application(_ application: UIApplication, didFinishLaunchingWithOptions lau
|
|
|
219
230
|
mParticleOptions.onAttributionComplete = { (attributionResult, error) in
|
|
220
231
|
NSLog(@"Attribution Complete. attributionResults = %@", attributionResult.linkInfo)
|
|
221
232
|
}
|
|
233
|
+
|
|
234
|
+
// Optional global CNAME setup. Configure before start.
|
|
235
|
+
let networkOptions = MPNetworkOptions()
|
|
236
|
+
networkOptions.customBaseURL = URL(string: "https://cname.example.com")
|
|
237
|
+
mParticleOptions.networkOptions = networkOptions
|
|
238
|
+
|
|
222
239
|
MParticle.sharedInstance().start(with: mParticleOptions)
|
|
223
240
|
return true
|
|
224
241
|
}
|
|
@@ -260,12 +277,34 @@ Next, you'll need to start the SDK:
|
|
|
260
277
|
NSLog(@"Attribution Complete. attributionResults = %@", attributionResult.linkInfo)
|
|
261
278
|
}
|
|
262
279
|
|
|
280
|
+
// Optional global CNAME setup. Configure before start.
|
|
281
|
+
MPNetworkOptions *networkOptions = [[MPNetworkOptions alloc] init];
|
|
282
|
+
networkOptions.customBaseURL = [NSURL URLWithString:@"https://cname.example.com"];
|
|
283
|
+
mParticleOptions.networkOptions = networkOptions;
|
|
284
|
+
|
|
263
285
|
[[MParticle sharedInstance] startWithOptions:mParticleOptions];
|
|
264
286
|
|
|
265
287
|
return YES;
|
|
266
288
|
}
|
|
267
289
|
```
|
|
268
290
|
|
|
291
|
+
### Rokt iOS Setup
|
|
292
|
+
|
|
293
|
+
For standard Rokt placements, add the mParticle Rokt kit:
|
|
294
|
+
|
|
295
|
+
```ruby
|
|
296
|
+
pod 'mParticle-Rokt', '~> 9.2'
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
In Expo apps, use `iosKits: ["mParticle-Rokt"]` for standard Rokt placements. The Expo plugin does not add payment-extension pods or URL callback forwarding in this release.
|
|
300
|
+
|
|
301
|
+
See [MIGRATING.md](./MIGRATING.md) for release-specific migration guidance.
|
|
302
|
+
|
|
303
|
+
For Android integrations that use `MParticle.Rokt.setSessionId()` or
|
|
304
|
+
`MParticle.Rokt.getSessionId()`, `android-core` and `android-rokt-kit`
|
|
305
|
+
`5.79.0` or newer are required. Android CNAME setup through
|
|
306
|
+
`customBaseUrl` also requires `android-core` `5.79.0` or newer.
|
|
307
|
+
|
|
269
308
|
See [Identity](http://docs.mparticle.com/developers/sdk/ios/identity/) for more information on supplying an `MPIdentityApiRequest` object during SDK initialization.
|
|
270
309
|
|
|
271
310
|
4. Remember to start Metro with:
|
|
@@ -285,13 +324,15 @@ and build your workspace from xCode.
|
|
|
285
324
|
For more help, see [the Android set up docs](https://docs.mparticle.com/developers/sdk/android/getting-started/#create-an-input).
|
|
286
325
|
|
|
287
326
|
```kotlin
|
|
288
|
-
package com.example.myapp
|
|
327
|
+
package com.example.myapp
|
|
289
328
|
|
|
290
|
-
import android.app.Application
|
|
291
|
-
import com.mparticle.MParticle
|
|
329
|
+
import android.app.Application
|
|
330
|
+
import com.mparticle.MParticle
|
|
331
|
+
import com.mparticle.MParticleOptions
|
|
332
|
+
import com.mparticle.networking.NetworkOptions
|
|
292
333
|
|
|
293
334
|
class MyApplication : Application() {
|
|
294
|
-
fun onCreate() {
|
|
335
|
+
override fun onCreate() {
|
|
295
336
|
super.onCreate()
|
|
296
337
|
val options: MParticleOptions = MParticleOptions.builder(this)
|
|
297
338
|
.credentials("REPLACE ME WITH KEY", "REPLACE ME WITH SECRET")
|
|
@@ -299,6 +340,12 @@ class MyApplication : Application() {
|
|
|
299
340
|
.logLevel(MParticle.LogLevel.VERBOSE)
|
|
300
341
|
//optional
|
|
301
342
|
.identify(identifyRequest)
|
|
343
|
+
//optional global CNAME setup
|
|
344
|
+
.networkOptions(
|
|
345
|
+
NetworkOptions.builder()
|
|
346
|
+
.setCustomBaseURL("https://cname.example.com")
|
|
347
|
+
.build()
|
|
348
|
+
)
|
|
302
349
|
//optional
|
|
303
350
|
.identifyTask(
|
|
304
351
|
BaseIdentityTask()
|
package/android/build.gradle
CHANGED
|
@@ -118,7 +118,9 @@ dependencies {
|
|
|
118
118
|
//
|
|
119
119
|
// (See https://github.com/mparticle/mparticle-android-sdk for the latest version)
|
|
120
120
|
//
|
|
121
|
-
|
|
121
|
+
// Bounded upper bound prevents resolving to 6.0.0-rc.1+ on Maven Central.
|
|
122
|
+
// 6.x removed deprecated symbols (e.g. UserAttributeListener); see #710.
|
|
123
|
+
api 'com.mparticle:android-core:[5.79.0, 6.0)'
|
|
122
124
|
|
|
123
125
|
//
|
|
124
126
|
// And, if you want to include kits, you can do so as follows:
|
|
@@ -134,6 +136,6 @@ dependencies {
|
|
|
134
136
|
testImplementation 'junit:junit:4.13.2'
|
|
135
137
|
testImplementation files('libs/java-json.jar')
|
|
136
138
|
|
|
137
|
-
testImplementation 'com.mparticle:android-core:5
|
|
139
|
+
testImplementation 'com.mparticle:android-core:5.79.0'
|
|
138
140
|
testImplementation("com.facebook.react:react-android:+")
|
|
139
141
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
# Specifies the JVM arguments used for the daemon process.
|
|
11
11
|
# The setting is particularly useful for tweaking memory settings.
|
|
12
12
|
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
|
|
13
|
-
org.gradle.jvmargs=-
|
|
13
|
+
org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=512m
|
|
14
14
|
|
|
15
15
|
# When configured, Gradle will run in incubating parallel mode.
|
|
16
16
|
# This option should only be used with decoupled projects. More details, visit
|
|
@@ -6,6 +6,7 @@ import androidx.lifecycle.LifecycleOwner
|
|
|
6
6
|
import androidx.lifecycle.lifecycleScope
|
|
7
7
|
import androidx.lifecycle.repeatOnLifecycle
|
|
8
8
|
import com.facebook.react.bridge.Arguments
|
|
9
|
+
import com.facebook.react.bridge.Promise
|
|
9
10
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
10
11
|
import com.facebook.react.bridge.ReactContext
|
|
11
12
|
import com.facebook.react.bridge.ReadableMap
|
|
@@ -56,6 +57,23 @@ class MPRoktModuleImpl(
|
|
|
56
57
|
MParticle.getInstance()?.Rokt()?.purchaseFinalized(placementId, catalogItemId, success)
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
fun close(promise: Promise) {
|
|
61
|
+
MParticle.getInstance()?.Rokt()?.close()
|
|
62
|
+
promise.resolve(null)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
fun setSessionId(
|
|
66
|
+
sessionId: String,
|
|
67
|
+
promise: Promise,
|
|
68
|
+
) {
|
|
69
|
+
MParticle.getInstance()?.Rokt()?.setSessionId(sessionId)
|
|
70
|
+
promise.resolve(null)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
fun getSessionId(promise: Promise) {
|
|
74
|
+
promise.resolve(MParticle.getInstance()?.Rokt()?.getSessionId())
|
|
75
|
+
}
|
|
76
|
+
|
|
59
77
|
fun setRoktEventHandler(roktEventHandler: MpRoktEventCallback) {
|
|
60
78
|
this.roktEventHandler = roktEventHandler
|
|
61
79
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.mparticle.react.rokt
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.bridge.Promise
|
|
3
4
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
5
|
import com.facebook.react.bridge.ReactMethod
|
|
5
6
|
import com.facebook.react.bridge.ReadableMap
|
|
@@ -68,6 +69,24 @@ class MPRoktModule(
|
|
|
68
69
|
impl.purchaseFinalized(placementId, catalogItemId, success)
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
@ReactMethod
|
|
73
|
+
override fun close(promise: Promise) {
|
|
74
|
+
impl.close(promise)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@ReactMethod
|
|
78
|
+
override fun setSessionId(
|
|
79
|
+
sessionId: String,
|
|
80
|
+
promise: Promise,
|
|
81
|
+
) {
|
|
82
|
+
impl.setSessionId(sessionId, promise)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@ReactMethod
|
|
86
|
+
override fun getSessionId(promise: Promise) {
|
|
87
|
+
impl.getSessionId(promise)
|
|
88
|
+
}
|
|
89
|
+
|
|
71
90
|
/**
|
|
72
91
|
* Process placeholders from ReadableMap to a map of Widgets for use with Rokt.
|
|
73
92
|
* This method handles the Fabric-specific view resolution.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.mparticle.react
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.bridge.Promise
|
|
3
4
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
5
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
5
6
|
import com.facebook.react.bridge.ReadableMap
|
|
@@ -32,4 +33,13 @@ abstract class NativeMPRoktSpec(
|
|
|
32
33
|
catalogItemId: String,
|
|
33
34
|
success: Boolean,
|
|
34
35
|
)
|
|
36
|
+
|
|
37
|
+
abstract fun close(promise: Promise)
|
|
38
|
+
|
|
39
|
+
abstract fun setSessionId(
|
|
40
|
+
sessionId: String,
|
|
41
|
+
promise: Promise,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
abstract fun getSessionId(promise: Promise)
|
|
35
45
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.mparticle.react.rokt
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.bridge.Promise
|
|
3
4
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
5
|
import com.facebook.react.bridge.ReactMethod
|
|
5
6
|
import com.facebook.react.bridge.ReadableMap
|
|
@@ -66,6 +67,24 @@ class MPRoktModule(
|
|
|
66
67
|
impl.purchaseFinalized(placementId, catalogItemId, success)
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
@ReactMethod
|
|
71
|
+
override fun close(promise: Promise) {
|
|
72
|
+
impl.close(promise)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@ReactMethod
|
|
76
|
+
override fun setSessionId(
|
|
77
|
+
sessionId: String,
|
|
78
|
+
promise: Promise,
|
|
79
|
+
) {
|
|
80
|
+
impl.setSessionId(sessionId, promise)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@ReactMethod
|
|
84
|
+
override fun getSessionId(promise: Promise) {
|
|
85
|
+
impl.getSessionId(promise)
|
|
86
|
+
}
|
|
87
|
+
|
|
69
88
|
private fun safeUnwrapPlaceholders(
|
|
70
89
|
placeholders: ReadableMap?,
|
|
71
90
|
nativeViewHierarchyManager: NativeViewHierarchyManager,
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
#import <RoktContracts/RoktContracts.h>
|
|
17
17
|
#endif
|
|
18
18
|
#import <React/RCTConvert.h>
|
|
19
|
+
#import <React/RCTBridgeModule.h>
|
|
19
20
|
#import <React/RCTEventEmitter.h>
|
|
20
21
|
#import <React/RCTViewManager.h>
|
|
21
22
|
#import <React/RCTUIManager.h>
|
|
@@ -209,6 +210,63 @@ RCT_EXPORT_METHOD(selectShoppableAds:(NSString *)identifier attributes:(NSDictio
|
|
|
209
210
|
}];
|
|
210
211
|
}
|
|
211
212
|
|
|
213
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
214
|
+
- (void)close:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
|
|
215
|
+
{
|
|
216
|
+
(void)reject;
|
|
217
|
+
[self closeWithResolve:resolve];
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
- (void)setSessionId:(NSString *)sessionId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
|
|
221
|
+
{
|
|
222
|
+
(void)reject;
|
|
223
|
+
[self setSessionIdWithString:sessionId resolve:resolve];
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
- (void)getSessionId:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
|
|
227
|
+
{
|
|
228
|
+
(void)reject;
|
|
229
|
+
[self getSessionIdWithResolve:resolve];
|
|
230
|
+
}
|
|
231
|
+
#else
|
|
232
|
+
RCT_EXPORT_METHOD(close:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
233
|
+
{
|
|
234
|
+
(void)reject;
|
|
235
|
+
[self closeWithResolve:resolve];
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
RCT_EXPORT_METHOD(setSessionId:(NSString *)sessionId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
239
|
+
{
|
|
240
|
+
(void)reject;
|
|
241
|
+
[self setSessionIdWithString:sessionId resolve:resolve];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
RCT_EXPORT_METHOD(getSessionId:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
245
|
+
{
|
|
246
|
+
(void)reject;
|
|
247
|
+
[self getSessionIdWithResolve:resolve];
|
|
248
|
+
}
|
|
249
|
+
#endif
|
|
250
|
+
|
|
251
|
+
- (void)closeWithResolve:(RCTPromiseResolveBlock)resolve
|
|
252
|
+
{
|
|
253
|
+
[[[MParticle sharedInstance] rokt] close];
|
|
254
|
+
resolve(nil);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
- (void)setSessionIdWithString:(NSString *)sessionId
|
|
258
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
259
|
+
{
|
|
260
|
+
[[[MParticle sharedInstance] rokt] setSessionId:sessionId ?: @""];
|
|
261
|
+
resolve(nil);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
- (void)getSessionIdWithResolve:(RCTPromiseResolveBlock)resolve
|
|
265
|
+
{
|
|
266
|
+
NSString *sessionId = [[[MParticle sharedInstance] rokt] getSessionId];
|
|
267
|
+
resolve(sessionId ?: [NSNull null]);
|
|
268
|
+
}
|
|
269
|
+
|
|
212
270
|
RCT_EXPORT_METHOD(purchaseFinalized : (NSString *)placementId catalogItemId : (
|
|
213
271
|
NSString *)catalogItemId success : (BOOL)success) {
|
|
214
272
|
[[[MParticle sharedInstance] rokt] purchaseFinalized:placementId
|
|
@@ -150,10 +150,7 @@ export interface Spec extends TurboModule {
|
|
|
150
150
|
setUserAttributeArray(mpid: string, key: string, value: Array<string>): void;
|
|
151
151
|
getUserAttributes(
|
|
152
152
|
mpid: string,
|
|
153
|
-
callback: (
|
|
154
|
-
error: CallbackError | null,
|
|
155
|
-
result: UserAttributes
|
|
156
|
-
) => void
|
|
153
|
+
callback: (error: CallbackError | null, result: UserAttributes) => void
|
|
157
154
|
): void;
|
|
158
155
|
setUserTag(mpid: string, tag: string): void;
|
|
159
156
|
incrementUserAttribute(mpid: string, key: string, value: number): void;
|
|
@@ -33,6 +33,12 @@ export interface Spec extends TurboModule {
|
|
|
33
33
|
attributes: { [key: string]: string },
|
|
34
34
|
roktConfig?: RoktConfigType
|
|
35
35
|
): void;
|
|
36
|
+
|
|
37
|
+
close(): Promise<void>;
|
|
38
|
+
|
|
39
|
+
setSessionId(sessionId: string): Promise<void>;
|
|
40
|
+
|
|
41
|
+
getSessionId(): Promise<string | null>;
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
export default TurboModuleRegistry.getEnforcing<Spec>('RNMPRokt');
|
package/js/rokt/rokt.ts
CHANGED
|
@@ -47,6 +47,18 @@ export abstract class Rokt {
|
|
|
47
47
|
MPRokt.purchaseFinalized(placementId, catalogItemId, success);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
static close(): Promise<void> {
|
|
51
|
+
return MPRokt.close();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static setSessionId(sessionId: string): Promise<void> {
|
|
55
|
+
return MPRokt.setSessionId(sessionId);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static getSessionId(): Promise<string | null> {
|
|
59
|
+
return MPRokt.getSessionId();
|
|
60
|
+
}
|
|
61
|
+
|
|
50
62
|
static createRoktConfig(colorMode?: ColorMode, cacheConfig?: CacheConfig) {
|
|
51
63
|
return new RoktConfig(colorMode ?? 'system', cacheConfig);
|
|
52
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeMParticle.js","sourceRoot":"","sources":["../../js/codegenSpecs/NativeMParticle.ts"],"names":[],"mappings":";;AACA,+CAAmD;
|
|
1
|
+
{"version":3,"file":"NativeMParticle.js","sourceRoot":"","sources":["../../js/codegenSpecs/NativeMParticle.ts"],"names":[],"mappings":";;AACA,+CAAmD;AAgNnD,kBAAe,kCAAmB,CAAC,YAAY,CAAO,aAAa,CAAC,CAAC"}
|
|
@@ -22,6 +22,9 @@ export interface Spec extends TurboModule {
|
|
|
22
22
|
selectShoppableAds(identifier: string, attributes: {
|
|
23
23
|
[key: string]: string;
|
|
24
24
|
}, roktConfig?: RoktConfigType): void;
|
|
25
|
+
close(): Promise<void>;
|
|
26
|
+
setSessionId(sessionId: string): Promise<void>;
|
|
27
|
+
getSessionId(): Promise<string | null>;
|
|
25
28
|
}
|
|
26
29
|
declare const _default: Spec;
|
|
27
30
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeMPRokt.js","sourceRoot":"","sources":["../../../js/codegenSpecs/rokt/NativeMPRokt.ts"],"names":[],"mappings":";;AACA,+CAAmD;
|
|
1
|
+
{"version":3,"file":"NativeMPRokt.js","sourceRoot":"","sources":["../../../js/codegenSpecs/rokt/NativeMPRokt.ts"],"names":[],"mappings":";;AACA,+CAAmD;AA0CnD,kBAAe,kCAAmB,CAAC,YAAY,CAAO,UAAU,CAAC,CAAC"}
|
package/lib/rokt/rokt.d.ts
CHANGED
|
@@ -12,6 +12,9 @@ export declare abstract class Rokt {
|
|
|
12
12
|
static selectPlacements(identifier: string, attributes: Record<string, string>, placeholders?: Record<string, number | null>, roktConfig?: IRoktConfig, fontFilesMap?: Record<string, string>): Promise<void>;
|
|
13
13
|
static selectShoppableAds(identifier: string, attributes: Record<string, string>, roktConfig?: IRoktConfig): Promise<void>;
|
|
14
14
|
static purchaseFinalized(placementId: string, catalogItemId: string, success: boolean): Promise<void>;
|
|
15
|
+
static close(): Promise<void>;
|
|
16
|
+
static setSessionId(sessionId: string): Promise<void>;
|
|
17
|
+
static getSessionId(): Promise<string | null>;
|
|
15
18
|
static createRoktConfig(colorMode?: ColorMode, cacheConfig?: CacheConfig): RoktConfig;
|
|
16
19
|
static createCacheConfig(cacheDurationInSeconds: number, cacheAttributes: Record<string, string>): CacheConfig;
|
|
17
20
|
}
|
package/lib/rokt/rokt.js
CHANGED
|
@@ -24,6 +24,15 @@ class Rokt {
|
|
|
24
24
|
static async purchaseFinalized(placementId, catalogItemId, success) {
|
|
25
25
|
MPRokt.purchaseFinalized(placementId, catalogItemId, success);
|
|
26
26
|
}
|
|
27
|
+
static close() {
|
|
28
|
+
return MPRokt.close();
|
|
29
|
+
}
|
|
30
|
+
static setSessionId(sessionId) {
|
|
31
|
+
return MPRokt.setSessionId(sessionId);
|
|
32
|
+
}
|
|
33
|
+
static getSessionId() {
|
|
34
|
+
return MPRokt.getSessionId();
|
|
35
|
+
}
|
|
27
36
|
static createRoktConfig(colorMode, cacheConfig) {
|
|
28
37
|
return new RoktConfig(colorMode !== null && colorMode !== void 0 ? colorMode : 'system', cacheConfig);
|
|
29
38
|
}
|
package/lib/rokt/rokt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rokt.js","sourceRoot":"","sources":["../../js/rokt/rokt.ts"],"names":[],"mappings":";;;AAAA,+CAA6C;AAC7C,wDAAwD;AAGxD,MAAM,MAAM,GAAG,IAAA,8BAAe,EAAwB,UAAU,CAAC,CAAC;AAElE,MAAsB,IAAI;IACxB;;;;;;;;;OASG;IACH,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,UAAkB,EAClB,UAAkC,EAClC,YAA4C,EAC5C,UAAwB,EACxB,YAAqC;QAErC,MAAM,CAAC,gBAAgB,CACrB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,YAAY,CACb,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAC7B,UAAkB,EAClB,UAAkC,EAClC,UAAwB;QAExB,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAC5B,WAAmB,EACnB,aAAqB,EACrB,OAAgB;QAEhB,MAAM,CAAC,iBAAiB,CAAC,WAAW,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,SAAqB,EAAE,WAAyB;QACtE,OAAO,IAAI,UAAU,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,QAAQ,EAAE,WAAW,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,CAAC,iBAAiB,CACtB,sBAA8B,EAC9B,eAAuC;QAEvC,OAAO,IAAI,WAAW,CAAC,sBAAsB,EAAE,eAAe,CAAC,CAAC;IAClE,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"rokt.js","sourceRoot":"","sources":["../../js/rokt/rokt.ts"],"names":[],"mappings":";;;AAAA,+CAA6C;AAC7C,wDAAwD;AAGxD,MAAM,MAAM,GAAG,IAAA,8BAAe,EAAwB,UAAU,CAAC,CAAC;AAElE,MAAsB,IAAI;IACxB;;;;;;;;;OASG;IACH,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,UAAkB,EAClB,UAAkC,EAClC,YAA4C,EAC5C,UAAwB,EACxB,YAAqC;QAErC,MAAM,CAAC,gBAAgB,CACrB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,YAAY,CACb,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAC7B,UAAkB,EAClB,UAAkC,EAClC,UAAwB;QAExB,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAC5B,WAAmB,EACnB,aAAqB,EACrB,OAAgB;QAEhB,MAAM,CAAC,iBAAiB,CAAC,WAAW,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,KAAK;QACV,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,SAAiB;QACnC,OAAO,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,YAAY;QACjB,OAAO,MAAM,CAAC,YAAY,EAAE,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,SAAqB,EAAE,WAAyB;QACtE,OAAO,IAAI,UAAU,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,QAAQ,EAAE,WAAW,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,CAAC,iBAAiB,CACtB,sBAA8B,EAC9B,eAAuC;QAEvC,OAAO,IAAI,WAAW,CAAC,sBAAsB,EAAE,eAAe,CAAC,CAAC;IAClE,CAAC;CACF;AAjED,oBAiEC;AAQD;;GAEG;AACH,MAAa,WAAW;IACtB;;;OAGG;IACH,YACkB,sBAA+B,EAC/B,eAAwC;QADxC,2BAAsB,GAAtB,sBAAsB,CAAS;QAC/B,oBAAe,GAAf,eAAe,CAAyB;IACvD,CAAC;CACL;AATD,kCASC;AAED,MAAM,UAAU;IAId,YAAY,SAAoB,EAAE,WAAyB;QACzD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;CACF;AACD,MAAM,EAAE,gBAAgB,EAAE,GAAG,4BAAa,CAAC;AAElC,4CAAgB"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCustomBaseUrl = void 0;
|
|
4
|
+
function getCustomBaseUrl(props) {
|
|
5
|
+
const customBaseUrl = props.customBaseUrl?.trim();
|
|
6
|
+
if (!customBaseUrl) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
let parsedCustomBaseUrl;
|
|
10
|
+
try {
|
|
11
|
+
parsedCustomBaseUrl = new URL(customBaseUrl);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
throw new Error('react-native-mparticle customBaseUrl must be a valid https URL');
|
|
15
|
+
}
|
|
16
|
+
if (parsedCustomBaseUrl.protocol !== 'https:' ||
|
|
17
|
+
!parsedCustomBaseUrl.hostname) {
|
|
18
|
+
throw new Error('react-native-mparticle customBaseUrl must be a valid https URL');
|
|
19
|
+
}
|
|
20
|
+
return customBaseUrl;
|
|
21
|
+
}
|
|
22
|
+
exports.getCustomBaseUrl = getCustomBaseUrl;
|
|
@@ -42,6 +42,12 @@ export interface MParticlePluginProps {
|
|
|
42
42
|
* @example ['mParticle-Rokt', 'mParticle-Amplitude']
|
|
43
43
|
*/
|
|
44
44
|
iosKits?: string[];
|
|
45
|
+
/**
|
|
46
|
+
* Custom base URL for global CNAME setup.
|
|
47
|
+
* This is applied before mParticle starts on iOS and Android.
|
|
48
|
+
* @example 'https://your-cname.example.com'
|
|
49
|
+
*/
|
|
50
|
+
customBaseUrl?: string;
|
|
45
51
|
/**
|
|
46
52
|
* Android kit artifact names to include (version auto-detected from core SDK)
|
|
47
53
|
* @example ['android-rokt-kit', 'android-amplitude-kit']
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.withMParticleAndroid = void 0;
|
|
4
4
|
const config_plugins_1 = require("@expo/config-plugins");
|
|
5
5
|
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
|
6
|
+
const customBaseUrl_1 = require("./customBaseUrl");
|
|
6
7
|
// Tag used for mergeContents to identify code blocks added by this plugin
|
|
7
8
|
const MPARTICLE_TAG = 'react-native-mparticle';
|
|
8
9
|
/**
|
|
@@ -44,6 +45,7 @@ function getAndroidEnvironment(environment) {
|
|
|
44
45
|
*/
|
|
45
46
|
function generateKotlinInitCode(props) {
|
|
46
47
|
const { androidApiKey, androidApiSecret, logLevel, environment, useEmptyIdentifyRequest = true, dataPlanId, dataPlanVersion, } = props;
|
|
48
|
+
const customBaseUrl = (0, customBaseUrl_1.getCustomBaseUrl)(props);
|
|
47
49
|
const lines = [
|
|
48
50
|
'// mParticle SDK initialization',
|
|
49
51
|
'val mParticleOptions = MParticleOptions.builder(this)',
|
|
@@ -61,6 +63,13 @@ function generateKotlinInitCode(props) {
|
|
|
61
63
|
const versionParam = dataPlanVersion ? `, ${dataPlanVersion}` : '';
|
|
62
64
|
lines.push(` .dataplan("${dataPlanId}"${versionParam})`);
|
|
63
65
|
}
|
|
66
|
+
if (customBaseUrl) {
|
|
67
|
+
lines.push(' .networkOptions(');
|
|
68
|
+
lines.push(' NetworkOptions.builder()');
|
|
69
|
+
lines.push(` .setCustomBaseURL(${JSON.stringify(customBaseUrl)})`);
|
|
70
|
+
lines.push(' .build()');
|
|
71
|
+
lines.push(' )');
|
|
72
|
+
}
|
|
64
73
|
if (useEmptyIdentifyRequest) {
|
|
65
74
|
lines.push(' .identify(IdentityApiRequest.withEmptyUser().build())');
|
|
66
75
|
}
|
|
@@ -73,6 +82,7 @@ function generateKotlinInitCode(props) {
|
|
|
73
82
|
*/
|
|
74
83
|
function generateJavaInitCode(props) {
|
|
75
84
|
const { androidApiKey, androidApiSecret, logLevel, environment, useEmptyIdentifyRequest = true, dataPlanId, dataPlanVersion, } = props;
|
|
85
|
+
const customBaseUrl = (0, customBaseUrl_1.getCustomBaseUrl)(props);
|
|
76
86
|
const lines = [
|
|
77
87
|
'// mParticle SDK initialization',
|
|
78
88
|
'MParticleOptions.Builder optionsBuilder = MParticleOptions.builder(this)',
|
|
@@ -90,6 +100,13 @@ function generateJavaInitCode(props) {
|
|
|
90
100
|
const versionParam = dataPlanVersion ? `, ${dataPlanVersion}` : '';
|
|
91
101
|
lines.push(` .dataplan("${dataPlanId}"${versionParam})`);
|
|
92
102
|
}
|
|
103
|
+
if (customBaseUrl) {
|
|
104
|
+
lines.push(' .networkOptions(');
|
|
105
|
+
lines.push(' NetworkOptions.builder()');
|
|
106
|
+
lines.push(` .setCustomBaseURL(${JSON.stringify(customBaseUrl)})`);
|
|
107
|
+
lines.push(' .build()');
|
|
108
|
+
lines.push(' )');
|
|
109
|
+
}
|
|
93
110
|
if (useEmptyIdentifyRequest) {
|
|
94
111
|
lines.push(' .identify(IdentityApiRequest.withEmptyUser().build())');
|
|
95
112
|
}
|
|
@@ -101,18 +118,30 @@ function generateJavaInitCode(props) {
|
|
|
101
118
|
/**
|
|
102
119
|
* Generate mParticle import statements for Kotlin
|
|
103
120
|
*/
|
|
104
|
-
function getKotlinImports() {
|
|
105
|
-
|
|
106
|
-
import com.mparticle.
|
|
107
|
-
import com.mparticle.
|
|
121
|
+
function getKotlinImports(props) {
|
|
122
|
+
const imports = [
|
|
123
|
+
'import com.mparticle.MParticle',
|
|
124
|
+
'import com.mparticle.MParticleOptions',
|
|
125
|
+
'import com.mparticle.identity.IdentityApiRequest',
|
|
126
|
+
];
|
|
127
|
+
if ((0, customBaseUrl_1.getCustomBaseUrl)(props)) {
|
|
128
|
+
imports.push('import com.mparticle.networking.NetworkOptions');
|
|
129
|
+
}
|
|
130
|
+
return imports.join('\n');
|
|
108
131
|
}
|
|
109
132
|
/**
|
|
110
133
|
* Generate mParticle import statements for Java
|
|
111
134
|
*/
|
|
112
|
-
function getJavaImports() {
|
|
113
|
-
|
|
114
|
-
import com.mparticle.
|
|
115
|
-
import com.mparticle.
|
|
135
|
+
function getJavaImports(props) {
|
|
136
|
+
const imports = [
|
|
137
|
+
'import com.mparticle.MParticle;',
|
|
138
|
+
'import com.mparticle.MParticleOptions;',
|
|
139
|
+
'import com.mparticle.identity.IdentityApiRequest;',
|
|
140
|
+
];
|
|
141
|
+
if ((0, customBaseUrl_1.getCustomBaseUrl)(props)) {
|
|
142
|
+
imports.push('import com.mparticle.networking.NetworkOptions;');
|
|
143
|
+
}
|
|
144
|
+
return imports.join('\n');
|
|
116
145
|
}
|
|
117
146
|
/**
|
|
118
147
|
* Add mParticle configuration to MainApplication
|
|
@@ -147,7 +176,7 @@ function addMParticleToKotlinMainApplication(contents, props) {
|
|
|
147
176
|
// Add import statements using mergeContents
|
|
148
177
|
const withImports = (0, generateCode_1.mergeContents)({
|
|
149
178
|
src: contents,
|
|
150
|
-
newSrc: getKotlinImports(),
|
|
179
|
+
newSrc: getKotlinImports(props),
|
|
151
180
|
anchor: /^package .+$/m,
|
|
152
181
|
offset: 1,
|
|
153
182
|
tag: `${MPARTICLE_TAG}-import`,
|
|
@@ -189,7 +218,7 @@ function addMParticleToJavaMainApplication(contents, props) {
|
|
|
189
218
|
// Add import statements using mergeContents
|
|
190
219
|
const withImports = (0, generateCode_1.mergeContents)({
|
|
191
220
|
src: contents,
|
|
192
|
-
newSrc: getJavaImports(),
|
|
221
|
+
newSrc: getJavaImports(props),
|
|
193
222
|
anchor: /^package .+;$/m,
|
|
194
223
|
offset: 1,
|
|
195
224
|
tag: `${MPARTICLE_TAG}-import`,
|
|
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.withMParticleIOS = void 0;
|
|
27
27
|
const config_plugins_1 = require("@expo/config-plugins");
|
|
28
28
|
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
|
29
|
+
const customBaseUrl_1 = require("./customBaseUrl");
|
|
29
30
|
const fs = __importStar(require("fs"));
|
|
30
31
|
const path = __importStar(require("path"));
|
|
31
32
|
// Tag used for mergeContents to identify code blocks added by this plugin
|
|
@@ -125,6 +126,12 @@ function generateSwiftInitCode(props) {
|
|
|
125
126
|
lines.push('let identifyRequest = MPIdentityApiRequest.withEmptyUser()');
|
|
126
127
|
lines.push('mParticleOptions.identifyRequest = identifyRequest');
|
|
127
128
|
}
|
|
129
|
+
const customBaseUrl = (0, customBaseUrl_1.getCustomBaseUrl)(props);
|
|
130
|
+
if (customBaseUrl) {
|
|
131
|
+
lines.push('let networkOptions = MPNetworkOptions()');
|
|
132
|
+
lines.push(`networkOptions.customBaseURL = URL(string: ${JSON.stringify(customBaseUrl)})`);
|
|
133
|
+
lines.push('mParticleOptions.networkOptions = networkOptions');
|
|
134
|
+
}
|
|
128
135
|
lines.push('MParticle.sharedInstance().start(with: mParticleOptions)');
|
|
129
136
|
return lines.join('\n ');
|
|
130
137
|
}
|
|
@@ -156,6 +163,12 @@ function generateObjcInitCode(props) {
|
|
|
156
163
|
lines.push('MPIdentityApiRequest *identifyRequest = [MPIdentityApiRequest requestWithEmptyUser];');
|
|
157
164
|
lines.push('mParticleOptions.identifyRequest = identifyRequest;');
|
|
158
165
|
}
|
|
166
|
+
const customBaseUrl = (0, customBaseUrl_1.getCustomBaseUrl)(props);
|
|
167
|
+
if (customBaseUrl) {
|
|
168
|
+
lines.push('MPNetworkOptions *networkOptions = [[MPNetworkOptions alloc] init];');
|
|
169
|
+
lines.push(`networkOptions.customBaseURL = [NSURL URLWithString:@${JSON.stringify(customBaseUrl)}];`);
|
|
170
|
+
lines.push('mParticleOptions.networkOptions = networkOptions;');
|
|
171
|
+
}
|
|
159
172
|
lines.push('[[MParticle sharedInstance] startWithOptions:mParticleOptions];');
|
|
160
173
|
return lines.join('\n ');
|
|
161
174
|
}
|
|
@@ -283,6 +296,9 @@ const KIT_TRANSITIVE_DEPENDENCIES = {
|
|
|
283
296
|
// "mParticle-Amplitude": [],
|
|
284
297
|
// "mParticle-Braze": [],
|
|
285
298
|
};
|
|
299
|
+
const KIT_VERSION_REQUIREMENTS = {
|
|
300
|
+
'mParticle-Rokt': "'~> 9.2'",
|
|
301
|
+
};
|
|
286
302
|
/**
|
|
287
303
|
* Get all pods that need dynamic framework linking
|
|
288
304
|
*/
|
|
@@ -304,6 +320,12 @@ function getDynamicFrameworkPods(iosKits) {
|
|
|
304
320
|
}
|
|
305
321
|
return [...new Set(pods)]; // Remove duplicates
|
|
306
322
|
}
|
|
323
|
+
function getKitPodDeclaration(kit) {
|
|
324
|
+
const versionRequirement = KIT_VERSION_REQUIREMENTS[kit];
|
|
325
|
+
return versionRequirement
|
|
326
|
+
? ` pod '${kit}', ${versionRequirement}`
|
|
327
|
+
: ` pod '${kit}'`;
|
|
328
|
+
}
|
|
307
329
|
/**
|
|
308
330
|
* Add kit pods and pre_install hook to Podfile
|
|
309
331
|
*/
|
|
@@ -343,7 +365,7 @@ end
|
|
|
343
365
|
}
|
|
344
366
|
// Add kit pods if specified
|
|
345
367
|
if (props.iosKits && props.iosKits.length > 0) {
|
|
346
|
-
const kitPods = props.iosKits.map(
|
|
368
|
+
const kitPods = props.iosKits.map(getKitPodDeclaration).join('\n');
|
|
347
369
|
// Check if kits are already added
|
|
348
370
|
const kitsAlreadyAdded = props.iosKits.every(kit => podfileContent.includes(`pod '${kit}'`));
|
|
349
371
|
if (!kitsAlreadyAdded) {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface CustomBaseUrlProps {
|
|
2
|
+
customBaseUrl?: string;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function getCustomBaseUrl(props: CustomBaseUrlProps): string | null {
|
|
6
|
+
const customBaseUrl = props.customBaseUrl?.trim();
|
|
7
|
+
|
|
8
|
+
if (!customBaseUrl) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let parsedCustomBaseUrl: URL;
|
|
13
|
+
try {
|
|
14
|
+
parsedCustomBaseUrl = new URL(customBaseUrl);
|
|
15
|
+
} catch {
|
|
16
|
+
throw new Error(
|
|
17
|
+
'react-native-mparticle customBaseUrl must be a valid https URL'
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (
|
|
22
|
+
parsedCustomBaseUrl.protocol !== 'https:' ||
|
|
23
|
+
!parsedCustomBaseUrl.hostname
|
|
24
|
+
) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
'react-native-mparticle customBaseUrl must be a valid https URL'
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return customBaseUrl;
|
|
31
|
+
}
|
|
@@ -56,6 +56,13 @@ export interface MParticlePluginProps {
|
|
|
56
56
|
*/
|
|
57
57
|
iosKits?: string[];
|
|
58
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Custom base URL for global CNAME setup.
|
|
61
|
+
* This is applied before mParticle starts on iOS and Android.
|
|
62
|
+
* @example 'https://your-cname.example.com'
|
|
63
|
+
*/
|
|
64
|
+
customBaseUrl?: string;
|
|
65
|
+
|
|
59
66
|
/**
|
|
60
67
|
* Android kit artifact names to include (version auto-detected from core SDK)
|
|
61
68
|
* @example ['android-rokt-kit', 'android-amplitude-kit']
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from '@expo/config-plugins';
|
|
6
6
|
import { mergeContents } from '@expo/config-plugins/build/utils/generateCode';
|
|
7
7
|
import { MParticlePluginProps } from './withMParticle';
|
|
8
|
+
import { getCustomBaseUrl } from './customBaseUrl';
|
|
8
9
|
|
|
9
10
|
// Tag used for mergeContents to identify code blocks added by this plugin
|
|
10
11
|
const MPARTICLE_TAG = 'react-native-mparticle';
|
|
@@ -62,6 +63,7 @@ function generateKotlinInitCode(props: MParticlePluginProps): string {
|
|
|
62
63
|
dataPlanId,
|
|
63
64
|
dataPlanVersion,
|
|
64
65
|
} = props;
|
|
66
|
+
const customBaseUrl = getCustomBaseUrl(props);
|
|
65
67
|
|
|
66
68
|
const lines: string[] = [
|
|
67
69
|
'// mParticle SDK initialization',
|
|
@@ -84,6 +86,16 @@ function generateKotlinInitCode(props: MParticlePluginProps): string {
|
|
|
84
86
|
lines.push(` .dataplan("${dataPlanId}"${versionParam})`);
|
|
85
87
|
}
|
|
86
88
|
|
|
89
|
+
if (customBaseUrl) {
|
|
90
|
+
lines.push(' .networkOptions(');
|
|
91
|
+
lines.push(' NetworkOptions.builder()');
|
|
92
|
+
lines.push(
|
|
93
|
+
` .setCustomBaseURL(${JSON.stringify(customBaseUrl)})`
|
|
94
|
+
);
|
|
95
|
+
lines.push(' .build()');
|
|
96
|
+
lines.push(' )');
|
|
97
|
+
}
|
|
98
|
+
|
|
87
99
|
if (useEmptyIdentifyRequest) {
|
|
88
100
|
lines.push(' .identify(IdentityApiRequest.withEmptyUser().build())');
|
|
89
101
|
}
|
|
@@ -107,6 +119,7 @@ function generateJavaInitCode(props: MParticlePluginProps): string {
|
|
|
107
119
|
dataPlanId,
|
|
108
120
|
dataPlanVersion,
|
|
109
121
|
} = props;
|
|
122
|
+
const customBaseUrl = getCustomBaseUrl(props);
|
|
110
123
|
|
|
111
124
|
const lines: string[] = [
|
|
112
125
|
'// mParticle SDK initialization',
|
|
@@ -129,6 +142,16 @@ function generateJavaInitCode(props: MParticlePluginProps): string {
|
|
|
129
142
|
lines.push(` .dataplan("${dataPlanId}"${versionParam})`);
|
|
130
143
|
}
|
|
131
144
|
|
|
145
|
+
if (customBaseUrl) {
|
|
146
|
+
lines.push(' .networkOptions(');
|
|
147
|
+
lines.push(' NetworkOptions.builder()');
|
|
148
|
+
lines.push(
|
|
149
|
+
` .setCustomBaseURL(${JSON.stringify(customBaseUrl)})`
|
|
150
|
+
);
|
|
151
|
+
lines.push(' .build()');
|
|
152
|
+
lines.push(' )');
|
|
153
|
+
}
|
|
154
|
+
|
|
132
155
|
if (useEmptyIdentifyRequest) {
|
|
133
156
|
lines.push(' .identify(IdentityApiRequest.withEmptyUser().build())');
|
|
134
157
|
}
|
|
@@ -143,19 +166,35 @@ function generateJavaInitCode(props: MParticlePluginProps): string {
|
|
|
143
166
|
/**
|
|
144
167
|
* Generate mParticle import statements for Kotlin
|
|
145
168
|
*/
|
|
146
|
-
function getKotlinImports(): string {
|
|
147
|
-
|
|
148
|
-
import com.mparticle.
|
|
149
|
-
import com.mparticle.
|
|
169
|
+
function getKotlinImports(props: MParticlePluginProps): string {
|
|
170
|
+
const imports = [
|
|
171
|
+
'import com.mparticle.MParticle',
|
|
172
|
+
'import com.mparticle.MParticleOptions',
|
|
173
|
+
'import com.mparticle.identity.IdentityApiRequest',
|
|
174
|
+
];
|
|
175
|
+
|
|
176
|
+
if (getCustomBaseUrl(props)) {
|
|
177
|
+
imports.push('import com.mparticle.networking.NetworkOptions');
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return imports.join('\n');
|
|
150
181
|
}
|
|
151
182
|
|
|
152
183
|
/**
|
|
153
184
|
* Generate mParticle import statements for Java
|
|
154
185
|
*/
|
|
155
|
-
function getJavaImports(): string {
|
|
156
|
-
|
|
157
|
-
import com.mparticle.
|
|
158
|
-
import com.mparticle.
|
|
186
|
+
function getJavaImports(props: MParticlePluginProps): string {
|
|
187
|
+
const imports = [
|
|
188
|
+
'import com.mparticle.MParticle;',
|
|
189
|
+
'import com.mparticle.MParticleOptions;',
|
|
190
|
+
'import com.mparticle.identity.IdentityApiRequest;',
|
|
191
|
+
];
|
|
192
|
+
|
|
193
|
+
if (getCustomBaseUrl(props)) {
|
|
194
|
+
imports.push('import com.mparticle.networking.NetworkOptions;');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return imports.join('\n');
|
|
159
198
|
}
|
|
160
199
|
|
|
161
200
|
/**
|
|
@@ -210,7 +249,7 @@ function addMParticleToKotlinMainApplication(
|
|
|
210
249
|
// Add import statements using mergeContents
|
|
211
250
|
const withImports = mergeContents({
|
|
212
251
|
src: contents,
|
|
213
|
-
newSrc: getKotlinImports(),
|
|
252
|
+
newSrc: getKotlinImports(props),
|
|
214
253
|
anchor: /^package .+$/m,
|
|
215
254
|
offset: 1, // Add after package declaration
|
|
216
255
|
tag: `${MPARTICLE_TAG}-import`,
|
|
@@ -261,7 +300,7 @@ function addMParticleToJavaMainApplication(
|
|
|
261
300
|
// Add import statements using mergeContents
|
|
262
301
|
const withImports = mergeContents({
|
|
263
302
|
src: contents,
|
|
264
|
-
newSrc: getJavaImports(),
|
|
303
|
+
newSrc: getJavaImports(props),
|
|
265
304
|
anchor: /^package .+;$/m,
|
|
266
305
|
offset: 1, // Add after package declaration
|
|
267
306
|
tag: `${MPARTICLE_TAG}-import`,
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from '@expo/config-plugins';
|
|
6
6
|
import { mergeContents } from '@expo/config-plugins/build/utils/generateCode';
|
|
7
7
|
import { MParticlePluginProps } from './withMParticle';
|
|
8
|
+
import { getCustomBaseUrl } from './customBaseUrl';
|
|
8
9
|
import * as fs from 'fs';
|
|
9
10
|
import * as path from 'path';
|
|
10
11
|
|
|
@@ -134,6 +135,17 @@ function generateSwiftInitCode(props: MParticlePluginProps): string {
|
|
|
134
135
|
lines.push('mParticleOptions.identifyRequest = identifyRequest');
|
|
135
136
|
}
|
|
136
137
|
|
|
138
|
+
const customBaseUrl = getCustomBaseUrl(props);
|
|
139
|
+
if (customBaseUrl) {
|
|
140
|
+
lines.push('let networkOptions = MPNetworkOptions()');
|
|
141
|
+
lines.push(
|
|
142
|
+
`networkOptions.customBaseURL = URL(string: ${JSON.stringify(
|
|
143
|
+
customBaseUrl
|
|
144
|
+
)})`
|
|
145
|
+
);
|
|
146
|
+
lines.push('mParticleOptions.networkOptions = networkOptions');
|
|
147
|
+
}
|
|
148
|
+
|
|
137
149
|
lines.push('MParticle.sharedInstance().start(with: mParticleOptions)');
|
|
138
150
|
|
|
139
151
|
return lines.join('\n ');
|
|
@@ -183,6 +195,19 @@ function generateObjcInitCode(props: MParticlePluginProps): string {
|
|
|
183
195
|
lines.push('mParticleOptions.identifyRequest = identifyRequest;');
|
|
184
196
|
}
|
|
185
197
|
|
|
198
|
+
const customBaseUrl = getCustomBaseUrl(props);
|
|
199
|
+
if (customBaseUrl) {
|
|
200
|
+
lines.push(
|
|
201
|
+
'MPNetworkOptions *networkOptions = [[MPNetworkOptions alloc] init];'
|
|
202
|
+
);
|
|
203
|
+
lines.push(
|
|
204
|
+
`networkOptions.customBaseURL = [NSURL URLWithString:@${JSON.stringify(
|
|
205
|
+
customBaseUrl
|
|
206
|
+
)}];`
|
|
207
|
+
);
|
|
208
|
+
lines.push('mParticleOptions.networkOptions = networkOptions;');
|
|
209
|
+
}
|
|
210
|
+
|
|
186
211
|
lines.push('[[MParticle sharedInstance] startWithOptions:mParticleOptions];');
|
|
187
212
|
|
|
188
213
|
return lines.join('\n ');
|
|
@@ -349,6 +374,10 @@ const KIT_TRANSITIVE_DEPENDENCIES: Record<string, string[]> = {
|
|
|
349
374
|
// "mParticle-Braze": [],
|
|
350
375
|
};
|
|
351
376
|
|
|
377
|
+
const KIT_VERSION_REQUIREMENTS: Record<string, string> = {
|
|
378
|
+
'mParticle-Rokt': "'~> 9.2'",
|
|
379
|
+
};
|
|
380
|
+
|
|
352
381
|
/**
|
|
353
382
|
* Get all pods that need dynamic framework linking
|
|
354
383
|
*/
|
|
@@ -373,6 +402,13 @@ function getDynamicFrameworkPods(iosKits?: string[]): string[] {
|
|
|
373
402
|
return [...new Set(pods)]; // Remove duplicates
|
|
374
403
|
}
|
|
375
404
|
|
|
405
|
+
function getKitPodDeclaration(kit: string): string {
|
|
406
|
+
const versionRequirement = KIT_VERSION_REQUIREMENTS[kit];
|
|
407
|
+
return versionRequirement
|
|
408
|
+
? ` pod '${kit}', ${versionRequirement}`
|
|
409
|
+
: ` pod '${kit}'`;
|
|
410
|
+
}
|
|
411
|
+
|
|
376
412
|
/**
|
|
377
413
|
* Add kit pods and pre_install hook to Podfile
|
|
378
414
|
*/
|
|
@@ -427,7 +463,7 @@ end
|
|
|
427
463
|
|
|
428
464
|
// Add kit pods if specified
|
|
429
465
|
if (props.iosKits && props.iosKits.length > 0) {
|
|
430
|
-
const kitPods = props.iosKits.map(
|
|
466
|
+
const kitPods = props.iosKits.map(getKitPodDeclaration).join('\n');
|
|
431
467
|
|
|
432
468
|
// Check if kits are already added
|
|
433
469
|
const kitsAlreadyAdded = props.iosKits.every(kit =>
|