A cancelled save dialog and a browser handoff were both recorded as DOWNLOAD SUCCEEDED, so the cancel rate hid inside the handoff success rate. BrowserDataObservation.outcome gains DISMISSED (additive). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import type {
|
|
BrowserDataObservation,
|
|
BrowserDataObserver,
|
|
BrowserDataFailureCode,
|
|
BrowserDataOperation,
|
|
} from "../../application/ports/browser-file-storage/shared.ts";
|
|
import { observeBrowserData } from "../browser-file-storage/result.ts";
|
|
|
|
export { browserDataByteBucket as byteBucket } from "../../application/ports/browser-file-storage/shared.ts";
|
|
|
|
type BrowserFileObservation = Readonly<{
|
|
operation: BrowserDataOperation;
|
|
outcome: "SUCCESS" | "DISMISSED" | "FAILED";
|
|
failureCode?: BrowserDataFailureCode;
|
|
byteBucket?: BrowserDataObservation["byteBucket"];
|
|
}>;
|
|
|
|
/**
|
|
* File adapters use the platform BrowserDataObserver as the telemetry SSOT.
|
|
* The helper below is the sole mapper from file-local outcomes. A dismissal
|
|
* stays `DISMISSED` (02-06): folded into `SUCCEEDED` it hid the save-dialog
|
|
* cancel rate inside the browser handoff success rate.
|
|
*/
|
|
export type BrowserFileObserver = BrowserDataObserver;
|
|
|
|
export function observeBrowserFile(
|
|
observer: BrowserFileObserver | undefined,
|
|
observation: BrowserFileObservation,
|
|
): void {
|
|
observeBrowserData(
|
|
observer,
|
|
Object.freeze({
|
|
operation: observation.operation,
|
|
outcome:
|
|
observation.outcome === "SUCCESS" ? "SUCCEEDED" : observation.outcome,
|
|
...(observation.failureCode
|
|
? { failureCode: observation.failureCode }
|
|
: {}),
|
|
...(observation.byteBucket
|
|
? { byteBucket: observation.byteBucket }
|
|
: {}),
|
|
}),
|
|
);
|
|
}
|