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

react-native-metrics

v1.0.0-alpha.2

Published

Test metrics logging library for React Native.

Downloads

4

Readme

react-native-metrics

Promoted metrics logging library for React Native. Released for iOS and Android.

Installation

Add "@promotedai/react-native-metrics" as a dependency in your package.json file.

Usage

Tracking sessions and events

Call startSession* or log* directly from your React Native code when these events occur.

import PromotedMetrics from "@promotedai/react-native-metrics";

PromotedMetrics.startSessionAndLogUser(user.uid);
PromotedMetrics.logAction("Add to cart");
PromotedMetrics.logView("Sign up");

Tracking impressions

Impression tracking is possible for any kind of content. Here is an example using SectionList or FlatList using onViewableItemsChanged.

import PromotedMetrics, { useImpressionTracker } from "@promotedai/react-native-metrics";

const { _viewabilityConfig, _onViewableItemsChanged } = useImpressionTracker(
  "MyListIdentifier",
  (viewToken) => ({
      content_id: viewToken.item.my_content_id,
      insertion_id: viewToken.item.promoted_insertion_id,
      name: viewToken.item.my_content_name
  }));

return (
  <FlatList
    onViewableItemsChanged={_onViewableItemsChanged}
    viewabilityConfig={_viewabilityConfig}
    ...
  />
);

Content objects

In many cases, the Typescript library expects Objects as arguments to represent content. For these content objects, the library expects the following keys:

  1. (Required) content_id, contentId, or _id should contain a unique identifier for the content. This identifier can be anything from your system.
  2. (Optional) insertion_id, or insertionId should contain the insertion ID as provided by Promoted for inserted content.
  3. (Optional) name can contain a human-readable name for the content, and can be used for debugging purposes. This field is not sent to backends.

If your content objects contain additional data, we recommend filtering out all data except the above:

const contentList = myViewableItems.map(i => ({
  content_id: i.my_content_id,
  insertion_id: i.promoted_insertion_id,
  name: i.my_content_name
}));
PromotedMetrics.collectionViewDidChange(contentList, "MyListIdentifier");