Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning for the serialization of data in self-describing event and entity #898

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading