Skip to content

test: verify PostHog timestamps use UTC - #21

Merged
marandaneto merged 2 commits into
mainfrom
fix/normalize-utc-timestamps
Aug 14, 2026
Merged

test: verify PostHog timestamps use UTC#21
marandaneto merged 2 commits into
mainfrom
fix/normalize-utc-timestamps

Conversation

@marandaneto

@marandaneto marandaneto commented Aug 14, 2026

Copy link
Copy Markdown
Member

Problem

The plugin relies on posthog-node to add timestamps when it sends events. We did not have regression coverage proving that these timestamps stay in UTC when OpenCode runs in a non-UTC timezone.

Changes

This adds an integration test that runs the plugin with TZ=America/Los_Angeles and freezes the clock at July 1, 2024 at 12:34:56.789 local time. The test sends an assistant message and a completed generation through the real plugin path, captures the compressed request with a local HTTP server, and verifies both sent_at and the $ai_generation timestamp are exactly 2024-07-01T19:34:56.789Z.

How did you test this code?

This change was prepared by an agent. I ran these automated checks:

  • pnpm test - 48 tests passed across 4 test files.
  • pnpm lint - oxlint and oxfmt checks passed.
  • pnpm typecheck - TypeScript type checking passed.

Checklist

  • Tests for new code (if applicable)
  • Accounted for backwards compatibility of any changes (no breaking changes!)

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

A Pi implementation agent prepared the test from a human-directed request. The test uses the real posthog-node request path rather than mocking timestamp generation so it covers the serialized payload that PostHog receives. Pi autoreview checked the committed branch against origin/main and reported no actionable findings.

@marandaneto marandaneto self-assigned this Aug 14, 2026
@marandaneto
marandaneto marked this pull request as ready for review August 14, 2026 09:12
@marandaneto
marandaneto requested a review from a team as a code owner August 14, 2026 09:12

@arnohillen arnohillen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(created by claude code)

[arno's agent] Verified at 27b5451: test-only, drives the real plugin path through a local HTTP server and asserts the gzip batch carries the canonical UTC instant.

@arnohillen

Copy link
Copy Markdown

(created by claude code)

[arno's agent] The PR body still mentions a changeset, but 27b5451 removed it and the diff is now test-only, so that sentence is stale.

@marandaneto

Copy link
Copy Markdown
Member Author

Fixed — I removed the stale changeset references from the PR description now that the diff is test-only. Thanks for catching that!

@marandaneto
marandaneto merged commit 0da95a7 into main Aug 14, 2026
11 checks passed
@marandaneto
marandaneto deleted the fix/normalize-utc-timestamps branch August 14, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants