Skip to content

Commit

Permalink
Code Formatting fix and Encoding fix
Browse files Browse the repository at this point in the history
Fixing formatting for code refactor within the identify call in MixpanelInstance

Adding line to URL encode the + sign
  • Loading branch information
argenisf committed Jan 12, 2021
1 parent fbe8753 commit c8f326d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
42 changes: 21 additions & 21 deletions Sources/MixpanelInstance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -768,31 +768,31 @@ extension MixpanelInstance {
}


if distinctId != self.distinctId {
let oldDistinctId = self.distinctId
self.alias = nil
self.distinctId = distinctId
self.userId = distinctId
self.track(event: "$identify", properties: ["$anon_distinct_id": oldDistinctId])
}
if distinctId != self.distinctId {
let oldDistinctId = self.distinctId
self.alias = nil
self.distinctId = distinctId
self.userId = distinctId
self.track(event: "$identify", properties: ["$anon_distinct_id": oldDistinctId])
}

if usePeople {
self.people.distinctId = distinctId
if !self.people.unidentifiedQueue.isEmpty {
self.readWriteLock.write {
for var r in self.people.unidentifiedQueue {
r["$distinct_id"] = self.distinctId
self.people.peopleQueue.append(r)
}
self.people.unidentifiedQueue.removeAll()
}
self.readWriteLock.read {
Persistence.archivePeople(self.people.peopleQueue, token: self.apiToken)
if usePeople {
self.people.distinctId = distinctId
if !self.people.unidentifiedQueue.isEmpty {
self.readWriteLock.write {
for var r in self.people.unidentifiedQueue {
r["$distinct_id"] = self.distinctId
self.people.peopleQueue.append(r)
}
self.people.unidentifiedQueue.removeAll()
}
self.readWriteLock.read {
Persistence.archivePeople(self.people.peopleQueue, token: self.apiToken)
}
} else {
self.people.distinctId = nil
}
} else {
self.people.distinctId = nil
}

self.archiveProperties()
Persistence.storeIdentity(token: self.apiToken,
Expand Down
2 changes: 2 additions & 0 deletions Sources/Network.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ struct BasePath {
}
components.path = path
components.queryItems = queryItems
//adding workaround to replece + for %2B as it's not done by default within URLComponents
components.percentEncodedQuery = components.percentEncodedQuery?.replacingOccurrences(of: "+", with: "%2B")
return components.url
}

Expand Down

0 comments on commit c8f326d

Please sign in to comment.