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

@backtrace/session-replay

v0.2.0

Published

Backtrace-JavaScript Session Replay module

Downloads

8

Readme

Backtrace Session Replay module

Backtrace captures and reports handled and unhandled exceptions in your production software so you can manage application quality through the complete product lifecycle.

The @backtrace/session-replay module allows your browser application to record user experience before an error occurs. You can view then the recording in Backtrace alongside your error reports.

Table of Contents

  1. Integration
  2. Features
  3. Advanced features

Integration

@backtrace/session-replay can be integrated with any Backtrace SDK that derives from the @backtrace/browser SDK.

Install the package

$ npm install @backtrace/session-replay

Integrate the module

To add the session replay integration, add the following code to the builder:

import { BacktraceClient, BacktraceConfiguration } from '@backtrace/browser';
import { BacktraceSessionReplayModule } from '@backtrace/session-replay';

// Configure client options
const options: BacktraceConfiguration = {
    // Name of the website/application
    name: 'MyWebPage',
    // Version of the website
    version: '1.2.3',
    // Submission url
    // <universe> is the subdomain of your Backtrace instance (<universe>.backtrace.io)
    // <token> can be found in Project Settings/Submission tokens
    url: 'https://submit.backtrace.io/<universe>/<token>/json',
};

// Initialize the client with the options
// Make sure to add `useModule` with `BacktraceSessionReplayModule`
const client = BacktraceClient.builder(options)
    .useModule(
        new BacktraceSessionReplayModule({
            maxEventCount: 100,
        }),
    )
    .build();

Features

Event limiting

You can configure max number of events, that will be sent with the report, using maxEventCount option:

new BacktraceSessionReplayModule({
    maxEventCount: 100,
});

By default, the event count will be set to 100. To disable max event limit, set disableMaxEventCount to true. Note: disabling the max event count is not recommended and may lead to large reports.

Sampling options

You can control how events will be captured and sent with the report.

new BacktraceSessionReplayModule({
    sampling: {
        input: 'last',
    },
});

| Option | Values | Default | Description | | ------------------ | ----------------------------------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | | mousemove | boolean/number | true | Controls whether mouse movement is recorded, or the interval of mouse movement events in milliseconds (i.e. will not capture more than one event every set time). | | mouseInteraction | boolean/{[MOUSE_INTERACTION]:boolean} | true | Controls all or specific mouse interactions. | | scroll | number | undefined | Interval of scrolling events in milliseconds (i.e. will not capture more than one event every set time). | | media | number | undefined | Interval of media events in milliseconds (i.e. will not capture more than one event every set time). | | input | 'all'/ 'last' | 'all' | Capture either all or last input events. When set to last, only final input will be captured. |

Mouse interactions

  • MouseUp
  • MouseDown
  • Click
  • ContextMenu
  • DblClick
  • Focus
  • Blur
  • TouchStart
  • TouchMove_Departed
  • TouchEnd
  • TouchCancel

Privacy options

You can control how information is sent to Backtrace. Use this to mask PII.

For example, if you want to hide all HTML elements that have the do-not-send class:

new BacktraceSessionReplayModule({
    privacy: {
        blockClass: 'do-not-send',
    },
});

| Option | Values | Default | Description | | --------------------- | -------------------------------------------------- | -------------------- | --------------------------------------------------------------------------------------------------------------------------- | | blockClass | string/RegExp | 'bt-block' | Blocks elements with this class. | | blockSelector | string | undefined | Blocks elements matching this selector. | | ignoreClass | string | 'bt-ignore' | Ignores elements with this class. | | ignoreSelector | string | undefined | Ignores elements matching this selector. | | ignoreCSSAttributes | string[] | [] | Set of CSS attributes that should be ignored. | | maskTextClass | string/RegExp | 'bt-mask' | Masks elements with this class. | | unmaskTextClass | string/RegExp | 'bt-unmask' | Unmasks elements with this class. | | maskTextSelector | string | undefined | Masks elements matching this selector. | | unmaskTextSelector | string | undefined | Unmasks elements matching this selector. | | maskAllText | boolean | true | If true, will mask all text. Use unmaskTextClass or unmaskTextSelector to unmask. | | maskAllInputs | boolean | true | If true, will mask all inputs. | | maskInputOptions | {[INPUT_TYPE]:boolean} | { password: true } | Mask specific kinds of inputs. | | maskInputFn | (text: string, element: HTMLElement) => string) | mask with asterisks | Callback to customize input masking. Returned string will be used in masked input. | | maskTextFn | (text: string, element?: HTMLElement) => string) | mask with asterisks | Callback to customize text masking. Returned string will be used in masked text. | | inspect | (event: eventWithTime) => eventWithTime? | include all events | Callback to inspect the added event. You must return an event for it to be included. Return undefined to skip this event. |

Input types

  • color
  • date
  • datetime-local
  • email
  • month
  • number
  • range
  • search
  • tel
  • text
  • time
  • url
  • week
  • textarea
  • select
  • password

Advanced features

@backtrace/session-replay is based on rrweb. You can use advancedOptions to pass options directly to rrweb:

new BacktraceSessionReplayModule({
    advancedOptions: {
        checkoutEveryNms: 10000,
    },
});

See rrweb guide for more details.