Skip to content
Merged
Changes from all commits
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
21 changes: 14 additions & 7 deletions mParticle-Rokt-Swift/MPRoktLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public class MPRoktLayout {
config: RoktConfig? = nil,
onEvent: ((RoktEvent) -> Void)? = nil
) {
MPLog.debug("Initializing MPRoktLayout with arguments:", sdkTriggered.wrappedValue, viewName ?? "nil", locationName, attributes)
MPRoktLayout.mpLog("Initializing MPRoktLayout with arguments sdkTriggered:\(sdkTriggered.wrappedValue), viewName:\(viewName ?? "nil"), locationName:\(locationName), attributes:\(attributes)")
confirmUser(attributes: attributes) { identifyCalled in
let preparedAttributes = MPKitRokt.prepareAttributes(attributes, filteredUser: Optional<FilteredMParticleUser>.none, performMapping: true)

MPLog.debug("Initializing RoktLayout with arguments:", sdkTriggered.wrappedValue, viewName ?? "nil", locationName, preparedAttributes)
MPRoktLayout.mpLog("Initializing RoktLayout with arguments sdkTriggered:\(sdkTriggered.wrappedValue), viewName: \(viewName ?? "nil"), locationName:\(locationName), attributes:\(preparedAttributes)")
self.roktLayout = RoktLayout.init(
sdkTriggered: sdkTriggered,
viewName: viewName,
Expand All @@ -44,7 +44,7 @@ public class MPRoktLayout {
)
// The Binding variable provided by the client allows us to trigger a re-render of the UI but we only want to do this if the value was true to start
if identifyCalled && sdkTriggered.wrappedValue {
MPLog.debug("Triggering Rokt Swift UI re-render")
MPRoktLayout.mpLog("Triggering Rokt Swift UI re-render")
DispatchQueue.main.async {
sdkTriggered.wrappedValue = false
sdkTriggered.wrappedValue = true
Expand Down Expand Up @@ -86,10 +86,10 @@ public class MPRoktLayout {
if emailMismatch || hashedEmailMismatch {
// If there is an existing email or hashed email but it doesn't match what was passed in, warn the customer
if emailMismatch {
MPLog.warning("The existing email on the user (\(userEmailIdentity ?? "nil")) does not match the email passed in to `selectPlacements:` (\(email ?? "nil")). Please remember to sync the email identity to mParticle as soon as you receive it. We will now identify the user before creating the layout")
MPRoktLayout.mpLog("The existing email on the user (\(userEmailIdentity ?? "nil")) does not match the email passed in to `selectPlacements:` (\(email ?? "nil")). Please remember to sync the email identity to mParticle as soon as you receive it. We will now identify the user before creating the layout")
}
if hashedEmailMismatch {
MPLog.warning("The existing hashed email on the user (\(user.identities[hashedEmailIdentity ?? NSNumber(value: -1)] ?? "nil")) does not match the email passed in to `selectPlacements:` (\(hashedEmail ?? "nil")). Please remember to sync the hashed email identity to mParticle as soon as you receive it. We will now identify the user before creating the layout")
MPRoktLayout.mpLog("The existing hashed email on the user (\(user.identities[hashedEmailIdentity ?? NSNumber(value: -1)] ?? "nil")) does not match the email passed in to `selectPlacements:` (\(hashedEmail ?? "nil")). Please remember to sync the hashed email identity to mParticle as soon as you receive it. We will now identify the user before creating the layout")
}

syncIdentities(user: user, email: email, hashedEmail: hashedEmail, hashedEmailKey: hashedEmailIdentity) {
Expand All @@ -115,14 +115,21 @@ public class MPRoktLayout {

mparticle.identity.identify(identityRequest) {apiResult, error in
if let error = error {
MPLog.error("Failed to sync email from selectPlacement to user: \(error)")
MPRoktLayout.mpLog("Failed to sync email from selectPlacement to user: \(error)")
completion()
} else {
if let identities = apiResult?.user.identities {
MPLog.debug("Updated user identity based off selectPlacement's attributes: \(identities)")
MPRoktLayout.mpLog("Updated user identity based off selectPlacement's attributes: \(identities)")
}
completion()
}
}
}

static func mpLog(_ message: String) {
let msg = "MPRokt -> \(message)"
if MParticle.sharedInstance().environment == .development {
print(msg)
}
}
}
Loading