diff --git a/README.md b/README.md index 02fb8a0..ad7ce75 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,6 @@ # react-native-appmetrica React Native bridge to the AppMetrica on both iOS and Android. -**NOTE: Only iOS support for now. Feel free to send PR with Android support.** - ## Installation 1. Setup [AppMetrica](https://tech.yandex.com/appmetrica/). @@ -38,4 +36,7 @@ AppMetrica.activateWithApiKey('...KEY...'); // Sends a custom event message and additional parameters (optional). AppMetrica.reportEvent('My event'); AppMetrica.reportEvent('My event', { foo: 'bar' }); + +// Send a custom error event +AppMetrica.reportError('My error'); ``` diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index d8b1766..3f6e98f 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,3 +1,3 @@ - + - \ No newline at end of file + diff --git a/android/src/main/java/com/aandrosov/AppMetrica/AppMetricaModule.java b/android/src/main/java/com/doochik/RNAppMetrica/AppMetricaModule.java similarity index 91% rename from android/src/main/java/com/aandrosov/AppMetrica/AppMetricaModule.java rename to android/src/main/java/com/doochik/RNAppMetrica/AppMetricaModule.java index 04caf96..96d4cfb 100644 --- a/android/src/main/java/com/aandrosov/AppMetrica/AppMetricaModule.java +++ b/android/src/main/java/com/doochik/RNAppMetrica/AppMetricaModule.java @@ -1,4 +1,4 @@ -package com.aandrosov.AppMetrica; +package com.doochik.RNAppMetrica; import android.app.Activity; import android.app.Application; @@ -41,6 +41,15 @@ public class AppMetricaModule extends ReactContextBaseJavaModule { } } + @ReactMethod + public void reportError(String message) { + try { + Integer.valueOf("00xffWr0ng"); + } catch (Throwable error) { + YandexMetrica.reportError(message, error); + } + } + @ReactMethod public void reportEvent(String message, @Nullable ReadableMap params) { if (params != null) { diff --git a/android/src/main/java/com/aandrosov/AppMetrica/AppMetricaPackage.java b/android/src/main/java/com/doochik/RNAppMetrica/AppMetricaPackage.java similarity index 95% rename from android/src/main/java/com/aandrosov/AppMetrica/AppMetricaPackage.java rename to android/src/main/java/com/doochik/RNAppMetrica/AppMetricaPackage.java index 65d747e..a4b26d9 100644 --- a/android/src/main/java/com/aandrosov/AppMetrica/AppMetricaPackage.java +++ b/android/src/main/java/com/doochik/RNAppMetrica/AppMetricaPackage.java @@ -1,4 +1,4 @@ -package com.aandrosov.AppMetrica; +package com.doochik.RNAppMetrica; import com.facebook.react.ReactPackage; import com.facebook.react.bridge.NativeModule; diff --git a/example/android/app/src/main/java/com/rnappmetrika/MainApplication.java b/example/android/app/src/main/java/com/rnappmetrika/MainApplication.java index 3645026..69cc9b7 100644 --- a/example/android/app/src/main/java/com/rnappmetrika/MainApplication.java +++ b/example/android/app/src/main/java/com/rnappmetrika/MainApplication.java @@ -3,7 +3,7 @@ package com.rnappmetrika; import android.app.Application; import com.facebook.react.ReactApplication; -import com.aandrosov.AppMetrica.AppMetricaPackage; +import com.doochik.RNAppMetrica.AppMetricaPackage; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; diff --git a/ios/RCTAppMetrica/RCTAppMetrica/RCTAppMetrica.m b/ios/RCTAppMetrica/RCTAppMetrica/RCTAppMetrica.m index 40f6b63..05446df 100644 --- a/ios/RCTAppMetrica/RCTAppMetrica/RCTAppMetrica.m +++ b/ios/RCTAppMetrica/RCTAppMetrica/RCTAppMetrica.m @@ -22,8 +22,8 @@ RCT_EXPORT_METHOD(reportEvent:(NSString *)message parameters:(nullable NSDiction [YMMYandexMetrica reportEvent:message parameters:params onFailure:NULL]; } -RCT_EXPORT_METHOD(reportError:(NSString *)message reason:(NSString *)reason) { - NSException *exception = [[NSException alloc] initWithName:message reason:reason userInfo:nil]; +RCT_EXPORT_METHOD(reportError:(NSString *)message) { + NSException *exception = [[NSException alloc] initWithName:message reason:nil userInfo:nil]; [YMMYandexMetrica reportError:message exception:exception onFailure:NULL]; } @end