Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion Sources/Segment/Plugins/Context.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class Context: PlatformPlugin {

internal var staticContext = staticContextData()
internal static var device = VendorSystem.current
internal let instanceId = UUID().uuidString

public func execute<T: RawEvent>(event: T?) -> T? {
guard var workingEvent = event else { return event }
Expand All @@ -21,6 +22,9 @@ public class Context: PlatformPlugin {

insertDynamicPlatformContextData(context: &context)

// add instanceId to the context
context["instanceId"] = instanceId

// if this event came in with context data already
// let it take precedence over our values.
if let eventContext = workingEvent.context?.dictionaryValue {
Expand All @@ -42,7 +46,7 @@ public class Context: PlatformPlugin {
// library name
staticContext["library"] = [
"name": "analytics-swift",
"version": __segment_version
"version": __segment_version,
]

// app info
Expand Down
1 change: 0 additions & 1 deletion Sources/Segment/Utilities/HTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ extension HTTPClient {
var request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: 60)
request.httpMethod = method
request.addValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")
request.addValue("Basic \(apiKey)", forHTTPHeaderField: "Authorization")
request.addValue("analytics-ios/\(Analytics.version())", forHTTPHeaderField: "User-Agent")
request.addValue("gzip", forHTTPHeaderField: "Accept-Encoding")

Expand Down