Skip to content

Commit 0f44a29

Browse files
feat: [ENG-3035] rename user-facing analytics setting key analytics.enabled to analytics.share (#746)
The key name now reflects what it controls: local analytics tracking is always on (regardless of auth or this setting); the flag only gates whether collected events are shared with the remote telemetry backend. - Rename the user-facing key value analytics.enabled -> analytics.share across settings set/get/list, the onboarding opt-in script, and the disclosure command reference. Hard rename (no alias) — the feature is unreleased. - Behavior unchanged: tracking stays always-on locally; the flag still gates only remote sharing. - Internals kept (value-only rename): GlobalConfig.analytics field, the globalConfig:setAnalytics transport event, in-process method names, and the key-constant identifier names.
1 parent 5364e7d commit 0f44a29

27 files changed

Lines changed: 87 additions & 87 deletions

File tree

src/oclif/commands/settings/set.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ export default class SettingsSet extends Command {
4444
options: ['text', 'json'],
4545
}),
4646
// Accepts the analytics disclosure non-interactively. Only meaningful when
47-
// setting `analytics.enabled true` (the one consent-gated key). Passing it
47+
// setting `analytics.share true` (the one consent-gated key). Passing it
4848
// for any other key emits `this.warn(...)` so the user does not silently
4949
// rely on a flag that has no behavioural effect for their command.
5050
yes: Flags.boolean({
5151
char: 'y',
5252
default: false,
53-
description: 'Accept the analytics disclosure non-interactively (only meaningful for analytics.enabled)',
53+
description: 'Accept the analytics disclosure non-interactively (only meaningful for analytics.share)',
5454
}),
5555
}
5656

@@ -120,7 +120,7 @@ export default class SettingsSet extends Command {
120120
return
121121
}
122122

123-
// Enable-to-true on `analytics.enabled` triggers the disclosure
123+
// Enable-to-true on `analytics.share` triggers the disclosure
124124
// prompt. Idempotent (no prompt if already enabled), false-unchanged,
125125
// and other keys unaffected. `collectConsent`'s `onError` calls
126126
// `this.error()` which throws CLIError; we let it propagate to

src/oclif/lib/analytics-disclosure.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface CollectConsentDeps {
6161
* 4. Otherwise, prompt and return the user's choice.
6262
*
6363
* Extracted from the legacy `brv analytics enable` command in M16.2 so
64-
* `brv settings set analytics.enabled true` can reuse the exact same
64+
* `brv settings set analytics.share true` can reuse the exact same
6565
* consent gate. M16.4 then deleted the legacy command; this lib is now
6666
* the sole consent surface.
6767
*/

src/server/core/interfaces/analytics/i-analytics-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type {AnalyticsBatch} from '../../domain/analytics/batch.js'
1818
export interface IAnalyticsClient {
1919
/**
2020
* Cancel any in-flight `flush()`'s HTTP request. M4.4: invoked by
21-
* `GlobalConfigHandler` when `brv settings set analytics.enabled false` flips the flag
21+
* `GlobalConfigHandler` when `brv settings set analytics.share false` flips the flag
2222
* so the daemon doesn't half-ship a batch across an enable/disable
2323
* boundary. No-op when no flush is in flight.
2424
*/

src/server/core/interfaces/analytics/i-analytics-http-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export type AnalyticsHttpSendResult =
6363
*/
6464
/**
6565
* Optional per-call controls. `signal` is the M4.4 cancellation hook
66-
* used by `brv settings set analytics.enabled false` (and by the daemon shutdown path) to
66+
* used by `brv settings set analytics.share false` (and by the daemon shutdown path) to
6767
* abort an in-flight send so the daemon doesn't half-ship a batch
6868
* across an enable/disable boundary.
6969
*/

src/server/infra/analytics/analytics-client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class AnalyticsClient implements IAnalyticsClient {
128128
* which classifies aborted requests as `network` failures — JSONL
129129
* records stay `pending` (so they ship on the next enabled flush).
130130
*
131-
* Called from `GlobalConfigHandler` when `brv settings set analytics.enabled false`
131+
* Called from `GlobalConfigHandler` when `brv settings set analytics.share false`
132132
* flips the flag, so the daemon doesn't half-ship a batch across an
133133
* enable/disable boundary. No-op when no flush is in flight.
134134
*/
@@ -156,7 +156,7 @@ export class AnalyticsClient implements IAnalyticsClient {
156156
* `flush()` is a thin caller — it does not inspect attempts.
157157
*/
158158
public async flush(): Promise<AnalyticsBatch> {
159-
// M4.4: `brv settings set analytics.enabled false` semantically means "stop shipping to
159+
// M4.4: `brv settings set analytics.share false` semantically means "stop shipping to
160160
// remote" — local tracking (JSONL + queue) continues unconditionally.
161161
// Gate here, NOT in `track()`. Records stay at `status='pending'` in
162162
// JSONL; the next flush after re-enable picks them up automatically.
@@ -378,7 +378,7 @@ export class AnalyticsClient implements IAnalyticsClient {
378378

379379
await this.deps.jsonlStore.updateStatus(result.succeeded, 'sent')
380380
// M4.4 N3 fix: when we cancelled the send ourselves (`abort()` fired
381-
// because `brv settings set analytics.enabled false` flipped the flag), DO NOT mark the
381+
// because `brv settings set analytics.share false` flipped the flag), DO NOT mark the
382382
// failed records as 'failed' — that bumps the M9.2 retry-cap
383383
// `attempts` counter on every cancel, and a few disable/enable
384384
// toggles during shipping could terminate records as `'failed'`

src/server/infra/analytics/analytics-flush-scheduler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface AnalyticsFlushSchedulerDeps {
1010
flush: () => Promise<unknown>
1111
/**
1212
* Lazy analytics-enabled gate. Re-checked on every trigger so a runtime
13-
* `brv settings set analytics.enabled false` (M1.4) immediately suspends scheduled flushes
13+
* `brv settings set analytics.share false` (M1.4) immediately suspends scheduled flushes
1414
* without restarting the daemon.
1515
*/
1616
isEnabled: () => boolean

src/server/infra/analytics/http-analytics-sender.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class HttpAnalyticsSender implements IAnalyticsSender {
8080
...(sessionKey !== undefined && sessionKey !== '' ? {sessionId: sessionKey} : {}),
8181
userAgent: this.deps.userAgent,
8282
},
83-
// M4.4: forward the cancellation signal so `brv settings set analytics.enabled false`
83+
// M4.4: forward the cancellation signal so `brv settings set analytics.share false`
8484
// (or shutdown) can abort an in-flight POST. The http client
8585
// classifies aborted requests as `network`, which maps here to
8686
// an all-failed result — same as any other transport failure.

src/server/infra/process/feature-handlers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ export async function setupFeatureHandlers({
277277
// M4.4: close the global-config-handler ↔ analyticsClient cycle.
278278
// The handler was constructed earlier (so its sync cache was
279279
// populated before the client read it); now that the client
280-
// exists, register it so `brv settings set analytics.enabled false` can call
280+
// exists, register it so `brv settings set analytics.share false` can call
281281
// `abort()` to cancel any in-flight HTTP.
282282
globalConfigHandler.setAnalyticsClient(analyticsClient)
283283

@@ -302,7 +302,7 @@ export async function setupFeatureHandlers({
302302
}
303303
new SettingsHandler({
304304
analyticsClient,
305-
// Route `analytics.enabled` GET/SET/RESET/LIST through the
305+
// Route `analytics.share` GET/SET/RESET/LIST through the
306306
// global-config handler so the canonical storage in config.json, the
307307
// device-id seeding race fix, the analytics cache, and the
308308
// abort-on-disable side-effect all stay unchanged.

src/server/infra/transport/handlers/global-config-handler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {processLog} from '../../../utils/process-logger.js'
1919
export interface GlobalConfigHandlerDeps {
2020
/**
2121
* M4.4: optional analytics client used to cancel any in-flight HTTP
22-
* send when `brv settings set analytics.enabled false` flips the flag.
22+
* send when `brv settings set analytics.share false` flips the flag.
2323
* Disable does NOT drop the queue or clear JSONL — those stay so a
2424
* future re-enable ships the backlog. Optional for back-compat with
2525
* test harnesses that don't construct a real analytics client.
@@ -93,7 +93,7 @@ export class GlobalConfigHandler implements IGlobalConfigRotator {
9393

9494
/**
9595
* Public async read of the persisted analytics flag. Surfaced for
96-
* the SettingsHandler facade so `brv settings get analytics.enabled`
96+
* the SettingsHandler facade so `brv settings get analytics.share`
9797
* resolves through the SAME `globalConfigStore.read()` path that
9898
* `globalConfig:get` uses. Returns the on-disk value (or `false`
9999
* when no config file exists).
@@ -162,7 +162,7 @@ export class GlobalConfigHandler implements IGlobalConfigRotator {
162162

163163
/**
164164
* Public write of the analytics flag. Surfaced for the SettingsHandler
165-
* facade so `brv settings set analytics.enabled <value>` goes through
165+
* facade so `brv settings set analytics.share <value>` goes through
166166
* the SAME write path as `globalConfig:setAnalytics` — concurrent-safe
167167
* via `writeChain`, refreshes the cache, emits `analytics_disabled`,
168168
* triggers the abort-on-disable on the analytics client.

src/server/infra/transport/handlers/settings-handler.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export type ReadonlyInfoSnapshot = boolean | number | Readonly<Record<string, un
4646
export type ReadonlyInfoProvider = () => Promise<ReadonlyInfoSnapshot> | ReadonlyInfoSnapshot
4747

4848
/**
49-
* Facade over `GlobalConfigHandler` for the `analytics.enabled` setting.
49+
* Facade over `GlobalConfigHandler` for the `analytics.share` setting.
5050
* The settings handler routes GET/SET/RESET/LIST for that key through
5151
* this facade instead of `FileSettingsStore`, so the canonical storage
5252
* in `config.json`, the device-id seeding race fix, the sync analytics
@@ -63,8 +63,8 @@ export interface AnalyticsEnabledFacade {
6363
export interface SettingsHandlerDeps {
6464
readonly analyticsClient?: IAnalyticsClient
6565
/**
66-
* Facade for the `analytics.enabled` writable key. When set,
67-
* GET/SET/RESET/LIST for `analytics.enabled` route through this facade
66+
* Facade for the `analytics.share` writable key. When set,
67+
* GET/SET/RESET/LIST for `analytics.share` route through this facade
6868
* instead of the file store. When unset, the key surfaces with
6969
* `current: undefined`.
7070
*/
@@ -187,7 +187,7 @@ export class SettingsHandler {
187187
return {error: readOnlyError(data.key), ok: false}
188188
}
189189

190-
// Global-config writables (analytics.enabled and any future ones)
190+
// Global-config writables (analytics.share and any future ones)
191191
// route through the injected facade. The file store stays
192192
// untouched. Type check still applies (boolean for the only
193193
// current case), so reuse `checkValueType` before delegating.
@@ -299,7 +299,7 @@ export class SettingsHandler {
299299
}
300300

301301
// Reset on a global-config writable means "back to descriptor.default".
302-
// For analytics.enabled the default is `false`, so we flip via the facade.
302+
// For analytics.share the default is `false`, so we flip via the facade.
303303
if (descriptor?.storage === 'global-config') {
304304
if (this.globalConfigHandler === undefined) {
305305
return {
@@ -414,7 +414,7 @@ export class SettingsHandler {
414414
}
415415

416416
if (descriptor.storage === 'global-config') {
417-
// Global-config-stored values (analytics.enabled) live in
417+
// Global-config-stored values (analytics.share) live in
418418
// config.json, not settings.json. Without an injected facade we
419419
// cannot resolve — surface `undefined` so the row still renders
420420
// rather than crashing.

0 commit comments

Comments
 (0)