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

@attentive-mobile/attentive-react-native-sdk

v1.0.0

Published

React Native Module for the Attentive SDK

Downloads

278

Readme

attentive-react-native-sdk

Attentive React Native SDK

The Attentive React Native SDK provides the functionality to render Attentive creative units and collect Attentive events in React Native mobile applications.

Installation

Run npm install @attentive-mobile/attentive-react-native-sdk from your app's root directory.

Usage

See the Example Project for a sample of how the Attentive React Native SDK is used.

*** NOTE: Please refrain from using any private or undocumented classes or methods as they may change between releases. ***

Import the SDK

import { Attentive, <other types you need here> } from 'attentive-react-native-sdk';

Create the AttentiveConfig

// Create an AttentiveConfiguration with your attentive domain, in production mode
const config : AttentiveConfiguration = {
  attentiveDomain: 'YOUR_ATTENTIVE_DOMAIN',
  mode: Mode.Production,
}
// Alternatively, use "debug" mode. When in debug mode, the Creative will not be shown, but instead a popup will show with debug information about your creative and any reason the Creative wouldn't show.
const config : AttentiveConfiguration = {
  attentiveDomain: 'YOUR_ATTENTIVE_DOMAIN',
  mode: Mode.Debug,
}

Initialize the SDK

// 'initialize' should be called as soon as possible after the app starts (see the example app for an example of initializing the SDK in the App element)
// Note: 'initialize' should only be called once per app session - if you call it multiple times it will throw an exception
Attentive.initialize(config);

Destroy the creative

// This will remove the creative along with its web view
Attentive.destroyCreative();

Identify the current user

// Before loading the creative or sending events, if you have any user identifiers, they will need to be registered. Each identifier is optional. It is okay to skip this step if you have no identifiers about the user yet.
const identifiers : UserIdentifiers = {
  'phone': '+15556667777',
  'email': '[email protected]',
  'klaviyoId': 'userKlaviyoId',
  'shopifyId': 'userShopifyId',
  'clientUserId': 'userClientUserId',
  'customIdentifiers': { 'customIdKey': 'customIdValue' }
};
Attentive.identify(identifiers);

The more identifiers that are passed to identify, the better the SDK will function. Here is the list of possible identifiers: | Identifier Name | Type | Description | | ------------------ | --------------------- | ----------------------------------------------------------------------------------------------------------------------- | | Client User ID | String | Your unique identifier for the user. This should be consistent across the user's lifetime. For example, a database id. | | Phone | String | The users's phone number in E.164 format | | Email | String | The users's email | | Shopify ID | String | The users's Shopify ID | | Klaviyo ID | String | The users's Klaviyo ID | | Custom Identifiers | Map<String,String> | Key-value pairs of custom identifier names and values. The values should be unique to this user. |

Load the Creative

// Trigger the Creative. This will show the Creative as a pop-up over the rest of the app.
Attentive.triggerCreative();

Record user events

The SDK currently supports PurchaseEvent, AddToCartEvent, ProductViewEvent, and CustomEvent.

// Construct one or more "Item"s, which represents the product(s) purchased
const items : Item[] = [
        {
          productId: '555',
          productVariantId: '777',
          price: {
            price: '14.99',
            currency: 'USD',
          },
        },
      ];

// Construct an "Order", which represents the order for the purchase
const order : Order = {
  orderId: '88888'
}

// (Optional) Construct a "Cart", which represents the cart this Purchase was made from
const cart : Cart = {
  cartId: '555555',
  cartCoupon: 'SOME-DISCOUNT'
}

// Construct a PurchaseEvent, which ties together the preceding objects
const purchaseEvent : PurchaseEvent = {
  items: items,
  order: order,
  cart: cart
}

// Record the PurchaseEvent
Attentive.recordPurchaseEvent(purchaseEvent);

The process is similar for the other events. See eventTypes.tsx for all events.

Update the current user when new identifiers are available

// If new identifiers are available for the user, register them
Attentive.identify({email: '[email protected]'});
Attentive.identify({email: '[email protected]'});
Attentive.identify({phone: '+15556667777'};)
// The SDK will have these two identifiers:
//   email: '[email protected]'
//   phone: '+15556667777'