Skip to content

Remove redundant code #87

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
Oct 27, 2021
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
65 changes: 0 additions & 65 deletions Sources/Segment/Types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -257,71 +257,6 @@ extension RawEvent {
}
}

/**
Set values to be received for this event in cloud-mode, specific to an integration key path.
Note that when specifying nil as the value, the key will be removed for the given key path. Additionally,
any keys that don't already exist in the path will be created as necessary.

Example:
```
trackEvent.setIntegrationValue(42, forKeyPath: "Amplitude.threshold")
```

- Parameters:
- value: The value to set for the given keyPath, or nil.
- forKeyPath: The key path for the value.
*/
public mutating func setIntegrationValue(_ value: Any?, forKeyPath keyPath: String) {
guard let existing = integrations?.dictionaryValue else {
// this shouldn't happen, might oughta log it.
Analytics.segmentLog(message: "Unable to get what should be a valid list of integrations from event.", kind: .error)
return
}

var new = existing
new[keyPath: KeyPath(keyPath)] = value
do {
integrations = try JSON(new)
} catch {
// this shouldn't happen, log it.
Analytics.segmentLog(message: "Unable to convert list of integrations to JSON. \(error)", kind: .error)
}
}

/**
Set context values for this event.
Note that when specifying nil as the value, the key will be removed for the given key path. Additionally,
any keys that don't already exist in the path will be created as necessary.

Example:
```
// the metadata key will be created as a dictionary, and the key nickname will be set.
trackEvent.setContextValue("Brandon's device", forKeyPath: "device.metadata.nickname")

// the metadata key will be removed entirely.
trackEvent.setContextValue(nil, forKeyPath: "device.metadata")
```

- Parameters:
- value: The value to set for the given keyPath, or nil.
- forKeyPath: The key path for the value.
*/
public mutating func setContextValue(_ value: Any?, forKeyPath keyPath: String) {
guard let existing = context?.dictionaryValue else {
// this shouldn't happen, might oughta log it.
Analytics.segmentLog(message: "Unable to get what should be a valid context from event.", kind: .error)
return
}

var new = existing
new[keyPath: KeyPath(keyPath)] = value
do {
context = try JSON(new)
} catch {
// this shouldn't happen, log it.
Analytics.segmentLog(message: "Unable to convert context to JSON. \(error)", kind: .error)
}
}
}


Expand Down