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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@codesight/codesight-js

v1.0.1

Published

JavaScript client for capturing events in web browsers for the CodeSight platform

Readme

Codesight, runtime insights at dev time.

JavaScript client for capturing events in web browsers or nodejs for CodeSight.

Installation

yarn

yarn add codesight-js

npm

npm install codesight-js

script tag

<script src="https://unpkg.com/[email protected]/dist/index.js"></script>

inline script

<script>
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n=n||self).cdst={})}(this,function(t){"use strict";function s(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var i,n;(n=i||(i={}))[n.function=0]="function";var a="platform.codesight.cloud",c="/api/1/session",e=function n(e){var r=this;!function(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),s(this,"session",void 0),s(this,"_onEvent",function(n,e){r.session.events[n]=e}),s(this,"invoke",function(n,e){var t=encodeURIComponent(n+e),s=r.session.events[t];s?s.count++:s={name:n,file:e,count:1,type:i.function},r._onEvent(t,s)}),s(this,"startSession",function(n){return r.session={id:function(){function n(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return n()+n()+"-"+n()+"-"+n()+"-"+n()+"-"+n()+n()+n()}(),apiKey:n.apiKey,project:n.project,environment:n.environment,start:new Date,end:null,events:{}},r.session}),s(this,"closeSession",function(){return r.session.end=new Date,r.session}),s(this,"postSession",function(){var n=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];if(0<Object.keys(r.session.events).length)if(XMLHttpRequest){var e=new XMLHttpRequest;e.open("POST","https://"+a+c,n),e.setRequestHeader("Content-type","application/json; charset=utf-8"),e.onreadystatechange=function(){4===e.readyState&&204===e.status&&(r.session.events={})},e.send(JSON.stringify(r.session))}else if(require){var t=require("https"),s=JSON.stringify(r.session),i={hostname:a,port:443,path:c,method:"POST",headers:{"Content-Type":"application/json; charset=utf-8","Content-Length":s.length}},o=t.request(i,function(n){n.on("data",function(){r.session.events={}})});o.write(s),o.end()}}),s(this,"postSessionAndExit",function(){process&&(r.closeSession(),r.postSession(),setTimeout(function(){process.exit()},5e3))}),this.session=this.startSession(e),setInterval(this.postSession.bind(this,!1),e.interval||3e4),window&&window.addEventListener("beforeunload",function(){r.closeSession(),navigator.sendBeacon?navigator.sendBeacon("https://"+a+c,JSON.stringify(r.session)):r.postSession(!1)})};t.instance={invoke:function(){},startSession:function(){},closeSession:function(){},postSession:function(){}};t.Client=e,t.initialize=function(n){return t.instance=new e(n),t.instance},t.i=function(n,e){t.instance.invoke(n,e)},Object.defineProperty(t,"__esModule",{value:!0})});
</script>

Setup

Basic Usage

First you need to initialize the client with your API key, project Id and environment Id. These can be found in your envrionment from CodeSight.cloud.

import * as cdst from 'codesight-js';

cdst.initialize({
    apiKey: '',
    project: '',
    envrionment: '',
    error: false, // optional, defaults to false
    interval: 30000, // optional, defaults to 30000
});

interval

Number of milliseconds to wait between sending session data back to CodeSight. Defaults to 30 seconds.

Function calls can then be reported to CodeSight using:

// myFunction: Function Name
// aW5kZXguanM=: LZ compressed base64 encoded filename (index.js) relative to .codesight file
cdst.i('myFunction', 'aW5kZXguanM=');

The VSCode extension (highly recommended) adds a command to add an invoke call and will automatically generate the LZ compressed base64 encoded filename.

Session data will be automatically sent back to CodeSight every 30 seconds (or the interval you configured during initialization).

Session data can be sent back manually at any point using:

// Or via exposed postSession
cdst.postSession();

When initializing the client an event handler to beforeunload is attached (if running in a browser environment), this event handler will close the session and send back any remaining session data.

When running in a nodejs envrionment you can call cdst.postSessionAndExit to post back the session data, after 10 seconds process.exit will be called.