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
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
package com.mparticle.react.testutils;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
|
|
6
|
+
import com.mparticle.MParticle;
|
|
7
|
+
import com.mparticle.UserAttributeListenerType;
|
|
8
|
+
import com.mparticle.consent.ConsentState;
|
|
9
|
+
import com.mparticle.identity.MParticleUser;
|
|
10
|
+
import com.mparticle.audience.AudienceTask;
|
|
11
|
+
import com.mparticle.audience.AudienceResponse;
|
|
12
|
+
|
|
13
|
+
import java.util.Map;
|
|
14
|
+
|
|
15
|
+
public class MockMParticleUser implements MParticleUser {
|
|
16
|
+
Long mpid = 0L;
|
|
17
|
+
|
|
18
|
+
public MockMParticleUser() {}
|
|
19
|
+
|
|
20
|
+
public MockMParticleUser(Long mpid) {
|
|
21
|
+
this.mpid = mpid;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@NonNull
|
|
25
|
+
@Override
|
|
26
|
+
public long getId() {
|
|
27
|
+
return mpid;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@NonNull
|
|
31
|
+
@Override
|
|
32
|
+
public Map<String, Object> getUserAttributes() {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@Nullable
|
|
37
|
+
@Override
|
|
38
|
+
public Map<String, Object> getUserAttributes(@Nullable UserAttributeListenerType userAttributeListener) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@Override
|
|
43
|
+
public boolean setUserAttributes(@NonNull Map<String, Object> map) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@NonNull
|
|
48
|
+
@Override
|
|
49
|
+
public Map<MParticle.IdentityType, String> getUserIdentities() {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@Override
|
|
54
|
+
public boolean setUserAttribute(@NonNull String s, @NonNull Object o) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@Override
|
|
59
|
+
public boolean setUserAttributeList(@NonNull String s, @NonNull Object o) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@Override
|
|
64
|
+
public boolean incrementUserAttribute(@NonNull String s, Number i) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@Override
|
|
69
|
+
public boolean removeUserAttribute(@NonNull String s) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@Override
|
|
74
|
+
public boolean setUserTag(@NonNull String s) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@NonNull
|
|
79
|
+
@Override
|
|
80
|
+
public ConsentState getConsentState() {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@Override
|
|
85
|
+
public void setConsentState(@Nullable ConsentState consentState) {
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@Override
|
|
90
|
+
public boolean isLoggedIn() {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@Override
|
|
95
|
+
public long getFirstSeenTime() {
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@Override
|
|
100
|
+
public long getLastSeenTime() {
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@Override
|
|
105
|
+
public AudienceTask<AudienceResponse> getUserAudiences() {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
package com.mparticle.react.testutils;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.Dynamic;
|
|
6
|
+
import com.facebook.react.bridge.DynamicFromObject;
|
|
7
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
8
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
9
|
+
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
10
|
+
import com.facebook.react.bridge.ReadableType;
|
|
11
|
+
import com.facebook.react.bridge.WritableMap;
|
|
12
|
+
|
|
13
|
+
import org.json.JSONException;
|
|
14
|
+
import org.json.JSONObject;
|
|
15
|
+
|
|
16
|
+
import java.util.ArrayList;
|
|
17
|
+
import java.util.Collection;
|
|
18
|
+
import java.util.HashMap;
|
|
19
|
+
import java.util.Iterator;
|
|
20
|
+
import java.util.List;
|
|
21
|
+
import java.util.Map;
|
|
22
|
+
|
|
23
|
+
public class MockMap implements WritableMap {
|
|
24
|
+
private Map map = new HashMap();
|
|
25
|
+
|
|
26
|
+
public MockMap() {}
|
|
27
|
+
|
|
28
|
+
public MockMap(JSONObject jsonObject) throws JSONException {
|
|
29
|
+
Map map = new HashMap();
|
|
30
|
+
Iterator<String> keys = jsonObject.keys();
|
|
31
|
+
while(keys.hasNext()) {
|
|
32
|
+
String key = keys.next();
|
|
33
|
+
map.put(key, jsonObject.get(key));
|
|
34
|
+
}
|
|
35
|
+
this.map = map;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public MockMap(Map map) {
|
|
39
|
+
this.map = map;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@Override
|
|
43
|
+
public boolean hasKey(String name) {
|
|
44
|
+
return map.containsKey(name);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Override
|
|
48
|
+
public boolean isNull(String name) {
|
|
49
|
+
return map.get(name) == null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Override
|
|
53
|
+
public boolean getBoolean(String name) {
|
|
54
|
+
return (boolean) map.get(name);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Override
|
|
58
|
+
public double getDouble(String name) {
|
|
59
|
+
return (double) map.get(name);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@Override
|
|
63
|
+
public int getInt(String name) {
|
|
64
|
+
return (int) map.get(name);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@Override
|
|
68
|
+
public long getLong(String name) {
|
|
69
|
+
return (long) map.get(name);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@Override
|
|
73
|
+
public String getString(String name) {
|
|
74
|
+
return (String) map.get(name);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@Override
|
|
78
|
+
public ReadableArray getArray(String name) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@Override
|
|
83
|
+
public ReadableMap getMap(String name) {
|
|
84
|
+
return new MockMap((Map) map.get(name));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@Override
|
|
88
|
+
public ReadableType getType(String name) {
|
|
89
|
+
Object obj = map.get(name);
|
|
90
|
+
if (obj instanceof String) {
|
|
91
|
+
return ReadableType.String;
|
|
92
|
+
}
|
|
93
|
+
if (obj instanceof Number) {
|
|
94
|
+
return ReadableType.Number;
|
|
95
|
+
}
|
|
96
|
+
if (obj instanceof Collection) {
|
|
97
|
+
return ReadableType.Array;
|
|
98
|
+
}
|
|
99
|
+
if (obj instanceof Map) {
|
|
100
|
+
return ReadableType.Map;
|
|
101
|
+
}
|
|
102
|
+
if (obj instanceof Boolean) {
|
|
103
|
+
return ReadableType.Boolean;
|
|
104
|
+
}
|
|
105
|
+
if (obj == null) {
|
|
106
|
+
return ReadableType.Null;
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@Override
|
|
112
|
+
public ReadableMapKeySetIterator keySetIterator() {
|
|
113
|
+
return new MockReadableMapKeySetIterator(map.keySet());
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@Override
|
|
117
|
+
public java.util.HashMap<String, Object> toHashMap() {
|
|
118
|
+
return new java.util.HashMap<>(map);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@Override
|
|
122
|
+
public void putNull(String key) {
|
|
123
|
+
map.put(key, null);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@Override
|
|
127
|
+
public void putBoolean(String key, boolean value) {
|
|
128
|
+
map.put(key, value);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@Override
|
|
132
|
+
public void putDouble(String key, double value) {
|
|
133
|
+
map.put(key, value);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@Override
|
|
137
|
+
public void putInt(String key, int value) {
|
|
138
|
+
map.put(key, value);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
@Override
|
|
142
|
+
public void putLong(String key, long value) {
|
|
143
|
+
map.put(key, value);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@Override
|
|
147
|
+
public void putString(String key, String value) {
|
|
148
|
+
map.put(key, value);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@Override
|
|
152
|
+
public void putArray(String key, ReadableArray value) {
|
|
153
|
+
map.put(key, value);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@Override
|
|
157
|
+
public void putMap(String key, ReadableMap value) {
|
|
158
|
+
map.put(key, value);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@Override
|
|
162
|
+
public void merge(ReadableMap source) {
|
|
163
|
+
throw new RuntimeException("Not Implemented");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@Override
|
|
167
|
+
public WritableMap copy() {
|
|
168
|
+
return new MockMap(new java.util.HashMap<>(map));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@NonNull
|
|
172
|
+
@Override
|
|
173
|
+
public Iterator<Map.Entry<String, Object>> getEntryIterator() {
|
|
174
|
+
return map.entrySet().iterator();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@NonNull
|
|
178
|
+
@Override
|
|
179
|
+
public Dynamic getDynamic(@NonNull String s) {
|
|
180
|
+
return new DynamicFromObject(map.get(s));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
class MockReadableMapKeySetIterator implements ReadableMapKeySetIterator {
|
|
184
|
+
List<String> keys;
|
|
185
|
+
int index = 0;
|
|
186
|
+
|
|
187
|
+
MockReadableMapKeySetIterator(Collection<String> keys) {
|
|
188
|
+
this.keys = new ArrayList(keys);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@Override
|
|
192
|
+
public boolean hasNextKey() {
|
|
193
|
+
return index < keys.size();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
@Override
|
|
197
|
+
public String nextKey() {
|
|
198
|
+
String val = keys.get(index);
|
|
199
|
+
index++;
|
|
200
|
+
return val;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
package com.mparticle.react.testutils;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
5
|
+
import com.facebook.react.bridge.ReadableType;
|
|
6
|
+
|
|
7
|
+
public class MockReadableArray implements ReadableArray {
|
|
8
|
+
|
|
9
|
+
@Override
|
|
10
|
+
public int size() {
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@Override
|
|
15
|
+
public boolean isNull(int index) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Override
|
|
20
|
+
public boolean getBoolean(int index) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@Override
|
|
25
|
+
public double getDouble(int index) {
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Override
|
|
30
|
+
public int getInt(int index) {
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@Override
|
|
35
|
+
public long getLong(int index) {
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
public String getString(int index) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@Override
|
|
45
|
+
public ReadableArray getArray(int index) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@Override
|
|
50
|
+
public ReadableMap getMap(int index) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Override
|
|
55
|
+
public ReadableType getType(int index) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@Override
|
|
60
|
+
public com.facebook.react.bridge.Dynamic getDynamic(int index) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@Override
|
|
65
|
+
public java.util.ArrayList<Object> toArrayList() {
|
|
66
|
+
return new java.util.ArrayList<>();
|
|
67
|
+
}
|
|
68
|
+
}
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./plugin/build/withMParticle');
|
|
@@ -58,18 +58,17 @@ RCT_EXTERN void RCTRegisterModule(Class);
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
{
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
// Convert JS struct to NSDictionary for internal use
|
|
61
|
+
// Extracts roktConfig fields into an NSDictionary, returning nil when the
|
|
62
|
+
// TurboModule bridge passes a null C++ reference for an omitted optional param.
|
|
63
|
+
// __attribute__((optnone)) is required: &ref != nullptr is UB in C++ and the
|
|
64
|
+
// compiler removes the check at -O2, causing a SIGSEGV in Release builds.
|
|
65
|
+
static NSDictionary * __attribute__((optnone)) safeExtractRoktConfigDict(
|
|
66
|
+
JS::NativeMPRokt::RoktConfigType &roktConfig) {
|
|
67
|
+
if (&roktConfig == nullptr) {
|
|
68
|
+
return nil;
|
|
69
|
+
}
|
|
71
70
|
NSMutableDictionary *roktConfigDict = [[NSMutableDictionary alloc] init];
|
|
72
|
-
if (
|
|
71
|
+
if (roktConfig.cacheConfig().has_value()) {
|
|
73
72
|
NSMutableDictionary *cacheConfigDict = [[NSMutableDictionary alloc] init];
|
|
74
73
|
auto cacheConfig = roktConfig.cacheConfig().value();
|
|
75
74
|
if (cacheConfig.cacheDurationInSeconds().has_value()) {
|
|
@@ -80,7 +79,19 @@ RCT_EXTERN void RCTRegisterModule(Class);
|
|
|
80
79
|
}
|
|
81
80
|
roktConfigDict[@"cacheConfig"] = cacheConfigDict;
|
|
82
81
|
}
|
|
82
|
+
return roktConfigDict;
|
|
83
|
+
}
|
|
83
84
|
|
|
85
|
+
// New Architecture Implementation
|
|
86
|
+
- (void)selectPlacements:(NSString *)identifer
|
|
87
|
+
attributes:(NSDictionary *)attributes
|
|
88
|
+
placeholders:(NSDictionary *)placeholders
|
|
89
|
+
roktConfig:(JS::NativeMPRokt::RoktConfigType &)roktConfig
|
|
90
|
+
fontFilesMap:(NSDictionary *)fontFilesMap
|
|
91
|
+
{
|
|
92
|
+
NSMutableDictionary *finalAttributes = [self convertToMutableDictionaryOfStrings:attributes];
|
|
93
|
+
|
|
94
|
+
NSDictionary *roktConfigDict = safeExtractRoktConfigDict(roktConfig);
|
|
84
95
|
MPRoktConfig *config = [self buildRoktConfigFromDict:roktConfigDict];
|
|
85
96
|
#else
|
|
86
97
|
// Old Architecture Implementation
|
|
@@ -117,6 +128,9 @@ RCT_EXPORT_METHOD(selectPlacements:(NSString *) identifer attributes:(NSDictiona
|
|
|
117
128
|
[self.eventManager onWidgetHeightChanges:height placement:placementId];
|
|
118
129
|
};
|
|
119
130
|
|
|
131
|
+
if (self.bridge == nil || self.bridge.uiManager == nil) {
|
|
132
|
+
NSLog(@"[mParticle-Rokt] addUIBlock skipped: self.bridge%@ is nil. selectPlacements will not be called. This can occur in New Architecture bridgeless production builds.", self.bridge == nil ? @"" : @".uiManager");
|
|
133
|
+
}
|
|
120
134
|
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
|
|
121
135
|
NSMutableDictionary *nativePlaceholders = [self getNativePlaceholders:placeholders viewRegistry:viewRegistry];
|
|
122
136
|
|
|
@@ -163,7 +163,8 @@ RCT_EXPORT_METHOD(getUserAttributes:(NSString *)mpid callback:(RCTResponseSender
|
|
|
163
163
|
{
|
|
164
164
|
MParticleUser *selectedUser = [[MParticleUser alloc] init];
|
|
165
165
|
selectedUser.userId = [NSNumber numberWithLong:mpid.longLongValue];
|
|
166
|
-
|
|
166
|
+
NSDictionary *attributes = [selectedUser userAttributes] ?: @{};
|
|
167
|
+
callback(@[[NSNull null], attributes]);
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
RCT_EXPORT_METHOD(setUserTag:(NSString *)mpid tag:(NSString *)tag)
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { TurboModule } from 'react-native';
|
|
2
2
|
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
4
|
|
|
4
5
|
export type CustomAttributes = { [key: string]: string | number | boolean };
|
|
5
|
-
export type UserAttributes =
|
|
6
|
-
[key: string]: string | string[] | number | boolean | null;
|
|
7
|
-
};
|
|
6
|
+
export type UserAttributes = UnsafeObject;
|
|
8
7
|
export type UserIdentities = { [key: string]: string };
|
|
9
8
|
|
|
10
9
|
export interface Product {
|
|
@@ -153,7 +152,7 @@ export interface Spec extends TurboModule {
|
|
|
153
152
|
mpid: string,
|
|
154
153
|
callback: (
|
|
155
154
|
error: CallbackError | null,
|
|
156
|
-
result: UserAttributes
|
|
155
|
+
result: UserAttributes
|
|
157
156
|
) => void
|
|
158
157
|
): void;
|
|
159
158
|
setUserTag(mpid: string, tag: string): void;
|
|
@@ -103,9 +103,10 @@ export class RoktLayoutView extends Component<
|
|
|
103
103
|
|
|
104
104
|
// Return the native component with the props
|
|
105
105
|
// Cast to React.ComponentType to make it compatible with JSX
|
|
106
|
+
// Using 'unknown' intermediate cast for compatibility with different @types/react versions
|
|
106
107
|
const RoktComponent =
|
|
107
108
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
108
|
-
RoktNativeLayoutComponent as React.ComponentType<any>;
|
|
109
|
+
RoktNativeLayoutComponent as unknown as React.ComponentType<any>;
|
|
109
110
|
return (
|
|
110
111
|
<RoktComponent
|
|
111
112
|
placeholderName={placeholderName}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { TurboModule } from 'react-native';
|
|
2
|
+
import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
|
|
2
3
|
export type CustomAttributes = {
|
|
3
4
|
[key: string]: string | number | boolean;
|
|
4
5
|
};
|
|
5
|
-
export type UserAttributes =
|
|
6
|
-
[key: string]: string | string[] | number | boolean | null;
|
|
7
|
-
};
|
|
6
|
+
export type UserAttributes = UnsafeObject;
|
|
8
7
|
export type UserIdentities = {
|
|
9
8
|
[key: string]: string;
|
|
10
9
|
};
|
|
@@ -130,7 +129,7 @@ export interface Spec extends TurboModule {
|
|
|
130
129
|
setLocation(latitude: number, longitude: number): void;
|
|
131
130
|
setUserAttribute(mpid: string, key: string, value: string): void;
|
|
132
131
|
setUserAttributeArray(mpid: string, key: string, value: Array<string>): void;
|
|
133
|
-
getUserAttributes(mpid: string, callback: (error: CallbackError | null, result: UserAttributes
|
|
132
|
+
getUserAttributes(mpid: string, callback: (error: CallbackError | null, result: UserAttributes) => void): void;
|
|
134
133
|
setUserTag(mpid: string, tag: string): void;
|
|
135
134
|
incrementUserAttribute(mpid: string, key: string, value: number): void;
|
|
136
135
|
removeUserAttribute(mpid: string, key: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeMParticle.js","sourceRoot":"","sources":["../../js/codegenSpecs/NativeMParticle.ts"],"names":[],"mappings":";;AACA,+CAAmD;
|
|
1
|
+
{"version":3,"file":"NativeMParticle.js","sourceRoot":"","sources":["../../js/codegenSpecs/NativeMParticle.ts"],"names":[],"mappings":";;AACA,+CAAmD;AAmNnD,kBAAe,kCAAmB,CAAC,YAAY,CAAO,aAAa,CAAC,CAAC"}
|
|
@@ -84,6 +84,7 @@ class RoktLayoutView extends react_1.Component {
|
|
|
84
84
|
const { placeholderName } = this.props;
|
|
85
85
|
// Return the native component with the props
|
|
86
86
|
// Cast to React.ComponentType to make it compatible with JSX
|
|
87
|
+
// Using 'unknown' intermediate cast for compatibility with different @types/react versions
|
|
87
88
|
const RoktComponent =
|
|
88
89
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
90
|
RoktLayoutNativeComponent_1.default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rokt-layout-view.android.js","sourceRoot":"","sources":["../../js/rokt/rokt-layout-view.android.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA0C;AAC1C,+CAAyC;AACzC,+GAAuF;AAwCvF,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,MAAM,EAAE;QACN,IAAI,EAAE,CAAC;QACP,eAAe,EAAE,aAAa;KAC/B;CACF,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAa,cAAe,SAAQ,iBAGnC;IACC,YAAY,KAA0B;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;QAWf;;;WAGG;QACK,wBAAmB,GAAG,CAAC,KAAyB,EAAE,EAAE;YAC1D,IAAI,KAAK,IAAI,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE;gBAC1D,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,QAA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YACrC,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;YAEvC,6CAA6C;YAC7C,6DAA6D;YAC7D,2FAA2F;YAC3F,MAAM,aAAa;YACjB,8DAA8D;YAC9D,mCAAgE,CAAC;YACnE,OAAO,CACL,CAAC,aAAa,CACZ,eAAe,CAAC,CAAC,eAAe,CAAC,CACjC,KAAK,CAAC,CAAC;oBACL,MAAM,CAAC,MAAM;oBACb;wBACE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;wBACzB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;wBAC/B,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU;wBACjC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW;wBACnC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY;qBACtC;iBACF,CAAC,CACF,qBAAqB,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAChD,qBAAqB,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,EAChD,CACH,CAAC;SACH;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,0CAA0C,EAAE,KAAK,CAAC,CAAC;YACjE,OAAO,IAAI,CAAC;SACb;IACH,CAAC;CACF;AA5ED,wCA4EC;AAED,kBAAe,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -4,31 +4,55 @@
|
|
|
4
4
|
"homepage": "https://www.mparticle.com",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "mParticle/react-native-mparticle",
|
|
7
|
-
"version": "2.
|
|
7
|
+
"version": "2.9.0",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"types": "lib/index.d.ts",
|
|
10
10
|
"react-native": "js/index",
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "tsc",
|
|
13
|
+
"build:plugin": "tsc --build plugin",
|
|
13
14
|
"clean": "rm -rf lib",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
15
|
+
"clean:plugin": "rm -rf plugin/build",
|
|
16
|
+
"prepare": "yarn clean && yarn build && yarn build:plugin",
|
|
17
|
+
"dev:pack": "yarn build && yarn build:plugin && yarn pack --filename react-native-mparticle-latest.tgz",
|
|
16
18
|
"dev:link": "./dev-link.sh",
|
|
17
19
|
"lint": "eslint '{js,lib}/**/*.{ts,tsx}' --fix",
|
|
18
20
|
"format": "prettier --write '{js,lib}/**/*.{ts,tsx}'",
|
|
19
21
|
"test": "npm run lint"
|
|
20
22
|
},
|
|
23
|
+
"files": [
|
|
24
|
+
"android",
|
|
25
|
+
"ios",
|
|
26
|
+
"js",
|
|
27
|
+
"lib",
|
|
28
|
+
"react-native-mparticle.podspec",
|
|
29
|
+
"app.plugin.js",
|
|
30
|
+
"plugin"
|
|
31
|
+
],
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public",
|
|
34
|
+
"provenance": true,
|
|
35
|
+
"registry": "https://registry.npmjs.org"
|
|
36
|
+
},
|
|
21
37
|
"dependencies": {},
|
|
22
38
|
"peerDependencies": {
|
|
23
39
|
"react": ">= 16.0.0-alpha.12",
|
|
24
|
-
"react-native": ">= 0.45.0"
|
|
40
|
+
"react-native": ">= 0.45.0",
|
|
41
|
+
"@expo/config-plugins": ">=7.0.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependenciesMeta": {
|
|
44
|
+
"@expo/config-plugins": {
|
|
45
|
+
"optional": true
|
|
46
|
+
}
|
|
25
47
|
},
|
|
26
48
|
"devDependencies": {
|
|
49
|
+
"@expo/config-plugins": "^7.2.5",
|
|
27
50
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
28
51
|
"@typescript-eslint/parser": "^5.62.0",
|
|
29
52
|
"eslint": "^8.45.0",
|
|
30
53
|
"eslint-config-prettier": "^8.10.0",
|
|
31
54
|
"eslint-plugin-prettier": "^4.2.1",
|
|
55
|
+
"expo-module-scripts": "^3.0.0",
|
|
32
56
|
"prettier": "^2.8.8",
|
|
33
57
|
"@types/react": "^18.0.0",
|
|
34
58
|
"@types/react-native": "^0.70.0",
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
/**
|
|
3
|
+
* mParticle plugin configuration options
|
|
4
|
+
*/
|
|
5
|
+
export interface MParticlePluginProps {
|
|
6
|
+
/**
|
|
7
|
+
* iOS API key from mParticle dashboard
|
|
8
|
+
*/
|
|
9
|
+
iosApiKey: string;
|
|
10
|
+
/**
|
|
11
|
+
* iOS API secret from mParticle dashboard
|
|
12
|
+
*/
|
|
13
|
+
iosApiSecret: string;
|
|
14
|
+
/**
|
|
15
|
+
* Android API key from mParticle dashboard
|
|
16
|
+
*/
|
|
17
|
+
androidApiKey: string;
|
|
18
|
+
/**
|
|
19
|
+
* Android API secret from mParticle dashboard
|
|
20
|
+
*/
|
|
21
|
+
androidApiSecret: string;
|
|
22
|
+
/**
|
|
23
|
+
* Log level for debugging
|
|
24
|
+
* @default 'none'
|
|
25
|
+
*/
|
|
26
|
+
logLevel?: 'none' | 'error' | 'warning' | 'debug' | 'verbose';
|
|
27
|
+
/**
|
|
28
|
+
* mParticle environment
|
|
29
|
+
* @default 'autoDetect'
|
|
30
|
+
*/
|
|
31
|
+
environment?: 'development' | 'production' | 'autoDetect';
|
|
32
|
+
/**
|
|
33
|
+
* Data plan ID for validation
|
|
34
|
+
*/
|
|
35
|
+
dataPlanId?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Data plan version for validation
|
|
38
|
+
*/
|
|
39
|
+
dataPlanVersion?: number;
|
|
40
|
+
/**
|
|
41
|
+
* iOS kit pod names to include
|
|
42
|
+
* @example ['mParticle-Rokt', 'mParticle-Amplitude']
|
|
43
|
+
*/
|
|
44
|
+
iosKits?: string[];
|
|
45
|
+
/**
|
|
46
|
+
* Android kit artifact names to include (version auto-detected from core SDK)
|
|
47
|
+
* @example ['android-rokt-kit', 'android-amplitude-kit']
|
|
48
|
+
*/
|
|
49
|
+
androidKits?: string[];
|
|
50
|
+
/**
|
|
51
|
+
* Whether to use an empty identify request at initialization
|
|
52
|
+
* If true or omitted, uses requestWithEmptyUser/withEmptyUser()
|
|
53
|
+
* If false, no identify request is made at initialization
|
|
54
|
+
* Identity should be updated from React Native code after initialization
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
useEmptyIdentifyRequest?: boolean;
|
|
58
|
+
}
|
|
59
|
+
declare const _default: ConfigPlugin<MParticlePluginProps>;
|
|
60
|
+
export default _default;
|