Skip to content

Commit

Permalink
Merge pull request #910 from snowplow/release/6.0.9
Browse files Browse the repository at this point in the history
Release/6.0.9
  • Loading branch information
matus-tomlein authored Nov 20, 2024
2 parents bf14959 + be5f6c3 commit c105d9f
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 6.0.9 (2024-11-21)
--------------------------
Handle nan values and other non-serializable data in events from the WebView tracker (#909)

Version 6.0.8 (2024-08-19)
--------------------------
Fix media tracking calls not being dispatched on the correct queue when tracking using AVPlayer
Expand Down
2 changes: 1 addition & 1 deletion Examples
2 changes: 1 addition & 1 deletion SnowplowTracker.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SnowplowTracker"
s.version = "6.0.8"
s.version = "6.0.9"
s.summary = "Snowplow event tracker for iOS, macOS, tvOS, watchOS for apps and games."
s.description = <<-DESC
Snowplow is a mobile and event analytics platform with a difference: rather than tell our users how they should analyze their data, we deliver their event-level data in their own data warehouse, on their own Amazon Redshift or Postgres database, so they can analyze it any way they choose. Snowplow mobile is used by data-savvy games companies and app developers to better understand their users and how they engage with their games and applications. Snowplow is open source using the business-friendly Apache License, Version 2.0 and scales horizontally to many billions of events.
Expand Down
5 changes: 5 additions & 0 deletions Sources/Core/Tracker/WebViewMessageHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ class WebViewMessageHandler: NSObject, WKScriptMessageHandler {
let context = body["context"] as? [[AnyHashable : Any]] ?? []
let trackers = body["trackers"] as? [String] ?? []

if !JSONSerialization.isValidJSONObject(event) || !JSONSerialization.isValidJSONObject(context) {
logError(message: "WebView: Received event payload is not serializable to JSON, skipping.")
return
}

if command == "trackSelfDescribingEvent" {
trackSelfDescribing(event, withContext: context, andTrackers: trackers)
} else if command == "trackStructEvent" {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/TrackerConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import Foundation

// --- Version
let kSPRawVersion = "6.0.8"
let kSPRawVersion = "6.0.9"
#if os(iOS)
let kSPVersion = "ios-\(kSPRawVersion)"
#elseif os(tvOS)
Expand Down
36 changes: 36 additions & 0 deletions Tests/TestWebViewMessageHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,41 @@ class TestWebViewMessageHandler: XCTestCase {
let context = payload?["co"] as? String
XCTAssert(context?.contains("{\"a\":\"b\"}") ?? false)
}

func testHandlesNonJSONSerializableDataInEvent() {
let message = MockWKScriptMessage(
body: [
"command": "trackSelfDescribingEvent",
"event": [
"schema": "http://schema.com",
"data": [
"key": Double.nan
]
]
])
webViewMessageHandler?.receivedMesssage(message) // shouldn't crash
}

func testHandlesNonJSONSerializableDataInContext() {
let message = MockWKScriptMessage(
body: [
"command": "trackSelfDescribingEvent",
"event": [
"schema": "http://schema.com",
"data": [
"key": "val"
]
],
"context": [
[
"schema": "http://context-schema.com",
"data": [
"a": Double.nan
]
]
]
])
webViewMessageHandler?.receivedMesssage(message) // shouldn't crash
}
}
#endif

0 comments on commit c105d9f

Please sign in to comment.