( entry: Record<string, unknown>, filePath: string = getUpdateRolloutLogFile(), )
| 168 | * reset once it grows past a small cap so it cannot grow unbounded. |
| 169 | */ |
| 170 | export async function appendRolloutDecisionLog( |
| 171 | entry: Record<string, unknown>, |
| 172 | filePath: string = getUpdateRolloutLogFile(), |
| 173 | ): Promise<void> { |
| 174 | try { |
| 175 | await mkdir(dirname(filePath), { recursive: true }); |
| 176 | const line = `${JSON.stringify(entry)}\n`; |
| 177 | const size = await stat(filePath).then((s) => s.size, () => 0); |
| 178 | if (size > ROLLOUT_LOG_MAX_BYTES) { |
| 179 | await writeFile(filePath, line, 'utf-8'); |
| 180 | return; |
| 181 | } |
| 182 | await appendFile(filePath, line, 'utf-8'); |
| 183 | } catch { |
| 184 | // Diagnostic logging must never affect the update flow. |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Stable per-installation id used for bucketing when telemetry has already |
no test coverage detected