Skip to content
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

Analytics: register SDK language and data source #1371

Merged
merged 14 commits into from Feb 22, 2023
Merged

Conversation

emilk
Copy link
Member

@emilk emilk commented Feb 21, 2023

Closes most of #396

Contains a bug fix for what SDK the log events originate from (we would before always set Python SDK as the source).

Adds a new field data_source which can be any of:

  • file (.rrd)
  • sdk (likely show())
  • ws_client (likely spawn())
  • tcp_server (likely connect())

Adds a app_env field that be any of python_sdk, rust_sdk, rust_cli, web (the latter won't happen until we have analytics on web).

Also adds a python_version when applicable.

Example

Starting rerun rust binary with CLI, then connecting to it from Python SDK:
image

TODO

  • Add analytics for if the viewer was started from Rust or Python
  • Python version
  • Ensure we send events when loading a file from the viewer
  • Send data_source as part of the open_recording event
  • Send an event when serve() is called (serving a web browser) separate PR

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I've added a line to CHANGELOG.md (if this is a big enough change to warrant it)

We would always log `Python SDK` as the source
@emilk emilk added 🦀 Rust API Rust logging API 🧑‍💻 dev experience developer experience (excluding CI) labels Feb 21, 2023
@emilk emilk changed the title Fix analytics recording_source for Rust Analytics: register SDK language and data source Feb 21, 2023
@teh-cmc teh-cmc self-requested a review February 22, 2023 08:21
@nikolausWest
Copy link
Member

I don't think we should go with the name new_recording since it is easy to confuse it with "created new recording" when we actually mean something like "viewer opened new recording". I'd prefer open_recording

@emilk emilk marked this pull request as draft February 22, 2023 13:58
@emilk emilk marked this pull request as ready for review February 22, 2023 15:21
@emilk
Copy link
Member Author

emilk commented Feb 22, 2023

Maybe we should leave the patch version off the python_version to make it easier to split the data?

Copy link
Member

@teh-cmc teh-cmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is absolutely fantastic.

I think this gives us a nice opportunity to streamline how we keep track of python & rust versions across host and recordings too (in another PR), see my inline comment.


Checklist:

  • rust viewer cli
  • rust spawn
  • rust viewer - python connect
  • rust viewer - rust connect
  • rust viewer - then manually open python rrd
  • rust viewer - then manually open rust rrd
  • rust viewer - python rrd straight from cli
  • rust viewer - rust rrd straight from cli
  • rust serve
    • not working, as expected
  • python viewer cli
  • python spawn
  • python viewer - rust connect
  • python viewer - python connect
  • python viewer - then manually open rust rrd
  • python viewer - then manually open python rrd
  • python viewer - python rrd straight from cli
  • python viewer - rust rrd straight from cli
  • python serve
    • not working, as expected

crates/re_viewer/src/viewer_analytics.rs Outdated Show resolved Hide resolved
Comment on lines +131 to +137
if let RecordingSource::PythonSdk(version) = &rec_info.recording_source {
// This will over-write what is set by `AppEnvironment`, if any.
// Usually these would be the same, but if you are using one python version to look
// at a recording from an older python version, then they will differ.
// For simplicity's sake we ignore this. We just want a rough idea of
// what python version our users use.
self.register("python_version", version.to_string());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can actually avoid this issue entirely: the python version that corresponds to the machine the user is running on (i.e. the machine that hosts the viewer) should never be included in events, it should only be part of the user profile (along with the rust version that's already there) i.e. update_metadata.

The viewer_started event then only keeps track of the app environment, while the open_recording event always keeps track of the python_version that corresponds to the machine doing the recording, never the host.
We can also put the rust version of the machine doing the recording in there, for consistency.

That way everything becomes consistent and relatively straightforward to reason about:

  • The python & rust versions seen in user profiles (update_metadata) are those of the host machine (the one hosting the viewer).
  • The python & rust versions seen in events correspond to the machine doing the recording.

I think this changes are trivial to add on top of everything you just did?
If we agree on that I'll just make another PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good!

Co-authored-by: Clement Rey <cr.rey.clement@gmail.com>
@emilk emilk merged commit 19d6c54 into main Feb 22, 2023
@emilk emilk deleted the emilk/more-analytics branch February 22, 2023 16:43
@emilk emilk added the 📊 analytics telemetry analytics label Feb 28, 2023
emilk added a commit that referenced this pull request Mar 2, 2023
* Fix analytics recording_source for Rust

We would always log `Python SDK` as the source

* New analytics event: data source

* Refactor: remove unused App::new

* new_recording -> open_recording

* Log `open_recording` event when opening files

* Store data_source as part of the LogDb and put it in the same avent

* Register what app environment we are running the viewer in

* Also register web viewer

* Add Python version

* More explicitly handle recording source in analytics

* compilation fix

* Fix web build

* Silence some clippy warnings on wasm builds

* rerun_cli

Co-authored-by: Clement Rey <cr.rey.clement@gmail.com>

---------

Co-authored-by: Clement Rey <cr.rey.clement@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📊 analytics telemetry analytics 🧑‍💻 dev experience developer experience (excluding CI) 🦀 Rust API Rust logging API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants