Skip to content

Commit 72415f4

Browse files
docs: add apple doc for track apis (#319)
Apple docs were missing from two of the track() APIs, and for another, had been copy-pasted from identify() without being updated. This updates it with something simple and functional.
1 parent 7eeb2ab commit 72415f4

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

Sources/Segment/Events.swift

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ extension Analytics {
1414
// and they need to write a middleware/enrichment now.
1515
// the objc version should accomodate them if it's really needed.
1616

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

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

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

0 commit comments

Comments
 (0)