Repository navigation
feat: send one final telemetry_opted_out event when telemetry is disabled #1501
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
Open
ralphstodomingo
wants to merge
3
commits into
feat/telemetry-user-identity
Choose a base branch
from
feat/telemetry-opt-out-marker
base: feat/telemetry-user-identity
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+366
−1
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
46b678d
feat: send one final telemetry_opted_out event when telemetry is disa…
ralphstodomingo 15a75c4
fix: opt-out marker reads the machine id bounded and leaves telemetry…
ralphstodomingo c858470
fix: a stale opt-out send never posts or writes the marker after a sh…
ralphstodomingo 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import fs from "fs" | ||
| import path from "path" | ||
| import { Global } from "../../global" | ||
| import { readExistingMachineId } from "@/altimate/util/machine-id" | ||
|
|
||
| /** | ||
| * The marker that says this machine already sent its final ``telemetry_opted_out`` event. | ||
| * | ||
| * A machine that turns telemetry off goes silent, which on the dashboards looks exactly like a | ||
| * client that stopped emitting. So the last event an opted-out machine sends is the opt-out | ||
| * itself, once; the marker is what makes it once. It lives next to the machine id because both | ||
| * describe the machine, not the user, and it is removed when telemetry is turned back on so a | ||
| * later opt-out is recorded again. See ``recordOptOut`` in index.ts. | ||
| * | ||
| * Paths go through ``Global.Path.home`` so a test that sets ``OPENCODE_TEST_HOME`` never reads | ||
| * or writes the real home directory; in a real session that is the same directory the machine | ||
| * id lives in. | ||
| */ | ||
| export namespace OptOutMarker { | ||
| function dir(): string { | ||
| return path.join(Global.Path.home, ".altimate") | ||
| } | ||
|
|
||
| export function markerPath(): string { | ||
| return path.join(dir(), "telemetry-opted-out") | ||
| } | ||
|
|
||
| /** The machine id minted by an earlier telemetry-enabled run, if any. Never mints one: a machine | ||
| * that never sent telemetry has nothing to mark. Bounded and symlink-safe, like the minting read. */ | ||
| export function readMachineId(): string | undefined { | ||
| return readExistingMachineId(path.join(dir(), "machine-id")) || undefined | ||
| } | ||
|
|
||
| export function exists(): boolean { | ||
| return fs.existsSync(markerPath()) | ||
| } | ||
|
|
||
| export function write(): void { | ||
| fs.mkdirSync(dir(), { recursive: true }) | ||
| fs.writeFileSync(markerPath(), `${new Date().toISOString()}\n`, { mode: 0o600 }) | ||
| } | ||
|
|
||
| /** Best effort: an unremovable marker (read-only directory) must never fail an init. */ | ||
| export function clear(): void { | ||
| try { | ||
| fs.rmSync(markerPath(), { force: true }) | ||
| } catch { | ||
| // leave it; the next opt-out is then not recorded again, which is the lesser failure | ||
| } | ||
| } | ||
| } |
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.
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.