Skip to content

Commit

Permalink
Merge pull request #425 from argenisf/master
Browse files Browse the repository at this point in the history
Remove alias check
  • Loading branch information
zihejia authored Jan 14, 2021
2 parents ce99d8c + c8f326d commit 69ef638
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
46 changes: 22 additions & 24 deletions Sources/MixpanelInstance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -767,35 +767,33 @@ extension MixpanelInstance {
self.hadPersistedDistinctId = true
}

// identify only changes the distinct id if it doesn't match either the existing or the alias;
// if it's new, blow away the alias as well.
if distinctId != self.alias {
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 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)
}
} else {
self.people.distinctId = nil
}
} else {
self.people.distinctId = nil
}

self.archiveProperties()
Persistence.storeIdentity(token: self.apiToken,
distinctID: self.distinctId,
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 69ef638

Please sign in to comment.