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

pacman-client

v1.5.6

Published

``` yarn start:dev ```

Downloads

300

Readme

Development

yarn start:dev

Use Local Tunnel

npx localtunnel --port 8080 --subdomain your-name

Build

Web Library

yarn build:web

This creates ./.build/pacman-{version}.js. You can use this file in browser:

<script src="pacman-1.2.0"></script>
<script>
  var pacmanClient = mkPacmanClient({
    rockmanId: "9718dee6f1404543ba0c8ad27c5be405",
    serverUrl:  "https://de-pacman.sam-media.com/api/v2/mstore",
    impressionNumber: 1,
    signalInterval: 1000 // in milliseconds
  });
  pacmanClient.sendFlowEvent({
    category: 'Flow',
    action: 'advance',
    label: 'msisdn-submitted',
    args:  {
      msisdn: '...'
    }
  })
</script>

Upload to S3

First make sure you have AWS CLI installed and configured.

yarn upload:s3

This will upload the contents of the .build directory to s3://mobirun/pacman

The final JS file will be at for example:

https://d2b4jmuffp1l21.cloudfront.net/pacman/pacman-1.2.0.js

Library Module

yarn build:module

This creates ./.build-lib/**.

import mkPacmanClient from 'pacman-client'
const pacmanClient = mkPacmanClient({
  rockmanId: "9718dee6f1404543ba0c8ad27c5be405",
  serverUrl:  "https://de-pacman.sam-media.com/api/v2/mstore",
  impressionNumber: 1,
  signalInterval: 1000 // in milliseconds
});
pacmanClient.sendFlowEvent({
  category: 'Flow',
  action: 'advance',
  label: 'msisdn-submitted',
  args:  {
    msisdn: '...'
  }
})

API

function mkPacmanClient(config: {
    serverUrl: string;
    rockmanId: string;
    impressionNumber: number;
    signalInterval: number; // in milliseconds, defaults to 1000
    events: EventsEmitter;
}): PacmanClient;

type PacmanClient = {
  sendFlowEvent: (flowEvent: FlowEvent) => void;
  sendCustomEvent: (typeName: string, eventName: string) => void;
  sendOptInFlowEvent: (optInFlowName: OptInFlowName) => void;
  predefinedFlowEvents: {
    onAdvanceInPreFlow: (label: string, args?: any) => void;
    onSubmitMSISDN: (i: {
        msisdn: string
    }) => void;
    onSubmitPIN: (i: {
        pin: string;
        msisdn?: string;
    }) => void;
  };
}

type FlowEvent {
  category: string;
  action?: string;
  label?: string;
  value?: number;
  args?: any;
}

type OptInFlowName = 
    "Block" | "Click to sms" | "Hybrid Pin" | "Msisdn to sms" | "Not available" 
  | "Pin" | "Redirect" | "To be determined" | "USSD" | "3G click";

Events API

const {events} = mkPacmanClient({...})

events.addEventListener('battery', ({charging, percent}) => {
  // 0 or 1 time
})

events.addEventListener('touchmove', ({deltaX, deltaY}) => {
  // 0 or many times
})

events.addEventListener('ftouch', () => {
  // 0 or 1 time
})

events.addEventListener('fmotion', () => {
  // 0 or 1 time
})

events.addEventListener('manusia', () => {
  // 0 or 1 time
})

List of event types:

  • battery ☀️ (new)

    { t: 'battery', a: { p: [ 1, 0.8 ] }, s: 0 } 
    // p: [is_charging, battery_percent]
  • battery-not-supported ☀️ (new)

    { t: 'battery-not-supported', s: 0 }
  • hidden

    { t: 'hidden', s: 3276.3 }
  • visible

    { t: 'visible', s: 3757.3 }
  • blur

    { t: 'blur', a: { e: 'window' }, s: 3275.9 }
  • focus

    { t: 'focus', a: { e: 'window' }, s: 3757.1 },
  • ftouch ☀️ (client logic updated)

    { t: 'ftouch', s: 58.2 }
  • fmotion ☀️ (client logic updated)

    { t: 'fmotion', s: 13.2 }
  • full_load

    { t: 'full_load', a: { p: [ 449, 1034 ] }, s: 0.2 }
  • html_load

    { t: 'html_load', a: { p: [ 449, 1034 ] }, s: 0.2 }
  • resize

    { t: 'resize', a: { p: [ 449, 1034 ] }, s: 0.9 }
  • scroll

    { t: 'scroll', a: { p: [ 0, 16 ] }, s: 0.5 }
  • click

    This is actually touch event, for backward compatibility I keep using click.

    { t: 'click', a: { e: '', p: [ 268.3, 298.5 ] }, s: 107.2 }
  • touchmove ☀️ (new)

    { t: 'touchmove', a: { p: [ -1.9, -180.1 ] }, s: 59.7 }
    // p: [delta X, delta Y]
  • mouseclick ☀️ (new)

    Mouse click events

    { t: 'mouseclick', a: { e: '', p: [ 268, 298 ] }, s: 107.2 }
  • unload ☀️ (new)

    { t: 'unload', s: 101.2 }
  • flow_event

  • get_sub_method

  • pageview

    {
      t: 'pageview',
      s: 0,
      a: {
        t: 'pageview',
        s: 0,
          
        // timezone in minutes
        tz: 60, 
          
        // Notification.permission
        n: 'default', 
          
        // window.top != window.self
        f: 0, 
          
        // navigator.connection.type
        nt: 'wifi', 
          
        // navigator.connection.effectiveType
        ns: '4g', 
          
        // navigator.language
        l: 'nl-nl', 
          
        // navigator.languages
        lz: 'nl-nl en-gb nl', 
          
        // document.body.clientWidth ⚠️
        vw: 412, 
          
        // document.body.clientHeight ⚠️
        vh: 756, 
          
        // window.screen.width
        sw: 412, 
          
        // window.screen.height
        sh: 892, 
          
        // window.screen.colorDepth
        sd: 24, 
          
        // window.devicePixelRatio
        sr: 2.625, 
          
        // navigator.platform
        np: 'Linux armv8l', 
          
        // navigator.doNotTrack
        dnt: null, 
          
        // navigator.cookieEnabled
        c: 1, 
          
        // !!navigator.sessionStorage
        ss: 1, 
          
        // !!navigator.webdriver
        wd: 0, 
          
        // !!window.localStorage
        ls: 1, 
          
        // !!window.indexedDB
        ib: 1, 
          
        // !!window.openDatabase
        od: 1, 
          
        // !!document.hasFocus()
        hf: 1, 
          
        // !!!document.hidden
        iv: 1, 
          
        // lied languages
        ll: 0, 
          
        // lied resolution
        lr: 0, 
          
        // lied OS ☀️ (client logic updated)
        lo: 0, 
          
        // lied browser ☀️ (client logic updated)
        lb: 0 
      }
    }