diff --git a/README.md b/README.md index 02fb8a0..4f8ad56 100644 --- a/README.md +++ b/README.md @@ -38,4 +38,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/java/com/doochik/RNAppMetrica/AppMetricaModule.java b/android/src/main/java/com/doochik/RNAppMetrica/AppMetricaModule.java index fe12de4..96d4cfb 100644 --- a/android/src/main/java/com/doochik/RNAppMetrica/AppMetricaModule.java +++ b/android/src/main/java/com/doochik/RNAppMetrica/AppMetricaModule.java @@ -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/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