D8LooPFocus modeCODE WORKSPACE
Normalize raw event records into a clean list of analytics-ready dictionaries with stable field names and validation handling.
Separate normalization from validation so the main flow stays readable during discussion.
Sample input
raw event records
Mixed-quality event payloads from an analytics ingestion job.
[
{
"user_id": 42,
"session_id": "s-100",
"event_name": "page_view",
"event_ts": "2026-03-20T09:00:00Z"
},
{
"user_id": 42,
"session_id": "s-100",
"event_name": "add_to_cart",
"event_ts": "2026-03-20T09:04:00Z"
},
{
"user_id": 77,
"session_id": "s-301",
"event_name": "checkout_start",
"event_ts": "bad_timestamp"
}
]Expected output
expected return shape
Keep normalized records and validation issues separate.
{
"normalized": [
{
"user_id": 42,
"session_id": "s-100",
"event_name": "add_to_cart",
"event_ts": "2026-03-20T09:04:00Z"
}
],
"errors": [
{
"row_index": 2,
"reason": "malformed timestamp"
}
]
}Constraints
Malformed timestamps should be captured in an error summary. Preserve only the newest event per user-session pair.
Expected skills
Parsing, validation, edge-case handling, and writing transformation logic that is easy to review.
Run the transform to inspect normalized rows and error summaries.