Add hook timestamp to telemetry reporting#5
Open
rishiy15 wants to merge 1 commit into
Open
Conversation
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's Changed
Adds an optional
tsfield (Unix epoch milliseconds — when the hook actually fired) to both telemetry events the plugin emits. This lets the 1Password desktop app, which ingests these events asynchronously, attribute each event to the time it occurred rather than the time it happened to be drained.scripts/lib/telemetry.shts_json_fragmenthelper that emits,"ts":<epoch_ms>; wired intowrite_execution_eventandwrite_install_event.Why
Telemetry events are written to disk and picked up out-of-band by the 1Password app — which may be closed or locked when a hook runs, so a backlog can be drained minutes-to-days later. Without a producer-side timestamp, every drained event is dated to ingest time, which fabricates a usage spike on the drain day and leaves the real days empty. Stamping the hook-fire time at write lets the app bucket events correctly (it maps
tsonto the Snowplow device-created timestamp).Event shape
tsis appended to the existing JSON lines, e.g.:{"schema":"agent_hook_execution","hook_name":"1password-validate-mounted-env-files","hook_version":"1.1.0","client":"cursor","event_type":"before_shell_execution","decision":"allow","deny_reason":null,"duration_bucket":"ms_0_to_50","mode":null,"mount_count":null,"ts":1782429269433}Safety & compatibility
Testing Done