(opts?: { createIfMissing?: boolean })
| 123 | } |
| 124 | |
| 125 | export async function getTelemetryStatus(opts?: { createIfMissing?: boolean }) { |
| 126 | const disabledBy = getDisabledByEnvironment() |
| 127 | const { config, configPath } = await readOrCreateTelemetryConfig( |
| 128 | opts?.createIfMissing ?? !disabledBy, |
| 129 | ) |
| 130 | |
| 131 | if (!config) { |
| 132 | return { |
| 133 | configPath, |
| 134 | disabledBy, |
| 135 | distinctId: undefined, |
| 136 | enabled: false, |
| 137 | noticeVersion: 0, |
| 138 | } satisfies TelemetryStatus |
| 139 | } |
| 140 | |
| 141 | if (disabledBy) { |
| 142 | return { |
| 143 | configPath, |
| 144 | disabledBy, |
| 145 | distinctId: config.distinctId, |
| 146 | enabled: false, |
| 147 | noticeVersion: config.noticeVersion, |
| 148 | } satisfies TelemetryStatus |
| 149 | } |
| 150 | |
| 151 | if (!config.enabled) { |
| 152 | return { |
| 153 | configPath, |
| 154 | disabledBy: 'config', |
| 155 | distinctId: config.distinctId, |
| 156 | enabled: false, |
| 157 | noticeVersion: config.noticeVersion, |
| 158 | } satisfies TelemetryStatus |
| 159 | } |
| 160 | |
| 161 | return { |
| 162 | configPath, |
| 163 | distinctId: config.distinctId, |
| 164 | enabled: true, |
| 165 | noticeVersion: config.noticeVersion, |
| 166 | } satisfies TelemetryStatus |
| 167 | } |
| 168 | |
| 169 | export async function markTelemetryNoticeSeen() { |
| 170 | const { config, configPath } = await readOrCreateTelemetryConfig(true) |
no test coverage detected