This commit is contained in:
Andrey Bondarenko 2021-01-21 14:29:24 +10:00
parent b651948d45
commit f606229340
7 changed files with 38 additions and 6480 deletions

View File

@ -1,33 +1,39 @@
# react-native-appmetrica
# react-native-appmetrica-next
React Native bridge to the [AppMetrica](https://appmetrica.yandex.com/) on both iOS and Android.
react-native-push-next library functionality is expanded [react-native-appmetrica](https://github.com/yandexmobile/react-native-appmetrica)
## Installation
1. `npm install react-native-appmetrica --save`
2. If React Native version <= 0.59: \
`react-native link react-native-appmetrica`
3. iOS only
* if `${PROJECT_DIR}/ios/Podfile` exists: \
`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: \
`npx pod-install`
* if `${PROJECT_DIR}/ios/Podfile` don't exists: \
- if `${PROJECT_DIR}/ios/Podfile` don't exists: \
[Setup AppMetrica](https://appmetrica.yandex.com/docs/mobile-sdk-dg/tasks/ios-quickstart.html) and placed frameworks at `${PROJECT_DIR}/ios/Frameworks`
## Usage
```js
import AppMetrica from 'react-native-appmetrica';
import AppMetrica from "react-native-appmetrica-next";
// Starts the statistics collection process.
AppMetrica.activate({
apiKey: '...KEY...',
apiKey: "...KEY...",
sessionTimeout: 120,
firstActivationAsUpdate: true,
});
// Sends a custom event message and additional parameters (optional).
AppMetrica.reportEvent('My event');
AppMetrica.reportEvent('My event', { foo: 'bar' });
AppMetrica.reportEvent("My event");
AppMetrica.reportEvent("My event", { foo: "bar" });
// Send a custom error event.
AppMetrica.reportError('My error');
AppMetrica.reportError("My error");
```

View File

@ -81,7 +81,7 @@ repositories {
dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+' // From node_modules
implementation 'com.yandex.android:mobmetricalib:3.13.3'
implementation 'com.yandex.android:mobmetricalib:3.18.0'
implementation 'com.android.installreferrer:installreferrer:1.1.2'
}

View File

@ -11,13 +11,13 @@ import {StyleSheet, Text, View, ScrollView, SafeAreaView} from 'react-native';
import AppMetrica from 'react-native-appmetrica';
function getRactNativeVersion() {
function getReactNativeVersion() {
const reactNativePackage = require('./node_modules/react-native/package.json');
return reactNativePackage.version;
}
function isReactNativeVersion(major, minor = 0, path = 0) {
const {curMajor, curMinor, curPath} = getRactNativeVersion()
const {curMajor, curMinor, curPath} = getReactNativeVersion()
.split('.')
.map(it => +it);
if (curMajor === major) {
@ -61,7 +61,7 @@ export default class App extends Component<Props> {
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>React Native Version</Text>
<Text style={styles.sectionDescription}>
{getRactNativeVersion()}
{getReactNativeVersion()}
</Text>
</View>
<View style={styles.sectionContainer}>

View File

@ -1,6 +1,6 @@
{
"name": "AppMetricaReactNativeSample",
"version": "0.0.1",
"version": "1.0.0",
"private": true,
"scripts": {
"android": "react-native run-android",
@ -12,17 +12,19 @@
"dependencies": {
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-appmetrica": "file:../appmetrica-plugin"
"react-native-appmetrica-next": "file:../"
},
"devDependencies": {
"@babel/core": "^7.6.2",
"@babel/runtime": "^7.6.2",
"@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.5.1",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.56.0",
"react-test-renderer": "16.9.0"
"@babel/core": "^7.11.1",
"@babel/runtime": "^7.11.2",
"@react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.3.0",
"eslint": "^7.7.0",
"jest": "^26.4.0",
"metro-react-native-babel-preset": "^0.62.0",
"prettier": "2.1.1",
"eslint-plugin-prettier": "3.1.4",
"react-test-renderer": "16.13.1"
},
"jest": {
"preset": "react-native"

File diff suppressed because it is too large Load Diff

View File

@ -30,6 +30,5 @@
"peerDependencies": {
"react-native": ">=0.59.0 <1.0.x"
},
"devDependencies": {
}
"devDependencies": {}
}

View File

@ -3,18 +3,18 @@ require "json"
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
Pod::Spec.new do |s|
s.name = "react-native-appmetrica"
s.name = "react-native-appmetrica-next-next"
s.version = package["version"]
s.summary = package["description"]
s.homepage = package["homepage"]
s.license = package["license"]
s.authors = { "Yandex LLC" => "appmetrica@yandex-team.com" }
s.platforms = { :ios => "9.0" }
s.source = { :git => "https://github.com/yandexmobile/react-native-appmetrica.git", :tag => "#{s.version}" }
s.source = { :git => "https://github.com/yandexmobile/react-native-appmetrica-next.git", :tag => "#{s.version}" }
s.source_files = "ios/**/*.{h,m,swift}"
s.requires_arc = true
s.dependency "React"
s.dependency 'YandexMobileMetrica', '3.9.4'
s.dependency 'YandexMobileMetrica', '3.12.0'
end