react-native-mparticle 2.8.1 → 2.9.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 +252 -94
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/android/gradle.properties +26 -0
- package/android/gradlew +160 -0
- package/android/gradlew.bat +90 -0
- package/android/libs/java-json.jar +0 -0
- package/android/src/main/java/com/mparticle/react/MParticleModule.kt +1 -1
- package/android/src/test/java/com/mparticle/react/IdentityApiTest.java +230 -0
- package/android/src/test/java/com/mparticle/react/MParticleUserTest.java +173 -0
- package/android/src/test/java/com/mparticle/react/testutils/MockMParticleUser.java +109 -0
- package/android/src/test/java/com/mparticle/react/testutils/MockMap.java +203 -0
- package/android/src/test/java/com/mparticle/react/testutils/MockReadableArray.java +68 -0
- package/android/src/test/java/com/mparticle/react/testutils/MockWritableMap.java +4 -0
- package/android/src/test/java/com/mparticle/react/testutils/Mutable.java +13 -0
- package/app.plugin.js +1 -0
- package/ios/RNMParticle/RNMPRokt.mm +25 -11
- package/ios/RNMParticle/RNMParticle.mm +2 -1
- package/js/codegenSpecs/NativeMParticle.ts +3 -4
- package/js/rokt/rokt-layout-view.android.tsx +2 -1
- package/lib/codegenSpecs/NativeMParticle.d.ts +3 -4
- package/lib/codegenSpecs/NativeMParticle.js.map +1 -1
- package/lib/rokt/rokt-layout-view.android.js +1 -0
- package/lib/rokt/rokt-layout-view.android.js.map +1 -1
- package/package.json +28 -4
- package/plugin/build/withMParticle.d.ts +60 -0
- package/plugin/build/withMParticle.js +30 -0
- package/plugin/build/withMParticleAndroid.d.ts +6 -0
- package/plugin/build/withMParticleAndroid.js +266 -0
- package/plugin/build/withMParticleIOS.d.ts +6 -0
- package/plugin/build/withMParticleIOS.js +362 -0
- package/plugin/src/withMParticle.ts +106 -0
- package/plugin/src/withMParticleAndroid.ts +359 -0
- package/plugin/src/withMParticleIOS.ts +459 -0
- package/plugin/tsconfig.json +8 -0
- package/react-native-mparticle.podspec +11 -0
- package/SECURITY.md +0 -9
package/README.md
CHANGED
|
@@ -6,23 +6,136 @@
|
|
|
6
6
|
React Native allows developers to use a single code base to deploy features to multiple platforms. With the mParticle React Native library, you can leverage a single API to deploy your data to hundreds of integrations from your iOS and Android apps.
|
|
7
7
|
|
|
8
8
|
### Supported Features
|
|
9
|
-
|
|
10
|
-
|
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
9
|
+
|
|
10
|
+
| Method | Android | iOS |
|
|
11
|
+
| ------------- | ------- | --- |
|
|
12
|
+
| Custom Events | ✓ | ✓ |
|
|
13
|
+
| Page Views | ✓ | ✓ |
|
|
14
|
+
| Identity | ✓ | ✓ |
|
|
15
|
+
| eCommerce | ✓ | ✓ |
|
|
16
|
+
| Consent | ✓ | ✓ |
|
|
16
17
|
|
|
17
18
|
# Installation
|
|
18
19
|
|
|
19
20
|
**Download and install the mParticle React Native library** from npm:
|
|
20
21
|
|
|
21
22
|
```bash
|
|
22
|
-
|
|
23
|
+
npm install react-native-mparticle --save
|
|
23
24
|
```
|
|
24
25
|
|
|
25
|
-
##
|
|
26
|
+
## Expo
|
|
27
|
+
|
|
28
|
+
This library supports Expo projects using the [Expo Config Plugin](https://docs.expo.dev/config-plugins/introduction/). The plugin automatically configures the native iOS and Android projects during `expo prebuild`.
|
|
29
|
+
|
|
30
|
+
### Installation - Expo
|
|
31
|
+
|
|
32
|
+
1. Install the library:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npx expo install react-native-mparticle
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
2. Add the plugin to your `app.json` or `app.config.js`:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"expo": {
|
|
43
|
+
"plugins": [
|
|
44
|
+
[
|
|
45
|
+
"react-native-mparticle",
|
|
46
|
+
{
|
|
47
|
+
"iosApiKey": "YOUR_IOS_API_KEY",
|
|
48
|
+
"iosApiSecret": "YOUR_IOS_API_SECRET",
|
|
49
|
+
"androidApiKey": "YOUR_ANDROID_API_KEY",
|
|
50
|
+
"androidApiSecret": "YOUR_ANDROID_API_SECRET"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
3. Run prebuild:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npx expo prebuild --clean
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
4. Run the app:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npx expo run:ios
|
|
68
|
+
# or
|
|
69
|
+
npx expo run:android
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Plugin Configuration Options
|
|
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
|
+
| `androidKits` | string[] | No | Android kit artifact names (e.g., `['android-rokt-kit']`) |
|
|
86
|
+
| `useEmptyIdentifyRequest` | boolean | No | Use empty user identify request at init (default: `true`) |
|
|
87
|
+
|
|
88
|
+
### Example with Kits
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"expo": {
|
|
93
|
+
"plugins": [
|
|
94
|
+
[
|
|
95
|
+
"react-native-mparticle",
|
|
96
|
+
{
|
|
97
|
+
"iosApiKey": "YOUR_IOS_API_KEY",
|
|
98
|
+
"iosApiSecret": "YOUR_IOS_API_SECRET",
|
|
99
|
+
"androidApiKey": "YOUR_ANDROID_API_KEY",
|
|
100
|
+
"androidApiSecret": "YOUR_ANDROID_API_SECRET",
|
|
101
|
+
"environment": "development",
|
|
102
|
+
"logLevel": "verbose",
|
|
103
|
+
"iosKits": ["mParticle-Rokt", "mParticle-Amplitude"],
|
|
104
|
+
"androidKits": ["android-rokt-kit", "android-amplitude-kit"]
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### What the Plugin Does
|
|
113
|
+
|
|
114
|
+
**iOS:**
|
|
115
|
+
|
|
116
|
+
- Adds mParticle SDK initialization to `AppDelegate` (supports both Swift and Objective-C)
|
|
117
|
+
- Configures `pre_install` hook in Podfile for dynamic framework linking
|
|
118
|
+
- Adds specified kit pod dependencies
|
|
119
|
+
|
|
120
|
+
**Android:**
|
|
121
|
+
|
|
122
|
+
- Adds mParticle SDK initialization to `MainApplication` (supports both Kotlin and Java)
|
|
123
|
+
- Adds specified kit Maven dependencies to `build.gradle`
|
|
124
|
+
|
|
125
|
+
### Version Support
|
|
126
|
+
|
|
127
|
+
| Expo SDK | React Native | iOS AppDelegate | Android MainApplication |
|
|
128
|
+
| -------- | ------------ | --------------- | ----------------------- |
|
|
129
|
+
| 53+ | 0.79+ | Swift | Kotlin |
|
|
130
|
+
| 50-52 | 0.73-0.78 | Objective-C++ | Kotlin |
|
|
131
|
+
| 49 | 0.72 | Objective-C++ | Java |
|
|
132
|
+
| ≤48 | ≤0.71 | Objective-C | Java |
|
|
133
|
+
|
|
134
|
+
The plugin automatically detects the language and generates appropriate code for each platform.
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## iOS (Manual Setup)
|
|
26
139
|
|
|
27
140
|
1. **Copy your mParticle key and secret** from [your app's dashboard][1].
|
|
28
141
|
|
|
@@ -33,6 +146,7 @@ $ npm install react-native-mparticle --save
|
|
|
33
146
|
The npm install step above will automatically include our react framework and the core iOS framework in your project. However depending on your app and its other dependecies you must integrate it in 1 of 3 ways
|
|
34
147
|
|
|
35
148
|
A. Static Libraries are the React Native default but since mParticle iOS contains swift code you need to add an exception for it in the from of a pre-install command in the Podfile.
|
|
149
|
+
|
|
36
150
|
```bash
|
|
37
151
|
pre_install do |installer|
|
|
38
152
|
installer.pod_targets.each do |pod|
|
|
@@ -44,24 +158,31 @@ pre_install do |installer|
|
|
|
44
158
|
end
|
|
45
159
|
end
|
|
46
160
|
```
|
|
161
|
+
|
|
47
162
|
Then run the following command
|
|
48
|
-
|
|
163
|
+
|
|
164
|
+
```bash
|
|
49
165
|
bundle exec pod install
|
|
50
166
|
```
|
|
51
167
|
|
|
52
|
-
B&C. Frameworks are the default for Swift development and while it isn't preferred by React Native it is supported. Additionally you can define whether the frameworks are built staticly or dynamically.
|
|
168
|
+
B&C. Frameworks are the default for Swift development and while it isn't preferred by React Native it is supported. Additionally you can define whether the frameworks are built staticly or dynamically.
|
|
53
169
|
|
|
54
170
|
Update your Podfile to be ready to use dynamically linked frameworks by commenting out the following line
|
|
171
|
+
|
|
55
172
|
```bash
|
|
56
173
|
# :flipper_configuration => flipper_config,
|
|
57
174
|
```
|
|
175
|
+
|
|
58
176
|
Then run either of the following commands
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
USE_FRAMEWORKS=static bundle exec pod install
|
|
59
180
|
```
|
|
60
|
-
|
|
61
|
-
```
|
|
181
|
+
|
|
62
182
|
or
|
|
63
|
-
|
|
64
|
-
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
USE_FRAMEWORKS=dynamic bundle exec pod install
|
|
65
186
|
```
|
|
66
187
|
|
|
67
188
|
3. Import and start the mParticle Apple SDK into Swift or Objective-C.
|
|
@@ -82,10 +203,10 @@ For more help, see [the iOS set up docs](https://docs.mparticle.com/developers/s
|
|
|
82
203
|
import mParticle_Apple_SDK
|
|
83
204
|
|
|
84
205
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
|
|
85
|
-
|
|
206
|
+
|
|
86
207
|
//override point for customization after application launch.
|
|
87
208
|
let mParticleOptions = MParticleOptions(key: "<<<App Key Here>>>", secret: "<<<App Secret Here>>>")
|
|
88
|
-
|
|
209
|
+
|
|
89
210
|
//optional- Please see the Identity page for more information on building this object
|
|
90
211
|
let request = MPIdentityApiRequest()
|
|
91
212
|
request.email = "email@example.com"
|
|
@@ -98,7 +219,7 @@ func application(_ application: UIApplication, didFinishLaunchingWithOptions lau
|
|
|
98
219
|
mParticleOptions.onAttributionComplete = { (attributionResult, error) in
|
|
99
220
|
NSLog(@"Attribution Complete. attributionResults = %@", attributionResult.linkInfo)
|
|
100
221
|
}
|
|
101
|
-
MParticle.sharedInstance().start(with: mParticleOptions)
|
|
222
|
+
MParticle.sharedInstance().start(with: mParticleOptions)
|
|
102
223
|
return true
|
|
103
224
|
}
|
|
104
225
|
```
|
|
@@ -125,7 +246,7 @@ Next, you'll need to start the SDK:
|
|
|
125
246
|
|
|
126
247
|
MParticleOptions *mParticleOptions = [MParticleOptions optionsWithKey:@"REPLACE ME"
|
|
127
248
|
secret:@"REPLACE ME"];
|
|
128
|
-
|
|
249
|
+
|
|
129
250
|
//optional - Please see the Identity page for more information on building this object
|
|
130
251
|
MPIdentityApiRequest *request = [MPIdentityApiRequest requestWithEmptyUser];
|
|
131
252
|
request.email = @"email@example.com";
|
|
@@ -138,9 +259,9 @@ Next, you'll need to start the SDK:
|
|
|
138
259
|
mParticleOptions.onAttributionComplete(MPAttributionResult * _Nullable attributionResult, NSError * _Nullable error) {
|
|
139
260
|
NSLog(@"Attribution Complete. attributionResults = %@", attributionResult.linkInfo)
|
|
140
261
|
}
|
|
141
|
-
|
|
262
|
+
|
|
142
263
|
[[MParticle sharedInstance] startWithOptions:mParticleOptions];
|
|
143
|
-
|
|
264
|
+
|
|
144
265
|
return YES;
|
|
145
266
|
}
|
|
146
267
|
```
|
|
@@ -148,13 +269,14 @@ Next, you'll need to start the SDK:
|
|
|
148
269
|
See [Identity](http://docs.mparticle.com/developers/sdk/ios/identity/) for more information on supplying an `MPIdentityApiRequest` object during SDK initialization.
|
|
149
270
|
|
|
150
271
|
4. Remember to start Metro with:
|
|
272
|
+
|
|
151
273
|
```bash
|
|
152
|
-
|
|
274
|
+
npm start
|
|
153
275
|
```
|
|
154
|
-
and build your workspace from xCode.
|
|
155
276
|
|
|
277
|
+
and build your workspace from xCode.
|
|
156
278
|
|
|
157
|
-
##
|
|
279
|
+
## Android (Manual Setup)
|
|
158
280
|
|
|
159
281
|
1. Copy your mParticle key and secret from [your workspace's dashboard](https://app.mparticle.com/setup/inputs/apps) and construct an `MParticleOptions` object.
|
|
160
282
|
|
|
@@ -191,15 +313,14 @@ class MyApplication : Application() {
|
|
|
191
313
|
}
|
|
192
314
|
```
|
|
193
315
|
|
|
194
|
-
> **Warning:** Don't log events in your `Application.onCreate()`. Android may instantiate your `Application` class in the background without your knowledge, including when the user isn't using their device, and lead to unexpected results.
|
|
195
|
-
|
|
316
|
+
> **Warning:** Don't log events in your `Application.onCreate()`. Android may instantiate your `Application` class in the background without your knowledge, including when the user isn't using their device, and lead to unexpected results.
|
|
196
317
|
|
|
197
318
|
# Usage
|
|
198
319
|
|
|
199
320
|
## Import the mParticle Module
|
|
200
321
|
|
|
201
322
|
```js
|
|
202
|
-
import MParticle from 'react-native-mparticle'
|
|
323
|
+
import MParticle from 'react-native-mparticle';
|
|
203
324
|
```
|
|
204
325
|
|
|
205
326
|
## Logging Events
|
|
@@ -207,38 +328,60 @@ import MParticle from 'react-native-mparticle'
|
|
|
207
328
|
To log basic events:
|
|
208
329
|
|
|
209
330
|
```js
|
|
210
|
-
MParticle.logEvent('Test event', MParticle.EventType.Other, {
|
|
331
|
+
MParticle.logEvent('Test event', MParticle.EventType.Other, {
|
|
332
|
+
'Test key': 'Test value',
|
|
333
|
+
});
|
|
211
334
|
```
|
|
212
335
|
|
|
213
336
|
To log commerce events:
|
|
214
337
|
|
|
215
338
|
```js
|
|
216
|
-
const product = new MParticle.Product('Test product for cart', '1234', 19.99)
|
|
217
|
-
const transactionAttributes = new MParticle.TransactionAttributes(
|
|
218
|
-
|
|
339
|
+
const product = new MParticle.Product('Test product for cart', '1234', 19.99);
|
|
340
|
+
const transactionAttributes = new MParticle.TransactionAttributes(
|
|
341
|
+
'Test transaction id'
|
|
342
|
+
);
|
|
343
|
+
const event = MParticle.CommerceEvent.createProductActionEvent(
|
|
344
|
+
MParticle.ProductActionType.AddToCart,
|
|
345
|
+
[product],
|
|
346
|
+
transactionAttributes
|
|
347
|
+
);
|
|
219
348
|
|
|
220
|
-
MParticle.logCommerceEvent(event)
|
|
349
|
+
MParticle.logCommerceEvent(event);
|
|
221
350
|
```
|
|
222
351
|
|
|
223
352
|
```js
|
|
224
|
-
const promotion = new MParticle.Promotion(
|
|
225
|
-
|
|
353
|
+
const promotion = new MParticle.Promotion(
|
|
354
|
+
'Test promotion id',
|
|
355
|
+
'Test promotion name',
|
|
356
|
+
'Test creative',
|
|
357
|
+
'Test position'
|
|
358
|
+
);
|
|
359
|
+
const event = MParticle.CommerceEvent.createPromotionEvent(
|
|
360
|
+
MParticle.PromotionActionType.View,
|
|
361
|
+
[promotion]
|
|
362
|
+
);
|
|
226
363
|
|
|
227
|
-
MParticle.logCommerceEvent(event)
|
|
364
|
+
MParticle.logCommerceEvent(event);
|
|
228
365
|
```
|
|
229
366
|
|
|
230
367
|
```js
|
|
231
|
-
const product = new MParticle.Product(
|
|
232
|
-
|
|
233
|
-
|
|
368
|
+
const product = new MParticle.Product(
|
|
369
|
+
'Test product that was viewed',
|
|
370
|
+
'5678',
|
|
371
|
+
29.99
|
|
372
|
+
);
|
|
373
|
+
const impression = new MParticle.Impression('Test impression list name', [
|
|
374
|
+
product,
|
|
375
|
+
]);
|
|
376
|
+
const event = MParticle.CommerceEvent.createImpressionEvent([impression]);
|
|
234
377
|
|
|
235
|
-
MParticle.logCommerceEvent(event)
|
|
378
|
+
MParticle.logCommerceEvent(event);
|
|
236
379
|
```
|
|
237
380
|
|
|
238
381
|
To log screen events:
|
|
239
382
|
|
|
240
383
|
```js
|
|
241
|
-
MParticle.logScreenEvent('Test screen', { 'Test key': 'Test value' })
|
|
384
|
+
MParticle.logScreenEvent('Test screen', { 'Test key': 'Test value' });
|
|
242
385
|
```
|
|
243
386
|
|
|
244
387
|
## User
|
|
@@ -246,49 +389,59 @@ MParticle.logScreenEvent('Test screen', { 'Test key': 'Test value' })
|
|
|
246
389
|
To set, remove, and get user details, call the `User` or `Identity` methods as follows:
|
|
247
390
|
|
|
248
391
|
```js
|
|
249
|
-
MParticle.User.setUserAttribute('User ID', 'Test key', 'Test value')
|
|
392
|
+
MParticle.User.setUserAttribute('User ID', 'Test key', 'Test value');
|
|
250
393
|
```
|
|
251
394
|
|
|
252
395
|
```js
|
|
253
|
-
MParticle.User.setUserAttribute(
|
|
396
|
+
MParticle.User.setUserAttribute(
|
|
397
|
+
'User ID',
|
|
398
|
+
MParticle.UserAttributeType.FirstName,
|
|
399
|
+
'Test first name'
|
|
400
|
+
);
|
|
254
401
|
```
|
|
255
402
|
|
|
256
403
|
```js
|
|
257
|
-
MParticle.User.setUserAttributeArray('User ID', 'Test key', [
|
|
404
|
+
MParticle.User.setUserAttributeArray('User ID', 'Test key', [
|
|
405
|
+
'Test value 1',
|
|
406
|
+
'Test value 2',
|
|
407
|
+
]);
|
|
258
408
|
```
|
|
259
409
|
|
|
260
410
|
```js
|
|
261
|
-
MParticle.User.setUserTag('User ID', 'Test value')
|
|
411
|
+
MParticle.User.setUserTag('User ID', 'Test value');
|
|
262
412
|
```
|
|
263
413
|
|
|
264
414
|
```js
|
|
265
|
-
MParticle.User.removeUserAttribute('User ID', 'Test key')
|
|
415
|
+
MParticle.User.removeUserAttribute('User ID', 'Test key');
|
|
266
416
|
```
|
|
267
417
|
|
|
268
418
|
```js
|
|
269
|
-
MParticle.Identity.getUserIdentities(
|
|
270
|
-
|
|
419
|
+
MParticle.Identity.getUserIdentities(userIdentities => {
|
|
420
|
+
console.debug(userIdentities);
|
|
271
421
|
});
|
|
272
422
|
```
|
|
273
423
|
|
|
274
424
|
## IdentityRequest
|
|
275
425
|
|
|
276
426
|
```js
|
|
277
|
-
var request = new MParticle.IdentityRequest()
|
|
427
|
+
var request = new MParticle.IdentityRequest();
|
|
278
428
|
```
|
|
279
429
|
|
|
280
430
|
**Setting** user identities:
|
|
281
431
|
|
|
282
432
|
```js
|
|
283
433
|
var request = new MParticle.IdentityRequest();
|
|
284
|
-
request.setUserIdentity(
|
|
434
|
+
request.setUserIdentity(
|
|
435
|
+
'example@example.com',
|
|
436
|
+
MParticle.UserIdentityType.Email
|
|
437
|
+
);
|
|
285
438
|
```
|
|
286
439
|
|
|
287
440
|
## Identity
|
|
288
441
|
|
|
289
442
|
```js
|
|
290
|
-
MParticle.Identity.getCurrentUser(
|
|
291
|
-
|
|
443
|
+
MParticle.Identity.getCurrentUser(currentUser => {
|
|
444
|
+
console.debug(currentUser.userID);
|
|
292
445
|
});
|
|
293
446
|
```
|
|
294
447
|
|
|
@@ -296,11 +449,11 @@ MParticle.Identity.getCurrentUser((currentUser) => {
|
|
|
296
449
|
var request = new MParticle.IdentityRequest();
|
|
297
450
|
|
|
298
451
|
MParticle.Identity.identify(request, (error, userId) => {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
452
|
+
if (error) {
|
|
453
|
+
console.debug(error); //error is an MParticleError
|
|
454
|
+
} else {
|
|
455
|
+
console.debug(userId);
|
|
456
|
+
}
|
|
304
457
|
});
|
|
305
458
|
```
|
|
306
459
|
|
|
@@ -309,11 +462,11 @@ var request = new MParticle.IdentityRequest();
|
|
|
309
462
|
request.email = 'test email';
|
|
310
463
|
|
|
311
464
|
MParticle.Identity.login(request, (error, userId) => {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
465
|
+
if (error) {
|
|
466
|
+
console.debug(error); //error is an MParticleError
|
|
467
|
+
} else {
|
|
468
|
+
console.debug(userId);
|
|
469
|
+
}
|
|
317
470
|
});
|
|
318
471
|
```
|
|
319
472
|
|
|
@@ -321,11 +474,11 @@ MParticle.Identity.login(request, (error, userId) => {
|
|
|
321
474
|
var request = new MParticle.IdentityRequest();
|
|
322
475
|
|
|
323
476
|
MParticle.Identity.logout(request, (error, userId) => {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
477
|
+
if (error) {
|
|
478
|
+
console.debug(error);
|
|
479
|
+
} else {
|
|
480
|
+
console.debug(userId);
|
|
481
|
+
}
|
|
329
482
|
});
|
|
330
483
|
```
|
|
331
484
|
|
|
@@ -334,31 +487,33 @@ var request = new MParticle.IdentityRequest();
|
|
|
334
487
|
request.email = 'test email 2';
|
|
335
488
|
|
|
336
489
|
MParticle.Identity.modify(request, (error, userId) => {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
490
|
+
if (error) {
|
|
491
|
+
console.debug(error); //error is an MParticleError
|
|
492
|
+
} else {
|
|
493
|
+
console.debug(userId);
|
|
494
|
+
}
|
|
342
495
|
});
|
|
343
496
|
```
|
|
344
497
|
|
|
345
498
|
## Attribution
|
|
346
|
-
|
|
499
|
+
|
|
500
|
+
```js
|
|
347
501
|
var attributions = MParticle.getAttributions();
|
|
348
502
|
```
|
|
349
503
|
|
|
350
|
-
In order to listen for Attributions asynchronously, you need to set the proper field in `MParticleOptions` as shown in the [Android](#
|
|
504
|
+
In order to listen for Attributions asynchronously, you need to set the proper field in `MParticleOptions` as shown in the [Android](#android-manual-setup) or the [iOS](#ios-manual-setup) SDK start examples.
|
|
351
505
|
|
|
352
506
|
## Kits
|
|
507
|
+
|
|
353
508
|
Check if a kit is active
|
|
354
509
|
|
|
355
|
-
```
|
|
510
|
+
```js
|
|
356
511
|
var isKitActive = MParticle.isKitActive(kitId);
|
|
357
512
|
```
|
|
358
513
|
|
|
359
514
|
Check and set the SDK's opt out status
|
|
360
515
|
|
|
361
|
-
```
|
|
516
|
+
```js
|
|
362
517
|
var isOptedOut = MParticle.getOptOut();
|
|
363
518
|
MParticle.setOptOut(!isOptedOut);
|
|
364
519
|
```
|
|
@@ -369,55 +524,58 @@ The method `MParticle.logPushRegistration()` accepts 2 parameters. For Android,
|
|
|
369
524
|
|
|
370
525
|
### Android
|
|
371
526
|
|
|
372
|
-
```
|
|
527
|
+
```js
|
|
373
528
|
MParticle.logPushRegistration(pushToken, senderId);
|
|
374
529
|
```
|
|
375
530
|
|
|
376
531
|
### iOS
|
|
377
532
|
|
|
378
|
-
```
|
|
533
|
+
```js
|
|
379
534
|
MParticle.logPushRegistration(pushToken, null);
|
|
380
535
|
```
|
|
381
536
|
|
|
382
537
|
## GDPR Consent
|
|
538
|
+
|
|
383
539
|
Add a GDPRConsent
|
|
384
540
|
|
|
385
|
-
```
|
|
541
|
+
```js
|
|
386
542
|
var gdprConsent = GDPRConsent()
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
543
|
+
.setConsented(true)
|
|
544
|
+
.setDocument('the document')
|
|
545
|
+
.setTimestamp(new Date().getTime()) // optional, native SDK will automatically set current timestamp if omitted
|
|
546
|
+
.setLocation('the location')
|
|
547
|
+
.setHardwareId('the hardwareId');
|
|
392
548
|
|
|
393
|
-
MParticle.addGDPRConsentState(gdprConsent,
|
|
549
|
+
MParticle.addGDPRConsentState(gdprConsent, 'the purpose');
|
|
394
550
|
```
|
|
395
551
|
|
|
396
552
|
Remove a GDPRConsent
|
|
397
|
-
|
|
398
|
-
|
|
553
|
+
|
|
554
|
+
```js
|
|
555
|
+
MParticle.removeGDPRConsentStateWithPurpose('the purpose');
|
|
399
556
|
```
|
|
400
557
|
|
|
401
558
|
## CCPA Consent
|
|
559
|
+
|
|
402
560
|
Add a CCPAConsent
|
|
403
561
|
|
|
404
|
-
```
|
|
562
|
+
```js
|
|
405
563
|
var ccpaConsent = CCPAConsent()
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
564
|
+
.setConsented(true)
|
|
565
|
+
.setDocument('the document')
|
|
566
|
+
.setTimestamp(new Date().getTime()) // optional, native SDK will automatically set current timestamp if omitted
|
|
567
|
+
.setLocation('the location')
|
|
568
|
+
.setHardwareId('the hardwareId');
|
|
411
569
|
|
|
412
570
|
MParticle.addCCPAConsentState(ccpaConsent);
|
|
413
571
|
```
|
|
414
572
|
|
|
415
573
|
Remove CCPAConsent
|
|
416
|
-
|
|
574
|
+
|
|
575
|
+
```js
|
|
417
576
|
MParticle.removeCCPAConsentState();
|
|
418
577
|
```
|
|
419
578
|
|
|
420
|
-
|
|
421
579
|
# License
|
|
422
580
|
|
|
423
581
|
Apache 2.0
|
|
Binary file
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Project-wide Gradle settings.
|
|
2
|
+
|
|
3
|
+
# IDE (e.g. Android Studio) users:
|
|
4
|
+
# Gradle settings configured through the IDE *will override*
|
|
5
|
+
# any settings specified in this file.
|
|
6
|
+
|
|
7
|
+
# For more details on how to configure your build environment visit
|
|
8
|
+
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
|
9
|
+
|
|
10
|
+
# Specifies the JVM arguments used for the daemon process.
|
|
11
|
+
# The setting is particularly useful for tweaking memory settings.
|
|
12
|
+
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
|
|
13
|
+
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
|
|
14
|
+
|
|
15
|
+
# When configured, Gradle will run in incubating parallel mode.
|
|
16
|
+
# This option should only be used with decoupled projects. More details, visit
|
|
17
|
+
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
|
18
|
+
# org.gradle.parallel=true
|
|
19
|
+
|
|
20
|
+
# AndroidX package structure to make it clearer which packages are bundled with the
|
|
21
|
+
# Android operating system, and which are packaged with your app's APK
|
|
22
|
+
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
|
23
|
+
android.useAndroidX=true
|
|
24
|
+
|
|
25
|
+
# Automatically convert third-party libraries to use AndroidX
|
|
26
|
+
android.enableJetifier=true
|