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

@runsidekick/sidekick-client

v0.0.8

Published

Sidekick Node.js Client

Downloads

9

Readme

About Sidekick

Sidekick is a production debugging and on-demand logging tool where you can debug your running applications while they keep on running. Sidekick provides the ability to add logs and put non-breaking breakpoints in your application code which captures the snapshot of the application state, the call stack, variables, etc.

Sidekick Actions:

  • A tracepoint is basically a non-breaking remote breakpoint. In short, it takes a screenshot of the variables when the code hits that line.
  • Logpoints open the way for dynamic logging to Sidekick users. Replacing traditional logging with dynamic logging has the potential to lower stage sizes, costs, and time for log searching while adding the ability to add new logpoints without editing the source code, redeploying or restarting the application

Client Features

  • Sidekick Node Client opens up a new & headless way to use Sidekick. It allows you to both use custom ingest functions for the tracepoint/logpoint events and put/edit/delete your tracepoints/logpoints easily using code.

Built With

Prerequisites

Tested with node v16.14.2

  • npm
    npm install npm@latest -g

Getting Started

Installation

  1. Install sidekick-client
    $ npm i @runsidekick/sidekick-client

Example usage

Put tracepoint on a line

  1. Import SidekickApi

      const { SidekickApi} = require('@runsidekick/sidekick-client')
  2. Create an instance from Sidekick Api

      const apiClient = new SidekickApi({apiKey:<Your Api Key>, apiToken:<Your Account Token>});
    
  3. Create a parameter that contains your file information to put tracepoint.

      const params= {
          applicationFilters: [
              {
                name: "Demo application",
                version: "v1.0",
                stage: "prod"
              }
            ],
          fileName: "gitlab.com/repos/...",
          lineNo: 23,
          expireSecs: -1,
          expireCount: -1,
          enableTracing: true,
          persist: true
    }
    
  4. Call putTracepoint function

      apiClient.putTracepoint(params);

Then your tracepoint will be added to line 23 in the given file. Also, you can use SidekickApi for any other operations such as removing tracepoint or putting log point.

Use custom ingest function for the tracepoint/logpoint events

  1. Create a config.json according to your needs

     "SIDEKICK_TRACEPOINT_INDEX": "sidekick_tracepoint",
     "SIDEKICK_LOGPOINT_INDEX": "sidekick_logpoint",
     "SIDEKICK_EMAIL": "<Email of your sidekick account>",
     "SIDEKICK_PASSWORD": "<Password of your sidekick account>",
  2. Import onTrigger from @runsidekick/sidekick-client

        const { onTrigger } = require('@runsidekick/sidekick-client')
  3. Create an ingest function that will send collected data to desired target:

        function ingestFunc (index) {
            return async function (data) {
                console.log(JSON.stringify({index,data}));
            }
        }
  4. Initialize Sidekick client info with proper parameters.

        const clientInfo = {
            sidekickEmail : config['SIDEKICK_EMAIL'], 
            sidekickPassword : config['SIDEKICK_PASSWORD'], 
            tracepointFunction : ingestFunc(config['SIDEKICK_TRACEPOINT_INDEX']),
            logpointFunction : ingestFunc(config['SIDEKICK_LOGPOINT_INDEX']),
            errorSnapshotFunction : ingestFunc(config['SIDEKICK_ERRORSTACK_INDEX'])
        }
    
        onTrigger(clientInfo);

Then your tracepoint events will be logged. You can customize the ingest function as you want.

If you have an on-premise setup add the fields below to client object (Optional):

 "sidekickHost": "ws://127.0.0.1",
 "sidekickPort": "7777"

If have your user token you can use it instead of email & password (Optional):

 "sidekickToken": "<>"

Roadmap

  • [x] Add websocket support
  • [x] Custom ingest function
  • [x] Add support for programattically putting logpoints & tracepoints using REST API

Contact

Barış Kaya - @boroskoyo

Sidekick: website

Special Thanks

Emin Bilgiç - linkedin