Skip to content

Commit

Permalink
replaced trace with debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Espinola committed Jun 26, 2024
1 parent 53be50d commit f15aa4a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
14 changes: 7 additions & 7 deletions Sources/API/ATTNAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ final class ATTNAPI: ATTNAPIProtocol {
}

guard let geoAdjustedDomain = geoAdjustedDomain else { return }
Loggers.network.trace("Successfully returned geoAdjustedDomain: \(geoAdjustedDomain, privacy: .public)")
Loggers.network.debug("Successfully returned geoAdjustedDomain: \(geoAdjustedDomain, privacy: .public)")
self?.sendEventInternal(event: event, userIdentity: userIdentity, domain: geoAdjustedDomain, callback: callback)
}
}
Expand All @@ -91,7 +91,7 @@ fileprivate extension ATTNAPI {
return
}

Loggers.event.trace("Building Event URL: \(url)")
Loggers.event.debug("Building Event URL: \(url)")

var urlRequest = URLRequest(url: url)
urlRequest.httpMethod = "POST"
Expand All @@ -102,7 +102,7 @@ fileprivate extension ATTNAPI {
} else if let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode > 400 {
Loggers.event.error("Error sending the event. Incorrect status code: '\(httpResponse.statusCode)'")
} else {
Loggers.event.trace("Successfully sent event of type '\(request.eventNameAbbreviation)'")
Loggers.event.debug("Successfully sent event of type '\(request.eventNameAbbreviation)'")
}

callback?(data, url, response, error)
Expand All @@ -117,7 +117,7 @@ fileprivate extension ATTNAPI {
return
}

Loggers.event.trace("Building Identity Event URL: \(url)")
Loggers.event.debug("Building Identity Event URL: \(url)")

var request = URLRequest(url: url)
request.httpMethod = "POST"
Expand All @@ -128,7 +128,7 @@ fileprivate extension ATTNAPI {
} else if let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode > 400 {
Loggers.event.error("Error sending the event. Incorrect status code: '\(httpResponse.statusCode)'")
} else {
Loggers.event.trace("Successfully sent user identity event")
Loggers.event.debug("Successfully sent user identity event")
}

callback?(data, url, response, error)
Expand Down Expand Up @@ -175,11 +175,11 @@ extension ATTNAPI {
return
}

Loggers.network.trace("Getting the geoAdjustedDomain for domain '\(domain)'...")
Loggers.network.debug("Getting the geoAdjustedDomain for domain '\(domain)'...")

let urlString = String(format: RequestConstants.dtagUrlFormat, domain)
guard let url = URL(string: urlString) else {
Loggers.network.trace("Invalid URL format for domain '\(domain)'")
Loggers.network.debug("Invalid URL format for domain '\(domain)'")
completionHandler(nil, NSError(domain: "com.attentive.API", code: NSURLErrorBadURL, userInfo: nil))
return
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/ATTNVisitorService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct ATTNVisitorService {
return createNewVisitorId()
}

Loggers.event.info("Obtained existing visitor id: \(existingVisitorId, privacy: .public)")
Loggers.event.info("Obtained existing visitor id: \(existingVisitorId)")

return existingVisitorId
}
Expand All @@ -32,7 +32,7 @@ struct ATTNVisitorService {
let newVisitorId = generateVisitorId()
persistentStorage.save(newVisitorId as NSObject, forKey: Constants.visitorIdKey)

Loggers.event.info("Generated new visitor id: \(newVisitorId, privacy: .public)")
Loggers.event.info("Generated new visitor id: \(newVisitorId)")

return newVisitorId
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/Helpers/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import os
enum Loggers {
private static var subsystem: String { Bundle.main.bundleIdentifier ?? "com.attentive.attentive-ios-sdk-local" }

static var network = os.Logger(subsystem: subsystem, category: "network")
static var event = os.Logger(subsystem: subsystem, category: "event")
static var creative = os.Logger(subsystem: subsystem, category: "creative")
static var network = Logger(subsystem: subsystem, category: "network")
static var event = Logger(subsystem: subsystem, category: "event")
static var creative = Logger(subsystem: subsystem, category: "creative")
}
30 changes: 15 additions & 15 deletions Sources/Public/SDK/ATTNSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public final class ATTNSDK: NSObject {
@objc public var skipFatigueOnCreative: Bool = false

public init(domain: String, mode: ATTNSDKMode) {
Loggers.creative.trace("Init ATTNSDKFramework v\(ATTNConstants.sdkVersion), Mode: \(mode.rawValue), Domain: \(domain)")
Loggers.creative.debug("Init ATTNSDKFramework v\(ATTNConstants.sdkVersion), Mode: \(mode.rawValue), Domain: \(domain)")

self.domain = domain
self.mode = mode
Expand Down Expand Up @@ -119,9 +119,9 @@ public final class ATTNSDK: NSObject {
guard self.domain != domain else { return }
self.domain = domain
api.update(domain: domain)
Loggers.creative.trace("Updated SDK with new domain: \(domain)")
Loggers.creative.debug("Updated SDK with new domain: \(domain)")
api.send(userIdentity: userIdentity)
Loggers.creative.trace("Retrigger Identity Event with new domain '\(domain)'")
Loggers.creative.debug("Retrigger Identity Event with new domain '\(domain)'")
}
}

Expand All @@ -136,7 +136,7 @@ fileprivate extension ATTNSDK {
webView = nil
ATTNSDK.isCreativeOpen = false
triggerHandler?(ATTNCreativeTriggerStatus.closed)
Loggers.creative.trace("Successfully closed creative")
Loggers.creative.debug("Successfully closed creative")
}

func launchCreative(
Expand All @@ -147,19 +147,19 @@ fileprivate extension ATTNSDK {
parentView = view
triggerHandler = handler

Loggers.creative.trace("Called showWebView in creativeSDK with domain: \(self.domain, privacy: .public)")
Loggers.creative.debug("Called showWebView in creativeSDK with domain: \(self.domain, privacy: .public)")

guard !ATTNSDK.isCreativeOpen else {
Loggers.creative.trace("Attempted to trigger creative, but creative is currently open. Taking no action")
Loggers.creative.debug("Attempted to trigger creative, but creative is currently open. Taking no action")
return
}

guard #available(iOS 14, *) else {
Loggers.creative.trace("Not showing the Attentive creative because the iOS version is too old.")
Loggers.creative.debug("Not showing the Attentive creative because the iOS version is too old.")
triggerHandler?(ATTNCreativeTriggerStatus.notOpened)
return
}
Loggers.creative.trace("The iOS version is new enough, continuing to show the Attentive creative.")
Loggers.creative.debug("The iOS version is new enough, continuing to show the Attentive creative.")

let creativePageUrl = urlBuilder.buildCompanyCreativeUrl(
configuration: ATTNCreativeUrlConfig(
Expand All @@ -171,10 +171,10 @@ fileprivate extension ATTNSDK {
)
)

Loggers.creative.trace("Requesting creative page url: \(creativePageUrl)" )
Loggers.creative.debug("Requesting creative page url: \(creativePageUrl)" )

guard let url = URL(string: creativePageUrl) else {
Loggers.creative.trace("URL could not be created.")
Loggers.creative.debug("URL could not be created.")
return
}

Expand Down Expand Up @@ -207,15 +207,15 @@ fileprivate extension ATTNSDK {
extension ATTNSDK: WKScriptMessageHandler {
public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
let messageBody = message.body as? String ?? ""
Loggers.creative.trace("Web event message: \(messageBody). isCreativeOpen: \(ATTNSDK.isCreativeOpen ? "YES" : "NO")")
Loggers.creative.debug("Web event message: \(messageBody). isCreativeOpen: \(ATTNSDK.isCreativeOpen ? "YES" : "NO")")

if messageBody == "CLOSE" {
closeCreative()
} else if messageBody == "IMPRESSION" {
Loggers.creative.trace("Creative opened and generated impression event")
Loggers.creative.debug("Creative opened and generated impression event")
ATTNSDK.isCreativeOpen = true
} else if messageBody == String(format: "%@ true", Constants.visibilityEvent), ATTNSDK.isCreativeOpen {
Loggers.creative.trace("Nav away from creative, closing")
Loggers.creative.debug("Nav away from creative, closing")
closeCreative()
}
}
Expand Down Expand Up @@ -254,14 +254,14 @@ extension ATTNSDK: WKNavigationDelegate {
) { [weak self] result in
guard let self = self else { return }
guard case let .success(statusAny) = result else {
Loggers.creative.trace("No status returned from JS. Not showing WebView.")
Loggers.creative.debug("No status returned from JS. Not showing WebView.")
self.triggerHandler?(ATTNCreativeTriggerStatus.notOpened)
return
}

switch ScriptStatus.getRawValue(from: statusAny) {
case .success:
Loggers.creative.trace("Found creative iframe, showing WebView.")
Loggers.creative.debug("Found creative iframe, showing WebView.")
if self.mode == .production {
self.parentView?.addSubview(webView)
}
Expand Down

0 comments on commit f15aa4a

Please sign in to comment.