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

remove initializer for setting identifiers in events #134

Merged
merged 3 commits into from
Jan 10, 2024
Merged
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
14 changes: 14 additions & 0 deletions Sources/KlaviyoSwift/KlaviyoModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public struct Event: Equatable {
public let uniqueId: String
public let identifiers: Identifiers?

@available(*, deprecated, renamed: "init(name:properties:value:uniqueId:)", message: "This initializer has been deprecated. Profile properties should be set prior to logging events.")
public init(name: EventName,
properties: [String: Any]? = nil,
identifiers: Identifiers? = nil,
Expand All @@ -87,6 +88,19 @@ public struct Event: Equatable {
self.uniqueId = uniqueId ?? environment.analytics.uuid().uuidString
self.identifiers = identifiers
}

public init(name: EventName,
properties: [String: Any]? = nil,
value: Double? = nil,
uniqueId: String? = nil) {
metric = .init(name: name)
_profile = AnyCodable([:])
_properties = AnyCodable(properties ?? [:])
identifiers = nil
self.value = value
time = environment.analytics.date()
Comment on lines +99 to +101
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be self.identifiers and self.time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I'm totally following but you don't have to use self if it's clear what you are setting. I think I have a swiftlint rule that will remove this but I can try setting it.

self.uniqueId = uniqueId ?? environment.analytics.uuid().uuidString
}
}

public struct Profile: Equatable {
Expand Down
Loading