Skip to content

Commit

Permalink
Add warning for the serialization of data in self-describing event an…
Browse files Browse the repository at this point in the history
…d entity
  • Loading branch information
matus-tomlein committed Jun 27, 2024
1 parent 50e7912 commit 47be2bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Sources/Snowplow/Events/SelfDescribing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@ public class SelfDescribing: SelfDescribingAbstract {
self.init(schema: eventData.schema, payload: eventData.data)
}

/// Creates a self-describing event using data represented as an Encodable struct.
/// NOTE: The data should be serializable to JSON using the JSONSerialization class in Foundation. An exception will be thrown if the data is not serializable. To make sure your data is serializable, you can use the `JSONSerialization.isValidJSONObject` function.
/// - Parameters:
/// - schema: A valid schema URI.
/// - payload: Payload for the event.
/// - Returns: A SelfDescribing event.
@objc
public init(schema: String, payload: [String : Any]) {
self._schema = schema
self._payload = payload
}

/// Creates a self-describing event using data represented as an Encodable struct.
/// NOTE: The data should be serializable to JSON using the JSONSerialization class in Foundation. An exception will be thrown if the data is not serializable. To make sure your data is serializable, you can use the `JSONSerialization.isValidJSONObject` function.
/// - Parameters:
/// - schema: A valid schema URI.
/// - data: Data represented using an Encodable struct.
Expand Down
5 changes: 5 additions & 0 deletions Sources/Snowplow/Payload/SelfDescribingJson.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class SelfDescribingJson: NSObject {
}

/// Initializes a newly allocated SPSelfDescribingJson.
/// NOTE: The data should be serializable to JSON using the JSONSerialization class in Foundation. An exception will be thrown if the data is not serializable. To make sure your data is serializable, you can use the `JSONSerialization.isValidJSONObject` function.
/// - Parameters:
/// - schema: A valid schema string.
/// - data: Data to set for data field of the self-describing JSON, should be an NSDictionary.
Expand All @@ -54,6 +55,7 @@ public class SelfDescribingJson: NSObject {
}

/// Initializes a newly allocated SPSelfDescribingJson.
/// NOTE: The data should be serializable to JSON using the JSONSerialization class in Foundation. An exception will be thrown if the data is not serializable. To make sure your data is serializable, you can use the `JSONSerialization.isValidJSONObject` function.
/// - Parameters:
/// - schema: A valid schema string.
/// - data: Dictionary to set for data field of the self-describing JSON.
Expand All @@ -64,6 +66,7 @@ public class SelfDescribingJson: NSObject {
}

/// Initializes a newly allocated SPSelfDescribingJson.
/// NOTE: The payload should be serializable to JSON using the JSONSerialization class in Foundation. An exception will be thrown if the data is not serializable. To make sure your data is serializable, you can use the `JSONSerialization.isValidJSONObject` function.
/// - Parameters:
/// - schema: A valid schema string.
/// - data: Payload to set for data field of the self-describing JSON.
Expand All @@ -74,6 +77,7 @@ public class SelfDescribingJson: NSObject {
}

/// Initializes a newly allocated SPSelfDescribingJson.
/// NOTE: The data should be serializable to JSON using the JSONSerialization class in Foundation. An exception will be thrown if the data is not serializable. To make sure your data is serializable, you can use the `JSONSerialization.isValidJSONObject` function.
/// - Parameters:
/// - schema: A valid schema URI.
/// - data: Self-describing JSON to set for data field of the self-describing JSON.
Expand Down Expand Up @@ -104,6 +108,7 @@ public class SelfDescribingJson: NSObject {
}

/// Sets the data field of the self-describing JSON.
/// NOTE: The data should be serializable to JSON using the JSONSerialization class in Foundation. An exception will be thrown if the data is not serializable. To make sure your data is serializable, you can use the `JSONSerialization.isValidJSONObject` function.
/// - Parameter data: A self-describing JSON to be nested into the data.
@objc
public func setData(withSelfDescribingJson data: SelfDescribingJson) {
Expand Down

0 comments on commit 47be2bd

Please sign in to comment.