Debug iOS v4
    • 2 Minutes to read
    • Dark
      Light

    Debug iOS v4

    • Dark
      Light

    Article summary

    The debug mode helps you to verify your track requests and check if all of your parameters are sent correctly.

    Please use the AppDelegate.Swift class to initiate the debug mode.

    Prepare Logging

    The following code is needed to be able to filter logging information in the console:

    if let id = everID, let code = mediaCode {
                     WebtrekkTracking.defaultLogger.logDebug( "\(everIDName)=\(id), \(mediaCodeName)=\(code)" )
                 } else {
                     WebtrekkTracking.defaultLogger.logDebug( "no deep link info" )
                 }
             }

    This will add both, the prefix "Webtrekk" and the corresponding type of logging information into the console.

    Example output in the console:

    [Webtrekk] [Warning] Element autoTrackPlaystoreUsername not found
    [Webtrekk] [Warning] Element autoTrackPlaystoreMail not found
    [Webtrekk] [Debug] track domain is:https: //trackdomain.net
    [Webtrekk] [Debug] trackID is: 988720192734534
    [Webtrekk] [Debug] sendDelay is: 300.0

    In the example above, "Webtrekk" is used to indicate the output of the Mapp Intelligence SDK, and "Warning" and "Debug" are used to indicate the type of output.

    Enable Webtrekk Logging

    If you want to enable logging for all types of notifications, you need to set the SDK test mode to "true":

    func initWithConfig(configName name: String? = nil) {
             if let _ = WebtrekkTracking.tracker {
                 releaseWebtrekkInstance()
             }
     
             do {
                 WebtrekkTracking.defaultLogger.testMode = true
                 if let name = name {
                     let configFileURL = Bundle.main.url(forResource: name, withExtension: "xml" , subdirectory: "Configurations/" )
                     try WebtrekkTracking.initTrack(configFileURL)
                 } else {
                     try WebtrekkTracking.initTrack()
                 }
             } catch let error as TrackerError {
                 WebtrekkTracking.defaultLogger.logError( "Error Webtrekk SDK initialization: \(error.message)" )
             } catch {
                 WebtrekkTracking.defaultLogger.logError( "Unkown error during Webtrekk SDK initialization" )
             }
         }

    This will start logging the following information to the console:

    Logging Type

    Information Provided

    debug

    • track domain

    • track ID

    • sendDelay

    • requests

    • queue size

    • user actions

    info

    • cleaning queue of requests

    • migrating from Webtrekk library v3

    • initialization completed

    • local configuration is up to date

    • updating configuration

    • info to use sendPedningEvents for the manual message if sendDelay is equal to 0

    warning

    • incorrect birthday or gender

    • the field name is too long (more than 255 characters)

    • request failed

    • request manager can not be started (if already is started) or stopped (if it is not running)

    • illegal values in configuration xml

    • about migration: information that app can not remove the previous version of library

    error

    • errors about requests

    • errors about campaigns and goals

    • missing information about products

    fault

    • enable logging for specific use cases when implementing the SDK

    Disable Logging

    In production, it is recommended to disable logging entirely. To do so, please disable logging and testMode:

    WebtrekkTracking.defaultLogger.enabled = false
    WebtrekkTracking.defaultLogger.testMode = false

    Example App

    In the Webtrekk Example App, you can check how logging works when you change the configuration in the AppDelegate.Swift class at line 122 and 123 before running the app in Xcode:

    https://github.com/Webtrekk/iOS-SDK-Example-App/blob/master/Sources/ModuleTest/AppDelegate.swift


    Was this article helpful?