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

feat: add telemetry to companion #1117

Merged
merged 32 commits into from
Jan 27, 2023

Conversation

SgtPooki
Copy link
Member

@SgtPooki SgtPooki commented Dec 16, 2022

Things implemented:

  • View tracking of companion pages
  • Session tracking (powering down the extension ends your session and stops tracking sessions)
  • consent management: disabling telemetry (opting-out) prevents the above two things from happening, but we do send an event indicating that you've opted-out

Things to do

image

@SgtPooki SgtPooki linked an issue Dec 16, 2022 that may be closed by this pull request
4 tasks
@SgtPooki
Copy link
Member Author

@juliaxbow I would love your opinion on the formatting of the telemetry section

@juliaxbow
Copy link

Descriptions

  • Telemetry section In the description, would say "To assist in our efforts, please consent to the collection of these metrics by toggling "on" in the corresponding section. You can change this setting at any time by navigating back to the Companion Preferences page." It's a little unusual to offer consent via a toggle but I think it's ok?
  • Is the toggle default to on? If so, we should change the wording even further. Something like "IPFS Companion is collecting minimal telemetry data to improve and prioritize our work. You may opt out of the collection of these metrics by toggling "off" in the corresponding section below. You can change this setting ......"
  • Metrics Section the metric collection description, I would change wording to "Sends ‘session’ and ‘view’ events only when ipfs-companion is enabled and your browser is not idle." Current wording raises the question of who is sending this information where?
  • The section header "minimal metrics: ..." makes it seem like there are additional, more intrusive metrics somewhere. Until we have other metrics we're tracking I think we can just call it "Session & Companion views." The Telemetry description already points to the fact that these are minimal.

Other

  • "Read More" links on the page have a link-out icon, so would add that in. (in the screenshot below i have the same link blue because I think all link-out icons should look like links but keep consistent with the rest of the page for now ;) )
  • The toggle is centered but it doesn't look like it is. Until we have more sections & metrics that we're tracking, I would move it up to be top-aligned with the first sentence in the description. I know this is inconsistent with all other toggles on the page but to me it's more clear what the user is agreeing to. This is subjective, though, so feel free to ignore.

Incl screenshot to show the suggested toggle alignment
Screen Shot 2022-12-16 at 8 07 57 PM

Copy link
Contributor

@whizzzkid whizzzkid left a comment

Choose a reason for hiding this comment

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

LGTM in principle, a few nits, I need to validate this locally though.

add-on/src/lib/telemetry.js Outdated Show resolved Hide resolved
}

/**
* @param {ReturnType<import('./state').initState>['options']} state
Copy link
Contributor

Choose a reason for hiding this comment

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

can we import types form the declaration from the lib?

add-on/src/lib/telemetry.js Outdated Show resolved Hide resolved
add-on/src/lib/telemetry.js Outdated Show resolved Hide resolved
@@ -0,0 +1,60 @@

import { MetricsProvider } from '@ipfs-shipyard/ignite-metrics/vanilla'
Copy link
Contributor

@whizzzkid whizzzkid Dec 17, 2022

Choose a reason for hiding this comment

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

@ipfs-shipyard/ignite-metrics/vanilla

This needs to be mapped correctly, this breaks the build.

Copy link
Member Author

Choose a reason for hiding this comment

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

This should be working properly with latest release of ignite-metrics

Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

Looks sensible, as long we address below:

  1. We should not be sending requests to Countly every minute a user uses a browser.
    (I assume that is what is happening? I was unable to build this and test locally)
    • This causes many issues, for example drains laptop battery by waking up WIFI when no internet conneciton would be needed otherwise.
    • As discussed, figure a way to batch things so we report them only once an hour or once a day.
  2. Regular people don't know what 'session' and 'view' means.
    • See my suggestions below on humanizing the language :)

add-on/_locales/en/messages.json Outdated Show resolved Hide resolved
add-on/_locales/en/messages.json Outdated Show resolved Hide resolved
add-on/_locales/en/messages.json Outdated Show resolved Hide resolved
add-on/_locales/en/messages.json Outdated Show resolved Hide resolved
add-on/src/lib/options.js Outdated Show resolved Hide resolved
add-on/src/lib/telemetry.js Outdated Show resolved Hide resolved
@SgtPooki SgtPooki changed the title [WIP] feat: add telemetry to companion feat: add telemetry to companion Jan 18, 2023
@SgtPooki SgtPooki marked this pull request as ready for review January 18, 2023 17:40
@SgtPooki SgtPooki requested review from meandavejustice and a team as code owners January 18, 2023 17:40
* use latest ignite-metrics library
* don't use singleton function for grabbing metricsProvider
* ensure metrics initialize and update properly
@SgtPooki
Copy link
Member Author

FYI @lidel @whizzzkid I had some changes locally that weren't pushed up... getting those up now

* Telemetry messages are passed between contexts using browser.runtime
* Upgraded to @ipfs-shipyard/ignite-metrics@1.3.0
* Updated consent handling from state to be more explicit
Copy link
Contributor

@whizzzkid whizzzkid left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

}
}

function onTelemetryMessage (request, sender) {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏽

@@ -556,6 +559,7 @@ export default async function init () {
await registerSubdomainProxy(getState, runtime)
shouldRestartIpfsClient = true
shouldStopIpfsClient = !state.active
state.active ? startSession() : endSession()
Copy link
Contributor

Choose a reason for hiding this comment

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

for now this should be ok, in the future we might wanna have a message being broadcast and such listeners can subscribe to those.

Comment on lines +106 to +112
${telemetryForm({
telemetryGroupMinimal: state.options.telemetryGroupMinimal,
telemetryGroupMarketing: state.options.telemetryGroupMarketing,
telemetryGroupPerformance: state.options.telemetryGroupPerformance,
telemetryGroupTracking: state.options.telemetryGroupTracking,
onOptionChange
})}
Copy link
Contributor

Choose a reason for hiding this comment

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

@SgtPooki was this updated?

"emitDeclarationOnly": true,
"declaration": true,
"moduleResolution": "nodenext",
"noImplicitAny": false
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding tsconfig.json and we can fix this when we have a better handle of things.

@whizzzkid
Copy link
Contributor

@lidel I think the default flush interval is good enough for now, we can revisit this later if needed.

figure a way to batch things so we report them only once an hour or once a day.

for now I think we can merge this and release as is.

@SgtPooki
Copy link
Member Author

Agreed with @whizzzkid. Metrics are only sent (currently) when interacting with the extension (enabling/disabling, viewing different pages), so battery use should not be a concern.

@SgtPooki SgtPooki merged commit 42eed02 into main Jan 27, 2023
@SgtPooki SgtPooki deleted the 1115-feat-getting-basic-metrics-in-ipfs-companion branch January 27, 2023 21:03
whizzzkid added a commit that referenced this pull request Jan 31, 2023
* main:
  feat: add telemetry to companion (#1117)
  chore: update PRIVACY-POLICY.md (#1137)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Feat: getting basic metrics in ipfs-companion
4 participants