tione-jupyterlab-telemetry
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

jupyterlab-telemetry

Version

A JupyterLab extension for logging and telemetry of usage data

Prerequisites

  • JupyterLab 1.0+

Installation

jupyter labextension install @jupyterlab/jupyterlab-telemetry

Usage

Define handlers that can receive events from the EventLog

import { EventLog } from "@jupyterlab/jupyterlab-telemetry";
 
function consoleHandler(el: EventLog, events: EventLog.RecordedEvent[]) {
  console.log(`[Handler1] Received events ${JSON.stringify(events)}`)
}
 
function consoleHandler2(el: EventLog, events: EventLog.RecordedEvent[]) {
  console.log(`[Handler2] Received events ${JSON.stringify(events)}`)
}

Create an instance of the EventLog and configure the handler and other options from EventLog.IOptions

 
const el = new EventLog({
  handlers: [consoleHandler, consoleHandler2],
  allowedSchemas: ['org.jupyter.foo', 'org.jupyterlab.commands.docmanager:open'],
  commandRegistry: app.commands,
  commandEmitIntervalSeconds: 2
});

Send custom events via the recordEvents interface. If the commandRegistry instance was passed, then the EventLog will subscribe to commands executed in the JupyterLab application and send the whitelisted ones to each configured handler.

el.recordEvent({
  schema: 'org.jupyter.foo',
  version: 1,
  body: {
    'foo': 'bar'
  }
});
 

Dispose the event log after use

el.dispose();

Development

For a development install, do the following in the repository directory:

yarn
yarn build
jupyter labextension install .

To rebuild the package and the JupyterLab app:

yarn build
jupyter lab build

To auto-build the package and JupyterLab on any change:

 
# In one terminal 
yarn watch
 
# In second terminal 
 
jupyter lab --watch
 

Readme

Keywords

Package Sidebar

Install

npm i tione-jupyterlab-telemetry

Weekly Downloads

0

Version

0.4.0

License

BSD-3-Clause

Unpacked Size

12.9 kB

Total Files

8

Last publish

Collaborators

  • brevinxie