Sidekick Node.js Client
npm install @runsidekick/sidekick-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
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
* 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.
Tested with node v16.14.2
* npm
``sh`
npm install npm@latest -g
1. Install sidekick-client
`sh `
$ npm i @runsidekick/sidekick-client
`js
const { SidekickApi} = require('@runsidekick/sidekick-client')
` 2. Create an instance from Sidekick Api
`js
const apiClient = new SidekickApi({apiKey:, apiToken:});
`
3. Create a parameter that contains your file information to put tracepoint.
`js
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
`js
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.
$3
1. Create a
config.json according to your needs
`js
"SIDEKICK_TRACEPOINT_INDEX": "sidekick_tracepoint",
"SIDEKICK_LOGPOINT_INDEX": "sidekick_logpoint",
"SIDEKICK_EMAIL": "",
"SIDEKICK_PASSWORD": "",
`
2. Import
onTrigger from @runsidekick/sidekick-client
`js
const { onTrigger } = require('@runsidekick/sidekick-client')
`
3. Create an ingest function that will send collected data to desired target:
`js
function ingestFunc (index) {
return async function (data) {
console.log(JSON.stringify({index,data}));
}
}
`4. Initialize Sidekick client info with proper parameters.
`js
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):
`js
"sidekickHost": "ws://127.0.0.1",
"sidekickPort": "7777"
` If have your user token you can use it instead of email & password (Optional):
`js
"sidekickToken": "<>"
``
- [x] Add websocket support
- [x] Custom ingest function
- [x] Add support for programattically putting logpoints & tracepoints using REST API
Barış Kaya - @boroskoyo
Sidekick: website