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

@swaarm/swaarm-sdk

v1.0.6

Published

Swaarm SDK for react native

Downloads

3

Readme

Swaarm SDK for React Native

The Swaarm SDK for React Native allows for better measurement and tracking of user journeys and activities in apps that use the React Native framework

Installation

To install the SDK you need to add the following dependencies to your package.json file:

    "@swaarm/swaarm-sdk": "^1.0.6",
    "@react-native-async-storage/async-storage": "^1.19.6",
    "react-native-device-info": "^10.11.0",

If you are already using the react-native-async-storage or react-native-device-info libraries in your project, feel free to skip them and use your existing versions.

To install the dependencies run:

    npm install

Installation for iOS

If you are targeting iOS as a platform make sure to also run:

    npx pod-install

Installation for Android

If you are targeting Android as a platform, make sure to add the following permissions in your AndroidManifest.xml file:

    <uses-permission android:name="android.permission.INTERNET" />

In your app's build.gradle file you will need to add:

compile 'com.android.installreferrer:installreferrer:2.2'

...

allprojects {
    repositories {
        maven {
            url "https://maven.google.com"
        }
    }
}

Proguard settings

If you are using Proguard, add these lines to your Proguard file:

-keep public class com.android.installreferrer.** { *; }

Configuration

In your App.js (or App.tsx), init the Swaarm SDK client using your tracking domain together with your app token as early as possible:

    SwaarmClient.init("track.mycompany.swaarm-app.com", "abc123");

To enable Swaarm SDK logging you can pass a third parameter:

    SwaarmClient.init("track.mycompany.swaarm-app.com", "abc123", true);

or call the log method at any point in the execution of the app:

    SwaarmClient.log(true)

Recording events

To record any event you can use the general SwaarmClient.event method which takes 3 parameters:

  • Event Type Id - the name of the event that you wanted to track as defined in Swaarm's Events under the "Advertiser Event Type Id" field. This can be "registration" or "first_time_deposit" etc.
  • Aggregated value - this is a numeric value that Swaarm will hold for you and can aggregate in the reports. Could be the amount of coins the user purchased, how many tasks they completed etc.
  • Custom value - this is a free field that can be used to store any additional information about the event. For a registration you might want to put the user's id or the email. For a payment you might want to store the package that the user selected. You can even send JSON and then analyse it using our SQL Lab.

Example:

    SwaarmClient.event('earned_coins', 120, '{"plan": "premium"}');

To register a purchase event you can use the more specialized SwaarmClient.purchase call

    SwaarmClient.purchase("registration", 12.42, "USD",  "iOS purchase or subscription receipt", "android purchase or subscription id")

By default, the method requires a monetary value and a currency. To enable the validation of purchases made using App/Play Store functionality you can pass the receipt or purchase id.

The SDK will automatically record app installations, open events or reinstalls, there is no need to fire such events