-
Notifications
You must be signed in to change notification settings - Fork 226
Report telemetry on actions taken in the UI #1953
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
bdfb2f2
Add method to loging telemetry of a UI interaction
robertbrignull f325eeb
Output telemetry on react state changes in MRVA results view
robertbrignull 34e98c4
Convert useStateWithTelemetry to use useMemo
robertbrignull f1a8564
Output telemetry when clicking links
robertbrignull 0aa2cd6
Make Telemetry.ts lowercase
robertbrignull 25a3ba7
Extract on-click handlers to consts
robertbrignull e9830ee
Add telemetry message to remote queries view
robertbrignull 98a29d2
Convert useStateWithTelemetry to useTelemetryOnChange
robertbrignull 47f63f6
Implement debounce for telemetry events
robertbrignull 2453038
Merge branch 'main' into robertbrignull/telemetry_ui
robertbrignull 18ddb3a
Use isCanary() method
robertbrignull 38cbb95
Avoid === true on a boolean
robertbrignull 293ec1f
Add debounce to variant-analysis-selected-repository-ids
robertbrignull 44a0cad
Make useTelemetryOnChange signature simpler
robertbrignull 3777eb3
Make isCanary a string
robertbrignull File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import { useEffect, useMemo, useRef } from "react"; | ||
| import { vscode } from "../vscode-api"; | ||
|
|
||
| /** | ||
| * A react effect that outputs telemetry events whenever the value changes. | ||
| * | ||
| * @param value Default value to pass to React.useState | ||
| * @param telemetryAction Name of the telemetry event to output | ||
| * @param options Extra optional arguments, including: | ||
| * filterTelemetryOnValue: If provided, only output telemetry events when the | ||
| * predicate returns true. If not provided always outputs telemetry. | ||
| * debounceTimeout: If provided, will not output telemetry events for every change | ||
| * but will wait until specified timeout happens with no new events ocurring. | ||
| */ | ||
| export function useTelemetryOnChange<S>( | ||
| value: S, | ||
| telemetryAction: string, | ||
| { | ||
| filterTelemetryOnValue, | ||
| debounceTimeoutMillis, | ||
| }: { | ||
| filterTelemetryOnValue?: (value: S) => boolean; | ||
| debounceTimeoutMillis?: number; | ||
| } = {}, | ||
| ) { | ||
| const previousValue = useRef(value); | ||
|
|
||
| const sendTelemetryFunc = useMemo<() => void>(() => { | ||
|
aeisenberg marked this conversation as resolved.
|
||
| if (debounceTimeoutMillis === undefined) { | ||
| return () => sendTelemetry(telemetryAction); | ||
| } else { | ||
| let timer: NodeJS.Timeout; | ||
| return () => { | ||
| clearTimeout(timer); | ||
| timer = setTimeout(() => { | ||
| sendTelemetry(telemetryAction); | ||
| }, debounceTimeoutMillis); | ||
| }; | ||
| } | ||
| }, [telemetryAction, debounceTimeoutMillis]); | ||
|
|
||
| useEffect(() => { | ||
| if (value === previousValue.current) { | ||
| return; | ||
| } | ||
| previousValue.current = value; | ||
|
|
||
| if (filterTelemetryOnValue && !filterTelemetryOnValue(value)) { | ||
| return; | ||
| } | ||
|
|
||
| sendTelemetryFunc(); | ||
| }, [sendTelemetryFunc, filterTelemetryOnValue, value, previousValue]); | ||
| } | ||
|
|
||
| export function sendTelemetry(telemetryAction: string) { | ||
| vscode.postMessage({ | ||
| t: "telemetry", | ||
| action: telemetryAction, | ||
| }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.