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

@detatsatrio/react-native-clarity

v2.0.2

Published

A plugin to provide the Clarity experience for the React Native applications.

Downloads

6

Readme

react-native-clarity

A ReactNative plugin that allows integrating Clarity with your application.

Installation

npm install @detatsatrio/react-native-clarity

Usage

import {LogLevel, initialize, setCustomUserId,  setCustomSessionId, setCustomTag, setCurrentScreenName, getCurrentSessionId } from 'react-native-clarity';

// Initialize Clarity.
let clarityConfig = {
  logLevel: LogLevel.Verbose,
  allowMeteredNetworkUsage: true
}

initialize('<ProjectId>', clarityConfig);

// Set custom user id.
setCustomUserId("<CustomUserId>");

// Set custom session id.
setCustomSessionId("<CustomSessionId>");

// Set custom tag.
setCustomTag("key", "value");

// Setting the current screen name when using React Navigation
import { ..., useFocusEffect } from '@react-navigation/native';

const HomeScreen = ({...}) => {
  useFocusEffect(
    React.useCallback(() => {
      setCurrentScreenName("Home");

      // To clear the current screen name when the screen goes out of focus:
      return () => { setCurrentScreenName(undefined); }
    }, [])
  );
  ...
};

// Get current session id to correlate with other tools.
getCurrentSessionId().then((id) => {...});

Initialization arguments

/**
 * Initializes the Clarity SDK if the API level is supported.
 * 
 * @param projectId     [REQUIRED] The Clarity project id to send data to.
 * @param config     [OPTIONAL] The clarity config, if not provided default values are used.
*/
function initialize(projectId: string, config?: ClarityConfig) 

/**
 * The configuration that will be used to customize the Clarity behaviour.
 * 
 * @param userId        [OPTIONAL default = null] A custom identifier for the current user. If passed as null, the user id
 *                      will be auto generated. The user id in general is sticky across sessions.
 *                      The provided user id must follow these conditions:
 *                          1. Cannot be an empty string.
 *                          2. Should be base36 and smaller than "1Z141Z4".
 * @param logLevel      [OPTIONAL default = LogLevel.None] The level of logging to show in the device logcat stream.
 * @param allowMeteredNetworkUsage  [OPTIONAL default = false] Allows uploading session data to the servers on device metered network.
 * @param enableWebViewCapture    [OPTIONAL default = true] Allows Clarity to capture the web views DOM content.
 * @param allowedDomains    [OPTIONAL default = ["*"]] The whitelisted domains to allow Clarity to capture their DOM content.
 *                          If it contains "*" as an element, all domains will be captured.
 * @param disableOnLowEndDevices [OPTIONAL default = false] Disable Clarity on low-end devices.
 */

interface ClarityConfig {
  userId?: string | null;
  logLevel?: LogLevel;
  allowMeteredNetworkUsage?: boolean;
  enableWebViewCapture?: boolean;
  allowedDomains?: string[];
  disableOnLowEndDevices?: Boolean;
}

License

MIT