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

@livesession/sdk

v1.1.4

Published

Add a LiveSession script to your site even easier with our SDK

Downloads

8,132

Readme

Livesession SDK

Official LiveSession SDK

This small package let you install LiveSession script and configure it properly.

If you need you can use methods that were also provided in this SDK.

Usage

npm i @livesession/sdk or yarn add @livesession/sdk

Next, you should initialize the SDK on your website like in this example:

import ls from "@livesession/sdk";

// init a script, trackID is required
ls.init("YOUR TRACKID", options, sdkOptions);

After LiveSession is inited, you can start recording session using method newPageView()

Initialization example with enabled recording

ls.init("123456789", { keystrokes: true, rootHostname: ".mypage.com" });
ls.newPageView();
// or with devMode on
ls.init(
  "1234.56789",
  { rootHostname: ".mypage.com" },
  {
    devMode: true, // process.env.NODE_ENV === "development"
  }
);
ls.newPageView();

Custom events

ls.track("User Subscribed", {
  plan: "premium",
  seats: 1,
  total: 255.50,
  isPatron: true
});

React usage

ls.init("YOUR-TRACK-ID", options, sdkOptions);
ls.newPageView();
ReactDOM.render(<App />, document.getElementById("root"));

Angular usage

Implementation is created thanks to @SkowyrnyMG

  1. Import SDK into your main app component

  2. Import OnInit from @angular/core

  3. Implement OnInit and call LiveSession init method in ngOnInit function, and start recording

// app.component.ts
import ls from '@livesession/sdk'

export class AppComponent implemets OnInit {
    ngOnInit(){
        ls.init("YOUR_TRACK_ID");
        ls.newPageView();
    }
}

For more about initializing script check out our guide

sdkOptions

As a third argument to init method you can pass sdkOptions object, here are all available variables:

| Variable | Parameter | Default | Info | | -------- | --------- | ------- | ------------------------------------------------- | | devMode | bool | false | Log methods into console instead of calling their | | scriptURL | string | https://cdn.livesession.io/track.js | Link to LiveSession tracking code, useful if you want to use a specific version of code|

Example

ls.init("exampleID", null, { devMode: true });

API

If you initialized script, you can simply customize it with following functions:

| Function | Parameter | Default | Allowed | | ----------------- | ---------------------------- | ----------------- | -----------------------------------------------| | init | trackID, options, sdkOptions | null, null, false | string(required), object, object | | getSessionURL | callback(url, isNewSession) | null | void(string, bool) | | identify | data | null | object | | invalidateSession | - | null | - | | newPageView | options | null | object | | setOptions | options | null | object | | setCustomParams | data | null | object | | off | - | null | - | | optOut | - | false | - | | debug | - | false | - | | track | event, properties | null, null | string(required), object | | log | logLevel, data | "log", null | string("log", "info", "warn", "error"), object |

If out want to learn more about all methods, go to our developers page

Types

logLevel supported

| Level | Description | | -------- |----------------------------------------------------------------------------------- | | "log" | Object will be logged as log | | "info" | Object will be logged as info | | "warn" | Object will be logged as warn | | "error" | Object will be logged as error |

Contributing

We're always open to work with our community. Let us know if you have ideas for new features or suggestions. Pull requests for bug fixes are also welcome!

Changelog

This package currently support v.1.4.0 of API, you can find more informations about API changelog here

License

MIT