1.0.4 • Published 5 years ago

@livesession/livesession-sdk v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

Coverage Status 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/livesession-sdk or yarn add @livesession/livesession-sdk

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

import ls from "@livesession/livesession-sdk";

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

Initialization example

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

React usage

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

Angular usage

  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

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

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

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:

VariableParameterDefaultInfo
devModeboolfalseLog methods into console instead of calling their

Example

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

API

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

FunctionParameterDefaultAllowed
inittrackID, options, sdkOptionsnull, null, falsestring(required), object, object
getSessionURLcallback(url, isNewSession)nullvoid(string, bool)
identifydatanullobject
invalidateSession-null-
newPageViewoptionsnullobject
setOptionsoptionsnullobject
setCustomParamsdatanullobject
off-null-
optOut-false-
debug-false-

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

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.1 of API, you can find more informations about API changelog here

License

MIT

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago