@metrixorg/react-native-plugin 2.2.14 → 2.4.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/android/.settings/org.eclipse.buildship.core.prefs +13 -0
- package/android/build.gradle +3 -3
- package/android/src/main/java/ir/metrix/reactnative/MetrixModule.java +31 -18
- package/android/src/main/java/ir/metrix/reactnative/ReadableMapUtils.java +72 -0
- package/android/src/main/java/ir/metrix/reactnative/Reflection.java +8 -4
- package/index.js +29 -4
- package/package.json +3 -3
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
arguments=--init-script /var/folders/3y/rmmx1z3n28q716pq_3s9py4w0000gn/T/db3b08fc4a9ef609cb16b96b200fa13e563f396e9bb1ed0905fdab7bc3bc513b.gradle --init-script /var/folders/3y/rmmx1z3n28q716pq_3s9py4w0000gn/T/52cde0cfcf3e28b8b7510e992210d9614505e0911af0c190bd590d7158574963.gradle
|
|
2
|
+
auto.sync=false
|
|
3
|
+
build.scans.enabled=false
|
|
4
|
+
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(8.9))
|
|
5
|
+
connection.project.dir=
|
|
6
|
+
eclipse.preferences.version=1
|
|
7
|
+
gradle.user.home=
|
|
8
|
+
java.home=/Library/Java/JavaVirtualMachines/zulu-17.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
|
package/android/build.gradle
CHANGED
|
@@ -38,9 +38,9 @@ rootProject.allprojects {
|
|
|
38
38
|
dependencies {
|
|
39
39
|
implementation 'com.facebook.react:react-native:+'
|
|
40
40
|
|
|
41
|
-
implementation 'ir.metrix.analytics:metrix-reactnative:2.
|
|
42
|
-
implementation 'ir.metrix.attribution:metrix-reactnative:2.
|
|
41
|
+
implementation 'ir.metrix.analytics:metrix-reactnative:2.4.0'
|
|
42
|
+
implementation 'ir.metrix.attribution:metrix-reactnative:2.4.0'
|
|
43
43
|
if (project.ext.notificationEnabled) {
|
|
44
|
-
api 'ir.metrix.notification:metrix-reactnative:2.
|
|
44
|
+
api 'ir.metrix.notification:metrix-reactnative:2.4.0'
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -46,21 +46,23 @@ public class MetrixModule extends ReactContextBaseJavaModule {
|
|
|
46
46
|
public void removeListeners(Integer count) { }
|
|
47
47
|
|
|
48
48
|
@ReactMethod
|
|
49
|
-
public void newEvent(String
|
|
50
|
-
ir.metrix.analytics.MetrixAnalytics.newEvent(
|
|
49
|
+
public void newEvent(String slug) {
|
|
50
|
+
ir.metrix.analytics.MetrixAnalytics.newEvent(slug);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
@ReactMethod
|
|
54
|
-
public void
|
|
55
|
-
|
|
54
|
+
public void newEventByName(String name) {
|
|
55
|
+
ir.metrix.analytics.MetrixAnalytics.newEventByName(name);
|
|
56
|
+
}
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
58
|
+
@ReactMethod
|
|
59
|
+
public void newCustomEvent(String slug, ReadableMap customAttributes) {
|
|
60
|
+
ir.metrix.analytics.MetrixAnalytics.newEvent(slug, ReadableMapUtils.toMap(customAttributes));
|
|
61
|
+
}
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
@ReactMethod
|
|
64
|
+
public void newCustomEventByName(String name, ReadableMap customAttributes) {
|
|
65
|
+
ir.metrix.analytics.MetrixAnalytics.newEventByName(name, ReadableMapUtils.toMap(customAttributes));
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
@ReactMethod
|
|
@@ -68,11 +70,21 @@ public class MetrixModule extends ReactContextBaseJavaModule {
|
|
|
68
70
|
ir.metrix.analytics.MetrixAnalytics.newRevenue(slug, revenue);
|
|
69
71
|
}
|
|
70
72
|
|
|
73
|
+
@ReactMethod
|
|
74
|
+
public void newRevenueByNameSimple(String name, Double revenue) {
|
|
75
|
+
ir.metrix.analytics.MetrixAnalytics.newRevenueByName(name, revenue);
|
|
76
|
+
}
|
|
77
|
+
|
|
71
78
|
@ReactMethod
|
|
72
79
|
public void newRevenueCurrency(String slug, Double revenue, String currency) {
|
|
73
80
|
ir.metrix.analytics.MetrixAnalytics.newRevenue(slug, revenue, RevenueCurrency.valueOf(currency));
|
|
74
81
|
}
|
|
75
82
|
|
|
83
|
+
@ReactMethod
|
|
84
|
+
public void newRevenueByNameCurrency(String name, Double revenue, String currency) {
|
|
85
|
+
ir.metrix.analytics.MetrixAnalytics.newRevenueByName(name, revenue, RevenueCurrency.valueOf(currency));
|
|
86
|
+
}
|
|
87
|
+
|
|
76
88
|
@ReactMethod
|
|
77
89
|
public void setSessionNumberListener() {
|
|
78
90
|
ir.metrix.analytics.MetrixAnalytics.setSessionNumberListener(
|
|
@@ -97,10 +109,9 @@ public class MetrixModule extends ReactContextBaseJavaModule {
|
|
|
97
109
|
|
|
98
110
|
@ReactMethod
|
|
99
111
|
public void setUserAttributes(ReadableMap userAttributes) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
ir.metrix.analytics.MetrixAnalytics.User.setCustomAttribute(key, userAttributes.getString(key));
|
|
112
|
+
Map<String, Object> customAttributes = ReadableMapUtils.toMap(userAttributes);
|
|
113
|
+
for (Map.Entry<String, Object> entry : customAttributes.entrySet()) {
|
|
114
|
+
ir.metrix.analytics.MetrixAnalytics.User.setCustomAttribute(entry.getKey(), entry.getValue());
|
|
104
115
|
}
|
|
105
116
|
}
|
|
106
117
|
|
|
@@ -189,6 +200,11 @@ public class MetrixModule extends ReactContextBaseJavaModule {
|
|
|
189
200
|
ir.metrix.analytics.MetrixAnalytics.User.channelDisabled(MessageChannel.valueOf(channel));
|
|
190
201
|
}
|
|
191
202
|
|
|
203
|
+
@ReactMethod
|
|
204
|
+
public void setSignature(String signature) {
|
|
205
|
+
ir.metrix.attribution.MetrixAttribution.setSignature(signature);
|
|
206
|
+
}
|
|
207
|
+
|
|
192
208
|
@ReactMethod
|
|
193
209
|
public void setPushToken(String token) {
|
|
194
210
|
ir.metrix.attribution.MetrixAttribution.setPushToken(token);
|
|
@@ -196,10 +212,7 @@ public class MetrixModule extends ReactContextBaseJavaModule {
|
|
|
196
212
|
|
|
197
213
|
@ReactMethod
|
|
198
214
|
public void loadInAppMessages() {
|
|
199
|
-
ir.metrix.
|
|
200
|
-
"ir.metrix.notification.MetrixNotification",
|
|
201
|
-
"loadInAppMessages"
|
|
202
|
-
);
|
|
215
|
+
Reflection.invokeStaticMethod("ir.metrix.notification.MetrixNotification", "loadInAppMessages");
|
|
203
216
|
}
|
|
204
217
|
|
|
205
218
|
@ReactMethod
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
package ir.metrix.reactnative;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.*;
|
|
4
|
+
import java.util.*;
|
|
5
|
+
|
|
6
|
+
public class ReadableMapUtils {
|
|
7
|
+
|
|
8
|
+
public static Map<String, Object> toMap(ReadableMap readableMap) {
|
|
9
|
+
Map<String, Object> result = new HashMap<>();
|
|
10
|
+
|
|
11
|
+
ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
|
|
12
|
+
while (iterator.hasNextKey()) {
|
|
13
|
+
String key = iterator.nextKey();
|
|
14
|
+
ReadableType type = readableMap.getType(key);
|
|
15
|
+
|
|
16
|
+
switch (type) {
|
|
17
|
+
case Null:
|
|
18
|
+
result.put(key, null);
|
|
19
|
+
break;
|
|
20
|
+
case Boolean:
|
|
21
|
+
result.put(key, readableMap.getBoolean(key));
|
|
22
|
+
break;
|
|
23
|
+
case Number:
|
|
24
|
+
// Double is used for both integer and floating point
|
|
25
|
+
result.put(key, readableMap.getDouble(key));
|
|
26
|
+
break;
|
|
27
|
+
case String:
|
|
28
|
+
result.put(key, readableMap.getString(key));
|
|
29
|
+
break;
|
|
30
|
+
case Map:
|
|
31
|
+
result.put(key, toMap(readableMap.getMap(key)));
|
|
32
|
+
break;
|
|
33
|
+
case Array:
|
|
34
|
+
result.put(key, toList(readableMap.getArray(key)));
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public static List<Object> toList(ReadableArray readableArray) {
|
|
43
|
+
List<Object> result = new ArrayList<>();
|
|
44
|
+
|
|
45
|
+
for (int i = 0; i < readableArray.size(); i++) {
|
|
46
|
+
ReadableType type = readableArray.getType(i);
|
|
47
|
+
|
|
48
|
+
switch (type) {
|
|
49
|
+
case Null:
|
|
50
|
+
result.add(null);
|
|
51
|
+
break;
|
|
52
|
+
case Boolean:
|
|
53
|
+
result.add(readableArray.getBoolean(i));
|
|
54
|
+
break;
|
|
55
|
+
case Number:
|
|
56
|
+
result.add(readableArray.getDouble(i));
|
|
57
|
+
break;
|
|
58
|
+
case String:
|
|
59
|
+
result.add(readableArray.getString(i));
|
|
60
|
+
break;
|
|
61
|
+
case Map:
|
|
62
|
+
result.add(toMap(readableArray.getMap(i)));
|
|
63
|
+
break;
|
|
64
|
+
case Array:
|
|
65
|
+
result.add(toList(readableArray.getArray(i)));
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -4,9 +4,13 @@ import java.lang.reflect.Method;
|
|
|
4
4
|
|
|
5
5
|
public class Reflection {
|
|
6
6
|
|
|
7
|
-
public static Object invokeStaticMethod(String className, String methodName)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
public static Object invokeStaticMethod(String className, String methodName) {
|
|
8
|
+
try {
|
|
9
|
+
Class<?> clazz = Class.forName(className);
|
|
10
|
+
Method method = clazz.getDeclaredMethod(methodName);
|
|
11
|
+
return method.invoke(null);
|
|
12
|
+
} catch (Exception e) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
11
15
|
}
|
|
12
16
|
}
|
package/index.js
CHANGED
|
@@ -18,6 +18,10 @@ Metrix.initialize = function (appId) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
Metrix.setSignature = function (signature) {
|
|
22
|
+
module_metrix.setSignature(signature);
|
|
23
|
+
};
|
|
24
|
+
|
|
21
25
|
Metrix.setPushToken = function (token) {
|
|
22
26
|
module_metrix.setPushToken(token);
|
|
23
27
|
};
|
|
@@ -47,11 +51,19 @@ Metrix.setUserIdListener = function (callback) {
|
|
|
47
51
|
module_metrix.setUserIdListener();
|
|
48
52
|
};
|
|
49
53
|
|
|
50
|
-
Metrix.newEvent = function (
|
|
54
|
+
Metrix.newEvent = function (slug, customAttributes) {
|
|
55
|
+
if (customAttributes) {
|
|
56
|
+
module_metrix.newCustomEvent(slug, customAttributes);
|
|
57
|
+
} else {
|
|
58
|
+
module_metrix.newEvent(slug);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
Metrix.newEventByName = function (name, customAttributes) {
|
|
51
63
|
if (customAttributes) {
|
|
52
|
-
module_metrix.
|
|
64
|
+
module_metrix.newCustomEventByName(name, customAttributes);
|
|
53
65
|
} else {
|
|
54
|
-
module_metrix.
|
|
66
|
+
module_metrix.newEventByName(name);
|
|
55
67
|
}
|
|
56
68
|
};
|
|
57
69
|
|
|
@@ -60,7 +72,7 @@ Metrix.newRevenue = function (slug, revenue, currency) {
|
|
|
60
72
|
module_metrix.newRevenueSimple(slug, revenue);
|
|
61
73
|
} else if (currency != null) {
|
|
62
74
|
if (typeof currency === 'string') {
|
|
63
|
-
module_metrix.
|
|
75
|
+
module_metrix.newRevenueCurrency(slug, revenue, currency);
|
|
64
76
|
} else {
|
|
65
77
|
let currencyValue = getCurrency(currency)
|
|
66
78
|
module_metrix.newRevenueCurrency(slug, revenue, currencyValue);
|
|
@@ -68,6 +80,19 @@ Metrix.newRevenue = function (slug, revenue, currency) {
|
|
|
68
80
|
}
|
|
69
81
|
};
|
|
70
82
|
|
|
83
|
+
Metrix.newRevenueByName = function (name, revenue, currency) {
|
|
84
|
+
if (currency == null) {
|
|
85
|
+
module_metrix.newRevenueByNameSimple(name, revenue);
|
|
86
|
+
} else if (currency != null) {
|
|
87
|
+
if (typeof currency === 'string') {
|
|
88
|
+
module_metrix.newRevenueByNameCurrency(name, revenue, currency);
|
|
89
|
+
} else {
|
|
90
|
+
let currencyValue = getCurrency(currency)
|
|
91
|
+
module_metrix.newRevenueByNameCurrency(name, revenue, currencyValue);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
71
96
|
Metrix.setUserAttributes = function (userAttributes) {
|
|
72
97
|
if (Platform.OS === "android") {
|
|
73
98
|
module_metrix.setUserAttributes(userAttributes);
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metrixorg/react-native-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Metrix React native plugin",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
8
|
"deploy": "git checkout master && git pull && git merge develop",
|
|
9
9
|
"major": "2",
|
|
10
|
-
"minor": "
|
|
11
|
-
"patch": "
|
|
10
|
+
"minor": "4",
|
|
11
|
+
"patch": "0"
|
|
12
12
|
},
|
|
13
13
|
"author": "Metrix",
|
|
14
14
|
"license": "Apache 2.0",
|