@runsidekick/sidekick-client

0.0.8 • Public • Published

Sidekick Discord Channel  Foresight monitoring  Sidekick Sandbox 

Sidekick Node.js client

Node.js client for Sidekick. Send your Sidekick logs and traces to any target in seconds!
Explore the docs »

Sidekick Home · Report Bug & Request Feature

Table of Contents
  1. About
  2. Getting Started
  3. Roadmap
  4. Contact

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.

(back to top)

Built With

(back to top)

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": "<>"

(back to top)

Roadmap

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

(back to top)

Contact

Barış Kaya - @boroskoyo

Sidekick: website

Special Thanks

Emin Bilgiç - linkedin

(back to top)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.8
    0
    • latest

Version History

Package Sidebar

Install

npm i @runsidekick/sidekick-client

Weekly Downloads

0

Version

0.0.8

License

ISC

Unpacked Size

42.1 kB

Total Files

10

Last publish

Collaborators

  • bcaglayan
  • yasinkalafat
  • sidekick-user