react-native-mparticle 2.9.2 → 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/README.md +51 -4
- package/android/build.gradle +2 -2
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/mparticle/react/rokt/MPRoktModuleImpl.kt +27 -0
- package/android/src/newarch/java/com/mparticle/react/rokt/MPRoktModule.kt +30 -4
- package/android/src/oldarch/java/com/mparticle/react/NativeMPRoktSpec.kt +16 -0
- package/android/src/oldarch/java/com/mparticle/react/rokt/MPRoktModule.kt +28 -0
- package/ios/RNMParticle/RNMPRokt.mm +138 -91
- package/ios/RNMParticle/RNMParticle.mm +18 -24
- package/ios/RNMParticle/RoktEventManager.h +3 -2
- package/ios/RNMParticle/RoktEventManager.m +71 -33
- package/ios/RNMParticle/RoktLayoutManager.m +7 -2
- package/ios/RNMParticle/RoktNativeLayoutComponentView.h +11 -2
- package/ios/RNMParticle/RoktNativeLayoutComponentView.mm +2 -2
- package/js/codegenSpecs/NativeMParticle.ts +1 -4
- package/js/codegenSpecs/rokt/NativeMPRokt.ts +12 -0
- package/js/rokt/rokt.ts +20 -0
- package/lib/codegenSpecs/NativeMParticle.js.map +1 -1
- package/lib/codegenSpecs/rokt/NativeMPRokt.d.ts +6 -0
- package/lib/codegenSpecs/rokt/NativeMPRokt.js.map +1 -1
- package/lib/rokt/rokt.d.ts +4 -0
- package/lib/rokt/rokt.js +12 -0
- package/lib/rokt/rokt.js.map +1 -1
- package/package.json +5 -3
- 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 +34 -3
- 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 +48 -3
- package/react-native-mparticle.podspec +4 -3
|
@@ -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
|
}
|
|
@@ -273,16 +286,28 @@ function addMParticleToObjcAppDelegate(contents, props) {
|
|
|
273
286
|
* These are dependencies of mParticle kits that must also be dynamic frameworks
|
|
274
287
|
*/
|
|
275
288
|
const KIT_TRANSITIVE_DEPENDENCIES = {
|
|
276
|
-
'mParticle-Rokt': [
|
|
289
|
+
'mParticle-Rokt': [
|
|
290
|
+
'Rokt-Widget',
|
|
291
|
+
'RoktContracts',
|
|
292
|
+
'RoktUXHelper',
|
|
293
|
+
'DcuiSchema',
|
|
294
|
+
],
|
|
277
295
|
// Add other kit dependencies here as needed
|
|
278
296
|
// "mParticle-Amplitude": [],
|
|
279
297
|
// "mParticle-Braze": [],
|
|
280
298
|
};
|
|
299
|
+
const KIT_VERSION_REQUIREMENTS = {
|
|
300
|
+
'mParticle-Rokt': "'~> 9.2'",
|
|
301
|
+
};
|
|
281
302
|
/**
|
|
282
303
|
* Get all pods that need dynamic framework linking
|
|
283
304
|
*/
|
|
284
305
|
function getDynamicFrameworkPods(iosKits) {
|
|
285
|
-
const pods = [
|
|
306
|
+
const pods = [
|
|
307
|
+
'mParticle-Apple-SDK',
|
|
308
|
+
'mParticle-Apple-SDK-ObjC',
|
|
309
|
+
'mParticle-Apple-SDK-Swift',
|
|
310
|
+
];
|
|
286
311
|
if (iosKits) {
|
|
287
312
|
for (const kit of iosKits) {
|
|
288
313
|
pods.push(kit);
|
|
@@ -295,6 +320,12 @@ function getDynamicFrameworkPods(iosKits) {
|
|
|
295
320
|
}
|
|
296
321
|
return [...new Set(pods)]; // Remove duplicates
|
|
297
322
|
}
|
|
323
|
+
function getKitPodDeclaration(kit) {
|
|
324
|
+
const versionRequirement = KIT_VERSION_REQUIREMENTS[kit];
|
|
325
|
+
return versionRequirement
|
|
326
|
+
? ` pod '${kit}', ${versionRequirement}`
|
|
327
|
+
: ` pod '${kit}'`;
|
|
328
|
+
}
|
|
298
329
|
/**
|
|
299
330
|
* Add kit pods and pre_install hook to Podfile
|
|
300
331
|
*/
|
|
@@ -334,7 +365,7 @@ end
|
|
|
334
365
|
}
|
|
335
366
|
// Add kit pods if specified
|
|
336
367
|
if (props.iosKits && props.iosKits.length > 0) {
|
|
337
|
-
const kitPods = props.iosKits.map(
|
|
368
|
+
const kitPods = props.iosKits.map(getKitPodDeclaration).join('\n');
|
|
338
369
|
// Check if kits are already added
|
|
339
370
|
const kitsAlreadyAdded = props.iosKits.every(kit => podfileContent.includes(`pod '${kit}'`));
|
|
340
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 ');
|
|
@@ -338,17 +363,30 @@ function addMParticleToObjcAppDelegate(
|
|
|
338
363
|
* These are dependencies of mParticle kits that must also be dynamic frameworks
|
|
339
364
|
*/
|
|
340
365
|
const KIT_TRANSITIVE_DEPENDENCIES: Record<string, string[]> = {
|
|
341
|
-
'mParticle-Rokt': [
|
|
366
|
+
'mParticle-Rokt': [
|
|
367
|
+
'Rokt-Widget',
|
|
368
|
+
'RoktContracts',
|
|
369
|
+
'RoktUXHelper',
|
|
370
|
+
'DcuiSchema',
|
|
371
|
+
],
|
|
342
372
|
// Add other kit dependencies here as needed
|
|
343
373
|
// "mParticle-Amplitude": [],
|
|
344
374
|
// "mParticle-Braze": [],
|
|
345
375
|
};
|
|
346
376
|
|
|
377
|
+
const KIT_VERSION_REQUIREMENTS: Record<string, string> = {
|
|
378
|
+
'mParticle-Rokt': "'~> 9.2'",
|
|
379
|
+
};
|
|
380
|
+
|
|
347
381
|
/**
|
|
348
382
|
* Get all pods that need dynamic framework linking
|
|
349
383
|
*/
|
|
350
384
|
function getDynamicFrameworkPods(iosKits?: string[]): string[] {
|
|
351
|
-
const pods = [
|
|
385
|
+
const pods = [
|
|
386
|
+
'mParticle-Apple-SDK',
|
|
387
|
+
'mParticle-Apple-SDK-ObjC',
|
|
388
|
+
'mParticle-Apple-SDK-Swift',
|
|
389
|
+
];
|
|
352
390
|
|
|
353
391
|
if (iosKits) {
|
|
354
392
|
for (const kit of iosKits) {
|
|
@@ -364,6 +402,13 @@ function getDynamicFrameworkPods(iosKits?: string[]): string[] {
|
|
|
364
402
|
return [...new Set(pods)]; // Remove duplicates
|
|
365
403
|
}
|
|
366
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
|
+
|
|
367
412
|
/**
|
|
368
413
|
* Add kit pods and pre_install hook to Podfile
|
|
369
414
|
*/
|
|
@@ -418,7 +463,7 @@ end
|
|
|
418
463
|
|
|
419
464
|
// Add kit pods if specified
|
|
420
465
|
if (props.iosKits && props.iosKits.length > 0) {
|
|
421
|
-
const kitPods = props.iosKits.map(
|
|
466
|
+
const kitPods = props.iosKits.map(getKitPodDeclaration).join('\n');
|
|
422
467
|
|
|
423
468
|
// Check if kits are already added
|
|
424
469
|
const kitsAlreadyAdded = props.iosKits.every(kit =>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'json'
|
|
2
2
|
|
|
3
3
|
new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
|
|
4
|
-
ios_platform =
|
|
4
|
+
ios_platform = '15.6'
|
|
5
5
|
|
|
6
6
|
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
7
7
|
|
|
@@ -14,7 +14,7 @@ Pod::Spec.new do |s|
|
|
|
14
14
|
|
|
15
15
|
s.homepage = package['homepage']
|
|
16
16
|
s.license = package['license']
|
|
17
|
-
s.platforms = { :ios => ios_platform, :tvos => "
|
|
17
|
+
s.platforms = { :ios => ios_platform, :tvos => "15.6" }
|
|
18
18
|
|
|
19
19
|
s.source = { :git => "https://github.com/mParticle/react-native-mparticle.git", :tag => "#{s.version}" }
|
|
20
20
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
@@ -25,5 +25,6 @@ Pod::Spec.new do |s|
|
|
|
25
25
|
s.dependency "React-Core"
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
s.dependency 'mParticle-Apple-SDK', '~>
|
|
28
|
+
s.dependency 'mParticle-Apple-SDK-ObjC', '~> 9.2'
|
|
29
|
+
s.dependency 'RoktContracts', '~> 2.0'
|
|
29
30
|
end
|