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

chore: update track public apis #421

Merged
merged 2 commits into from
Dec 6, 2023
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
25 changes: 7 additions & 18 deletions Sources/Common/CustomerIOInstance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ public protocol CustomerIOInstance: AutoMockable {

// sourcery:Name=identifyEncodable
// sourcery:DuplicateMethod=identify
func identify<RequestBody: Encodable>(
func identify<RequestBody: Codable>(
identifier: String,
// TODO: update AnyEncodable to AnyCodable?
// sourcery:Type=AnyEncodable
// sourcery:TypeCast="AnyEncodable(body)"
body: RequestBody
Expand All @@ -30,7 +31,7 @@ public protocol CustomerIOInstance: AutoMockable {

// sourcery:Name=trackEncodable
// sourcery:DuplicateMethod=track
func track<RequestBody: Encodable>(
func track<RequestBody: Codable>(
name: String,
// sourcery:Type=AnyEncodable
// sourcery:TypeCast="AnyEncodable(data)"
Expand All @@ -44,7 +45,7 @@ public protocol CustomerIOInstance: AutoMockable {

// sourcery:Name=screenEncodable
// sourcery:DuplicateMethod=screen
func screen<RequestBody: Encodable>(
func screen<RequestBody: Codable>(
name: String,
// sourcery:Type=AnyEncodable
// sourcery:TypeCast="AnyEncodable(data)"
Expand Down Expand Up @@ -223,7 +224,7 @@ public class CustomerIO: CustomerIOInstance {
[Learn more](https://customer.io/docs/api/#operation/identify)
- body: Request body of identifying profile. Use to define user attributes.
*/
public func identify<RequestBody: Encodable>(
public func identify<RequestBody: Codable>(
identifier: String,
body: RequestBody
) {
Expand Down Expand Up @@ -256,7 +257,7 @@ public class CustomerIO: CustomerIOInstance {
- name: Name of the event you want to track.
- data: Optional event body data
*/
public func track<RequestBody: Encodable>(
public func track<RequestBody: Codable>(
name: String,
data: RequestBody?
) {
Expand All @@ -280,7 +281,7 @@ public class CustomerIO: CustomerIOInstance {
- name: Name of the currently active screen
- data: Optional event body data
*/
public func screen<RequestBody: Encodable>(
public func screen<RequestBody: Codable>(
name: String,
data: RequestBody
) {
Expand All @@ -294,18 +295,6 @@ public class CustomerIO: CustomerIOInstance {
guard let logger = diGraph?.logger else {
return
}
automaticScreenView(name: name, data: StringAnyEncodable(logger: logger, data))
}

// Designed to be called from swizzled methods for automatic screen tracking.
// Because swizzled functions are not able to determine what siteId instance of
// the SDK the app is using, we simply call `screen()` on all siteIds of the SDK
// and if automatic screen view tracking is not setup for that siteId, the function
// call to the instance will simply be ignored.
func automaticScreenView<RequestBody: Encodable>(
name: String,
data: RequestBody
) {
implementation?.screen(name: name, data: data)
}

Expand Down
Loading
Loading