v0.1.4: Scan and queue without an API key - #6
Merged
Merged
Conversation
…ance tests for offline scanning
SendHeartbeat checked the API key before InsertEvents, so an editor that started sending heartbeats before the user signed in dropped every event instead of queueing it. Insert first, then skip only the upload half when no key exists — the same rule Ingest/Upload already follow. cli.App.Sync returned an error without a key while agentlib.Client.Sync returned nil; both now skip the upload and succeed.
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.
Summary
Scanning and queueing are local work and no longer require an API key. The key
gates only the upload half, so a user who has not signed in yet keeps
accumulating history instead of losing it — and it uploads as soon as a key is
saved.
This matters for the Windows front-end consuming
pkg/agentlib: it can scan andrecord from first launch, before any sign-in flow completes.
Changes
cli.App.Ingestno longer requires a key;cli.App.Uploaddoes (3ec862f)agentlib.Client.Syncscans, then skips the upload when no key is configuredagentlib.Client.SendHeartbeatnow inserts the event before checking thekey — previously an editor sending heartbeats pre-sign-in dropped every one
cli.App.Syncandagentlib.Client.Synchad opposite behavior without a key(error vs nil); both now skip the upload and succeed
Testing
TestSendHeartbeatWithoutAPIKeyQueuesEventasserts the event is actually inthe queue, not merely that no error was returned — verified it fails against
the old ordering
TestSyncWithoutAPIKeyScansOffline,TestIngestWorksWithoutAPIKey,TestUploadRequiresAPIKeycover the splitgo vet ./...andgo test -race ./...pass