Implement sendError for Android
This commit is contained in:
parent
60d2a2b63e
commit
8c036a64b7
@ -38,4 +38,7 @@ AppMetrica.activateWithApiKey('...KEY...');
|
|||||||
// Sends a custom event message and additional parameters (optional).
|
// Sends a custom event message and additional parameters (optional).
|
||||||
AppMetrica.reportEvent('My event');
|
AppMetrica.reportEvent('My event');
|
||||||
AppMetrica.reportEvent('My event', { foo: 'bar' });
|
AppMetrica.reportEvent('My event', { foo: 'bar' });
|
||||||
|
|
||||||
|
// Send a custom error event
|
||||||
|
AppMetrica.reportError('My error');
|
||||||
```
|
```
|
||||||
|
@ -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
|
@ReactMethod
|
||||||
public void reportEvent(String message, @Nullable ReadableMap params) {
|
public void reportEvent(String message, @Nullable ReadableMap params) {
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
|
@ -22,8 +22,8 @@ RCT_EXPORT_METHOD(reportEvent:(NSString *)message parameters:(nullable NSDiction
|
|||||||
[YMMYandexMetrica reportEvent:message parameters:params onFailure:NULL];
|
[YMMYandexMetrica reportEvent:message parameters:params onFailure:NULL];
|
||||||
}
|
}
|
||||||
|
|
||||||
RCT_EXPORT_METHOD(reportError:(NSString *)message reason:(NSString *)reason) {
|
RCT_EXPORT_METHOD(reportError:(NSString *)message) {
|
||||||
NSException *exception = [[NSException alloc] initWithName:message reason:reason userInfo:nil];
|
NSException *exception = [[NSException alloc] initWithName:message reason:nil userInfo:nil];
|
||||||
[YMMYandexMetrica reportError:message exception:exception onFailure:NULL];
|
[YMMYandexMetrica reportError:message exception:exception onFailure:NULL];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
Loading…
Reference in New Issue
Block a user