Approaches to modifying the Tealeaf iOS SDK configuration
Updating a single configuration key and value
API to update key and value
// Helper method to update key/value in configuration
EOApplicationHelper.sharedInstance().setConfigItem(
KEY_NAME_IN_CONFIGURATION, value: VALUE_FOR_CONFIGURATION,
forModuleName: MODULE_TO_UPDATE)
Example using the API
// Example that updates boolean value for key named "RemoveSwiftUIDuplicates" for Module named "TLFCoreModule"
// Note: kTLFCoreModule is a constant for "TLFCoreModule"
EOApplicationHelper.sharedInstance().setConfigItem(
"RemoveSwiftUIDuplicates", value: false, forModuleName: kTLFCoreModule)
Updating layout configuration
Layout configuration consists of two objects:
AutoLayout
AppendMapIds
Below is an example of default layout configuration.
{
"AutoLayout": {
"GlobalScreenSettings": {
"ScreenChange": true,
"DisplayName": "",
"CaptureLayoutDelay": 1,
"ScreenShot": true,
"NumberOfWebViews": 0,
"CaptureUserEvents": true,
"CaptureScreenVisits": false,
"CaptureLayoutOn": 2,
"CaptureScreenshotOn": 2,
"Masking": {
"HasMasking": true,
"HasCustomMask": true,
"Sensitive": {
"capitalCaseAlphabet": "X",
"number": "9",
"smallCaseAlphabet": "x",
"symbol": "#"
},
"MaskIdList": [],
"MaskValueList": [],
"MaskAccessibilityIdList": [],
"MaskAccessibilityLabelList": []
}
},
"ExampleMaskingPage": {
"ScreenChange": false,
"DisplayName": "",
"CaptureLayoutDelay": 0,
"ScreenShot": false,
"NumberOfWebViews": 0,
"CaptureUserEvents": false,
"CaptureScreenVisits": false,
"CaptureLayoutOn": 0,
"CaptureScreenshotOn": 0,
"Masking": {
"HasMasking": true,
"HasCustomMask": true,
"Sensitive": {
"capitalCaseAlphabet": "X",
"number": "9",
"smallCaseAlphabet": "x",
"symbol": "#"
},
"MaskIdList": [
"^9[0-9][0-9][0-9]$",
"^\\[wvv,0\\],\\[dddv,0\\],\\[v,0\\],\\[v,0\\],\\[v,0\\],\\[b,0\\](.)*$"
],
"MaskValueList": [
"^4[0-9]{12}(?:[0-9]{3})?$",
"^3[47][0-9]{13}$",
"^65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})$",
"^(5[1-5][0-9]{14}|2(22[1-9][0-9]{12}|2[3-9][0-9]{13}|[3-6][0-9]{14}|7[0-1][0-9]{13}|720[0-9]{12}))$"
],
"MaskAccessibilityIdList": [],
"MaskAccessibilityLabelList": []
}
},
"StartViewController": {
"DisplayName": "Start",
"CaptureLayoutDelay": 0,
"ScreenShot": true,
"CaptureScreenshotOn": 2
},
"WEWKWebViewController": {
"DisplayName": "WKWebView",
"CaptureLayoutDelay": 500,
"ScreenShot": false,
"NumberOfWebViews": 1,
"CaptureScreenshotOn": 0
},
"DoubleWebPageViewController": {
"DisplayName": "Multi WKWebView",
"CaptureLayoutDelay": 500,
"ScreenShot": false,
"NumberOfWebViews": 2,
"CaptureScreenshotOn": 0
},
"WKCookieWebViewController": {
"DisplayName": "WKCookieWebView",
"CaptureLayoutDelay": 500,
"ScreenShot": false,
"NumberOfWebViews": 1,
"CaptureScreenshotOn": 0
}
},
"AppendMapIds": {
"[w,9290],[v,0]": {
"mid": "ASimpleUIView"
},
"tag2999999": {
"mid": "giveAdditionalId1"
},
"idxPathValue": {
"mid": "giveAdditionalId2"
}
}
}
Example using the API to update layout configuration.
import UIKit
import Tealeaf
import EOCore
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let tealeafApplicationHelperObj = TealeafApplicationHelper()
// Enable library to load configuration settings
let appKey:String = "https://lib-us-2.brilliantcollector.com/collector/collectorPost"
let postMessageURL:String = "b6c3709b7a4c479bb4b00000000yyyyyy"
tealeafApplicationHelperObj.enableFramework(appKey, withPostMessageUrl: postMessageURL)
// Read the new TealeafLayoutConfig settings
let tlfAdvFilePath: String? = Bundle.main.path(forResource: "TealeafLayoutConfig", ofType: "json")
var layoutConfigDict: [AnyHashable : Any] = [:]
// read data into layoutConfigDict
loadJson(filePath: tlfAdvFilePath!, jsonDict: &layoutConfigDict)
// Update values in configuration for both json objects "AutoLayout" & "AppendMapIds"
EOApplicationHelper.sharedInstance().setConfigItem("AutoLayout", value:layoutConfigDict["AutoLayout"], forModuleName:kTLFCoreModule)
EOApplicationHelper.sharedInstance().setConfigItem("AppendMapIds", value:layoutConfigDict["AppendMapIds"], forModuleName:kTLFCoreModule)
// Update values in configuration
EOApplicationHelper.sharedInstance().setConfigItem("RemoveSwiftUIDuplicates", value:false, forModuleName:kTLFCoreModule)
EOApplicationHelper.sharedInstance().setConfigItem("LogFullRequestResponsePayloads", value:true, forModuleName:kTLFCoreModule)
return true
}
func loadJson(filePath: String, jsonDict: inout [AnyHashable : Any]) {
let jsonData = NSData(contentsOfFile: filePath) as Data?
if let jsonData = jsonData, let json = try? JSONSerialization.jsonObject(with: jsonData, options: []) as? [AnyHashable : Any] {
jsonDict = json
}
print("\(filePath):")
print("\(jsonDict)")
let error: Error? = nil
if error != nil {
print("Error: was not able to load for \(filePath)")
}
}
....
}
Updated 5 months ago