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

mergn-webapp-sdk

v1.0.145

Published

[![npm version](https://img.shields.io/npm/v/mergn-webapp-sdk)](https://www.npmjs.com/package/mergn-webapp-sdk) [![npm downloads](https://img.shields.io/npm/dm/mergn-webapp-sdk.svg)](https://www.npmjs.com/package/mergn-webapp-sdk)

Downloads

1,746

Readme

Mergn Web SDK

npm version npm downloads

Installation

Mergn Web SDK is available as an npm package.

Using a package manager

npm install --save mergn-webapp-sdk@latest

import mergn from 'mergn-webapp-sdk';

Using a CDN

<script src="https://cdn.jsdelivr.net/npm/mergn-webapp-sdk@latest/dist/index.global.js"></script>

Initialization

Add your Mergn account credentials

mergn.init('Api_Key', options?: {
  swPath?: string || '/'; // custom service worker path. Defaults to root '/'
}); // Replace with values applicable to you. Refer below

Api_Key (mandatory): This value is given by Mergn Team.

options (optional): Additional initialization parameters.

mergn-sw.js (mandatory): A service worker file given by Mergn Team to enable features like web push notifications. This file must be kept in the root of the project like public folder in case of React. Or a custom path given in swPath option.

Event Record

Events monitor specific user actions within your app or website, such as app launch, product view, song play, photo share, purchase, or item favoring.


mergn.recordEvent(eventName: string, eventProperties?: { eventProperty: string; value: string | number }[];
): Promise<void>

Example:

// event without properties
mergn.recordEvent('Product viewed')

// event with properties
mergn.recordEvent('Product viewed', [{ eventProperty: 'Mens Accessories', value: 59.99 }])

Note: In most cases, it's recommended to use recordEvent without awaiting the returned Promise. This allows your application to continue running without waiting for the event recording to complete.

Attribute Record

Records or updates the attributes of user such as name, age or address.

mergn.recordAttribute(attributeName: string, value: string | number): Promise<void>

mergn.recordAttribute('Age', 35);

Note: In most cases, it's recommended to use recordAttribute without awaiting the returned Promise. This allows your application to continue running without waiting for the attribute recording to complete.

User Set Identity

Use this method for setting identity.

await mergn.login('Unique_Identity'): Promise<void>;

Unique_Identity (mandatory): This value is the customer's unique identity in your database like Id or Email.

Note: it's recommended to use login with awaiting the returned Promise. This allows your application to set identity successfully which would later be used for recording events and attributes.

User Logout

Use this method where user is logged out successfully to record logout event.

mergn.logout();

Offline Mode

mergn-webapp-sdk automatically queue events in case of internet disruption, and sends them once internet is restored while the user is on the website

max event queue limit is 50, after which events are ignored

Debugging

! MUST DISABLE ON PRODUCTION

To show logs while debugging

mergn.setDebugLevel(LOG_LEVEL);

LOG_LEVEL (mandatory): Enter corresponding value:

NONE = 0, INFO = 1, ERROR = 2, ALL = 3,

Default is 0