Skip to content

docs: add apple doc for track() apis #319

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

Merged
merged 1 commit into from
Apr 2, 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
21 changes: 13 additions & 8 deletions Sources/Segment/Events.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ extension Analytics {
// and they need to write a middleware/enrichment now.
// the objc version should accomodate them if it's really needed.

/// Tracks an event performed by a user, including some additional event properties.
/// - Parameters:
/// - name: Name of the action, e.g., 'Purchased a T-Shirt'
/// - properties: Properties specific to the named event. For example, an event with
/// the name 'Purchased a Shirt' might have properties like revenue or size.
public func track<P: Codable>(name: String, properties: P?) {
do {
if let properties = properties {
Expand All @@ -29,6 +34,9 @@ extension Analytics {
}
}

/// Tracks an event performed by a user.
/// - Parameters:
/// - name: Name of the action, e.g., 'Purchased a T-Shirt'
public func track(name: String) {
track(name: name, properties: nil as TrackEvent?)
}
Expand Down Expand Up @@ -133,15 +141,12 @@ extension Analytics {
// MARK: - Untyped Event Signatures

extension Analytics {
/// Associate a user with their unique ID and record traits about them.
/// Tracks an event performed by a user, including some additional event properties.
/// - Parameters:
/// - userId: A database ID for this user. If you don't have a userId
/// but want to record traits, just pass traits into the event and they will be associated
/// with the anonymousId of that user. In the case when user logs out, make sure to
/// call ``reset()`` to clear the user's identity info. For more information on how we
/// generate the UUID and Apple's policies on IDs, see
/// https://segment.io/libraries/ios#ids
/// - properties: A dictionary of traits you know about the user. Things like: email, name, plan, etc.
/// - name: Name of the action, e.g., 'Purchased a T-Shirt'
/// - properties: A dictionary or properties specific to the named event.
/// For example, an event with the name 'Purchased a Shirt' might have properties
/// like revenue or size.
public func track(name: String, properties: [String: Any]? = nil) {
var props: JSON? = nil
if let properties = properties {
Expand Down