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

@bookingbooster/bbtm

v0.2.13

Published

The **BBTM** library is used to track reservations conversion for any accommodation facility that uses the Booking Booster app.

Downloads

102

Readme

BBTM

The BBTM library is used to track reservations conversion for any accommodation facility that uses the Booking Booster app.

Table of Contents

Installation

Install the library using npm:

npm install @bookingbooster/bbtm

Usage

Import the Library Import and initialize BBTM in your JavaScript/


import BBTM from '@bookingbooster/bbtm';

const bbtm = new BBTM();

// Initialize with URL parameters
bbtm.init();

// Get the current session token
const token = bbtm.getSessionToken();

// Use the token to restore session if needed
// E.g. when the booking page changes, use the token retrieved via getSessionToken() in a previous page where init() has been called
bbtm.setSessionToken(token);

// Confirm a successful reservation
bbtm.sendConversion().then(() => {
  console.log('Reservation conversion successfully sent to the BBTM.');
});

Api Reference

class BBTM Constructor Creates an instance of BBTM. Throws an error if used in a non-browser environment.


init(options?: BBTMOptions): void

Initializes the session using the URL parameters bbclk, bbacc, and bbsrc. If those paramethers are in the URL they will have priority over the optional provided storage

Parameters:

interface BBTMOptions {
  storage?: BBTMStorage;
}

getSessionToken(): string | null

Retrieves the current session token. This token should be saved and reused to maintain a session across different steps of the reservation process.

Returns: A string containing the session token, or null if any required values are missing.


setSessionToken(newToken: string): void

Restores the session token. Use the token obtained from getSessionToken to set the session across different components of your application.

Parameters: newToken (string): The token string to restore.


sendConversion(): Promise<boolean>

Confirms the completion of a reservation process. This should be called at the final step of a successful booking.

Returns: Promise indicating the success of the operation.


BBTM Local Storage The BBTM class utilizes a session storage system to handle reservation data. You have the option to use the default storage system (localStorage) or implement your own custom storage solution.

Default Storage: BBTMLocalStorage The library includes a BBTMLocalStorage class that implements the BBTMStorage interface. This class handles storing and retrieving the session data in localStorage.

Example with provided storage

const bbtm = new BBTM();
bbtm.init({ storage: new BBTMLocalStorage() });

Custom Storage If you prefer to use a different storage mechanism (e.g., sessionStorage, a custom database, or an API), you can create your own storage class by implementing the BBTMStorage interface.

BBTMStorage Interface The interface you need to implement custom storage solutions:

export interface BBTMStorage {
  set(session: BBTMSession): void | Promise<void>;
  get(): BBTMSession | Promise<BBTMSession> | undefined | Promise<undefined>;
}