Skip to content

Commit

Permalink
Do not decode iglu json webhook ue_pr paramter on coerce
Browse files Browse the repository at this point in the history
When attempting convering RawEvent into CollectorPayload we previously
were convering it through proper JSON decoder. But as this is already
manually modified through recovery process we can skip decoding and
instead simply pass the JSON.
Otherwise we'd need to alter RawEvent to contain `body` field which it
is missing. And we cannot.
  • Loading branch information
peel committed Jun 26, 2024
1 parent 38e7435 commit f710d5d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,13 @@ object payload {
cp
}
case e @ Payload.EnrichmentPayload(_, p) if p.vendor == "com.snowplowanalytics.iglu" =>
extractData(e)
.flatMap { case (schema, data) =>
data
.as[List[NVP]](json.nvpsDecoder)
.map(nvps => querystring.fromNVP(nvps :+ NVP("schema", Some(schema))))
.leftMap(err => UncoerciblePayload(e, err.toString))
}
.map { querystring =>
val cp = convert(p)
cp.querystring = querystring
cp
}

extractData(e).map { case (schema, data) =>
val cp = convert(p)
cp.body = data.noSpaces
cp.querystring = s"schema=$schema"
cp.contentType = "application/json"
cp
}
case Payload.EnrichmentPayload(_, p) => convert(p).asRight
case p => Left(UncocoerciblePayload(p.toString, "Unsupported request format"))
}
Expand Down
35 changes: 15 additions & 20 deletions core/src/test/resources/expected_payloads.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,24 +224,19 @@
"event_version": "2-0-0"
},
{
"platform": "app",
"etl_tstamp": "1970-01-18T08:40:00",
"collector_tstamp": "2024-02-02T12:51:38.534",
"event": "unstruct",
"v_tracker": "com.snowplowanalytics.iglu-v1",
"v_collector": "ssc-2.10.0-kinesis",
"user_ipaddress": "34.76.244.217",
"network_userid": "ccbd375d-e37f-4919-811c-780f460a3ed4",
"page_url": "https://www.lorem.com/Ipsum-dolor-sit-AMET",
"page_urlscheme": "https",
"page_urlhost": "www.lorem.com",
"page_urlport": 443,
"page_urlpath": "/Ipsum-dolor-sit-AMET",
"useragent": "python-requests/2.31.0",
"derived_tstamp": "2024-02-02T12:51:38.534",
"event_vendor": "com.snowplowanalytics.iglu",
"event_name": "anything-a",
"event_format": "jsonschema",
"event_version": "1-0-0"
}
"platform" : "app",
"etl_tstamp" : "1970-01-18T08:40:00",
"collector_tstamp" : "2024-02-02T12:51:38.534",
"event" : "unstruct",
"v_tracker" : "com.snowplowanalytics.iglu-v1",
"v_collector" : "ssc-2.10.0-kinesis",
"user_ipaddress" : "34.76.244.217",
"network_userid" : "ccbd375d-e37f-4919-811c-780f460a3ed4",
"useragent" : "python-requests/2.31.0",
"derived_tstamp" : "2024-02-02T12:51:38.534",
"event_vendor" : "com.snowplowanalytics.iglu",
"event_name" : "anything-a",
"event_format" : "jsonschema",
"event_version" : "1-0-0"
}
]

0 comments on commit f710d5d

Please sign in to comment.