react-native-mparticle 3.1.1 → 3.1.3
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 +17 -16
- package/package.json +1 -1
- package/plugin/build/withMParticle.d.ts +8 -0
- package/plugin/build/withMParticleAndroid.js +26 -8
- package/plugin/build/withMParticleIOS.js +16 -4
- package/plugin/src/withMParticle.ts +9 -0
- package/plugin/src/withMParticleAndroid.ts +31 -12
- package/plugin/src/withMParticleIOS.ts +24 -12
package/README.md
CHANGED
|
@@ -71,20 +71,21 @@ npx expo run:android
|
|
|
71
71
|
|
|
72
72
|
### Plugin Configuration Options
|
|
73
73
|
|
|
74
|
-
| Option | Type | Required | Description
|
|
75
|
-
| ------------------------- | -------- | -------- |
|
|
76
|
-
| `iosApiKey` | string | Yes | iOS API key from mParticle dashboard
|
|
77
|
-
| `iosApiSecret` | string | Yes | iOS API secret from mParticle dashboard
|
|
78
|
-
| `androidApiKey` | string | Yes | Android API key from mParticle dashboard
|
|
79
|
-
| `androidApiSecret` | string | Yes | Android API secret from mParticle dashboard
|
|
80
|
-
| `logLevel` | string | No | Log level: `'none'`, `'error'`, `'warning'`, `'debug'`, `'verbose'`
|
|
81
|
-
| `environment` | string | No | Environment: `'development'`, `'production'`, `'autoDetect'`
|
|
82
|
-
| `dataPlanId` | string | No | Data plan ID for validation
|
|
83
|
-
| `dataPlanVersion` | number | No | Data plan version
|
|
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
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
74
|
+
| Option | Type | Required | Description |
|
|
75
|
+
| ------------------------- | -------- | -------- | --------------------------------------------------------------------------------------------- |
|
|
76
|
+
| `iosApiKey` | string | Yes | iOS API key from mParticle dashboard |
|
|
77
|
+
| `iosApiSecret` | string | Yes | iOS API secret from mParticle dashboard |
|
|
78
|
+
| `androidApiKey` | string | Yes | Android API key from mParticle dashboard |
|
|
79
|
+
| `androidApiSecret` | string | Yes | Android API secret from mParticle dashboard |
|
|
80
|
+
| `logLevel` | string | No | Log level: `'none'`, `'error'`, `'warning'`, `'debug'`, `'verbose'` |
|
|
81
|
+
| `environment` | string | No | Environment: `'development'`, `'production'`, `'autoDetect'` |
|
|
82
|
+
| `dataPlanId` | string | No | Data plan ID for validation |
|
|
83
|
+
| `dataPlanVersion` | number | No | Data plan version |
|
|
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 |
|
|
86
|
+
| `pinningDisabled` | boolean | No | Disable SSL pinning (`MPNetworkOptions` on iOS; `setPinningDisabledInDevelopment` on Android) |
|
|
87
|
+
| `androidKits` | string[] | No | Android kit artifact names (e.g., `['android-rokt-kit']`) |
|
|
88
|
+
| `useEmptyIdentifyRequest` | boolean | No | Use empty user identify request at init (default: `true`) |
|
|
88
89
|
|
|
89
90
|
### Example with Kits
|
|
90
91
|
|
|
@@ -123,14 +124,14 @@ For global CNAME setup, add the optional shared `customBaseUrl` setting:
|
|
|
123
124
|
**iOS:**
|
|
124
125
|
|
|
125
126
|
- Adds mParticle SDK initialization to `AppDelegate` (supports both Swift and Objective-C)
|
|
126
|
-
- Sets `MPNetworkOptions
|
|
127
|
+
- Sets `MPNetworkOptions` (`customBaseURL` and/or `pinningDisabled`) before startup when those plugin options are configured
|
|
127
128
|
- Configures `pre_install` hook in Podfile for dynamic framework linking
|
|
128
129
|
- Adds specified kit pod dependencies
|
|
129
130
|
|
|
130
131
|
**Android:**
|
|
131
132
|
|
|
132
133
|
- Adds mParticle SDK initialization to `MainApplication` (supports both Kotlin and Java)
|
|
133
|
-
- Sets `NetworkOptions
|
|
134
|
+
- Sets `NetworkOptions` (`setCustomBaseURL` and/or `setPinningDisabledInDevelopment`) before startup when those plugin options are configured
|
|
134
135
|
- Adds specified kit Maven dependencies to `build.gradle`
|
|
135
136
|
|
|
136
137
|
### Version Support
|
package/package.json
CHANGED
|
@@ -48,6 +48,14 @@ export interface MParticlePluginProps {
|
|
|
48
48
|
* @example 'https://your-cname.example.com'
|
|
49
49
|
*/
|
|
50
50
|
customBaseUrl?: string;
|
|
51
|
+
/**
|
|
52
|
+
* When true, disables SSL certificate pinning for mParticle network traffic.
|
|
53
|
+
*
|
|
54
|
+
* - **iOS:** Sets `MPNetworkOptions.pinningDisabled` before startup.
|
|
55
|
+
* - **Android:** Sets `NetworkOptions.Builder.setPinningDisabledInDevelopment(true)`
|
|
56
|
+
* (mParticle's Android API for proxy/debug builds; see Android SDK docs).
|
|
57
|
+
*/
|
|
58
|
+
pinningDisabled?: boolean;
|
|
51
59
|
/**
|
|
52
60
|
* Android kit artifact names to include (version auto-detected from core SDK)
|
|
53
61
|
* @example ['android-rokt-kit', 'android-amplitude-kit']
|
|
@@ -6,6 +6,9 @@ const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
|
|
6
6
|
const customBaseUrl_1 = require("./customBaseUrl");
|
|
7
7
|
// Tag used for mergeContents to identify code blocks added by this plugin
|
|
8
8
|
const MPARTICLE_TAG = 'react-native-mparticle';
|
|
9
|
+
function shouldEmitNetworkOptions(props) {
|
|
10
|
+
return Boolean((0, customBaseUrl_1.getCustomBaseUrl)(props) || props.pinningDisabled === true);
|
|
11
|
+
}
|
|
9
12
|
/**
|
|
10
13
|
* Get the mParticle log level string for Android
|
|
11
14
|
*/
|
|
@@ -46,6 +49,7 @@ function getAndroidEnvironment(environment) {
|
|
|
46
49
|
function generateKotlinInitCode(props) {
|
|
47
50
|
const { androidApiKey, androidApiSecret, logLevel, environment, useEmptyIdentifyRequest = true, dataPlanId, dataPlanVersion, } = props;
|
|
48
51
|
const customBaseUrl = (0, customBaseUrl_1.getCustomBaseUrl)(props);
|
|
52
|
+
const pinningDisabled = props.pinningDisabled === true;
|
|
49
53
|
const lines = [
|
|
50
54
|
'// mParticle SDK initialization',
|
|
51
55
|
'val mParticleOptions = MParticleOptions.builder(this)',
|
|
@@ -63,10 +67,15 @@ function generateKotlinInitCode(props) {
|
|
|
63
67
|
const versionParam = dataPlanVersion ? `, ${dataPlanVersion}` : '';
|
|
64
68
|
lines.push(` .dataplan("${dataPlanId}"${versionParam})`);
|
|
65
69
|
}
|
|
66
|
-
if (
|
|
70
|
+
if (shouldEmitNetworkOptions(props)) {
|
|
67
71
|
lines.push(' .networkOptions(');
|
|
68
72
|
lines.push(' NetworkOptions.builder()');
|
|
69
|
-
|
|
73
|
+
if (customBaseUrl) {
|
|
74
|
+
lines.push(` .setCustomBaseURL(${JSON.stringify(customBaseUrl)})`);
|
|
75
|
+
}
|
|
76
|
+
if (pinningDisabled) {
|
|
77
|
+
lines.push(' .setPinningDisabledInDevelopment(true)');
|
|
78
|
+
}
|
|
70
79
|
lines.push(' .build()');
|
|
71
80
|
lines.push(' )');
|
|
72
81
|
}
|
|
@@ -83,6 +92,7 @@ function generateKotlinInitCode(props) {
|
|
|
83
92
|
function generateJavaInitCode(props) {
|
|
84
93
|
const { androidApiKey, androidApiSecret, logLevel, environment, useEmptyIdentifyRequest = true, dataPlanId, dataPlanVersion, } = props;
|
|
85
94
|
const customBaseUrl = (0, customBaseUrl_1.getCustomBaseUrl)(props);
|
|
95
|
+
const pinningDisabled = props.pinningDisabled === true;
|
|
86
96
|
const lines = [
|
|
87
97
|
'// mParticle SDK initialization',
|
|
88
98
|
'MParticleOptions.Builder optionsBuilder = MParticleOptions.builder(this)',
|
|
@@ -100,10 +110,15 @@ function generateJavaInitCode(props) {
|
|
|
100
110
|
const versionParam = dataPlanVersion ? `, ${dataPlanVersion}` : '';
|
|
101
111
|
lines.push(` .dataplan("${dataPlanId}"${versionParam})`);
|
|
102
112
|
}
|
|
103
|
-
if (
|
|
113
|
+
if (shouldEmitNetworkOptions(props)) {
|
|
104
114
|
lines.push(' .networkOptions(');
|
|
105
115
|
lines.push(' NetworkOptions.builder()');
|
|
106
|
-
|
|
116
|
+
if (customBaseUrl) {
|
|
117
|
+
lines.push(` .setCustomBaseURL(${JSON.stringify(customBaseUrl)})`);
|
|
118
|
+
}
|
|
119
|
+
if (pinningDisabled) {
|
|
120
|
+
lines.push(' .setPinningDisabledInDevelopment(true)');
|
|
121
|
+
}
|
|
107
122
|
lines.push(' .build()');
|
|
108
123
|
lines.push(' )');
|
|
109
124
|
}
|
|
@@ -124,7 +139,7 @@ function getKotlinImports(props) {
|
|
|
124
139
|
'import com.mparticle.MParticleOptions',
|
|
125
140
|
'import com.mparticle.identity.IdentityApiRequest',
|
|
126
141
|
];
|
|
127
|
-
if ((
|
|
142
|
+
if (shouldEmitNetworkOptions(props)) {
|
|
128
143
|
imports.push('import com.mparticle.networking.NetworkOptions');
|
|
129
144
|
}
|
|
130
145
|
return imports.join('\n');
|
|
@@ -138,7 +153,7 @@ function getJavaImports(props) {
|
|
|
138
153
|
'import com.mparticle.MParticleOptions;',
|
|
139
154
|
'import com.mparticle.identity.IdentityApiRequest;',
|
|
140
155
|
];
|
|
141
|
-
if ((
|
|
156
|
+
if (shouldEmitNetworkOptions(props)) {
|
|
142
157
|
imports.push('import com.mparticle.networking.NetworkOptions;');
|
|
143
158
|
}
|
|
144
159
|
return imports.join('\n');
|
|
@@ -267,9 +282,12 @@ const withMParticleAppBuildGradle = (config, props) => {
|
|
|
267
282
|
return config;
|
|
268
283
|
}
|
|
269
284
|
// Generate kit dependency lines
|
|
270
|
-
//
|
|
285
|
+
// Bounded range matches the core SDK range in android/build.gradle so the
|
|
286
|
+
// kit and core stay paired on a 5.x line. An unbounded `+` would resolve
|
|
287
|
+
// to a pre-release (e.g. 6.0.0-rc.1) and transitively drag the core past
|
|
288
|
+
// the bridge's compiled-against API surface.
|
|
271
289
|
const kitDependencies = props.androidKits
|
|
272
|
-
.map(kit => ` implementation "com.mparticle:${kit}
|
|
290
|
+
.map(kit => ` implementation "com.mparticle:${kit}:[5.79.0, 6.0)"`)
|
|
273
291
|
.join('\n');
|
|
274
292
|
// Use mergeContents for idempotent injection
|
|
275
293
|
const withKits = (0, generateCode_1.mergeContents)({
|
|
@@ -127,9 +127,15 @@ function generateSwiftInitCode(props) {
|
|
|
127
127
|
lines.push('mParticleOptions.identifyRequest = identifyRequest');
|
|
128
128
|
}
|
|
129
129
|
const customBaseUrl = (0, customBaseUrl_1.getCustomBaseUrl)(props);
|
|
130
|
-
|
|
130
|
+
const pinningDisabled = props.pinningDisabled === true;
|
|
131
|
+
if (customBaseUrl || pinningDisabled) {
|
|
131
132
|
lines.push('let networkOptions = MPNetworkOptions()');
|
|
132
|
-
|
|
133
|
+
if (customBaseUrl) {
|
|
134
|
+
lines.push(`networkOptions.customBaseURL = URL(string: ${JSON.stringify(customBaseUrl)})`);
|
|
135
|
+
}
|
|
136
|
+
if (pinningDisabled) {
|
|
137
|
+
lines.push('networkOptions.pinningDisabled = true');
|
|
138
|
+
}
|
|
133
139
|
lines.push('mParticleOptions.networkOptions = networkOptions');
|
|
134
140
|
}
|
|
135
141
|
lines.push('MParticle.sharedInstance().start(with: mParticleOptions)');
|
|
@@ -164,9 +170,15 @@ function generateObjcInitCode(props) {
|
|
|
164
170
|
lines.push('mParticleOptions.identifyRequest = identifyRequest;');
|
|
165
171
|
}
|
|
166
172
|
const customBaseUrl = (0, customBaseUrl_1.getCustomBaseUrl)(props);
|
|
167
|
-
|
|
173
|
+
const pinningDisabled = props.pinningDisabled === true;
|
|
174
|
+
if (customBaseUrl || pinningDisabled) {
|
|
168
175
|
lines.push('MPNetworkOptions *networkOptions = [[MPNetworkOptions alloc] init];');
|
|
169
|
-
|
|
176
|
+
if (customBaseUrl) {
|
|
177
|
+
lines.push(`networkOptions.customBaseURL = [NSURL URLWithString:@${JSON.stringify(customBaseUrl)}];`);
|
|
178
|
+
}
|
|
179
|
+
if (pinningDisabled) {
|
|
180
|
+
lines.push('networkOptions.pinningDisabled = YES;');
|
|
181
|
+
}
|
|
170
182
|
lines.push('mParticleOptions.networkOptions = networkOptions;');
|
|
171
183
|
}
|
|
172
184
|
lines.push('[[MParticle sharedInstance] startWithOptions:mParticleOptions];');
|
|
@@ -63,6 +63,15 @@ export interface MParticlePluginProps {
|
|
|
63
63
|
*/
|
|
64
64
|
customBaseUrl?: string;
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* When true, disables SSL certificate pinning for mParticle network traffic.
|
|
68
|
+
*
|
|
69
|
+
* - **iOS:** Sets `MPNetworkOptions.pinningDisabled` before startup.
|
|
70
|
+
* - **Android:** Sets `NetworkOptions.Builder.setPinningDisabledInDevelopment(true)`
|
|
71
|
+
* (mParticle's Android API for proxy/debug builds; see Android SDK docs).
|
|
72
|
+
*/
|
|
73
|
+
pinningDisabled?: boolean;
|
|
74
|
+
|
|
66
75
|
/**
|
|
67
76
|
* Android kit artifact names to include (version auto-detected from core SDK)
|
|
68
77
|
* @example ['android-rokt-kit', 'android-amplitude-kit']
|
|
@@ -10,6 +10,10 @@ import { getCustomBaseUrl } from './customBaseUrl';
|
|
|
10
10
|
// Tag used for mergeContents to identify code blocks added by this plugin
|
|
11
11
|
const MPARTICLE_TAG = 'react-native-mparticle';
|
|
12
12
|
|
|
13
|
+
function shouldEmitNetworkOptions(props: MParticlePluginProps): boolean {
|
|
14
|
+
return Boolean(getCustomBaseUrl(props) || props.pinningDisabled === true);
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
/**
|
|
14
18
|
* Get the mParticle log level string for Android
|
|
15
19
|
*/
|
|
@@ -64,6 +68,7 @@ function generateKotlinInitCode(props: MParticlePluginProps): string {
|
|
|
64
68
|
dataPlanVersion,
|
|
65
69
|
} = props;
|
|
66
70
|
const customBaseUrl = getCustomBaseUrl(props);
|
|
71
|
+
const pinningDisabled = props.pinningDisabled === true;
|
|
67
72
|
|
|
68
73
|
const lines: string[] = [
|
|
69
74
|
'// mParticle SDK initialization',
|
|
@@ -86,12 +91,17 @@ function generateKotlinInitCode(props: MParticlePluginProps): string {
|
|
|
86
91
|
lines.push(` .dataplan("${dataPlanId}"${versionParam})`);
|
|
87
92
|
}
|
|
88
93
|
|
|
89
|
-
if (
|
|
94
|
+
if (shouldEmitNetworkOptions(props)) {
|
|
90
95
|
lines.push(' .networkOptions(');
|
|
91
96
|
lines.push(' NetworkOptions.builder()');
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
97
|
+
if (customBaseUrl) {
|
|
98
|
+
lines.push(
|
|
99
|
+
` .setCustomBaseURL(${JSON.stringify(customBaseUrl)})`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
if (pinningDisabled) {
|
|
103
|
+
lines.push(' .setPinningDisabledInDevelopment(true)');
|
|
104
|
+
}
|
|
95
105
|
lines.push(' .build()');
|
|
96
106
|
lines.push(' )');
|
|
97
107
|
}
|
|
@@ -120,6 +130,7 @@ function generateJavaInitCode(props: MParticlePluginProps): string {
|
|
|
120
130
|
dataPlanVersion,
|
|
121
131
|
} = props;
|
|
122
132
|
const customBaseUrl = getCustomBaseUrl(props);
|
|
133
|
+
const pinningDisabled = props.pinningDisabled === true;
|
|
123
134
|
|
|
124
135
|
const lines: string[] = [
|
|
125
136
|
'// mParticle SDK initialization',
|
|
@@ -142,12 +153,17 @@ function generateJavaInitCode(props: MParticlePluginProps): string {
|
|
|
142
153
|
lines.push(` .dataplan("${dataPlanId}"${versionParam})`);
|
|
143
154
|
}
|
|
144
155
|
|
|
145
|
-
if (
|
|
156
|
+
if (shouldEmitNetworkOptions(props)) {
|
|
146
157
|
lines.push(' .networkOptions(');
|
|
147
158
|
lines.push(' NetworkOptions.builder()');
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
159
|
+
if (customBaseUrl) {
|
|
160
|
+
lines.push(
|
|
161
|
+
` .setCustomBaseURL(${JSON.stringify(customBaseUrl)})`
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
if (pinningDisabled) {
|
|
165
|
+
lines.push(' .setPinningDisabledInDevelopment(true)');
|
|
166
|
+
}
|
|
151
167
|
lines.push(' .build()');
|
|
152
168
|
lines.push(' )');
|
|
153
169
|
}
|
|
@@ -173,7 +189,7 @@ function getKotlinImports(props: MParticlePluginProps): string {
|
|
|
173
189
|
'import com.mparticle.identity.IdentityApiRequest',
|
|
174
190
|
];
|
|
175
191
|
|
|
176
|
-
if (
|
|
192
|
+
if (shouldEmitNetworkOptions(props)) {
|
|
177
193
|
imports.push('import com.mparticle.networking.NetworkOptions');
|
|
178
194
|
}
|
|
179
195
|
|
|
@@ -190,7 +206,7 @@ function getJavaImports(props: MParticlePluginProps): string {
|
|
|
190
206
|
'import com.mparticle.identity.IdentityApiRequest;',
|
|
191
207
|
];
|
|
192
208
|
|
|
193
|
-
if (
|
|
209
|
+
if (shouldEmitNetworkOptions(props)) {
|
|
194
210
|
imports.push('import com.mparticle.networking.NetworkOptions;');
|
|
195
211
|
}
|
|
196
212
|
|
|
@@ -364,9 +380,12 @@ const withMParticleAppBuildGradle: ConfigPlugin<MParticlePluginProps> = (
|
|
|
364
380
|
}
|
|
365
381
|
|
|
366
382
|
// Generate kit dependency lines
|
|
367
|
-
//
|
|
383
|
+
// Bounded range matches the core SDK range in android/build.gradle so the
|
|
384
|
+
// kit and core stay paired on a 5.x line. An unbounded `+` would resolve
|
|
385
|
+
// to a pre-release (e.g. 6.0.0-rc.1) and transitively drag the core past
|
|
386
|
+
// the bridge's compiled-against API surface.
|
|
368
387
|
const kitDependencies = props.androidKits
|
|
369
|
-
.map(kit => ` implementation "com.mparticle:${kit}
|
|
388
|
+
.map(kit => ` implementation "com.mparticle:${kit}:[5.79.0, 6.0)"`)
|
|
370
389
|
.join('\n');
|
|
371
390
|
|
|
372
391
|
// Use mergeContents for idempotent injection
|
|
@@ -136,13 +136,19 @@ function generateSwiftInitCode(props: MParticlePluginProps): string {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
const customBaseUrl = getCustomBaseUrl(props);
|
|
139
|
-
|
|
139
|
+
const pinningDisabled = props.pinningDisabled === true;
|
|
140
|
+
if (customBaseUrl || pinningDisabled) {
|
|
140
141
|
lines.push('let networkOptions = MPNetworkOptions()');
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
if (customBaseUrl) {
|
|
143
|
+
lines.push(
|
|
144
|
+
`networkOptions.customBaseURL = URL(string: ${JSON.stringify(
|
|
145
|
+
customBaseUrl
|
|
146
|
+
)})`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
if (pinningDisabled) {
|
|
150
|
+
lines.push('networkOptions.pinningDisabled = true');
|
|
151
|
+
}
|
|
146
152
|
lines.push('mParticleOptions.networkOptions = networkOptions');
|
|
147
153
|
}
|
|
148
154
|
|
|
@@ -196,15 +202,21 @@ function generateObjcInitCode(props: MParticlePluginProps): string {
|
|
|
196
202
|
}
|
|
197
203
|
|
|
198
204
|
const customBaseUrl = getCustomBaseUrl(props);
|
|
199
|
-
|
|
205
|
+
const pinningDisabled = props.pinningDisabled === true;
|
|
206
|
+
if (customBaseUrl || pinningDisabled) {
|
|
200
207
|
lines.push(
|
|
201
208
|
'MPNetworkOptions *networkOptions = [[MPNetworkOptions alloc] init];'
|
|
202
209
|
);
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
210
|
+
if (customBaseUrl) {
|
|
211
|
+
lines.push(
|
|
212
|
+
`networkOptions.customBaseURL = [NSURL URLWithString:@${JSON.stringify(
|
|
213
|
+
customBaseUrl
|
|
214
|
+
)}];`
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
if (pinningDisabled) {
|
|
218
|
+
lines.push('networkOptions.pinningDisabled = YES;');
|
|
219
|
+
}
|
|
208
220
|
lines.push('mParticleOptions.networkOptions = networkOptions;');
|
|
209
221
|
}
|
|
210
222
|
|