npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

capacitor-appmetrica-plugin

v3.0.1

Published

Yandex App metrica plugin for Capacitor

Downloads

297

Readme

Плагин Yandex App Metrica для Capacitor

  • Поддержка Capacitor 2, 3 - 5.
  • Работает на платформах: iOS, Android.
  • Поддерживает E-Commerce события
  • Поддерживает отправку атрибутов профиля
  • Deeplinks (не тестровались)
  • Locations (не тестровались)

Версии App Metrica SDK:

  • iOS: 4.5.0
  • Android: 5.2.0

Демо приложение

cd example

npm install
npm run build

npx cap sync
npx cap open android|ios

Установка

Capacitor 3, 4, 5:

npm install capacitor-appmetrica-plugin

npx cap sync

Для Capacitor 2:

npm install capacitor-appmetrica-plugin@^2.0.0

npx cap sync

Android

Настройка геолокации (опционально)

Подробнее: ссылка

Открыть файл: android/app/src/main/AndroidManifest.xml

<manifest>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <application>...</application>
</manifest>

Использование

Создать новое приложение и получить ключ здесь.

Конфигурация/Активация

import { AppMetrica } from 'capacitor-appmetrica-plugin';

AppMetrica.activate({
  apiKey: "<API key приложения>",
  logs: true
}).then(() => {
  // Успешная активация
}).catch(() => {
  // Что-то пошло не так
});

Отправка событий

Простое событие:

AppMetrica.reportEvent({
  name: "Имя события",
  params: {
    "ключ": "значение"
  }
});

Событие ошибки:

AppMetrica.reportError({
  group: "идентификатор_группы",
  message: "Сообщение ошибки",
  parameters: { // В Android данные передаются в виде JSON строки внутри Throwable объекта
    key: "value",
  }
});

WARNING: Ранее данные события ошибки передавались через поля name и error - данные значения объявлены как deprecated, будут удалены в следующей версии.

Отправка атрибутов профиля

Задать идентификатор профиля:

AppMetrica.setUserProfileId({ id: 'user_id_1' })

Отправка атрибутов:

const userProfile: YAMUserProfile = {
  name: 'Nalivayko Ivan',
  gender: 'male',
  notificationEnabled: true,
  birthDate: { // or { age: 20 }
    year: 2001,
    month: 1,
    day: 1
  }
};

AppMetrica.reportUserProfile(userProfile);

E-Commerce события

const screen: ECommerceScreen = {
  "name": "ProductCardActivity",
  "searchQuery": "даниссимо кленовый сироп",
  "categoriesPath": ["Акции", "Красная цена"],
  "payload": {
      "full_screen": "true",
  }
};

AppMetrica.showScreenEvent(screen);
const screen: ECommerceScreen = {
  "name": "ProductCardActivity",
  "searchQuery": "даниссимо кленовый сироп",
  "categoriesPath": ["Акции", "Красная цена"],
  "payload": {
      "full_screen": "true",
  }
};

const actualPrice: ECommercePrice = {
  "fiat": [4.53, "USD"],
  "internalComponents": [
    [30570000, "wood"],
    [26.89, "iron"],
    [5.1, "gold"]
  ]
};

const product: ECommerceProduct = {
  "sku": "779213",
  "name": "Продукт творожный «Даниссимо» 5.9%, 130 г.",
  "actualPrice": actualPrice,
  "originalPrice": {
    "fiat": [5.78, "USD"],
    "internalComponents": [
      [30590000, "wood"],
      [26.92, "iron"],
      [5.5, "gold"],
    ]
  },
  "categoriesPath": ["Продукты", "Молочные продукты", "Йогурты"],
  "promocodes": ["BT79IYX", "UT5412EP"],
  "payload": {
    "full_screen": "true",
  }
};

AppMetrica.showProductCardEvent({ product, screen });
const screen: ECommerceScreen = {
  "name": "ProductCardActivity",
  "searchQuery": "даниссимо кленовый сироп",
  "categoriesPath": ["Акции", "Красная цена"],
  "payload": {
      "full_screen": "true",
  }
};

const actualPrice: ECommercePrice = {
  "fiat": [4.53, "USD"],
  "internalComponents": [
    [30570000, "wood"],
    [26.89, "iron"],
    [5.1, "gold"]
  ]
};

const product: ECommerceProduct = {
  "sku": "779213",
  "name": "Продукт творожный «Даниссимо» 5.9%, 130 г.",
  "actualPrice": actualPrice,
  "originalPrice": {
    "fiat": [5.78, "USD"],
    "internalComponents": [
      [30590000, "wood"],
      [26.92, "iron"],
      [5.5, "gold"],
    ]
  },
  "categoriesPath": ["Продукты", "Молочные продукты", "Йогурты"],
  "promocodes": ["BT79IYX", "UT5412EP"],
  "payload": {
    "full_screen": "true",
  }
};

const referrer: ECommerceReferrer = {
  "type": "button",
  "identifier": "76890",
  "screen": screen
};

AppMetrica.showProductDetailsEvent({ product, referrer });
const screen: ECommerceScreen = {
  "name": "ProductCardActivity",
  "searchQuery": "даниссимо кленовый сироп",
  "categoriesPath": ["Акции", "Красная цена"],
  "payload": {
      "full_screen": "true",
  }
};

const actualPrice: ECommercePrice = {
  "fiat": [4.53, "USD"],
  "internalComponents": [
    [30570000, "wood"],
    [26.89, "iron"],
    [5.1, "gold"]
  ]
};

const product: ECommerceProduct = {
  "sku": "779213",
  "name": "Продукт творожный «Даниссимо» 5.9%, 130 г.",
  "actualPrice": actualPrice,
  "originalPrice": {
    "fiat": [5.78, "USD"],
    "internalComponents": [
      [30590000, "wood"],
      [26.92, "iron"],
      [5.5, "gold"],
    ]
  },
  "categoriesPath": ["Продукты", "Молочные продукты", "Йогурты"],
  "promocodes": ["BT79IYX", "UT5412EP"],
  "payload": {
    "full_screen": "true",
  }
};

const referrer: ECommerceReferrer = {
  "type": "button",
  "identifier": "76890",
  "screen": screen
};

const addedItem: ECommerceCartItem = {
  product,
  referrer,
  quantity: 1.0,
  revenue: actualPrice
};

// Добавление
AppMetrica.addCartItemEvent(addedItem);

// Удаление
AppMetrica.removeCartItemEvent(addedItem);
const screen: ECommerceScreen = {
  "name": "ProductCardActivity",
  "searchQuery": "даниссимо кленовый сироп",
  "categoriesPath": ["Акции", "Красная цена"],
  "payload": {
      "full_screen": "true",
  }
};

const actualPrice: ECommercePrice = {
  "fiat": [4.53, "USD"],
  "internalComponents": [
    [30570000, "wood"],
    [26.89, "iron"],
    [5.1, "gold"]
  ]
};

const product: ECommerceProduct = {
  "sku": "779213",
  "name": "Продукт творожный «Даниссимо» 5.9%, 130 г.",
  "actualPrice": actualPrice,
  "originalPrice": {
    "fiat": [5.78, "USD"],
    "internalComponents": [
      [30590000, "wood"],
      [26.92, "iron"],
      [5.5, "gold"],
    ]
  },
  "categoriesPath": ["Продукты", "Молочные продукты", "Йогурты"],
  "promocodes": ["BT79IYX", "UT5412EP"],
  "payload": {
    "full_screen": "true",
  }
};

const referrer: ECommerceReferrer = {
  "type": "button",
  "identifier": "76890",
  "screen": screen
};

const addedItem: ECommerceCartItem = {
  product,
  referrer,
  quantity: 1.0,
  revenue: actualPrice
};

const order: ECommerceOrder = {
  "identifier": "88528768",
  "cartItems": [
    addedItem,
    // ...
  ],
  "payload": ["black_friday": "true"]
};

// Начало оформления
AppMetrica.beginCheckoutEvent(order);

// Завершение покупки
AppMetrica.purchaseEvent(order);

Местоположение

const location: YAMLocation = {
  latitude: 51.660781
  longitude: 39.200296

  // altitude?: number;
  // accuracy?: number;
  // vAccuracy?: number;
  // hAccuracy?: number;
  // course?: number;
  // speed?: number;
  // timestamp?: number;
};

AppMetrica.setLocation(location);
AppMetrica.setLocationTracking({ enabled: true });

Документация

Android SDK

iOS SDK