Skip to content

Commit

Permalink
Logs InApp content block data without HTML content
Browse files Browse the repository at this point in the history
  • Loading branch information
adam1929 committed Apr 19, 2024
1 parent a93ab9d commit 0006060
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 43 deletions.
5 changes: 2 additions & 3 deletions ExponeaSDK/Example/Views/AuthenticationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,13 @@ class AuthenticationViewController: UIViewController {
publicKey: advancedAuthPubKey,
expiration: nil
)



let exponea = Exponea.shared.onInitSucceeded {
Exponea.logger.log(.verbose, message: "Configuration initialization succeeded")
//Uncomment if you want to test in-app message delegate
//Exponea.shared.inAppMessagesDelegate = InAppDelegate(overrideDefaultBehavior: true, trackActions: false)
}

Exponea.logger.logLevel = .verbose
exponea.checkPushSetup = true
Exponea.logger.log(.verbose, message: "Before Configuration call")
exponea.configure(
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,9 @@ public struct InAppContentBlocksDisplayStatus: Codable, Equatable {
let displayed: Date?
let interacted: Date?
}

internal extension InAppContentBlockResponse {
func describe() -> String {
return "ID:\(id), Name:\(name)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,22 @@ public struct PersonalizedInAppContentBlockResponse: Codable {
self.ttlSeen = ttlSeen
}
}

extension PersonalizedInAppContentBlockResponse {
func describeDetailed() -> String {
return """
{
id: \(id),
status: \(status),
ttlSeconds: \(ttlSeconds),
variantId: \(String(describing: variantId)),
hasTrackingConsent: \(String(describing: hasTrackingConsent)),
variantName: \(String(describing: variantName)),
contentType: \(String(describing: contentType)),
ttlSeen: \(String(describing: ttlSeen)),
tag: \(String(describing: tag)),
isCorruptedImage: \(isCorruptedImage)
}
"""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,14 @@ struct QueueLoadData {
let indexPath: IndexPath
let expired: [InAppContentBlockResponse]
}

extension QueueData {
func describeDetailed() -> String {
return """
{
inAppContentBlocks: \(inAppContentBlocks.describe()),
newValue: \(newValue.describeDetailed())
}
"""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,19 @@ public struct UsedInAppContentBlocks {
self.hasBeenLoaded = hasBeenLoaded
self.placeholderData = placeholderData
}

func describeDetailed() -> String {
return """
{
tag: \(tag),
indexPath: \(indexPath),
messageId: \(messageId),
placeholder: \(placeholder),
height: \(height),
hasBeenLoaded: \(hasBeenLoaded),
placeholderData: \(String(describing: placeholderData?.describe())),
isActive: \(isActive)
}
"""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ public protocol InAppContentBlockCallbackType {

internal struct DefaultInAppContentBlockCallback: InAppContentBlockCallbackType {
func onMessageShown(placeholderId: String, contentBlock: InAppContentBlockResponse) {
Exponea.logger.log(.verbose, message: "Tracking of InApp Content Block \(contentBlock.id) show")
Exponea.logger.log(
.verbose,
message: "Tracking of InApp Content Block \(contentBlock) show"
)
Exponea.shared.trackInAppContentBlockShown(placeholderId: placeholderId, message: contentBlock)
}
func onNoMessageFound(placeholderId: String) {
Expand Down
6 changes: 2 additions & 4 deletions ExponeaSDK/ExponeaSDK/Classes/Others/HtmlNormalizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public class HtmlNormalizer {
document = try SwiftSoup.parse(originalHtml)
} catch {
Exponea.logger.log(
.verbose,
.warning,
message: "[HTML] Unable to parse original HTML source code \(originalHtml)"
)
document = nil
Expand Down Expand Up @@ -122,9 +122,7 @@ public class HtmlNormalizer {
return nil
}
do {
let result = try document.html()
Exponea.logger.log(.verbose, message: "[HTML] Output is:\n \(String(describing: result))")
return result
return try document.html()
} catch let error {
Exponea.logger.log(.error, message: "[HTML] Output cannot be exported: \(error)")
return nil
Expand Down

0 comments on commit 0006060

Please sign in to comment.