react-native-appmetrica/README.md

40 lines
1.2 KiB
Markdown
Raw Normal View History

2021-01-21 07:29:24 +03:00
# react-native-appmetrica-next
2020-06-08 22:14:06 +03:00
React Native bridge to the [AppMetrica](https://appmetrica.yandex.com/) on both iOS and Android.
2021-01-21 07:29:24 +03:00
react-native-push-next library functionality is expanded [react-native-appmetrica](https://github.com/yandexmobile/react-native-appmetrica)
2020-06-08 22:14:06 +03:00
## Installation
2021-01-21 07:29:24 +03:00
`npm install react-native-appmetrica-next --save`
or
`yearn add react-native-appmetrica-next`
1. If React Native version <= 0.59: \
`react-native link react-native-appmetrica-next`
2. iOS only
- if `${PROJECT_DIR}/ios/Podfile` exists: \
2020-06-08 22:14:06 +03:00
`npx pod-install`
2021-01-21 07:29:24 +03:00
- if `${PROJECT_DIR}/ios/Podfile` don't exists: \
2020-06-08 22:14:06 +03:00
[Setup AppMetrica](https://appmetrica.yandex.com/docs/mobile-sdk-dg/tasks/ios-quickstart.html) and placed frameworks at `${PROJECT_DIR}/ios/Frameworks`
## Usage
```js
2021-01-21 07:29:24 +03:00
import AppMetrica from "react-native-appmetrica-next";
2020-06-08 22:14:06 +03:00
// Starts the statistics collection process.
2020-12-22 15:03:52 +03:00
AppMetrica.activate({
2021-01-21 07:29:24 +03:00
apiKey: "...KEY...",
2020-06-08 22:14:06 +03:00
sessionTimeout: 120,
firstActivationAsUpdate: true,
});
// Sends a custom event message and additional parameters (optional).
2021-01-21 07:29:24 +03:00
AppMetrica.reportEvent("My event");
AppMetrica.reportEvent("My event", { foo: "bar" });
2020-06-08 22:14:06 +03:00
// Send a custom error event.
2021-01-21 07:29:24 +03:00
AppMetrica.reportError("My error");
2020-06-08 22:14:06 +03:00
```