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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@janiscommerce/app-analytics

v4.0.1

Published

Analytics methods for janis apps

Readme

@janiscommerce/app-analytics

janis-logo

Firebase Analytics tracking for Janis React Native apps.

Requirements

  • @react-native-firebase/app and @react-native-firebase/analytics installed and configured
  • @janiscommerce/app-crashlytics installed (used for internal error reporting in production)

See Firebase setup for Android/iOS configuration.

Installation

npm install @janiscommerce/app-analytics

Usage

1. Create an instance

import Analytics from '@janiscommerce/app-analytics'

const analytics = new Analytics({ appVersion: '1.0.0' })

| Param | Type | Required | Description | | --- | --- | --- | --- | | appVersion | string | Yes | App version string | | isDebugMode | boolean | No | When true, events are sent even in dev environment |

2. Register user identity at login

Call setSession() once after the user logs in. It fetches the user from the OAuth token and registers identity in Firebase via setUserId and setUserProperties.

await analytics.setSession()

3. Send events

// Log an action
await analytics.sendAction('button_press', 'Home')
await analytics.sendAction('button_press', 'Home', { itemId: '123' })

// Log a custom event
await analytics.sendCustomEvent('order_created', { orderId: '123' })

// Log a screen view
await analytics.sendScreenTracking('Home', 'HomeScreen')

4. Update user properties after login

Use setUserProperties to register or update dynamic user attributes after login (e.g. when a warehouse operator selects a depot).

await analytics.setUserProperties({ warehouseId: 'WH-001' })
await analytics.setUserProperties({ language: 'es-AR' })

5. Clear user identity at logout

Call clearSession() when the user logs out. It clears user identity from Firebase and nullifies all registered user properties, including any extras set via setUserProperties.

await analytics.clearSession()

API

new Analytics({ appVersion, isDebugMode })

Creates a new Analytics instance. Throws if appVersion is not provided or is not a string.

setSession()

Fetches user info from the OAuth token and registers identity in Firebase:

  • Calls analytics().setUserId(sub) with the token's sub field
  • Calls analytics().setUserProperties({ userEmail, client, language, userProfile }) with the token's fields

Required token fields: sub, email, tcode. Optional: locale, profileName.

Must be called once at login before sending events.

clearSession()

Clears user identity from Firebase and resets session state:

  • Calls analytics().setUserId(null)
  • Nullifies all user properties registered during the session (both from setSession() and setUserProperties())
  • Resets session state while preserving appVersion and isDebugMode

Must be called at logout.

setUserProperties(properties)

Updates one or more Firebase user properties. Accepts a non-empty object of key/value pairs.

await analytics.setUserProperties({ warehouseId: 'WH-001', zone: 'north' })

Properties registered via this method are automatically cleared on clearSession().

sendAction(actionName, screenName[, params])

Logs a Firebase action event.

| Param | Type | Required | Description | | --- | --- | --- | --- | | actionName | string | Yes | Name of the action (formatted to lowercase with underscores) | | screenName | string | No | Screen where the action was triggered | | params | object | No | Extra params to include in the event |

Returns true on success, false on error, null if session not ready or dev environment.

sendCustomEvent(eventName[, params])

Logs a custom Firebase event.

| Param | Type | Required | Description | | --- | --- | --- | --- | | eventName | string | Yes | Name of the event | | params | object | No | Sent as individual Firebase event params |

Returns true on success, false on error, null if session not ready or dev environment.

sendScreenTracking(screenName[, screenClass])

Logs a Firebase screen view event.

| Param | Type | Required | Description | | --- | --- | --- | --- | | screenName | string | Yes | Name of the screen the user is viewing | | screenClass | string | No | Class associated with the screen |

Returns true on success, false on error, null if session not ready or dev environment.


Base event params

Every event automatically includes:

| Param | Source | | --- | --- | | appVersion | Constructor param | | deviceId | @janiscommerce/app-device-info | | device | @janiscommerce/app-device-info | | osVersion | @janiscommerce/app-device-info | | connection | @janiscommerce/app-device-info (fetched fresh per event) |

User identity fields (userEmail, client, language, userProfile) are registered as Firebase user properties via setSession() — they do not travel as event params.


Firebase setup

Android

Add the Google Services plugin to android/build.gradle:

dependencies {
  classpath 'com.google.gms:google-services:4.3.15'
}

Add to android/app/build.gradle:

plugins {
  id("com.google.gms.google-services")
}

dependencies {
  implementation platform('com.google.firebase:firebase-bom:32.2.2')
  implementation 'com.google.firebase:firebase-analytics'
}

Clean the project:

cd android && ./gradlew clean && cd ..

Documentation