-
-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for optional telemetry plugin #1018
Add support for optional telemetry plugin #1018
Conversation
awesome. this is something i've been wanting for awhile. thanks for adding this. |
7878ad0
to
c2563cf
Compare
cc @jtpio: for work on |
0231575
to
c2b7ccc
Compare
Thanks @dlqqq for the ping! It looks like telemetry would be useful to JupyterLab and the extension ecosystem in general. Wondering if you already have some ideas on how this could generalized so it can be used by any plugin? Maybe leveraging the existing Also cc @afshin who was recently looking into telemetry and metrics via the built-in |
c2b7ccc
to
7a4d4a0
Compare
This is a great idea, thanks for reaching out! I'd be very interested in working with you, @afshin, and the rest of your team to develop a general, standardized strategy for emitting & handling telemetry in JupyterLab & JupyterLab extensions (if one doesn't already exist 😁). I'd also love it if we could create a "how-to" guide for devs looking to implement telemetry in the extension development docs. Integrations with other JupyterLab APIs like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks and works well within the scope of the PR.
Note that “3 vertical dots” menu on the Jupyternaut response does not log actions as of now and it probably should for the consistency but this can be addressed in a separate PR.
Ah, I was hoping we could have a chance to discuss this a bit more before it gets merged. Telemetry is not only useful for Jupyter AI. I'm a bit worried that we if we start having many different ways for doing this, and each extension implementing its own thing, it will quickly become difficult to find a way to generalize that later. |
Hi @jtpio. For context, logging functionality is also implemented in Jupyter Scheduler and implementation is not the same as here. So this is not the first extension to do it. See Jupyter Scheduler PRs jupyter-server/jupyter-scheduler#448, jupyter-server/jupyter-scheduler#457, jupyter-server/jupyter-scheduler#472, jupyter-server/jupyter-scheduler#523. I'm also sure that if / when JupyterLab would provide default logging mechanism, both Jupyter Scheduler and Jupyter AI teams would be happy to consider transitioning to it. |
* remove console log accidentally merged with jupyterlab#1013 * set metadata on stream messages in the chat_history array * implement support for optional telemetry plugin * anonymize message & code details * export telemetry hook from NPM package entry point
Description
This PR introduces support for an optional telemetry plugin, which receives interaction events that are emitted from Jupyter AI's frontend.
The telemetry plugin is not implemented in Jupyter AI, meaning that nothing happens when an interaction event occurs by default. To clarify: no telemetry data ever leaves the user's browser memory by default. This can be readily verified from the code proposed here.
This feature is mainly for admins managing custom deployments who need to obtain usage data on their deployments. This change should leave almost all users completely unaffected.
This PR introduces 4 types of telemetry events, all of which are emitted from the code toolbar:
'copy' | 'replace' | 'insert-above' | 'insert-below'
.Admins can listen to these telemetry events only by providing a telemetry plugin in a separate labextension package. This is done by writing a separate plugin that implements & provides
IJaiTelemetryHandler
(imported from@jupyter-ai/core/tokens
).The plugin implementation of
IJaiTelemetryHandler
should return an object with one method:onEvent(e)
, wheree: TelemetryEvent
represents a telemetry event emitted by Jupyter AI's frontend. The definition ofTelemetryEvent
is given below:metadata
field to agent messages #1013, namely by a) removing a danglingconsole.log()
statement, and b) ensuring that message metadata is recorded in the chat history array used to serveGET api/ai/chats/history
.Demo
No telemetry events ever appear in the browser console by default; this is a quick proof-of-concept that shows telemetry events are being emitted by the frontend & captured by a custom plugin. See the next section for steps on how to reproduce this locally.
Screen.Recording.2024-10-07.at.1.01.00.PM.mov
Steps to reproduce demo
packages/jupyter-ai/src/index.ts
:telemetryPlugin
to the list of default exports at the bottom of the same file:jlpm build
, refresh, and observe that interaction events are being captured & logged to the console, as shown in the demo video.