react-native-mparticle 2.5.0 → 2.6.2

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 CHANGED
@@ -3,38 +3,58 @@
3
3
  [![npm version](https://badge.fury.io/js/react-native-mparticle.svg)](https://badge.fury.io/js/react-native-mparticle)
4
4
  [![Standard - JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](http://standardjs.com/)
5
5
 
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
+
8
+ ### Supported Features
9
+ | Method | Android | iOS |
10
+ | --- | --- | --- |
11
+ | Custom Events | <li> [X] </li> | <li> [X] </li> |
12
+ | Page Views | <li> [X] </li> | <li> [X] </li> |
13
+ | Identity | <li> [X] </li> | <li> [X] </li> |
14
+ | eCommerce | <li> [X] </li> | <li> [X] </li> |
15
+ | Consent | <li> [X] </li> | <li> [X] </li> |
16
+
6
17
  # Installation
7
18
 
8
- **First, download the library** from npm:
19
+ 1. **Download and install the mParticle React Native library** from npm:
9
20
 
10
21
  ```bash
11
22
  $ npm install react-native-mparticle --save
12
23
  ```
13
24
 
14
- **Second, install the native dependencies**. You can use `rnpm` (now part of `react-native` core via `link`) to add native dependencies automatically:
25
+ 2. **Install the native dependencies**. You can use `rnpm` (now part of `react-native` core via `link`) to add native dependencies automatically:
15
26
 
16
27
  ```bash
17
28
  $ react-native link
18
29
  ```
19
30
 
20
- **Grab your mParticle key and secret** from [your app's dashboard][1] and move on to the OS-specific instructions below.
31
+ ## <a name="iOS"></a>iOS
21
32
 
22
- [1]: https://app.mparticle.com/apps
33
+ 1. **Copy your mParticle key and secret** from [your app's dashboard][1].
23
34
 
24
- ## <a name="iOS"></a>iOS
35
+ [1]: https://app.mparticle.com/setup/inputs/apps
25
36
 
26
- **Install the SDK** using CocoaPods:
37
+ 2. **Install the SDK** using CocoaPods:
27
38
 
28
39
  ```bash
29
40
  $ # Update your Podfile to depend on 'mParticle-Apple-SDK' version 7.2.0 or later
30
41
  $ pod install
31
42
  ```
32
43
 
33
- The mParticle SDK is initialized by calling the `startWithOptions` method within the `application:didFinishLaunchingWithOptions:` delegate call. Preferably the location of the initialization method call should be one of the last statements in the `application:didFinishLaunchingWithOptions:`. The `startWithOptions` method requires an options argument containing your key and secret and an initial Identity request.
44
+ The mParticle SDK is initialized by calling the `startWithOptions` method within the `application:didFinishLaunchingWithOptions:` delegate call.
45
+
46
+ Preferably the location of the initialization method call should be one of the last statements in the `application:didFinishLaunchingWithOptions:`.
47
+
48
+ The `startWithOptions` method requires an options argument containing your key and secret and an initial Identity request.
49
+
50
+ > Note that you must initialize the SDK in the `application:didFinishLaunchingWithOptions:` method. Other parts of the SDK rely on the `UIApplicationDidBecomeActiveNotification` notification to function properly. Failing to start the SDK as indicated will impair it. Also, please do **not** use _GCD_'s `dispatch_async` to start the SDK.
34
51
 
35
- > Note that it is imperative for the SDK to be initialized in the `application:didFinishLaunchingWithOptions:` method. Other parts of the SDK rely on the `UIApplicationDidBecomeActiveNotification` notification to function properly. Failing to start the SDK as indicated will impair it. Also, please do **not** use _GCD_'s `dispatch_async` to start the SDK.
52
+ For more help, see [the iOS set up docs](https://docs.mparticle.com/developers/sdk/ios/getting-started/#create-an-input).
36
53
 
37
- #### Swift
54
+ 3. Import and start the mParticle Apple SDK into Swift or Objective-C.
55
+
56
+
57
+ #### Swift Example
38
58
 
39
59
  ```swift
40
60
  import mParticle_Apple_SDK
@@ -62,7 +82,7 @@ func application(_ application: UIApplication, didFinishLaunchingWithOptions lau
62
82
  }
63
83
  ```
64
84
 
65
- #### Objective-C
85
+ #### Objective-C Example
66
86
 
67
87
  For apps supporting iOS 8 and above, Apple recommends using the import syntax for **modules** or **semantic import**. However, if you prefer the traditional CocoaPods and static libraries delivery mechanism, that is fully supported as well.
68
88
 
@@ -107,15 +127,17 @@ Next, you'll need to start the SDK:
107
127
  }
108
128
  ```
109
129
 
110
- Please see [Identity](http://docs.mparticle.com/developers/sdk/ios/identity/) for more information on supplying an `MPIdentityApiRequest` object during SDK initialization.
130
+ See [Identity](http://docs.mparticle.com/developers/sdk/ios/identity/) for more information on supplying an `MPIdentityApiRequest` object during SDK initialization.
111
131
 
112
132
 
113
133
  ## <a name="Android"></a>Android
114
134
 
115
- 1. Grab your mParticle key and secret from [your workspace's dashboard](https://app.mparticle.com/apps) and construct an `MParticleOptions` object.
135
+ 1. Copy your mParticle key and secret from [your workspace's dashboard](https://app.mparticle.com/setup/inputs/apps) and construct an `MParticleOptions` object.
116
136
 
117
137
  2. Call `start` from the `onCreate` method of your app's `Application` class. It's crucial that the SDK be started here for proper session management. If you don't already have an `Application` class, create it and then specify its fully-qualified name in the `<application>` tag of your app's `AndroidManifest.xml`.
118
138
 
139
+ For more help, see [the Android set up docs](https://docs.mparticle.com/developers/sdk/android/getting-started/#create-an-input).
140
+
119
141
  ```java
120
142
  package com.example.myapp;
121
143
 
@@ -143,28 +165,26 @@ public class MyApplication extends Application {
143
165
  }
144
166
  ```
145
167
 
146
- > **Warning:** It's generally not a good idea to log events in your `Application.onCreate()`. Android may instantiate your `Application` class for a lot of reasons, in the background, while the user isn't even using their device.
168
+ > **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.
147
169
 
148
170
 
149
171
  # Usage
150
172
 
151
- ## Import
152
-
153
- **Importing** the module:
173
+ ## Import the mParticle Module
154
174
 
155
175
  ```js
156
176
  import MParticle from 'react-native-mparticle'
157
177
  ```
158
178
 
159
- ## Events
179
+ ## Logging Events
160
180
 
161
- **Logging** events:
181
+ To log basic events:
162
182
 
163
183
  ```js
164
184
  MParticle.logEvent('Test event', MParticle.EventType.Other, { 'Test key': 'Test value' })
165
185
  ```
166
186
 
167
- **Logging** commerce events:
187
+ To log commerce events:
168
188
 
169
189
  ```js
170
190
  const product = new MParticle.Product('Test product for cart', '1234', 19.99)
@@ -189,16 +209,16 @@ const event = MParticle.CommerceEvent.createImpressionEvent([impression])
189
209
  MParticle.logCommerceEvent(event)
190
210
  ```
191
211
 
192
- **Logging** screen events:
212
+ To log screen events:
193
213
 
194
214
  ```js
195
215
  MParticle.logScreenEvent('Test screen', { 'Test key': 'Test value' })
196
216
  ```
197
217
 
198
218
  ## User
199
- **Setting** user attributes and tags:
200
219
 
201
- Use Identify or currentUser to retrieve the userID for these calls
220
+ To set, remove, and get user details, call the `User` or `Identity` methods as follows:
221
+
202
222
  ```js
203
223
  MParticle.User.setUserAttribute('User ID', 'Test key', 'Test value')
204
224
  ```
@@ -254,9 +274,6 @@ MParticle.Identity.getCurrentUser((currentUser) => {
254
274
  });
255
275
  ```
256
276
 
257
- **Using** static methods to update and change identity
258
-
259
-
260
277
  ```js
261
278
  var request = new MParticle.IdentityRequest();
262
279
 
@@ -330,7 +347,7 @@ MParticle.setOptOut(!isOptedOut);
330
347
 
331
348
  ## Push Registration
332
349
 
333
- The method `MParticle.logPushRegistration()` accepts 2 parameters. For Android, provide both the pushToken and senderId. For iOS, provide the push token in the first parameter, and simply pass `null` for the second parameter
350
+ The method `MParticle.logPushRegistration()` accepts 2 parameters. For Android, provide both the `pushToken` and `senderId`. For iOS, provide the push token in the first parameter, and simply pass `null` for the second parameter.
334
351
 
335
352
  ### Android
336
353
 
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <classpath>
3
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
4
+ <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
5
+ <classpathentry kind="output" path="bin/default"/>
6
+ </classpath>
File without changes
@@ -0,0 +1,2 @@
1
+ #Wed Mar 17 12:51:17 EDT 2021
2
+ gradle.version=5.4.1
File without changes
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>android</name>
4
+ <comment>Project android created by Buildship.</comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>org.eclipse.jdt.core.javabuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ <buildCommand>
14
+ <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15
+ <arguments>
16
+ </arguments>
17
+ </buildCommand>
18
+ </buildSpec>
19
+ <natures>
20
+ <nature>org.eclipse.jdt.core.javanature</nature>
21
+ <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22
+ </natures>
23
+ <filteredResources>
24
+ <filter>
25
+ <id>1630678802180</id>
26
+ <name></name>
27
+ <type>30</type>
28
+ <matcher>
29
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
30
+ <arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31
+ </matcher>
32
+ </filter>
33
+ </filteredResources>
34
+ </projectDescription>
@@ -0,0 +1,13 @@
1
+ arguments=
2
+ auto.sync=false
3
+ build.scans.enabled=false
4
+ connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
5
+ connection.project.dir=
6
+ eclipse.preferences.version=1
7
+ gradle.user.home=
8
+ java.home=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
9
+ jvm.arguments=
10
+ offline.mode=false
11
+ override.workspace.settings=true
12
+ show.console.view=true
13
+ show.executions.view=true
@@ -24,7 +24,7 @@ android {
24
24
 
25
25
  buildscript {
26
26
  repositories {
27
- jcenter()
27
+ mavenCentral()
28
28
  google()
29
29
  }
30
30
  dependencies {
@@ -33,7 +33,7 @@ buildscript {
33
33
  }
34
34
 
35
35
  repositories {
36
- jcenter()
36
+ mavenCentral()
37
37
  google()
38
38
  }
39
39
 
@@ -86,9 +86,9 @@ public class MParticleModule extends ReactContextBaseJavaModule {
86
86
  }
87
87
 
88
88
  @ReactMethod
89
- public void logScreenEvent(final String event, final ReadableMap attributesMap) {
89
+ public void logScreenEvent(final String event, final ReadableMap attributesMap, final boolean shouldUploadEvent) {
90
90
  Map<String, String> attributes = ConvertStringMap(attributesMap);
91
- MParticle.getInstance().logScreen(event, attributes);
91
+ MParticle.getInstance().logScreen(event, attributes, shouldUploadEvent);
92
92
  }
93
93
 
94
94
  @ReactMethod
@@ -595,6 +595,19 @@ public class MParticleModule extends ReactContextBaseJavaModule {
595
595
  if (map.hasKey("shouldUploadEvent")) {
596
596
  builder.shouldUploadEvent(map.getBoolean("shouldUploadEvent"));
597
597
  }
598
+ if (map.hasKey("customAttributes")) {
599
+ builder.customAttributes(ConvertStringMap(map.getMap("customAttributes")));
600
+ }
601
+ if (map.hasKey("currency")) {
602
+ builder.currency(map.getString("currency"));
603
+ }
604
+ if (map.hasKey("checkoutStep")) {
605
+ builder.checkoutStep(map.getInt("checkoutStep"));
606
+ }
607
+ if (map.hasKey("checkoutOptions")) {
608
+ builder.checkoutOptions(map.getString("checkoutOptions"));
609
+ }
610
+
598
611
 
599
612
  return builder.build();
600
613
  }
@@ -34,9 +34,9 @@ RCT_EXPORT_METHOD(logCommerceEvent:(MPCommerceEvent *)commerceEvent)
34
34
  [[MParticle sharedInstance] logCommerceEvent:commerceEvent];
35
35
  }
36
36
 
37
- RCT_EXPORT_METHOD(logScreenEvent:(NSString *)screenName attributes:(NSDictionary *)attributes)
37
+ RCT_EXPORT_METHOD(logScreenEvent:(NSString *)screenName attributes:(NSDictionary *)attributes shouldUploadEvent:(BOOL)shouldUploadEvent)
38
38
  {
39
- [[MParticle sharedInstance] logScreen:screenName eventInfo:attributes];
39
+ [[MParticle sharedInstance] logScreen:screenName eventInfo:attributes shouldUploadEvent:shouldUploadEvent];
40
40
  }
41
41
 
42
42
  RCT_EXPORT_METHOD(setATTStatus:(NSInteger)status withATTStatusTimestampMillis:(nonnull NSNumber *)timestamp)
@@ -413,11 +413,13 @@ typedef NS_ENUM(NSUInteger, MPReactCommerceEventAction) {
413
413
  commerceEvent.productListSource = json[@"productActionListSource"];
414
414
  commerceEvent.screenName = json[@"screenName"];
415
415
  commerceEvent.transactionAttributes = [RCTConvert MPTransactionAttributes:json[@"transactionAttributes"]];
416
- commerceEvent.action = [RCTConvert MPCommerceEventAction:json[@"productActionType"]];
417
416
  commerceEvent.checkoutStep = [json[@"checkoutStep"] intValue];
418
417
  commerceEvent.nonInteractive = [json[@"nonInteractive"] boolValue];
419
418
  if (json[@"shouldUploadEvent"] != nil) {
420
- event.shouldUploadEvent = [json[@"shouldUploadEvent"] boolValue]
419
+ commerceEvent.shouldUploadEvent = [json[@"shouldUploadEvent"] boolValue];
420
+ }
421
+ if (json[@"customAttributes"] != nil) {
422
+ commerceEvent.customAttributes = json[@"customAttributes"];
421
423
  }
422
424
 
423
425
  NSMutableArray *products = [NSMutableArray array];
@@ -606,7 +608,7 @@ typedef NS_ENUM(NSUInteger, MPReactCommerceEventAction) {
606
608
  event.startTime = json[@"startTime"];
607
609
  event.type = [json[@"type"] intValue];
608
610
  if (json[@"shouldUploadEvent"] != nil) {
609
- event.shouldUploadEvent = [json[@"shouldUploadEvent"] boolValue]
611
+ event.shouldUploadEvent = [json[@"shouldUploadEvent"] boolValue];
610
612
  }
611
613
 
612
614
  NSDictionary *jsonFlags = json[@"customFlags"];
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:">
6
+ </FileRef>
7
+ </Workspace>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>IDEDidComputeMac32BitWarning</key>
6
+ <true/>
7
+ </dict>
8
+ </plist>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Bucket
3
+ uuid = "39402CF6-7BAB-4033-9C4A-41AE5477C134"
4
+ type = "1"
5
+ version = "2.0">
6
+ </Bucket>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>RNMParticle.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>0</integer>
11
+ </dict>
12
+ </dict>
13
+ </dict>
14
+ </plist>
package/js/index.js CHANGED
@@ -96,8 +96,8 @@ const logCommerceEvent = (commerceEvent) => {
96
96
  NativeModules.MParticle.logCommerceEvent(commerceEvent)
97
97
  }
98
98
 
99
- const logScreenEvent = (screenName, attributes = null) => {
100
- NativeModules.MParticle.logScreenEvent(screenName, attributes)
99
+ const logScreenEvent = (screenName, attributes = null, shouldUploadEvent = true) => {
100
+ NativeModules.MParticle.logScreenEvent(screenName, attributes, shouldUploadEvent)
101
101
  }
102
102
 
103
103
  // Use ATTAuthStatus constants for status
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "homepage": "https://www.mparticle.com",
5
5
  "license": "Apache-2.0",
6
6
  "repository": "mParticle/react-native-mparticle",
7
- "version": "2.5.0",
7
+ "version": "2.6.2",
8
8
  "main": "js/index.js",
9
9
  "scripts": {
10
10
  "test": "./node_modules/standard/bin/cmd.js",