Repository navigation
feat(analytics): write game outcomes to S3 (TWG-8) - #31
Merged
Merged
Conversation
Implements OpenSpec change twg-8-s3-game-analytics. - add @aws-sdk/client-s3 runtime dependency - new analytics helper (writeAnalytics): builds the outcome record, derives the YYYY/MM/DD/<gameId>.json key, guards on ANALYTICS_BUCKET, and swallows S3 errors so the player path is never affected - play handler emits analytics on won/lost transitions in the twinge and next-round paths via an isTerminalPhase guard - CDK: per-region twinge-analytics-<stage> bucket with BLOCK_ALL public access, SSE-S3, 365-day expiry lifecycle, ANALYTICS_BUCKET env var, and least-privilege grantPut(playHandler) - unit tests for the helper (key format, schema, error swallow, env guard) and both handler paths (emit on won/lost, skip on playing) Tasks 1.1-6.1 complete; 6.2 deferred (needs live AWS deploy).
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
Captures every explicitly-terminated Twinge game as a JSON record in S3 for ad-hoc analysis with Athena.
Four outcome values:
won— deck exhausted (nextRound)lost— lives hit 0 (twinge)abandoned— last player left voluntarily (leaveGame)ended— host explicitly terminated (endGame)Infrastructure:
TwingeAnalyticsStack— single S3 bucket (twinge-analytics-prod) in eu-central-1, 365-day lifecyclegames/year=YYYY/month=MM/day=DD/<gameId>-<ts>.json) for Athena compatibilityKnown gap: Games that expire via DynamoDB TTL (all players disconnect without action) are not captured — accepted, would require DynamoDB Streams + 10 regional stream processors.
What was tested
Deployment order
TwingeAnalyticsStackto eu-central-1 first (creates bucket)TwingeServiceStackupdatesCloses TWG-8