@appmetrica/react-native-analytics 3.5.0 → 4.0.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/build.gradle +12 -16
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/AndroidManifestNew.xml +1 -1
- package/android/src/main/java/io/appmetrica/analytics/reactnative/AppMetricaModule.java +56 -49
- package/android/src/main/java/io/appmetrica/analytics/reactnative/AppMetricaPackage.java +26 -14
- package/android/src/main/java/io/appmetrica/analytics/reactnative/ReactNativeDeferredDeeplinkListener.java +1 -3
- package/android/src/main/java/io/appmetrica/analytics/reactnative/ReactNativeDeferredDeeplinkParametersListener.java +4 -5
- package/android/src/main/java/io/appmetrica/analytics/reactnative/ReactNativeStartupParamsListener.java +23 -7
- package/android/src/main/java/io/appmetrica/analytics/reactnative/ReporterModule.java +17 -18
- package/android/src/main/java/io/appmetrica/analytics/reactnative/Utils.java +7 -27
- package/appmetrica-react-native-analytics.podspec +2 -23
- package/ios/AMARNAppMetrica.h +6 -2
- package/ios/{AMARNAppMetrica.m → AMARNAppMetrica.mm} +65 -39
- package/ios/{AMARNAppMetricaUtils.m → AMARNAppMetricaUtils.mm} +1 -1
- package/ios/AMARNReporter.h +6 -2
- package/ios/{AMARNReporter.m → AMARNReporter.mm} +24 -20
- package/ios/AMARNStartupParamsUtils.mm +33 -0
- package/lib/commonjs/deferredDeeplink.js.map +1 -1
- package/lib/commonjs/ecommerce.js +1 -1
- package/lib/commonjs/ecommerce.js.map +1 -1
- package/lib/commonjs/error.js +1 -1
- package/lib/commonjs/error.js.map +1 -1
- package/lib/commonjs/externalAttribution.js.map +1 -1
- package/lib/commonjs/index.js +63 -52
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/reporter.js +17 -25
- package/lib/commonjs/reporter.js.map +1 -1
- package/lib/commonjs/revenue.js.map +1 -1
- package/lib/commonjs/specs/NativeAppMetrica.js +9 -0
- package/lib/commonjs/specs/NativeAppMetrica.js.map +1 -0
- package/lib/commonjs/specs/NativeReporter.js +9 -0
- package/lib/commonjs/specs/NativeReporter.js.map +1 -0
- package/lib/commonjs/types.js +27 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/userProfile.js.map +1 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/deferredDeeplink.js +1 -1
- package/lib/module/deferredDeeplink.js.map +1 -1
- package/lib/module/ecommerce.js +3 -1
- package/lib/module/ecommerce.js.map +1 -1
- package/lib/module/error.js +3 -1
- package/lib/module/error.js.map +1 -1
- package/lib/module/externalAttribution.js +2 -0
- package/lib/module/externalAttribution.js.map +1 -1
- package/lib/module/index.js +24 -18
- package/lib/module/index.js.map +1 -1
- package/lib/module/reporter.js +3 -10
- package/lib/module/reporter.js.map +1 -1
- package/lib/module/revenue.js +2 -0
- package/lib/module/revenue.js.map +1 -1
- package/lib/module/specs/NativeAppMetrica.js +5 -0
- package/lib/module/specs/NativeAppMetrica.js.map +1 -0
- package/lib/module/specs/NativeReporter.js +5 -0
- package/lib/module/specs/NativeReporter.js.map +1 -0
- package/lib/module/types.js +21 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/userProfile.js +2 -0
- package/lib/module/userProfile.js.map +1 -1
- package/lib/module/utils.js +2 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/src/ecommerce.d.ts +1 -1
- package/lib/typescript/src/ecommerce.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +7 -50
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/reporter.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeAppMetrica.d.ts +41 -0
- package/lib/typescript/src/specs/NativeAppMetrica.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeReporter.d.ts +21 -0
- package/lib/typescript/src/specs/NativeReporter.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +64 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +22 -8
- package/src/ecommerce.ts +2 -2
- package/src/index.ts +36 -82
- package/src/reporter.ts +1 -18
- package/src/specs/NativeAppMetrica.ts +52 -0
- package/src/specs/NativeReporter.ts +22 -0
- package/src/types.ts +95 -0
- package/ios/AMARNStartupParamsUtils.m +0 -53
- /package/ios/{AMARNExceptionSerializer.m → AMARNExceptionSerializer.mm} +0 -0
- /package/ios/{AMARNExternalAttribution.m → AMARNExternalAttribution.mm} +0 -0
- /package/ios/{AMARNUserProfileSerializer.m → AMARNUserProfileSerializer.mm} +0 -0
package/android/build.gradle
CHANGED
|
@@ -5,24 +5,12 @@ buildscript {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
dependencies {
|
|
8
|
-
classpath "com.android.tools.build:gradle:
|
|
8
|
+
classpath "com.android.tools.build:gradle:8.2.1"
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
def reactNativeArchitectures() {
|
|
13
|
-
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
14
|
-
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
def isNewArchitectureEnabled() {
|
|
18
|
-
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
19
|
-
}
|
|
20
|
-
|
|
21
12
|
apply plugin: "com.android.library"
|
|
22
|
-
|
|
23
|
-
if (isNewArchitectureEnabled()) {
|
|
24
|
-
apply plugin: "com.facebook.react"
|
|
25
|
-
}
|
|
13
|
+
apply plugin: "com.facebook.react"
|
|
26
14
|
|
|
27
15
|
def getExtOrDefault(name) {
|
|
28
16
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["AppMetrica_" + name]
|
|
@@ -73,6 +61,14 @@ android {
|
|
|
73
61
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
74
62
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
75
63
|
}
|
|
64
|
+
|
|
65
|
+
sourceSets {
|
|
66
|
+
main {
|
|
67
|
+
java.srcDirs += [
|
|
68
|
+
"generated/java"
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
76
72
|
}
|
|
77
73
|
|
|
78
74
|
repositories {
|
|
@@ -84,6 +80,6 @@ dependencies {
|
|
|
84
80
|
// For < 0.71, this will be from the local maven repo
|
|
85
81
|
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
86
82
|
//noinspection GradleDynamicVersion
|
|
87
|
-
implementation "com.facebook.react:react-
|
|
88
|
-
implementation
|
|
83
|
+
implementation "com.facebook.react:react-android"
|
|
84
|
+
implementation("io.appmetrica.analytics:analytics:8.0.0")
|
|
89
85
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
package="io.appmetrica.analytics.reactnative">
|
|
3
3
|
|
|
4
4
|
<application>
|
|
5
|
-
<meta-data android:name="io.appmetrica.analytics.plugin_id" android:value="react-native-
|
|
5
|
+
<meta-data android:name="io.appmetrica.analytics.plugin_id" android:value="react-native-4.0.0" />
|
|
6
6
|
</application>
|
|
7
7
|
|
|
8
8
|
</manifest>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
2
|
|
|
3
3
|
<application>
|
|
4
|
-
<meta-data android:name="io.appmetrica.analytics.plugin_id" android:value="react-native-
|
|
4
|
+
<meta-data android:name="io.appmetrica.analytics.plugin_id" android:value="react-native-4.0.0" />
|
|
5
5
|
</application>
|
|
6
6
|
|
|
7
7
|
</manifest>
|
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
package io.appmetrica.analytics.reactnative;
|
|
2
2
|
|
|
3
|
-
import android.text.TextUtils;
|
|
4
3
|
import android.util.Log;
|
|
4
|
+
|
|
5
5
|
import androidx.annotation.NonNull;
|
|
6
|
+
|
|
6
7
|
import com.facebook.react.bridge.Callback;
|
|
7
|
-
import com.facebook.react.bridge.Promise;
|
|
8
8
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
9
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
10
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
11
9
|
import com.facebook.react.bridge.ReadableArray;
|
|
12
10
|
import com.facebook.react.bridge.ReadableMap;
|
|
13
|
-
import com.facebook.react.module.annotations.ReactModule;
|
|
14
11
|
|
|
15
|
-
import java.util.
|
|
12
|
+
import java.util.HashMap;
|
|
16
13
|
import java.util.Map;
|
|
17
14
|
|
|
18
15
|
import io.appmetrica.analytics.AppMetrica;
|
|
19
16
|
import io.appmetrica.analytics.AppMetricaConfig;
|
|
20
17
|
import io.appmetrica.analytics.ModulesFacade;
|
|
18
|
+
import io.appmetrica.analytics.StartupParamsCallback;
|
|
21
19
|
import io.appmetrica.analytics.ecommerce.ECommerceEvent;
|
|
22
20
|
import io.appmetrica.analytics.plugins.PluginErrorDetails;
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
public class AppMetricaModule extends
|
|
22
|
+
|
|
23
|
+
public class AppMetricaModule extends NativeAppMetricaSpec {
|
|
26
24
|
|
|
27
25
|
public static final String NAME = "AppMetrica";
|
|
28
26
|
public static final String TAG = "AppMetricaModule";
|
|
@@ -41,7 +39,7 @@ public class AppMetricaModule extends ReactContextBaseJavaModule {
|
|
|
41
39
|
return NAME;
|
|
42
40
|
}
|
|
43
41
|
|
|
44
|
-
@
|
|
42
|
+
@Override
|
|
45
43
|
public void activate(ReadableMap configMap) {
|
|
46
44
|
AppMetricaConfig config = Utils.toAppMetricaConfig(configMap);
|
|
47
45
|
AppMetrica.activate(reactContext, config);
|
|
@@ -50,33 +48,33 @@ public class AppMetricaModule extends ReactContextBaseJavaModule {
|
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
@
|
|
54
|
-
public
|
|
55
|
-
|
|
51
|
+
@Override
|
|
52
|
+
public double getLibraryApiLevel() {
|
|
53
|
+
return AppMetrica.getLibraryApiLevel();
|
|
56
54
|
}
|
|
57
55
|
|
|
58
|
-
@
|
|
59
|
-
public
|
|
60
|
-
|
|
56
|
+
@Override
|
|
57
|
+
public String getLibraryVersion() {
|
|
58
|
+
return AppMetrica.getLibraryVersion();
|
|
61
59
|
}
|
|
62
60
|
|
|
63
|
-
@
|
|
61
|
+
@Override
|
|
64
62
|
public void pauseSession() {
|
|
65
|
-
AppMetrica.pauseSession(getCurrentActivity());
|
|
63
|
+
AppMetrica.pauseSession(reactContext.getCurrentActivity());
|
|
66
64
|
}
|
|
67
65
|
|
|
68
|
-
@
|
|
66
|
+
@Override
|
|
69
67
|
public void reportAppOpen(String deeplink) {
|
|
70
68
|
AppMetrica.reportAppOpen(deeplink);
|
|
71
69
|
}
|
|
72
70
|
|
|
73
|
-
@
|
|
71
|
+
@Override
|
|
74
72
|
public void reportError(String identifier, String message, ReadableMap _reason) {
|
|
75
73
|
PluginErrorDetails errorDetails = _reason != null ? ExceptionSerializer.fromObject(_reason) : null;
|
|
76
74
|
AppMetrica.getPluginExtension().reportError(identifier, message, errorDetails);
|
|
77
75
|
}
|
|
78
76
|
|
|
79
|
-
@
|
|
77
|
+
@Override
|
|
80
78
|
public void reportEvent(String eventName, ReadableMap attributes) {
|
|
81
79
|
if (attributes == null) {
|
|
82
80
|
AppMetrica.reportEvent(eventName);
|
|
@@ -85,42 +83,42 @@ public class AppMetricaModule extends ReactContextBaseJavaModule {
|
|
|
85
83
|
}
|
|
86
84
|
}
|
|
87
85
|
|
|
88
|
-
@
|
|
89
|
-
public void requestStartupParams(
|
|
90
|
-
AppMetrica.requestStartupParams(reactContext, new ReactNativeStartupParamsListener(listener), Utils.
|
|
86
|
+
@Override
|
|
87
|
+
public void requestStartupParams(Callback listener, ReadableArray identifiers) {
|
|
88
|
+
AppMetrica.requestStartupParams(reactContext, new ReactNativeStartupParamsListener(listener), Utils.toListOfStrings(identifiers));
|
|
91
89
|
}
|
|
92
90
|
|
|
93
|
-
@
|
|
91
|
+
@Override
|
|
94
92
|
public void resumeSession() {
|
|
95
93
|
AppMetrica.resumeSession(getCurrentActivity());
|
|
96
94
|
}
|
|
97
95
|
|
|
98
|
-
@
|
|
96
|
+
@Override
|
|
99
97
|
public void sendEventsBuffer() {
|
|
100
98
|
AppMetrica.sendEventsBuffer();
|
|
101
99
|
}
|
|
102
100
|
|
|
103
|
-
@
|
|
101
|
+
@Override
|
|
104
102
|
public void setLocation(ReadableMap locationMap) {
|
|
105
103
|
AppMetrica.setLocation(Utils.toLocation(locationMap));
|
|
106
104
|
}
|
|
107
105
|
|
|
108
|
-
@
|
|
106
|
+
@Override
|
|
109
107
|
public void setLocationTracking(boolean enabled) {
|
|
110
108
|
AppMetrica.setLocationTracking(enabled);
|
|
111
109
|
}
|
|
112
110
|
|
|
113
|
-
@
|
|
111
|
+
@Override
|
|
114
112
|
public void setDataSendingEnabled(boolean enabled) {
|
|
115
113
|
AppMetrica.setDataSendingEnabled(enabled);
|
|
116
114
|
}
|
|
117
115
|
|
|
118
|
-
@
|
|
116
|
+
@Override
|
|
119
117
|
public void setUserProfileID(String userProfileID) {
|
|
120
118
|
AppMetrica.setUserProfileID(userProfileID);
|
|
121
119
|
}
|
|
122
120
|
|
|
123
|
-
@
|
|
121
|
+
@Override
|
|
124
122
|
public void reportECommerce(ReadableMap ecommerceEvent) {
|
|
125
123
|
ECommerceEvent event = Utils.toECommerceEvent(ecommerceEvent);
|
|
126
124
|
if (event != null) {
|
|
@@ -130,17 +128,17 @@ public class AppMetricaModule extends ReactContextBaseJavaModule {
|
|
|
130
128
|
}
|
|
131
129
|
}
|
|
132
130
|
|
|
133
|
-
@
|
|
131
|
+
@Override
|
|
134
132
|
public void reportRevenue(ReadableMap revenue) {
|
|
135
133
|
AppMetrica.reportRevenue(Utils.toRevenue(revenue));
|
|
136
134
|
}
|
|
137
135
|
|
|
138
|
-
@
|
|
136
|
+
@Override
|
|
139
137
|
public void reportAdRevenue(ReadableMap revenue) {
|
|
140
138
|
AppMetrica.reportAdRevenue(Utils.toAdRevenue(revenue));
|
|
141
139
|
}
|
|
142
140
|
|
|
143
|
-
@
|
|
141
|
+
@Override
|
|
144
142
|
public void reportUserProfile(ReadableMap userProfile) {
|
|
145
143
|
try {
|
|
146
144
|
AppMetrica.reportUserProfile(Utils.toUserProfile(userProfile));
|
|
@@ -149,12 +147,12 @@ public class AppMetricaModule extends ReactContextBaseJavaModule {
|
|
|
149
147
|
}
|
|
150
148
|
}
|
|
151
149
|
|
|
152
|
-
@
|
|
150
|
+
@Override
|
|
153
151
|
public void putErrorEnvironmentValue(String key, String value) {
|
|
154
152
|
AppMetrica.putErrorEnvironmentValue(key, value);
|
|
155
153
|
}
|
|
156
154
|
|
|
157
|
-
@
|
|
155
|
+
@Override
|
|
158
156
|
public void reportErrorWithoutIdentifier(String message, ReadableMap error) {
|
|
159
157
|
PluginErrorDetails details = ExceptionSerializer.fromObject(error);
|
|
160
158
|
if (details.getStacktrace().isEmpty()) {
|
|
@@ -164,13 +162,13 @@ public class AppMetricaModule extends ReactContextBaseJavaModule {
|
|
|
164
162
|
}
|
|
165
163
|
}
|
|
166
164
|
|
|
167
|
-
@
|
|
165
|
+
@Override
|
|
168
166
|
public void reportUnhandledException(ReadableMap error) {
|
|
169
167
|
PluginErrorDetails details = ExceptionSerializer.fromObject(error);
|
|
170
168
|
AppMetrica.getPluginExtension().reportUnhandledException(details);
|
|
171
169
|
}
|
|
172
170
|
|
|
173
|
-
@
|
|
171
|
+
@Override
|
|
174
172
|
public void reportExternalAttribution(ReadableMap attribution) {
|
|
175
173
|
ModulesFacade.reportExternalAttribution(
|
|
176
174
|
ExternalAttributionSerializer.parseSource(attribution.getString("source")),
|
|
@@ -178,43 +176,52 @@ public class AppMetricaModule extends ReactContextBaseJavaModule {
|
|
|
178
176
|
);
|
|
179
177
|
}
|
|
180
178
|
|
|
181
|
-
@
|
|
179
|
+
@Override
|
|
182
180
|
public void putAppEnvironmentValue(String key, String value) {
|
|
183
181
|
AppMetrica.putAppEnvironmentValue(key, value);
|
|
184
182
|
}
|
|
185
183
|
|
|
186
|
-
@
|
|
184
|
+
@Override
|
|
187
185
|
public void clearAppEnvironment() {
|
|
188
186
|
AppMetrica.clearAppEnvironment();
|
|
189
187
|
}
|
|
190
188
|
|
|
191
|
-
@
|
|
189
|
+
@Override
|
|
192
190
|
public void activateReporter(ReadableMap configMap) {
|
|
193
191
|
AppMetrica.activateReporter(reactContext, Utils.toReporterConfig(configMap));
|
|
194
192
|
}
|
|
195
193
|
|
|
196
|
-
@
|
|
194
|
+
@Override
|
|
197
195
|
public void touchReporter(String apiKey) {
|
|
198
196
|
AppMetrica.getReporter(reactContext, apiKey);
|
|
199
197
|
}
|
|
200
198
|
|
|
201
|
-
@
|
|
202
|
-
public
|
|
203
|
-
|
|
199
|
+
@Override
|
|
200
|
+
public String getDeviceId() {
|
|
201
|
+
return AppMetrica.getDeviceId(reactContext);
|
|
204
202
|
}
|
|
205
203
|
|
|
206
|
-
@
|
|
207
|
-
public
|
|
208
|
-
|
|
204
|
+
@Override
|
|
205
|
+
public String getUuid() {
|
|
206
|
+
return AppMetrica.getUuid(reactContext);
|
|
209
207
|
}
|
|
210
208
|
|
|
211
|
-
@
|
|
209
|
+
@Override
|
|
212
210
|
public void requestDeferredDeeplink(Callback failureCallback, Callback successCallback) {
|
|
213
211
|
AppMetrica.requestDeferredDeeplink(new ReactNativeDeferredDeeplinkListener(failureCallback, successCallback));
|
|
214
212
|
}
|
|
215
213
|
|
|
216
|
-
@
|
|
214
|
+
@Override
|
|
217
215
|
public void requestDeferredDeeplinkParameters(Callback failureCallback, Callback successCallback) {
|
|
218
216
|
AppMetrica.requestDeferredDeeplinkParameters(new ReactNativeDeferredDeeplinkParametersListener(failureCallback, successCallback));
|
|
219
217
|
}
|
|
218
|
+
|
|
219
|
+
@Override
|
|
220
|
+
protected Map<String, Object> getTypedExportedConstants() {
|
|
221
|
+
Map<String, Object> constants = new HashMap<>();
|
|
222
|
+
constants.put("DEVICE_ID_HASH_KEY", StartupParamsCallback.APPMETRICA_DEVICE_ID_HASH);
|
|
223
|
+
constants.put("DEVICE_ID_KEY", StartupParamsCallback.APPMETRICA_DEVICE_ID);
|
|
224
|
+
constants.put("UUID_KEY", StartupParamsCallback.APPMETRICA_UUID);
|
|
225
|
+
return constants;
|
|
226
|
+
}
|
|
220
227
|
}
|
|
@@ -2,28 +2,40 @@ package io.appmetrica.analytics.reactnative;
|
|
|
2
2
|
|
|
3
3
|
import androidx.annotation.NonNull;
|
|
4
4
|
|
|
5
|
-
import com.facebook.react.
|
|
5
|
+
import com.facebook.react.BaseReactPackage;
|
|
6
6
|
import com.facebook.react.bridge.NativeModule;
|
|
7
7
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
-
import com.facebook.react.
|
|
8
|
+
import com.facebook.react.module.model.ReactModuleInfo;
|
|
9
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
|
9
10
|
|
|
10
|
-
import java.util.
|
|
11
|
-
import java.util.
|
|
12
|
-
|
|
11
|
+
import java.util.HashMap;
|
|
12
|
+
import java.util.Map;
|
|
13
|
+
|
|
14
|
+
public class AppMetricaPackage extends BaseReactPackage {
|
|
13
15
|
|
|
14
|
-
public class AppMetricaPackage implements ReactPackage {
|
|
15
|
-
@NonNull
|
|
16
16
|
@Override
|
|
17
|
-
public
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
public NativeModule getModule(String name, @NonNull ReactApplicationContext reactContext) {
|
|
18
|
+
if (name.equals(AppMetricaModule.NAME)) {
|
|
19
|
+
return new AppMetricaModule(reactContext);
|
|
20
|
+
} else if (name.equals(ReporterModule.NAME)) {
|
|
21
|
+
return new ReporterModule(reactContext);
|
|
22
|
+
} else {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
@NonNull
|
|
25
28
|
@Override
|
|
26
|
-
public
|
|
27
|
-
return
|
|
29
|
+
public ReactModuleInfoProvider getReactModuleInfoProvider() {
|
|
30
|
+
return new ReactModuleInfoProvider() {
|
|
31
|
+
@NonNull
|
|
32
|
+
@Override
|
|
33
|
+
public Map<String, ReactModuleInfo> getReactModuleInfos() {
|
|
34
|
+
Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
|
|
35
|
+
moduleInfos.put(AppMetricaModule.NAME, new ReactModuleInfo(AppMetricaModule.NAME, AppMetricaModule.NAME, false, false, false, true));
|
|
36
|
+
moduleInfos.put(ReporterModule.NAME, new ReactModuleInfo(ReporterModule.NAME, ReporterModule.NAME, false, false, false, true));
|
|
37
|
+
return moduleInfos;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
28
40
|
}
|
|
29
41
|
}
|
|
@@ -2,12 +2,10 @@ package io.appmetrica.analytics.reactnative;
|
|
|
2
2
|
|
|
3
3
|
import androidx.annotation.NonNull;
|
|
4
4
|
import androidx.annotation.Nullable;
|
|
5
|
+
|
|
5
6
|
import com.facebook.react.bridge.Callback;
|
|
6
|
-
import com.facebook.react.bridge.WritableMap;
|
|
7
|
-
import com.facebook.react.bridge.WritableNativeMap;
|
|
8
7
|
|
|
9
8
|
import io.appmetrica.analytics.DeferredDeeplinkListener;
|
|
10
|
-
import io.appmetrica.analytics.StartupParamsCallback;
|
|
11
9
|
|
|
12
10
|
public class ReactNativeDeferredDeeplinkListener implements DeferredDeeplinkListener {
|
|
13
11
|
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
package io.appmetrica.analytics.reactnative;
|
|
2
2
|
|
|
3
3
|
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.Arguments;
|
|
4
6
|
import com.facebook.react.bridge.Callback;
|
|
5
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
6
7
|
import com.facebook.react.bridge.WritableMap;
|
|
7
|
-
import com.facebook.react.bridge.WritableNativeMap;
|
|
8
|
-
import com.facebook.react.bridge.Arguments;
|
|
9
8
|
|
|
10
|
-
import io.appmetrica.analytics.DeferredDeeplinkListener;
|
|
11
|
-
import io.appmetrica.analytics.DeferredDeeplinkParametersListener;
|
|
12
9
|
import java.util.Map;
|
|
13
10
|
|
|
11
|
+
import io.appmetrica.analytics.DeferredDeeplinkParametersListener;
|
|
12
|
+
|
|
14
13
|
public class ReactNativeDeferredDeeplinkParametersListener implements DeferredDeeplinkParametersListener {
|
|
15
14
|
@NonNull
|
|
16
15
|
private final Callback failureListener;
|
|
@@ -3,10 +3,14 @@ package io.appmetrica.analytics.reactnative;
|
|
|
3
3
|
import androidx.annotation.NonNull;
|
|
4
4
|
import androidx.annotation.Nullable;
|
|
5
5
|
|
|
6
|
+
import com.facebook.react.bridge.Arguments;
|
|
6
7
|
import com.facebook.react.bridge.Callback;
|
|
7
8
|
import com.facebook.react.bridge.WritableMap;
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
import java.util.Map;
|
|
11
|
+
|
|
9
12
|
import io.appmetrica.analytics.StartupParamsCallback;
|
|
13
|
+
import io.appmetrica.analytics.StartupParamsItem;
|
|
10
14
|
|
|
11
15
|
public class ReactNativeStartupParamsListener implements StartupParamsCallback {
|
|
12
16
|
|
|
@@ -24,15 +28,27 @@ public class ReactNativeStartupParamsListener implements StartupParamsCallback {
|
|
|
24
28
|
|
|
25
29
|
@Override
|
|
26
30
|
public void onRequestError(@NonNull Reason reason, @Nullable Result result) {
|
|
27
|
-
listener.invoke(
|
|
31
|
+
listener.invoke(toParamsMap(result), reason.value);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private static WritableMap convertParametersItem(StartupParamsItem paramsItem) {
|
|
35
|
+
WritableMap itemMap = Arguments.createMap();
|
|
36
|
+
if (paramsItem.getId() != null) {
|
|
37
|
+
itemMap.putString("id", paramsItem.getId());
|
|
38
|
+
}
|
|
39
|
+
if (paramsItem.getErrorDetails() != null) {
|
|
40
|
+
itemMap.putString("errorDetails", paramsItem.getErrorDetails());
|
|
41
|
+
}
|
|
42
|
+
itemMap.putString("status", paramsItem.getStatus().name());
|
|
43
|
+
return itemMap;
|
|
28
44
|
}
|
|
29
45
|
|
|
30
46
|
private static WritableMap toParamsMap(@Nullable Result result){
|
|
31
47
|
if (result == null) return null;
|
|
32
|
-
WritableMap
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return
|
|
48
|
+
WritableMap paramsMap = Arguments.createMap();
|
|
49
|
+
for (Map.Entry<String, StartupParamsItem> entry : result.parameters.entrySet()) {
|
|
50
|
+
paramsMap.putMap(entry.getKey(), convertParametersItem(entry.getValue()));
|
|
51
|
+
}
|
|
52
|
+
return paramsMap;
|
|
37
53
|
}
|
|
38
54
|
}
|
|
@@ -5,15 +5,13 @@ import android.util.Log;
|
|
|
5
5
|
import androidx.annotation.NonNull;
|
|
6
6
|
|
|
7
7
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
9
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
10
8
|
import com.facebook.react.bridge.ReadableMap;
|
|
11
9
|
|
|
12
10
|
import io.appmetrica.analytics.AppMetrica;
|
|
13
11
|
import io.appmetrica.analytics.ecommerce.ECommerceEvent;
|
|
14
12
|
import io.appmetrica.analytics.plugins.PluginErrorDetails;
|
|
15
13
|
|
|
16
|
-
public class ReporterModule extends
|
|
14
|
+
public class ReporterModule extends NativeReporterSpec {
|
|
17
15
|
|
|
18
16
|
public static final String NAME = "AppMetricaReporter";
|
|
19
17
|
|
|
@@ -33,13 +31,13 @@ public class ReporterModule extends ReactContextBaseJavaModule {
|
|
|
33
31
|
return NAME;
|
|
34
32
|
}
|
|
35
33
|
|
|
36
|
-
@
|
|
34
|
+
@Override
|
|
37
35
|
public void reportError(String apiKey, String identifier, String message, ReadableMap _reason) {
|
|
38
36
|
PluginErrorDetails errorDetails = _reason != null ? ExceptionSerializer.fromObject(_reason) : null;
|
|
39
37
|
AppMetrica.getReporter(reactContext, apiKey).getPluginExtension().reportError(identifier, message, errorDetails);
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
@
|
|
40
|
+
@Override
|
|
43
41
|
public void reportErrorWithoutIdentifier(String apiKey, String message, ReadableMap error) {
|
|
44
42
|
PluginErrorDetails details = ExceptionSerializer.fromObject(error);
|
|
45
43
|
if (details.getStacktrace().isEmpty()) {
|
|
@@ -49,13 +47,13 @@ public class ReporterModule extends ReactContextBaseJavaModule {
|
|
|
49
47
|
}
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
@
|
|
50
|
+
@Override
|
|
53
51
|
public void reportUnhandledException(String apiKey, ReadableMap error) {
|
|
54
52
|
PluginErrorDetails details = ExceptionSerializer.fromObject(error);
|
|
55
53
|
AppMetrica.getReporter(reactContext, apiKey).getPluginExtension().reportUnhandledException(details);
|
|
56
54
|
}
|
|
57
55
|
|
|
58
|
-
@
|
|
56
|
+
@Override
|
|
59
57
|
public void reportEvent(String apiKey, String eventName, ReadableMap attributes) {
|
|
60
58
|
if (attributes == null) {
|
|
61
59
|
AppMetrica.getReporter(reactContext, apiKey).reportEvent(eventName);
|
|
@@ -64,37 +62,38 @@ public class ReporterModule extends ReactContextBaseJavaModule {
|
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
@
|
|
65
|
+
@Override
|
|
68
66
|
public void pauseSession(String apiKey) {
|
|
69
67
|
AppMetrica.getReporter(reactContext, apiKey).pauseSession();
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
@
|
|
70
|
+
@Override
|
|
73
71
|
public void resumeSession(String apiKey) {
|
|
74
72
|
AppMetrica.getReporter(reactContext, apiKey).resumeSession();
|
|
75
73
|
}
|
|
76
74
|
|
|
77
|
-
@
|
|
75
|
+
@Override
|
|
78
76
|
public void sendEventsBuffer(String apiKey) {
|
|
79
77
|
AppMetrica.getReporter(reactContext, apiKey).sendEventsBuffer();
|
|
80
78
|
}
|
|
81
79
|
|
|
82
|
-
@
|
|
80
|
+
@Override
|
|
83
81
|
public void clearAppEnvironment(String apiKey) {
|
|
84
82
|
AppMetrica.getReporter(reactContext, apiKey).clearAppEnvironment();
|
|
85
83
|
}
|
|
86
84
|
|
|
87
|
-
@
|
|
85
|
+
@Override
|
|
88
86
|
public void putAppEnvironmentValue(String apiKey, String key, String value) {
|
|
89
87
|
AppMetrica.getReporter(reactContext, apiKey).putAppEnvironmentValue(key, value);
|
|
90
88
|
}
|
|
91
89
|
|
|
92
|
-
|
|
90
|
+
|
|
91
|
+
@Override
|
|
93
92
|
public void setUserProfileID(String apiKey, String userProfileID) {
|
|
94
93
|
AppMetrica.getReporter(reactContext, apiKey).setUserProfileID(userProfileID);
|
|
95
94
|
}
|
|
96
95
|
|
|
97
|
-
@
|
|
96
|
+
@Override
|
|
98
97
|
public void reportUserProfile(String apiKey, ReadableMap userProfile) {
|
|
99
98
|
try {
|
|
100
99
|
AppMetrica.getReporter(reactContext, apiKey).reportUserProfile(Utils.toUserProfile(userProfile));
|
|
@@ -103,17 +102,17 @@ public class ReporterModule extends ReactContextBaseJavaModule {
|
|
|
103
102
|
}
|
|
104
103
|
}
|
|
105
104
|
|
|
106
|
-
@
|
|
105
|
+
@Override
|
|
107
106
|
public void setDataSendingEnabled(String apiKey, boolean enabled) {
|
|
108
107
|
AppMetrica.getReporter(reactContext, apiKey).setDataSendingEnabled(enabled);
|
|
109
108
|
}
|
|
110
109
|
|
|
111
|
-
@
|
|
110
|
+
@Override
|
|
112
111
|
public void reportAdRevenue(String apiKey, ReadableMap AdRevenueMap) {
|
|
113
112
|
AppMetrica.getReporter(reactContext, apiKey).reportAdRevenue(Utils.toAdRevenue(AdRevenueMap));
|
|
114
113
|
}
|
|
115
114
|
|
|
116
|
-
@
|
|
115
|
+
@Override
|
|
117
116
|
public void reportECommerce(String apiKey, ReadableMap ecommerceEvent) {
|
|
118
117
|
ECommerceEvent event = Utils.toECommerceEvent(ecommerceEvent);
|
|
119
118
|
if (event != null) {
|
|
@@ -123,7 +122,7 @@ public class ReporterModule extends ReactContextBaseJavaModule {
|
|
|
123
122
|
}
|
|
124
123
|
}
|
|
125
124
|
|
|
126
|
-
@
|
|
125
|
+
@Override
|
|
127
126
|
public void reportRevenue(String apiKey, ReadableMap revenueMap) {
|
|
128
127
|
AppMetrica.getReporter(reactContext, apiKey).reportRevenue(Utils.toRevenue(revenueMap));
|
|
129
128
|
}
|
|
@@ -13,7 +13,6 @@ import io.appmetrica.analytics.AppMetricaConfig;
|
|
|
13
13
|
import io.appmetrica.analytics.PreloadInfo;
|
|
14
14
|
import io.appmetrica.analytics.ReporterConfig;
|
|
15
15
|
import io.appmetrica.analytics.Revenue;
|
|
16
|
-
import io.appmetrica.analytics.StartupParamsCallback;
|
|
17
16
|
import io.appmetrica.analytics.profile.UserProfile;
|
|
18
17
|
import io.appmetrica.analytics.ecommerce.ECommerceAmount;
|
|
19
18
|
import io.appmetrica.analytics.ecommerce.ECommerceCartItem;
|
|
@@ -320,7 +319,7 @@ abstract class Utils {
|
|
|
320
319
|
static ECommerceEvent toECommerceEvent(@NonNull ReadableMap ecommerceEventMap) {
|
|
321
320
|
String type = ecommerceEventMap.getString("ecommerceEvent");
|
|
322
321
|
if (type == null) return null;
|
|
323
|
-
if (type.equals("
|
|
322
|
+
if (type.equals("showScreenEvent")) {
|
|
324
323
|
ReadableMap screenMap = ecommerceEventMap.getMap("ecommerceScreen");
|
|
325
324
|
if (screenMap != null) {
|
|
326
325
|
return ECommerceEvent.showScreenEvent(toECommerceScreen(screenMap));
|
|
@@ -367,24 +366,6 @@ abstract class Utils {
|
|
|
367
366
|
return null;
|
|
368
367
|
}
|
|
369
368
|
|
|
370
|
-
@NonNull
|
|
371
|
-
static List<String> toStartupKeyList(@NonNull ReadableArray keys) {
|
|
372
|
-
ArrayList<String> startupKeys = new ArrayList<>();
|
|
373
|
-
for (int i = 0; i < keys.size(); i++) {
|
|
374
|
-
String item = keys.getString(i);
|
|
375
|
-
if (item.equals("appmetrica_device_id_hash")) {
|
|
376
|
-
startupKeys.add(StartupParamsCallback.APPMETRICA_DEVICE_ID_HASH);
|
|
377
|
-
}
|
|
378
|
-
if (item.equals("appmetrica_device_id")) {
|
|
379
|
-
startupKeys.add(StartupParamsCallback.APPMETRICA_DEVICE_ID);
|
|
380
|
-
}
|
|
381
|
-
if (item.equals("appmetrica_uuid")) {
|
|
382
|
-
startupKeys.add(StartupParamsCallback.APPMETRICA_UUID);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
return startupKeys;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
369
|
@NonNull
|
|
389
370
|
static Revenue toRevenue(@NonNull ReadableMap revenueMap) {
|
|
390
371
|
long price = (long) (revenueMap.getDouble("price") * 1000000);
|
|
@@ -504,15 +485,14 @@ abstract class Utils {
|
|
|
504
485
|
return newMap;
|
|
505
486
|
}
|
|
506
487
|
|
|
507
|
-
@
|
|
508
|
-
|
|
488
|
+
@NonNull
|
|
489
|
+
static List<String> toListOfStrings(@Nullable ReadableArray oldArray) {
|
|
490
|
+
List<String> newArray = new ArrayList<>();
|
|
509
491
|
if (oldArray == null) {
|
|
510
|
-
return
|
|
492
|
+
return newArray;
|
|
511
493
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
for (Object object : list) {
|
|
515
|
-
newArray.add(Objects.toString(object));
|
|
494
|
+
for (int i = 0; i < oldArray.size(); i++) {
|
|
495
|
+
newArray.add(oldArray.getString(i));
|
|
516
496
|
}
|
|
517
497
|
return newArray;
|
|
518
498
|
}
|