Package Exports
- @jupyterlab/jupyterlab-telemetry
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@jupyterlab/jupyterlab-telemetry) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
jupyterlab-telemetry
A JupyterLab extension for logging and telemetry of usage data
Prerequisites
- JupyterLab 1.0+
Installation
jupyter labextension install 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 JuptyerLab 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