Migrate from DataDomeSDK 1.x to DataDomeSDK 2.x

We have redesigned the DataDomeSDK v2 from the ground up to ease the integration. We have also revisited the architecture which led to a more stable framework with enhanced performance.
The exposed APIs have been redesigned as well.
A simple way to migrate the SDK to v2 is by completely removing the DataDomeSDK v1 from your app source code and deleting any calls to the SDK. Once done, follow the DataDomeSDK v2 integration documentation.

Please find below a detailed step-by-step guide for migrating to version 2 of the SDK.

Updating the version using Cocoapods

Make the following version change In your Podfile to get version 2 of the SDK:

Old Podfile configuration:

pod "DataDomeSDK", "~> 1.116.18"

New Podfile configuration:

pod "DataDomeSDK", "~> 2.5.6"


Note about versioning

Please note that the versioning pattern has changed from v1 to v2. DataDomeSDK v1 relies on the major.x.minor versioning pattern where x is the version of Xcode (e.g., 116 represents Xcode 11.6). We have been delivering a specific version of the SDK for each version of Xcode to avoid swift API stability issues.

In version 2.5.0 of our SDK, we have switched to the XCFramework format, which renders the need to create a specific build for each swift version obsolete. Thanks to this new format, we are now able to support standard semantic versioning for our SDK.

Finally, run pod install to get the new version integrated into your project.
Obviously the project won't build, since we broke the exposed API of the SDK in version 2.

Fixing the compiler issues

Remove explicit code for event tracking

In version 1.x, the app developer had to explicitly write code for logging events (examples of events: validating a request, presenting a Captcha, did the Captcha get resolved, did the user tap on the screen, etc.). In version 2 of the SDK, the above is performed automatically by the SDK.
In order to migrate the event tracking, make sure to remove all code logging events.
In the example below, the following call should be removed, and any call using the API logEvent should also be removed:

dataDomeSdk?.logEvent(id: 2, message: "User-agent changed", source: logSource)

All code related to capturing touch events and reporting them to the SDK is now obsolete. These implementations should be removed if they are only used for reporting touch events to the DataDomeSDK:

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
  dataDomeSdk?.handleTouchEvent(touches, offType: .down, inView: self.view)

override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
  dataDomeSdk?.handleTouchEvent(touches, offType: .up, inView: self.view)

override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
  dataDomeSdk?.handleTouchEvent(touches, offType: .move, inView: self.view)

Following the code removal, the event tracker is now fully autonomous and can automatically log the necessary events from the app without requiring any extra code from the app developer.

Remove the conformance and implementation of the DataDomeSDKDelegate protocol

To reduce the code coupling between the app and the SDK, we have completely eliminated the DataDomeSDKDelegate protocol. Please proceed to the removal of the DataDomeSDKDelegate conformance and implementation in your code:

Old implementation:

class MyViewController: UIViewController, DataDomeSDKDelegate {
    func captchaNeedsContainer(_ instance: DataDomeSDK, 
                               forCaptchaUrl url: String) {
        //Code here

    func captcha(_ instance: DataDomeSDK, 
                 willAppear webView: UIView?) {
        //Code here

    func captcha(_ instance: DataDomeSDK, 
                 didAppear webView: UIView?) {
        //Code here

    func captcha(_ instance: DataDomeSDK, 
                 willDisappear webView: UIView?) {
        //Code here

    func captcha(_ instance: DataDomeSDK, 
                 didDisappear webView: UIView?) {
        //Code here

    func datadomeRespond(_ responseCode: Int, 
                         withData data: Any?) {
        //Code here

After removing the conformance and the implementation:

class MyViewController: UIViewController {

Remove the DataDomeSDK instantiation

Below are the details concerning instantiating DataDomeSDK v1:

let dataDomeSdk = DataDomeSDK(key: key, appVersion: appVersion, userAgent: userAgent)
  • The key parameter is the client side key provided by DataDome. Providing the key to the SDK as parameter is not convenient when using multiple keys for multiple environments (dev, prod, pre-prod, uat, etc.). We decided to move the key to the app's Info.plist file where it could be declined by configuration. Please create a new entry in your app's Info.plist file with DataDomeKey as "key" and your client side key as "value". Please refer to this section for more information.
  • The appVersion parameter is accessible from the SDK. Requesting it as input is not necessary and is prone to errors.
  • The userAgent parameter is used for debug purposes. Passing it to the init as hardcoded information is prone to errors. Developers may forget a debug user agent in their code while submitting the app to production. We have decided to move the user agent to the environment variables that are read-only while on XCode. Please refer to this section for more information.

Now that all inputs to the SDK init function are not necessary, we have completely eliminated the init from the SDK. Please proceed to removing the instantiation from the SDK and the declaration of the dataDomeSdk variable.

Following the steps above, your code should now be able to compile.

Choosing the networking configuration to use for your app

Depending on your app requirements, please refer to this documentation in order to adopt the right integration flow for the SDK (Using URLSession, Alamofire or Moya, using automatic UI navigation or manual navigation, etc.).