🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

rn-yandex-metrics

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rn-yandex-metrics

React Native bridge for Yandex Appmetrica

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

rn-yandex-metrics

Install
yarn add rn-yandex-metrics
  • IOS

    RN<0.60:

    react-native link rn-yandex-metrics
    

    With CocoaPods, add the following line to your Podfile:

    pod 'rn-yandex-metrics', :path => '../node_modules/rn-yandex-metrics'
    pod 'YandexMobileMetrica', '3.17.0'
    

    Then run pod install.

    RN>=0.60: With React Native 0.60 and later, linking of pods is done automatically

    cd ios
    pod install
    
  • Android

    RN<0.60:

    2.1. Open up android/app/src/main/java/[...]/MainApplication.java

    • Add import com.mastereugene.yandexmetrics.YandexMetricsPackage; to the imports at the top of the file

    • Add new YandexMetricsPackage() to the list returned by the getPackages() method

       2.2. Append the following lines to `android/settings.gradle`:
       `include ':rn-yandex-metrics'
      

      project(':rn-yandex-metrics').projectDir = new File(rootProject.projectDir, '../node_modules/rn-yandex-metrics/android')`

       2.3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
       ` implementation project(':rn-yandex-metrics')`
      

    RN>=0.60: With React Native 0.60 and later, linking is done automatically

Usage

import YandexMetrics from 'rn-yandex-metrics';

// Initialize
YandexMetrics.activateWithApiKey('KEY');

// OR
YandexMetrics.activateWithConfig({
  apiKey: 'KEY',
  sessionTimeout: 120,
  firstActivationAsUpdate: true,
});


YandexMetrics.setUserProfileID('12345');

YandexMetrics.setUserProfileAttributes({ ... })

// Sends a custom event message and additional parameters (optional).
YandexMetrics.reportEvent('My event');
YandexMetrics.reportEvent('My event', 'Test');
YandexMetrics.reportEvent('My event', { foo: 'bar' });

// Send a custom error event and additional parameters (optional).
YandexMetrics.reportError('My error');
YandexMetrics.reportError('My error', 'Test');
YandexMetrics.reportError('My error', { foo: 'bar' });
YandexMetrics.reportError('My error', new Error('test'));

Keywords

react-native

FAQs

Package last updated on 25 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts