-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathwithMParticle.ts
More file actions
122 lines (103 loc) · 3.24 KB
/
Copy pathwithMParticle.ts
File metadata and controls
122 lines (103 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import { ConfigPlugin, createRunOncePlugin } from '@expo/config-plugins';
import { withMParticleIOS } from './withMParticleIOS';
import { withMParticleAndroid } from './withMParticleAndroid';
const pkg = require('../../package.json');
/**
* mParticle plugin configuration options
*/
export interface MParticlePluginProps {
/**
* iOS API key from mParticle dashboard
*/
iosApiKey: string;
/**
* iOS API secret from mParticle dashboard
*/
iosApiSecret: string;
/**
* Android API key from mParticle dashboard
*/
androidApiKey: string;
/**
* Android API secret from mParticle dashboard
*/
androidApiSecret: string;
/**
* Log level for debugging
* @default 'none'
*/
logLevel?: 'none' | 'error' | 'warning' | 'debug' | 'verbose';
/**
* mParticle environment
* @default 'autoDetect'
*/
environment?: 'development' | 'production' | 'autoDetect';
/**
* Data plan ID for validation
*/
dataPlanId?: string;
/**
* Data plan version for validation
*/
dataPlanVersion?: number;
/**
* iOS kit pod names to include
* @example ['mParticle-Rokt', 'mParticle-Amplitude']
*/
iosKits?: string[];
/**
* Custom base URL for global CNAME setup.
* This is applied before mParticle starts on iOS and Android.
* @example 'https://your-cname.example.com'
*/
customBaseUrl?: string;
/**
* When true, disables SSL certificate pinning for mParticle network traffic.
*
* - **iOS:** Sets `MPNetworkOptions.pinningDisabled` before startup.
* - **Android:** Sets `NetworkOptions.Builder.setPinningDisabledInDevelopment(true)`
* (mParticle's Android API for proxy/debug builds; see Android SDK docs).
*/
pinningDisabled?: boolean;
/**
* Android kit artifact names to include (version auto-detected from core SDK)
* @example ['android-rokt-kit', 'android-amplitude-kit']
*/
androidKits?: string[];
/**
* Whether to use an empty identify request at initialization
* If true or omitted, uses requestWithEmptyUser/withEmptyUser()
* If false, no identify request is made at initialization
* Identity should be updated from React Native code after initialization
* @default true
*/
useEmptyIdentifyRequest?: boolean;
}
/**
* Expo Config Plugin for mParticle React Native SDK
*
* This plugin configures your Expo project to use the mParticle SDK by:
* - Adding mParticle SDK initialization to iOS AppDelegate
* - Adding mParticle SDK initialization to Android MainApplication
* - Adding kit dependencies to iOS Podfile
* - Adding kit dependencies to Android build.gradle
*/
const withMParticle: ConfigPlugin<MParticlePluginProps> = (config, props) => {
// Validate required props
if (!props.iosApiKey || !props.iosApiSecret) {
throw new Error(
'react-native-mparticle plugin requires iosApiKey and iosApiSecret'
);
}
if (!props.androidApiKey || !props.androidApiSecret) {
throw new Error(
'react-native-mparticle plugin requires androidApiKey and androidApiSecret'
);
}
// Apply iOS modifications
config = withMParticleIOS(config, props);
// Apply Android modifications
config = withMParticleAndroid(config, props);
return config;
};
export default createRunOncePlugin(withMParticle, pkg.name, pkg.version);