From f710d5dd931e2519c6bcff52ca81f8bb9fbc07c1 Mon Sep 17 00:00:00 2001 From: Piotr Limanowski Date: Wed, 26 Jun 2024 17:50:13 +0200 Subject: [PATCH 1/2] Do not decode iglu json webhook ue_pr paramter on coerce 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. --- .../event/recovery/utils/payload.scala | 20 ++++------- .../src/test/resources/expected_payloads.json | 35 ++++++++----------- 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/event/recovery/utils/payload.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/event/recovery/utils/payload.scala index adb0dce..d55f621 100644 --- a/core/src/main/scala/com/snowplowanalytics/snowplow/event/recovery/utils/payload.scala +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/event/recovery/utils/payload.scala @@ -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")) } diff --git a/core/src/test/resources/expected_payloads.json b/core/src/test/resources/expected_payloads.json index 881efde..5e0e942 100644 --- a/core/src/test/resources/expected_payloads.json +++ b/core/src/test/resources/expected_payloads.json @@ -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" + } ] From b1961c31afddeb08a5379a8cbb62434507961fa9 Mon Sep 17 00:00:00 2001 From: Piotr Limanowski Date: Wed, 26 Jun 2024 17:53:19 +0200 Subject: [PATCH 2/2] Prepare for 0.7.2 release --- CHANGELOG | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 8a6c17b..d84c631 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +Version 0.7.2 (2024-06-26) +-------------------------- +Do not decode iglu json webhook ue_pr paramter on coerce (close #144) + Version 0.7.1 (2024-06-18) -------------------------- Make NVP codec isomorphic (close #143)