Repository navigation
feat(sweetlink): optional capture sinks (s3/http/module) - #46
Merged
Merged
Conversation
Fan every capture artifact (screenshot, metrics, console logs, a11y
report) out to remote storage in addition to the local disk save,
configured with SWEETLINK_CAPTURE_SINKS (JSON array of sink configs).
Built-in sink types:
- s3: any S3-compatible service (AWS S3, Cloudflare R2, MinIO,
Spaces) via a zero-dependency SigV4 PUT; endpoint + {bucket}
placeholder supported, region 'auto' for R2
- http: POST raw bytes + capture headers to a webhook URL; parses
{"url"} / Location for a permanent link
- module: dynamic import() of a user module exporting sink.upload(),
so any backend (Google Drive, Dropbox, internal CDN) is a ~10-line
file
Sinks are best-effort fan-out: local saving is untouched, a failing
sink logs and never blocks the browser response, and one malformed
config never disables the others. Signature verified against the AWS
SigV4 test-suite vector; 20 new tests.
Enables durable Devbar/Sweetlink captures on factory preview
workspaces when paired with an http sink pointed at the workspace
drain host (DEV-14160).
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Adds an opt-in, pluggable capture-sink system to the Sweetlink daemon. Every capture artifact the screenshot handler saves locally (screenshot JPG, metrics JSON, console logs text+JSON, a11y report) can now also be fanned out to remote storage.
Configuration
Env var
SWEETLINK_CAPTURE_SINKS— a JSON array:[ {"type":"s3","bucket":"captures","prefix":"devbar", "endpoint":"https://<account>.r2.cloudflarestorage.com","region":"auto", "accessKeyId":"...","secretAccessKey":"..."}, {"type":"http","url":"https://example.com/hook","headers":{"authorization":"Bearer ..."}}, {"type":"module","path":"./my-gdrive-sink.mjs"} ]Sink types
s3— any S3-compatible service (AWS S3, Cloudflare R2, MinIO, DigitalOcean Spaces) via a zero-dependency SigV4 PUT — no new package dependencies.endpointfor non-AWS services;{bucket}placeholder for virtual-hosted endpoints;region: "auto"for R2.http— POST raw bytes withx-capture-filename/x-capture-kindheaders to any webhook (generic receivers, Google Apps Script → Drive, the Factory workspace drain host); surfaces a permanent link from a{"url"}body orLocationheader.module— dynamicimport()of a user module exportingsink.upload(artifact)— the "whatever else" escape hatch (real Google Drive OAuth sink, Dropbox, internal CDN, …) in ~10 lines.Semantics
Sinks are best-effort fan-out: the local disk save is unchanged and remains the source of truth; sink failures log (
[Sweetlink] Capture sink "x" failed…) and never block or fail the browser response; one malformed config never disables the others.Validation
{bucket}endpoint URL construction, live local HTTP server round-trip, module sinks incl. default export, dispatcher failure isolation).tsc --noEmitclean; the only full-suite failures reproduce on a clean tree (load-related flakes in playground/auto tests); all touched-area suites pass.Downstream
Enables the DEV-14160 slice "Devbar capture persistence": a factory workspace sets
SWEETLINK_CAPTURE_SINKSwith anhttpsink pointed at the workspace drain host — captures taken on a wip preview become durable instead of landing on the container's ephemeral disk.