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

@optimizely/sdk-plugin-pending-events

v0.5.0

Published

Event Dispatcher plugin that provides a persistent pending event queue

Downloads

11

Readme

@optimizely/sdk-plugin-pending-events

BrowserStack Status

An unsupported, experimental⚠️ EventDispatcher for Optimizely Full Stack (javascript-sdk, Web browser environment) that keeps a queue of pending (not completed) events persisted to localStorage, and retries pending events on initialization.

Motivation

Tracking click in browsers is difficult because browsers often redirect users before tracking requests complete. This example suggests one of many possible solutions to the above problem. Feel free to try it out, modify according the the LICENSE, and suggest changes here. And if you have another method for tackling this problem, we'd love to hear from you! Drop us a line at [email protected].

Install

npm install @optimizely/sdk-plugin-pending-events --save

Usage

See example for an example of how this is used:

$ cd example
$ npm install
$ npm start

Load the URL provided by webpack-serve in a browser of your choice.

API

index

Construct an EventDispatcher compatible with @optimizely/optimizely-sdk

Parameters

  • localStorageKey String Key under which to persist/load pending events in window.localStorage
  • sendJSON SendJSON Function to call to send payload
  • logger Function?

Returns EventDispatcher An object with a dispatchEvent method, suitable for use as an EventDispatcher

SendJSON

Function to call to send JSON

Type: Function

Parameters

  • url String URL to send to
  • options Object
    • options.method String HTTP method to use
    • options.body String Body text (should be stringified JSON)
  • callback SendJSONCallback Function to call, with no arguments, if successful, and with Error object, if error

Examples

// Example sendJSON built using fetch
const sendJSON = (url, options, callback) => {
  const {method, body} = options;
  return fetch(url, {
    method,
    body,
    headers: {
      'content-type': 'application/json',
    }
  })
  .then((resp) => {
    if (resp.status < 400) {
      callback();
    } else {
      callback(new Error(`Bad response code: ${resp.status}`));
    }
  }, callback);
}

SendJSONCallback

Type: Function

Parameters

  • error Error? Error, if any