-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Refactor MPUserAttributeChange to Swift (#317)
* refactor: Refactor MPUserAttributeChange to Swift * Simplify logic on Zoom pairing session with Brandon --------- Co-authored-by: Ben Baron <[email protected]>
- Loading branch information
1 parent
07c96ca
commit 488c9e3
Showing
9 changed files
with
59 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@class MPSideloadedKit; | ||
@class MPKitContainer; | ||
|
||
/** | ||
An SDK session. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// MPUserAttributeChange.swift | ||
// mParticle-Apple-SDK | ||
// | ||
// Created by Brandon Stalnaker on 12/9/24. | ||
// | ||
|
||
import Foundation | ||
|
||
@objc public class MPUserAttributeChange : NSObject { | ||
|
||
@objc public var key: String | ||
@objc public var timestamp: Date? | ||
@objc public var userAttributes: [String : Any]? | ||
@objc public var value: Any? | ||
@objc public var valueToLog: Any? | ||
@objc public private(set) var changed: Bool | ||
@objc public var deleted: Bool | ||
@objc public var isArray: Bool | ||
|
||
@objc public init?(userAttributes: [String : Any]? = nil, key: String, value: Any?) { | ||
guard value == nil || value is [Any] || value is NSNull || value is String || value is NSNumber else { | ||
return nil | ||
} | ||
|
||
if userAttributes == nil && value == nil { | ||
return nil | ||
} | ||
|
||
self.key = key | ||
self.value = value | ||
self.deleted = false | ||
self.valueToLog = value | ||
self.userAttributes = userAttributes | ||
|
||
let existingValue = userAttributes?[key] | ||
self.isArray = (value is [Any] || existingValue is [Any]) | ||
self.changed = !equals(existingValue, value) | ||
super.init() | ||
} | ||
} | ||
|
||
fileprivate func equals(_ x : Any?, _ y : Any?) -> Bool { | ||
guard let x = x as? AnyHashable, let y = y as? AnyHashable else { | ||
return false | ||
} | ||
return x == y | ||
} |