Skip to content

Commit e5683fb

Browse files
fix: Update Debug Logging (#36)
1 parent fd64e75 commit e5683fb

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

mParticle-Rokt-Swift/MPRoktLayout.swift

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ public class MPRoktLayout {
2929
config: RoktConfig? = nil,
3030
onEvent: ((RoktEvent) -> Void)? = nil
3131
) {
32-
MPLog.debug("Initializing MPRoktLayout with arguments:", sdkTriggered.wrappedValue, viewName ?? "nil", locationName, attributes)
32+
MPRoktLayout.mpLog("Initializing MPRoktLayout with arguments sdkTriggered:\(sdkTriggered.wrappedValue), viewName:\(viewName ?? "nil"), locationName:\(locationName), attributes:\(attributes)")
3333
confirmUser(attributes: attributes) { identifyCalled in
3434
let preparedAttributes = MPKitRokt.prepareAttributes(attributes, filteredUser: Optional<FilteredMParticleUser>.none, performMapping: true)
3535

36-
MPLog.debug("Initializing RoktLayout with arguments:", sdkTriggered.wrappedValue, viewName ?? "nil", locationName, preparedAttributes)
36+
MPRoktLayout.mpLog("Initializing RoktLayout with arguments sdkTriggered:\(sdkTriggered.wrappedValue), viewName: \(viewName ?? "nil"), locationName:\(locationName), attributes:\(preparedAttributes)")
3737
self.roktLayout = RoktLayout.init(
3838
sdkTriggered: sdkTriggered,
3939
viewName: viewName,
@@ -44,7 +44,7 @@ public class MPRoktLayout {
4444
)
4545
// 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
4646
if identifyCalled && sdkTriggered.wrappedValue {
47-
MPLog.debug("Triggering Rokt Swift UI re-render")
47+
MPRoktLayout.mpLog("Triggering Rokt Swift UI re-render")
4848
DispatchQueue.main.async {
4949
sdkTriggered.wrappedValue = false
5050
sdkTriggered.wrappedValue = true
@@ -86,10 +86,10 @@ public class MPRoktLayout {
8686
if emailMismatch || hashedEmailMismatch {
8787
// If there is an existing email or hashed email but it doesn't match what was passed in, warn the customer
8888
if emailMismatch {
89-
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")
89+
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")
9090
}
9191
if hashedEmailMismatch {
92-
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")
92+
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")
9393
}
9494

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

116116
mparticle.identity.identify(identityRequest) {apiResult, error in
117117
if let error = error {
118-
MPLog.error("Failed to sync email from selectPlacement to user: \(error)")
118+
MPRoktLayout.mpLog("Failed to sync email from selectPlacement to user: \(error)")
119119
completion()
120120
} else {
121121
if let identities = apiResult?.user.identities {
122-
MPLog.debug("Updated user identity based off selectPlacement's attributes: \(identities)")
122+
MPRoktLayout.mpLog("Updated user identity based off selectPlacement's attributes: \(identities)")
123123
}
124124
completion()
125125
}
126126
}
127127
}
128+
129+
static func mpLog(_ message: String) {
130+
let msg = "MPRokt -> \(message)"
131+
if MParticle.sharedInstance().environment == .development {
132+
print(msg)
133+
}
134+
}
128135
}

0 commit comments

Comments
 (0)