Travel iOS SDK
4.1 Import the Wunderkind SDK to your project.
4.3 Opting Users Out of Tracking
4.3.1 Context Information Tracking
4.4.2 Car Rental Progress event
4.4.3 Car Rental Add To Cart event
1. SDK Stats
Minimum Xcode version: 10.0+
Minimum iOS version: 11.0+
SDK Current Version: 1.3.4
2. Integration Steps:
- Follow the steps in the Installation section to include the Wunderkind SDK in your project.
- Initialize the SDK in your project with the steps defined under the Usage section.
- Replace
WEBSITE_ID
with your website ID in the main SDK'sinitialize
function and make sure to setisDebugMode
flag to true both in development and testing environments.
3. Installation
3.1 Install with CocoaPods
You can use CocoaPods to install the Wunderkind SDK into your projects.
To install the Wunderkind SDK into your Xcode project using CocoaPods, please follow next steps:
- Define the latest Wunderkind SDK in the Podfile.
platform :ios, '11.0'
use_frameworks!
target 'AppTarget' do
pod 'Wunderkind', podspec: 'https://storage.googleapis.com/wunderkind-ios-sdk/latest.podspec'
end
If you wish to install specific version x.y.z
, please refer to the corresponding podspec file.
platform :ios, '11.0'
use_frameworks!
target 'AppTarget' do
pod 'Wunderkind', podspec: 'https://storage.googleapis.com/wunderkind-ios-sdk/x.y.z.podspec'
end
- Install the pods, then open your
.xcworkspace
file to see the project in Xcode:
$ pod install
$ open your-project.xcworkspace
3.2 Manual Installation
To integrate framework manually,
- Download the
x.y.z
version from Cloud Storage (https://storage.googleapis.com/wunderkind-ios-sdk/x.y.z.zip). - Drag and drop
WunderkindKit.xcframework
to "Frameworks, Libraries, and Embedded Content" in "General" Settings of your application's target. - If you placed the framework in a custom file system’s location, please specify it in FRAMEWORK_SEARCH_PATHS (in your Build Settings).
4. Usage
In order to allow your app to track events, please follow the steps highlighted in this section.
4.1 Import the Wunderkind SDK to your project.
import WunderkindKit
4.2 SDK Initialization
Initialize SDK with your WEBSITE_ID
(If you don't know your WEBSITE_ID
, please contact our support team), and set a corresponding environment configuration isDebugMode
(details below).
The initialization is mandatory. Failure to do so will result in the SDK being unable to track events properly. In most cases, this should be done in application:didFinishLaunchingWithOptions:
💬By default debug mode is disabled, but setting isDebugMode
to true
will allow you to verify events tracking functionality in a debug environment. Please make sure to set it to false
before deploying to production.
⚠️isDebugMode
must be set to false
before promoting to production.
class AppDelegate: UIResponder, UIApplicationDelegate {
..
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions
launchOptions: [UIApplication.LaunchOptionsKey: Any]?)
- Bool {
..
Wunderkind.shared.initialize(websiteId: WEBSITE_ID, isDebugMode:isDebugMode)
}
4.3 Opting Users Out of Tracking
Client-side tracking of user data may be enabled/disabled by controlling a userʼs opt-in/out state. The opt-in/out state of a user is controlled by an opt-out flag that affects on the user's location, the IDFA and user's device information.
- User information is tracked by default - A user must therefore explicitly opt-out to disable tracking.
4.3.1 Context Information Tracking
The Wunderkind SDK collects device/context specific information, which include:
- Device Information:
- Operating system name
- Operating system version
- Device model
- Screen resolution
- Device type
- App Information:
- Installation date
- Bundle identifier
- Version number
- Build number
Users may opt-in/out of context tracking and this can be set through the isContextInfoTrackingEnabled
property, which is enabled by default.
💬Device/Context tracking is enabled by default.
Wunderkind.shared.isContextInfoTrackingEnabled = false
4.4 Track Events
⚠️It’s imperative that SDK functions be only called once for a single application event. Duplicate calls may occur when using inheritance patterns and accidental calls to the same SDK functions from parent and child objects simultaneously.
💬Please refer to the Wunderkind SDK Reference section for more information about classes and types that are used in SDK's API.
💬Underlying data points gathered by the Wunderkind SDK may be reviewed by using proxy applications such as Charles or Proxyman and through the use of request interceptions. This will help you to validate that events are sent with the expected arguments provided via the API functions. Also note that events are sent to the backend every 1 minute.
Please also refer to the Logging section below to customize your project's debug logs section to review Wunderkind SDK's expected results (initialization result, events saving and sending response).
The following is a list of public functions in Wunderkind class that may be used for tracking events.
4.4.1 Logged in event
Overview
This event is triggered when a user explicitly successfully signed in to their app. This event is also triggered when a user signed up to their app.
Wunderkind.shared.trackAffiliateLoggedIn(email: String, phone: String?, accountType: AccountType,
affiliateNumber: String?)
💬email
property is required to be non-empty otherwise this event will not be tracked.
Example Implementation:
final class LoginViewController: BaseViewController {
...
func loginWasSuccessful() {
// This event is triggered when a user explicitly successfully signed in to their app.
Wunderkind.shared.trackAffiliateLoggedIn(email: emailTextField.text, phone: phoneTextField.text, accountType
affiliateNumber: affiliateNumberField.affiliateNumber)
}
}
4.4.2 Car Rental Progress event
Overview
These events should be triggered when a user completes progress in finishing a rental request.
Swift:
Wunderkind.shared.trackCarRentalProgress(progress: CarRentalProgress)
💬See section 5. Wunderkind SDK Reference for data structure references
4.4.3 Car Rental Add To Cart event
Overview
These events should be triggered when a user adds a Car rental to their cart.
Wunderkind.shared.trackCarRentalAddToCart(rental: CarRentalAddToCart)
💬See section 5. Wunderkind SDK Reference for data structure references
4.4.4 Rental Purchase event
Overview
This event is triggered when a user purchases a rental item and completes their order.
Wunderkind.shared.trackRentalPurchase(rentalOrder: rentalOrder)
⚠️Should purchase event attributes not be entered correctly, the following error may be generated in your project’s logs:Unfortunately, event "Purchase" hasn't been tracked since you have provided a nullable parameter or a not valid one.
final class CheckoutViewController: BaseViewController {
...
func purchaseWasSuccessful() {
let invoice = Invoice(amount: 40.0,
tax: 2.5,
shipping: 4.5,
totalDiscount: nil,
currency: .USD)
let customer = Customer(email: "test@wunderkind.co",
phone: "+12223334445")
let product = Product(productId: "TestProductId",
skuId: "TestSKUId",
price: 10.0,
quantity: 2)
let purchaseOrder = Order(orderId: "TestOrderId",
invoice: invoice,
paymentMethod: "Credit Card",
products: [product],
customer: customer,
coupons: ["TestCoupon"],
goal: "purchase")
let rentalOrder = RentalOrder(
accountType: order.accountType,
affiliateNumber: order.affiliateNumber,
order: purchaseOrder
)
Wunderkind.shared.trackRentalPurchase(order: rentalOrder)
}
}
4.4.5 Text Opt In Event
Overview
This event is triggered when a user opts in to text messaging.
💬Pass null for languageCode, unless the desired language is French then pass a String with value “fr”
Wunderkind.shared.trackTextOptIn(phoneNumber: String, languageCode: String?)
Example Implementation:
final class SignupViewController: BaseViewController {
...
func textOptInSelected(givenPhoneNumber: String, selectedLanguage: String) {
if (selectedLanguage == "french"){
Wunderkind.shared.trackTextOptIn(phoneNumber: givenPhoneNumber, languageCode: "fr")
}
else {
Wunderkind.shared.trackTextOptIn(phoneNumber: givenPhoneNumber, languageCode: null)
}
}
}
4.5 Logging
The Wunderkind SDK provides logging capabilities in order to report on events collected and are useful to validate user data.
Setting logLevel
property to debug
will allow you to trace data going through the Wunderkind SDK.
Wunderkind.shared.logLevel = .debug
Setting logLevel
property to none
will allow you to disable logging.
Wunderkind.shared.logLevel = .none
💬logLevel
default value is info
, which notifies you about events deemed to be important (Activation, Validation Errors, etc.)
5. Wunderkind SDK Reference
5.1 Car Rental Progress
CarRentalProgress(options: [String],
isRentalOneWay: Bool,
details: RentalDetails,
request: CarRentalRequest,
account: RentalAccount
)
Example:
CarRentalProgress(options: ["chrysler_pacifica_or_similar", "chevrolet_suburban_or_similar", "toyota_camry_or_sim
isRentalOneWay: false,
details: RentalDetails,
request: CarRentalRequest,
account: RentalAccount
)
5.2 Car Rental Add To Cart
CarRentalAddToCart(selectedOption: String,
isRentalOneWay: Bool,
details: RentalDetails,
request: CarRentalRequest,
account: RentalAccount
)
Example:
CarRentalAddToCart(selectedOption: "chrysler_pacifica_or_similar",
isRentalOneWay: false,
details: RentalDetails,
request: CarRentalRequest,
account: RentalAccount
)
5.3 Rental Details
RentalDetails(ancillaryItems: Bool,
stepNumber: Int?,
travelersCount: Int?,
title: String?,
url: URL
)
Example:
RentalDetails(
ancillaryItems: false,
stepNumber: 3,
travelersCount: 6,
title: "extras",
url: URL(string: "https://www.wunderkindTravel.com/en/reservation")!
)
5.4 Car Rental Request
CarRentalRequest(carCode: String?,
startLocation: RentalLocation,
dropOffLocation: RentalLocation?,
startTimestamp: TimeInterval,
endTimestamp: TimeInterval
)
Example:
RentalRequest(
carCode: "F",
startLocation: .init(
title: "Youngstown Municipal Airport, Vienna, OH, US-(YNG)",
code: "YNG"
),
dropOffLocation: nil,
startTimestamp: 1708203600,
endTimestamp: 170906760
)
5.5 Rental Account
RentalAccount(accountType: AccountType,
affiliateNumber: String?,
countryOfResidence: String?,
age: Decimal
)
Example:
RentalAccount(
accountType: .leisure,
affiliateNumber: "24323112",
countryOfResidence: "USA",
age: 45
)
5.6 Rental Location
RentalLocation(title: String, code: String)
Example:
RentalLocation(title: "Youngstown Municipal Airport, Vienna, OH, US-(YNG)", code: "YNG")
5.7 Invoice
Invoice(amount: Decimal,
tax: Decimal,
shipping: Decimal,
totalDiscount: Decimal?,
currency: Currency)
💬amount
, tax
, shipping
properties are required to be greater than or equal to 0.0 otherwise this event will not be tracked. Also, if totalDiscount
property is not null, it must be greater than or equal to 0.0.
5.8 Customer
Customer(email: String,
phone: String)
💬email
, phone
properties are required to be non-empty otherwise this event will not be tracked.
5.9 Product
Product(productId: String,
skuId: String,
price: Decimal,
quantity: Int64)
💬productId
, skuId
properties are required to be non-empty, price
, quantity
properties are required to be greater than or equal to 0 otherwise this event will not be tracked.
5.10 Order
Order(orderId: String,
invoice: Invoice,
paymentMethod: String?,
products: [Product],
customer: Customer,
coupons: [String]?,
goal: String)
💬orderId
, goal
, products
properties are required to be non-empty otherwise this event will not be tracked. Also, if paymentMethod
or coupons
properties are not null, they must be non-empty.
5.11 Account Type
enum AccountType: Int {
case leisure
case business
}
5.12 Currency
enum Currency: Int {
case USD
case KRW
case AED
case LTL
case ARS
case MAD
case AUD
case MXN
case BGN
case MYR
case BOB
case NOK
case BRL
case NZD
case CAD
case PEN
case CHF
case PHP
case CLP
case PKR
case CNY
case PLN
case COP
case RON
case CZK
case RSD
case DKK
case RUB
case EGP
case SAR
case EUR
case SEK
case GBP
case SGD
case HKD
case THB
case HRK
case TRY
case HUF
case TWD
case IDR
case UAH
case ILS
case VEF
case INR
case VND
case JPY
case ZAR
}
5.13 LogLevel
enum LogLevel: Int {
case none
case debug
case info
}
6. Change log
Version | Release | Date Details |
1.2.0 | 1.10.2024 | Initial Wunderkind Travel SDK release. |
7. License
Distributed under the MIT License. To view the full license, visit http://www.wunderkind.co/legal/sdklicense-agreement