Skip to content

Commit

Permalink
Merge pull request #154 from superwall-me/develop
Browse files Browse the repository at this point in the history
v3.2.1
  • Loading branch information
yusuftor authored Jul 20, 2023
2 parents 819fab5 + d9b13b4 commit be8b0bf
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

The changelog for `SuperwallKit`. Also see the [releases](https://github.com/superwall-me/Superwall-iOS/releases) on GitHub.

## 3.2.1

### Fixes

- Fixes `user_attributes` being fired on every app launch when it wasn't necessary.

## 3.2.0

### Enhancements
Expand Down
58 changes: 46 additions & 12 deletions Sources/SuperwallKit/Identity/IdentityManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,29 @@ class IdentityManager {
self.storage = storage
self.configManager = configManager
self._appUserId = storage.get(AppUserId.self)
self._aliasId = storage.get(AliasId.self) ?? IdentityLogic.generateAlias()
self._seed = storage.get(Seed.self) ?? IdentityLogic.generateSeed()

var extraAttributes: [String: Any] = [:]

if let aliasId = storage.get(AliasId.self) {
self._aliasId = aliasId
} else {
self._aliasId = IdentityLogic.generateAlias()
storage.save(_aliasId, forType: AliasId.self)
extraAttributes["aliasId"] = self._aliasId
}

if let seed = storage.get(Seed.self) {
self._seed = seed
} else {
self._seed = IdentityLogic.generateSeed()
storage.save(_seed, forType: Seed.self)
extraAttributes["seed"] = self._seed
}
self._userAttributes = storage.get(UserAttributes.self) ?? [:]

if !extraAttributes.isEmpty {
mergeUserAttributes(extraAttributes, shouldTrackMerge: false)
}
}

/// Checks for static config upgrade before setting identity.
Expand All @@ -127,7 +147,7 @@ class IdentityManager {
) {
try? await configManager.getAssignments()
}
saveIds()

group.leave()

didSetIdentity()
Expand Down Expand Up @@ -219,6 +239,7 @@ class IdentityManager {
storage.save(appUserId, forType: AppUserId.self)
}

// Save incase these have also changed.
storage.save(_aliasId, forType: AliasId.self)
storage.save(_seed, forType: Seed.self)

Expand Down Expand Up @@ -269,26 +290,39 @@ extension IdentityManager {
// MARK: - User Attributes
extension IdentityManager {
/// Merges the attributes on an async queue
func mergeUserAttributes(_ newUserAttributes: [String: Any?]) {
func mergeUserAttributes(
_ newUserAttributes: [String: Any?],
shouldTrackMerge: Bool = true
) {
queue.async { [weak self] in
self?._mergeUserAttributes(newUserAttributes)
self?._mergeUserAttributes(
newUserAttributes,
shouldTrackMerge: shouldTrackMerge
)
}
}

/// Merges the provided user attributes with existing attributes then saves them.
private func _mergeUserAttributes(_ newUserAttributes: [String: Any?]) {
///
/// - Parameter shouldTrackMerge: A boolean indicated whether the merge should be tracked in analytics.
private func _mergeUserAttributes(
_ newUserAttributes: [String: Any?],
shouldTrackMerge: Bool = true
) {
let mergedAttributes = IdentityLogic.mergeAttributes(
newUserAttributes,
with: _userAttributes,
appInstalledAtString: deviceHelper.appInstalledAtString
)

Task {
let trackableEvent = InternalSuperwallEvent.Attributes(
appInstalledAtString: deviceHelper.appInstalledAtString,
customParameters: mergedAttributes
)
await Superwall.shared.track(trackableEvent)
if shouldTrackMerge {
Task {
let trackableEvent = InternalSuperwallEvent.Attributes(
appInstalledAtString: deviceHelper.appInstalledAtString,
customParameters: mergedAttributes
)
await Superwall.shared.track(trackableEvent)
}
}

storage.save(mergedAttributes, forType: UserAttributes.self)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SuperwallKit/Misc/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ let sdkVersion = """
*/

let sdkVersion = """
3.2.0
3.2.1
"""
2 changes: 1 addition & 1 deletion SuperwallKit.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "SuperwallKit"
s.version = "3.2.0"
s.version = "3.2.1"
s.summary = "Superwall: In-App Paywalls Made Easy"
s.description = "Paywall infrastructure for mobile apps :) we make things like editing your paywall and running price tests as easy as clicking a few buttons. superwall.com"

Expand Down
6 changes: 5 additions & 1 deletion SuperwallKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
2BEA0C3FED992CB3BBD2F5CC /* SK1StoreProductDiscount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C064AE76E6545B9595305D7 /* SK1StoreProductDiscount.swift */; };
2C1CC812D17087B1CE54161A /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = F98F66F7AA2F9F3E96849D8A /* Config.swift */; };
2C7867867DDAD83E5856ECC9 /* ASN1Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8087A8CD8F4FC7C745010428 /* ASN1Types.swift */; };
2CC98A7FC5577F9B8B0C9AD2 /* Error+SafeLocalizedDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A7FFEA64AF7F4E09F052FCD /* Error+SafeLocalizedDescription.swift */; };
2D751F5C2F463DEEF0A49B42 /* PaywallCloseReason.swift in Sources */ = {isa = PBXBuildFile; fileRef = C36308E59620C724F701B803 /* PaywallCloseReason.swift */; };
2EBE499C9918DE5823659CD0 /* InAppReceiptPayload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 072886BB8C0E08DF414D9162 /* InAppReceiptPayload.swift */; };
2EC1D279019CD3FB64E4674A /* TriggerResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25515131DF0AE67E26BFF462 /* TriggerResult.swift */; };
Expand Down Expand Up @@ -643,6 +644,7 @@
98D3CEEDCBBDB85C54FDC128 /* PresentPaywall.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresentPaywall.swift; sourceTree = "<group>"; };
990461F7A9B2F3ED62B3A628 /* PaywallViewControllerDelegateAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaywallViewControllerDelegateAdapter.swift; sourceTree = "<group>"; };
991415992A1EA3C9E6DB7D25 /* TriggerSessionTrigger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TriggerSessionTrigger.swift; sourceTree = "<group>"; };
9A7FFEA64AF7F4E09F052FCD /* Error+SafeLocalizedDescription.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Error+SafeLocalizedDescription.swift"; sourceTree = "<group>"; };
9B75209DF76859131941CA0F /* Variables.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Variables.swift; sourceTree = "<group>"; };
9C2580C3CD6A8BF0C5258665 /* SWWebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SWWebView.swift; sourceTree = "<group>"; };
9DC4D23D1EDDA249C928930D /* PaddingListener.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaddingListener.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1127,6 +1129,7 @@
51407421A3CBF7AF0FC76E60 /* Bundle+Helpers.swift */,
A9A3C997FDC1550AF477CA1D /* Decimal+Rounding.swift */,
B2E6016BF483A4C47FF7A7C0 /* Encodable+Dictionary.swift */,
9A7FFEA64AF7F4E09F052FCD /* Error+SafeLocalizedDescription.swift */,
8DE36D141F461F6E945823FA /* Future+Async.swift */,
E2243C6BF6BE477794F568ED /* GCControllerElement+buttonName.swift */,
FD778E66506BA51BEB5EE89C /* JSONEncoder+Superwall.swift */,
Expand Down Expand Up @@ -2215,7 +2218,7 @@
path = Assignment;
sourceTree = "<group>";
};
"TEMP_89BC623C-3735-4CC4-AA1A-3C36C0A6D055" /* Events */ = {
"TEMP_ECE821B9-9409-4D69-BD4B-9789D2EF963D" /* Events */ = {
isa = PBXGroup;
children = (
);
Expand Down Expand Up @@ -2454,6 +2457,7 @@
9EAE577E60052F5E1C7B9657 /* EmptyResponse.swift in Sources */,
CB1E11FB74879A29DD1C9EB1 /* Encodable+Dictionary.swift in Sources */,
11477D1EB60D1FDA32F5099A /* Endpoint.swift in Sources */,
2CC98A7FC5577F9B8B0C9AD2 /* Error+SafeLocalizedDescription.swift in Sources */,
B2842C329F0F9AAFC2040C35 /* EvaluateRules.swift in Sources */,
35597883CB038DBEE63E162B /* EventData.swift in Sources */,
211B94C3D7CEE3DEF10E5C79 /* EventsQueue.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
shouldUseLaunchSchemeArgsEnv = "NO">
<Testables>
<TestableReference
skipped = "NO">
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AE77960D397D727A12230C60"
Expand Down
3 changes: 2 additions & 1 deletion project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ targets:
SuperwallKit:
scheme:
testTargets:
- SuperwallKitTests
- name: SuperwallKitTests
parallelizable: true
commandLineArguments:
SUPERWALL_UNIT_TESTS: true
settings:
Expand Down

0 comments on commit be8b0bf

Please sign in to comment.