1.3.2 • Published 11 months ago

@promotedai/react-native-metrics v1.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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");
1.3.2

11 months ago

1.3.1

11 months ago

1.2.4

2 years ago

1.2.3

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.0.2

2 years ago

1.1.0

2 years ago

1.0.1

3 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.0

3 years ago

0.7.0

3 years ago

0.5.1

3 years ago

0.5.0

3 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.2.2

3 years ago

0.2.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago