-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add telemetry config management with related UI dialog and settings #6028
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
14 commits
Select commit
Hold shift + click to select a range
bef0fab
add telemetry config management with related UI dialog and settings
zanesq 93e8aff
merge in upstream + main
zanesq 5ba9eba
add section to onboarding and show modal for more info if on onboardi…
zanesq ab0bd23
fix not being able to clear modal selector
zanesq 08e1ab5
style to match onboarding page
zanesq 8ddc039
share more between settings panels
zanesq 482c3f9
remove unused inline variant
zanesq df9999e
change to isWelcome boolean
zanesq 4daa69d
remove comments
zanesq 6270dee
fix some types and comments
zanesq 8f17805
change optional props be explicit
zanesq d245075
remove telemetry route and use existing config system
zanesq 22c1fea
change to use read and upsert
zanesq bad50bb
add toast for failed telemetry status
zanesq 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| import { useState, useEffect } from 'react'; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this file could do with a quick look over on comments |
||
| import { BaseModal } from './ui/BaseModal'; | ||
| import { Button } from './ui/button'; | ||
| import { Goose } from './icons/Goose'; | ||
| import { TELEMETRY_UI_ENABLED } from '../updates'; | ||
| import { toastService } from '../toasts'; | ||
| import { useConfig } from './ConfigContext'; | ||
|
|
||
| const TELEMETRY_CONFIG_KEY = 'GOOSE_TELEMETRY_ENABLED'; | ||
|
|
||
| type TelemetryOptOutModalProps = | ||
| | { controlled: false } | ||
| | { controlled: true; isOpen: boolean; onClose: () => void }; | ||
|
|
||
| export default function TelemetryOptOutModal(props: TelemetryOptOutModalProps) { | ||
| const { read, upsert } = useConfig(); | ||
| const isControlled = props.controlled; | ||
| const controlledIsOpen = isControlled ? props.isOpen : undefined; | ||
| const onClose = isControlled ? props.onClose : undefined; | ||
| const [showModal, setShowModal] = useState(false); | ||
| const [isLoading, setIsLoading] = useState(false); | ||
|
|
||
| // Only check telemetry choice on first launch in uncontrolled mode | ||
| useEffect(() => { | ||
| if (isControlled) return; | ||
|
|
||
| const checkTelemetryChoice = async () => { | ||
| try { | ||
| const provider = await read('GOOSE_PROVIDER', false); | ||
|
|
||
| if (!provider || provider === '') { | ||
| return; | ||
| } | ||
|
|
||
| const telemetryEnabled = await read(TELEMETRY_CONFIG_KEY, false); | ||
|
|
||
| if (telemetryEnabled === null) { | ||
| setShowModal(true); | ||
| } | ||
| } catch (error) { | ||
| console.error('Failed to check telemetry config:', error); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. eh let's not drop errors on the floor |
||
| toastService.error({ | ||
| title: 'Configuration Error', | ||
| msg: 'Failed to check telemetry configuration.', | ||
| traceback: error instanceof Error ? error.stack || '' : '', | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| checkTelemetryChoice(); | ||
| }, [isControlled, read]); | ||
|
|
||
| const handleChoice = async (enabled: boolean) => { | ||
| setIsLoading(true); | ||
| try { | ||
| await upsert(TELEMETRY_CONFIG_KEY, enabled, false); | ||
| setShowModal(false); | ||
| onClose?.(); | ||
| } catch (error) { | ||
| console.error('Failed to set telemetry preference:', error); | ||
| setShowModal(false); | ||
| onClose?.(); | ||
| } finally { | ||
| setIsLoading(false); | ||
| } | ||
| }; | ||
|
|
||
| if (!TELEMETRY_UI_ENABLED) { | ||
| return null; | ||
| } | ||
|
|
||
| const isModalOpen = controlledIsOpen !== undefined ? controlledIsOpen : showModal; | ||
|
|
||
| if (!isModalOpen) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <BaseModal | ||
| isOpen={isModalOpen} | ||
| actions={ | ||
| <div className="flex flex-col gap-2 pb-3 px-3"> | ||
| <Button | ||
| variant="default" | ||
| onClick={() => handleChoice(true)} | ||
| disabled={isLoading} | ||
| className="w-full h-[44px] rounded-lg" | ||
| > | ||
| Yes, share anonymous usage data | ||
| </Button> | ||
| <Button | ||
| variant="ghost" | ||
| onClick={() => handleChoice(false)} | ||
| disabled={isLoading} | ||
| className="w-full h-[44px] rounded-lg text-text-muted hover:text-text-default" | ||
| > | ||
| No thanks | ||
| </Button> | ||
| </div> | ||
| } | ||
| > | ||
| <div className="px-2 py-3"> | ||
| <div className="flex justify-center mb-4"> | ||
| <Goose className="size-10 text-text-default" /> | ||
| </div> | ||
| <h2 className="text-2xl font-regular dark:text-white text-gray-900 text-center mb-3"> | ||
| Help improve goose | ||
| </h2> | ||
| <p className="text-text-default text-sm mb-3"> | ||
| Would you like to help improve goose by sharing anonymous usage data? This helps us | ||
| understand how goose is used and identify areas for improvement. | ||
| </p> | ||
| <div className="text-text-muted text-xs space-y-1"> | ||
| <p className="font-medium text-text-default">What we collect:</p> | ||
| <ul className="list-disc list-inside space-y-0.5 ml-1"> | ||
| <li>Operating system and architecture</li> | ||
| <li>goose version</li> | ||
| <li>Provider and model used</li> | ||
| <li>Number of extensions enabled</li> | ||
| <li>Session count and token usage (aggregated)</li> | ||
| </ul> | ||
| <p className="mt-3 text-text-muted"> | ||
| We never collect your conversations, code, or any personal data. You can change this | ||
| setting anytime in Settings → App. | ||
| </p> | ||
| </div> | ||
| </div> | ||
| </BaseModal> | ||
| ); | ||
| } | ||
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
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.
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.
to be honest, I don't think you need any of this. our config already reads environment variables and you can already read the config from the client. so no need for a special handler here or routes I would think
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.
ah thanks I didn't realize it did all that, will look into refactoring quickly 👍