react-native-mparticle 2.6.2 → 2.7.1-patch.1
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/.github/workflows/pull-request.yml +31 -0
- package/README.md +26 -23
- package/android/.project +2 -2
- package/android/.settings/org.eclipse.buildship.core.prefs +1 -1
- package/android/src/main/java/com/mparticle/react/MParticleModule.java +22 -3
- package/ios/RNMParticle/RNMParticle.m +5 -0
- package/ios/RNMParticle.xcodeproj/project.xcworkspace/xcuserdata/bstalnaker.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/js/index.js +5 -0
- package/package.json +1 -1
- package/.github/workflows/react-ci.yml +0 -22
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: "Build and Test"
|
|
2
|
+
|
|
3
|
+
on: [pull_request, push]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
js-tests:
|
|
7
|
+
name: "JS Tests"
|
|
8
|
+
runs-on: macOS-latest
|
|
9
|
+
steps:
|
|
10
|
+
- name: "Checkout"
|
|
11
|
+
uses: actions/checkout@v2
|
|
12
|
+
- uses: actions/setup-node@master
|
|
13
|
+
- uses: c-hive/gha-yarn-cache@v1
|
|
14
|
+
|
|
15
|
+
- name: "Install node modules"
|
|
16
|
+
run: |
|
|
17
|
+
yarn install
|
|
18
|
+
|
|
19
|
+
- name: "Run test"
|
|
20
|
+
run: |
|
|
21
|
+
yarn test
|
|
22
|
+
android-unit-tests:
|
|
23
|
+
name: "Android Unit Tests"
|
|
24
|
+
runs-on: ubuntu-18.04
|
|
25
|
+
steps:
|
|
26
|
+
- name: "Checkout"
|
|
27
|
+
uses: actions/checkout@v2
|
|
28
|
+
|
|
29
|
+
- name: "Run Android Unit Tests"
|
|
30
|
+
working-directory: android
|
|
31
|
+
run: ./gradlew test
|
package/README.md
CHANGED
|
@@ -61,24 +61,23 @@ import mParticle_Apple_SDK
|
|
|
61
61
|
|
|
62
62
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
//override point for customization after application launch.
|
|
65
65
|
let mParticleOptions = MParticleOptions(key: "<<<App Key Here>>>", secret: "<<<App Secret Here>>>")
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
//optional- Please see the Identity page for more information on building this object
|
|
68
68
|
let request = MPIdentityApiRequest()
|
|
69
69
|
request.email = "email@example.com"
|
|
70
70
|
mParticleOptions.identifyRequest = request
|
|
71
|
+
//optional
|
|
71
72
|
mParticleOptions.onIdentifyComplete = { (apiResult, error) in
|
|
72
73
|
NSLog("Identify complete. userId = %@ error = %@", apiResult?.user.userId.stringValue ?? "Null User ID", error?.localizedDescription ?? "No Error Available")
|
|
73
74
|
}
|
|
75
|
+
//optional
|
|
74
76
|
mParticleOptions.onAttributionComplete = { (attributionResult, error) in
|
|
75
77
|
NSLog(@"Attribution Complete. attributionResults = %@", attributionResult.linkInfo)
|
|
76
78
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
MParticle.sharedInstance().start(with: mParticleOptions)
|
|
80
|
-
|
|
81
|
-
return true
|
|
79
|
+
MParticle.sharedInstance().start(with: mParticleOptions)
|
|
80
|
+
return true
|
|
82
81
|
}
|
|
83
82
|
```
|
|
84
83
|
|
|
@@ -110,13 +109,15 @@ Next, you'll need to start the SDK:
|
|
|
110
109
|
MParticleOptions *mParticleOptions = [MParticleOptions optionsWithKey:@"REPLACE ME"
|
|
111
110
|
secret:@"REPLACE ME"];
|
|
112
111
|
|
|
113
|
-
//Please see the Identity page for more information on building this object
|
|
112
|
+
//optional - Please see the Identity page for more information on building this object
|
|
114
113
|
MPIdentityApiRequest *request = [MPIdentityApiRequest requestWithEmptyUser];
|
|
115
114
|
request.email = @"email@example.com";
|
|
116
115
|
mParticleOptions.identifyRequest = request;
|
|
116
|
+
//optional
|
|
117
117
|
mParticleOptions.onIdentifyComplete = ^(MPIdentityApiResult * _Nullable apiResult, NSError * _Nullable error) {
|
|
118
118
|
NSLog(@"Identify complete. userId = %@ error = %@", apiResult.user.userId, error);
|
|
119
119
|
};
|
|
120
|
+
//optional
|
|
120
121
|
mParticleOptions.onAttributionComplete(MPAttributionResult * _Nullable attributionResult, NSError * _Nullable error) {
|
|
121
122
|
NSLog(@"Attribution Complete. attributionResults = %@", attributionResult.linkInfo)
|
|
122
123
|
}
|
|
@@ -138,29 +139,31 @@ See [Identity](http://docs.mparticle.com/developers/sdk/ios/identity/) for more
|
|
|
138
139
|
|
|
139
140
|
For more help, see [the Android set up docs](https://docs.mparticle.com/developers/sdk/android/getting-started/#create-an-input).
|
|
140
141
|
|
|
141
|
-
```
|
|
142
|
+
```kotlin
|
|
142
143
|
package com.example.myapp;
|
|
143
144
|
|
|
144
145
|
import android.app.Application;
|
|
145
146
|
import com.mparticle.MParticle;
|
|
146
147
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
.
|
|
148
|
+
class MyApplication : Application() {
|
|
149
|
+
fun onCreate() {
|
|
150
|
+
super.onCreate()
|
|
151
|
+
val options: MParticleOptions = MParticleOptions.builder(this)
|
|
152
|
+
.credentials("REPLACE ME WITH KEY", "REPLACE ME WITH SECRET")
|
|
153
|
+
//optional
|
|
154
|
+
.logLevel(MParticle.LogLevel.VERBOSE)
|
|
155
|
+
//optional
|
|
154
156
|
.identify(identifyRequest)
|
|
157
|
+
//optional
|
|
155
158
|
.identifyTask(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
159
|
+
BaseIdentityTask()
|
|
160
|
+
.addFailureListener { errorResponse -> }
|
|
161
|
+
.addSuccessListener{ result -> }
|
|
162
|
+
)
|
|
163
|
+
//optional
|
|
160
164
|
.attributionListener(this)
|
|
161
|
-
.build()
|
|
162
|
-
|
|
163
|
-
MParticle.start(options);
|
|
165
|
+
.build()
|
|
166
|
+
MParticle.start(options)
|
|
164
167
|
}
|
|
165
168
|
}
|
|
166
169
|
```
|
package/android/.project
CHANGED
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
</natures>
|
|
23
23
|
<filteredResources>
|
|
24
24
|
<filter>
|
|
25
|
-
<id>
|
|
25
|
+
<id>1669992816070</id>
|
|
26
26
|
<name></name>
|
|
27
27
|
<type>30</type>
|
|
28
28
|
<matcher>
|
|
29
29
|
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
|
30
|
-
<arguments>node_modules
|
|
30
|
+
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
|
31
31
|
</matcher>
|
|
32
32
|
</filter>
|
|
33
33
|
</filteredResources>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
arguments
|
|
1
|
+
arguments=--init-script /var/folders/g2/z0qqdq651r90nx1z1l28fpj1wbw2yx/T/d146c9752a26f79b52047fb6dc6ed385d064e120494f96f08ca63a317c41f94c.gradle --init-script /var/folders/g2/z0qqdq651r90nx1z1l28fpj1wbw2yx/T/52cde0cfcf3e28b8b7510e992210d9614505e0911af0c190bd590d7158574963.gradle
|
|
2
2
|
auto.sync=false
|
|
3
3
|
build.scans.enabled=false
|
|
4
4
|
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
|
|
@@ -13,6 +13,8 @@ import com.facebook.react.bridge.Callback;
|
|
|
13
13
|
import com.facebook.react.bridge.ReadableType;
|
|
14
14
|
import com.facebook.react.bridge.WritableMap;
|
|
15
15
|
import com.facebook.react.bridge.WritableNativeMap;
|
|
16
|
+
import com.facebook.react.bridge.WritableArray;
|
|
17
|
+
import com.facebook.react.bridge.WritableNativeArray;
|
|
16
18
|
import com.mparticle.AttributionResult;
|
|
17
19
|
import com.mparticle.MParticle;
|
|
18
20
|
import com.mparticle.MPEvent;
|
|
@@ -60,13 +62,18 @@ public class MParticleModule extends ReactContextBaseJavaModule {
|
|
|
60
62
|
return "MParticle";
|
|
61
63
|
}
|
|
62
64
|
|
|
65
|
+
@ReactMethod
|
|
66
|
+
public void upload() {
|
|
67
|
+
MParticle.getInstance().upload();
|
|
68
|
+
}
|
|
69
|
+
|
|
63
70
|
@ReactMethod
|
|
64
71
|
public void logEvent(final String name, int type, final ReadableMap attributesMap) {
|
|
65
72
|
Map<String, String> attributes = ConvertStringMap(attributesMap);
|
|
66
73
|
MParticle.EventType eventType = ConvertEventType(type);
|
|
67
74
|
|
|
68
75
|
MPEvent event = new MPEvent.Builder(name, eventType)
|
|
69
|
-
.
|
|
76
|
+
.customAttributes(attributes)
|
|
70
77
|
.build();
|
|
71
78
|
MParticle.getInstance().logEvent(event);
|
|
72
79
|
}
|
|
@@ -121,7 +128,19 @@ public class MParticleModule extends ReactContextBaseJavaModule {
|
|
|
121
128
|
selectedUser.getUserAttributes(new UserAttributeListener() {
|
|
122
129
|
@Override
|
|
123
130
|
public void onUserAttributesReceived(Map<String, String> userAttributes, Map<String, List<String>> userAttributeLists, Long mpid) {
|
|
124
|
-
|
|
131
|
+
WritableMap resultMap = new WritableNativeMap();
|
|
132
|
+
for (Map.Entry<String, String> entry : userAttributes.entrySet()) {
|
|
133
|
+
resultMap.putString(entry.getKey(), entry.getValue());
|
|
134
|
+
}
|
|
135
|
+
for (Map.Entry<String, List<String>> entry : userAttributeLists.entrySet()) {
|
|
136
|
+
WritableArray resultArray = new WritableNativeArray();
|
|
137
|
+
List<String> valueList = entry.getValue();
|
|
138
|
+
for (String arrayVal : valueList) {
|
|
139
|
+
resultArray.pushString(arrayVal);
|
|
140
|
+
}
|
|
141
|
+
resultMap.putArray(entry.getKey(), resultArray);
|
|
142
|
+
}
|
|
143
|
+
completion.invoke(null, resultMap);
|
|
125
144
|
}
|
|
126
145
|
});
|
|
127
146
|
} else {
|
|
@@ -496,7 +515,7 @@ public class MParticleModule extends ReactContextBaseJavaModule {
|
|
|
496
515
|
if (map.hasKey("info")) {
|
|
497
516
|
ReadableMap customInfoMap = map.getMap("info");
|
|
498
517
|
Map<String, String> customInfo = ConvertStringMap(customInfoMap);
|
|
499
|
-
builder.
|
|
518
|
+
builder.customAttributes(customInfo);
|
|
500
519
|
}
|
|
501
520
|
|
|
502
521
|
if (map.hasKey("customFlags")) {
|
|
@@ -19,6 +19,11 @@ RCT_EXTERN void RCTRegisterModule(Class);
|
|
|
19
19
|
RCTRegisterModule(self);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
RCT_EXPORT_METHOD(upload)
|
|
23
|
+
{
|
|
24
|
+
[[MParticle sharedInstance] upload];
|
|
25
|
+
}
|
|
26
|
+
|
|
22
27
|
RCT_EXPORT_METHOD(logEvent:(NSString *)eventName type:(NSInteger)type attributes:(NSDictionary *)attributes)
|
|
23
28
|
{
|
|
24
29
|
[[MParticle sharedInstance] logEvent:eventName eventType:type eventInfo:attributes];
|
|
Binary file
|
package/js/index.js
CHANGED
|
@@ -84,6 +84,10 @@ const ATTAuthStatus = {
|
|
|
84
84
|
|
|
85
85
|
// ******** Main API ********
|
|
86
86
|
|
|
87
|
+
const upload = () => {
|
|
88
|
+
NativeModules.MParticle.upload()
|
|
89
|
+
}
|
|
90
|
+
|
|
87
91
|
const logEvent = (eventName, type = EventType.Other, attributes = null) => {
|
|
88
92
|
NativeModules.MParticle.logEvent(eventName, type, attributes)
|
|
89
93
|
}
|
|
@@ -660,6 +664,7 @@ const MParticle = {
|
|
|
660
664
|
GDPRConsent,
|
|
661
665
|
CCPAConsent,
|
|
662
666
|
|
|
667
|
+
upload,
|
|
663
668
|
logEvent, // Methods
|
|
664
669
|
logMPEvent,
|
|
665
670
|
logCommerceEvent,
|
package/package.json
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
name: Continuous Integration
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
push:
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
build:
|
|
9
|
-
runs-on: macOS-latest
|
|
10
|
-
steps:
|
|
11
|
-
- name: Checkout
|
|
12
|
-
uses: actions/checkout@v2
|
|
13
|
-
- uses: actions/setup-node@master
|
|
14
|
-
- uses: c-hive/gha-yarn-cache@v1
|
|
15
|
-
|
|
16
|
-
- name: Install node modules
|
|
17
|
-
run: |
|
|
18
|
-
yarn install
|
|
19
|
-
|
|
20
|
-
- name: Run test
|
|
21
|
-
run: |
|
|
22
|
-
yarn test
|