Travel Android SDK
3.1 Direct adding AAR
3.2 Using Maven
4.1 Import the Wunderkind SDK to your project.
4.2 SDK Initialization
4.3 Opting Users Out of Tracking
4.3.1 Location Tracking
4.3.2 Google Advertising ID Tracking (AAID)
4.3.3 Context Information Tracking
4.4 Track Events
4.4.1 Logged in event
4.4.2 LoggedOut Event
4.4.3 Car Rental Progress event
4.4.4 Car Rental Add To Cart event
4.4.5 Rental Purchase event
4.4.6 Text Opt In Event
4.5 Logging
5.1 Car Rental Progress
5.2 Car Rental Add To Cart
5.3 Rental Details
5.4 Car Rental Request
5.5 Rental Account
5.6 Rental Location
5.7 Invoice
5.8 Customer
5.9 Product
5.10 Order
5.11 Currency
5.12 LogLevel
1. SDK Stats
Minimum Android Studio Version: 3.3.2+
Minimum Android Version: 5.0+ (API 21+)
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
⚠️Before proceeding further please ensure that you have a corresponding permission for “Google Advertising Id” (Ad Id) if your Android application project targets latest Android SDK 33.
Such a permission should be set in app’s AndroidManifest.xml
file:<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
If you decide to opt-out of Ad Id tracking, please refer to corresponding section below.
The Wunderkind SDK supports multiple methods for installing into a project. Two have been listed here (Direct adding AAR and using Maven).
3.1 Direct adding AAR
- Navigate to project's
app
module and createlibs
directory. - Place your
.aar
(e.g.wunderkindsdk.aar
.) file in this directory. - In order to define a new repository which points to the
app
module'slibs
folder, please include the code below to theandroid
block of app level'sbuild.gradle
file:
repositories {
flatDir {
dirs 'libs'
}
}
- Include the code below to
dependencies
block or thebuild.gradle
file:
compile(name:' wunderkindsdk', ext:'aar')
3.2 Using Maven
You’ll find below the steps required to install the Wunderkind SDK into your Android Studio project, using Maven repository, which are hosted in Google Platform's Artifact registry.
- Navigate to
build.gradle
in application's module (by default it's inapp
folder) and add these lines:
android {
repositories {
maven {
url "https://us-central1-maven.pkg.dev/bx-production-coreapi/wunderkind-sdk-android"
}
}
}
- Add dependencies in the same app's
build.gradle
file
implementation "co.wunderkind.sdk:wunderkindsdk:1.0.8"
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 co.wunderkind.sdk.Wunderkind
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 MainActivity
/ Application
💬By default, debug mode is disabled and 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.
public class MainActivity extends AppCompatActivity {
@Override
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
..
Wunderkind.getInstance().initialize(context: this, 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.
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 may be set through the isContextInfoTrackingEnabled
property, which is enabled by default.
💬Device/Context tracking is enabled by default.
Wunderkind.getInstance().setIsContextInfoTrackingEnabled(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 to get more information on 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 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 can 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.getInstance().trackAffiliateLoggedIn(@NotNull String email, @NotNull String phone, @NotNull AccountTyp
💬email
property is required to be non-empty otherwise this event will not be tracked.
Example Implementation:
public class LogInActivity extends AppCompatActivity {
protected void onSuccessfulLogin() {
wunderkind.getInstance().trackLoggedIn(email, phone, accountType, affiliateNumber);
}
}
4.4.2 LoggedOut Event
Overview
This event is called when a user logs out of the application.
Wunderkind.getInstance().trackLoggedOut()
Example Implementation:
public class LogoutActivity extends AppCompatActivity {
protected void onSuccessfulLogout() {
wunderkind.getInstance().trackLoggedOut();
}
}
4.4.3 Car Rental Progress event
Overview
These events should be triggered when a user completes progress in finishing a rental request.
Wunderkind.getInstance().trackCarRentalProgress(CarRentalProgress)
💬See section 5. Wunderkind SDK Reference for data structure references
4.4.4 Car Rental Add To Cart event
Overview
These events should be triggered when a user adds a Car rental to their cart.
Wunderkind.getInstance().trackCarRentalAddToCart(CarRentalAddToCart)
💬See section 5. Wunderkind SDK Reference for data structure references
4.4.5 Rental Purchase event
Overview
This event is triggered when a user purchases an item and completes their order.
Wunderkind.getInstance().trackRentalPurchase(@NotNull RentalOrder rentalOrder)
⚠️Please note that due to the importance of the Purchase event, it’s imperative that all of its attributes (Invoice, Customer, Product, Order) be correctly set.
⚠️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
Example Implementation:
public class CheckoutActivity extends AppCompatActivity {
protected void onSuccessfulPurchase() {
List couponList = new ArrayList<>();
couponList.add("TestCoupon");
List products = new ArrayList<>();
Double price = 10.0;
Long quantity = 1L;
products.add(new Product("PRODUCT-ID", "SKU-ID", price, quantity));
Double amount = 100.0;
Double tax = 10.0;
Double shipping = 10.0;
Double totalDiscount = 10.0;
String paymentMethod = "Visa Card";
String customerEmail = "test@java.com";
String customerPhone = "+12223334445";
String goal = "purchase";
Order order = new Order("TestOrderId",
new Invoice(amount, tax, shipping, totalDiscount, Currency.USD),
paymentMethod,
products,
new Customer(customerEmail, customerPhone),
couponList,
goal
);
RentalOrder rentalOrder = new RentalOrder(accountType, order, affiliateNumber)
Wunderkind.getInstance().trackPurchase(rentalOrder);
}
}
4.4.6 Text Opt In Event
Overview
This event is triggered when a user opts in to text messaging.
💬Pass null for launguageCode, unless the desired language is French then pass a String with value “fr”
Wunderkind.getInstance().trackTextOptIn(phoneNumber: String, languageCode: String?);
Example Implementation:
public class CheckoutActivity extends AppCompatActivity {
protected void onTextMessageOptedIn(givenPhoneNumber: String, selectedLanguage: String?) {
if (selectedLanguage == "french"){
Wunderkind.getInstance().trackTextOptIn(phoneNumber: givenPhoneNumber, languageCode: "fr")
}
else {
Wunderkind.getInstance().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.getInstance().setLogLevel(LogLevel.DEBUG);
Setting logLevel
property to none
will allow you to disable logging.
Wunderkind.getInstance().setLogLevel(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(val options: [String],
val isRentalOneWay: Bool,
val details: RentalDetails,
val request: CarRentalRequest,
val account: RentalAccount
)
Example:
CarRentalProgress(["chrysler_pacifica_or_similar", "chevrolet_suburban_or_similar", "toyota_camry_or_similar"],
false,
RentalDetails,
CarRentalRequest
RentalAccount
)
5.2 Car Rental Add To Cart
CarRentalAddToCart(val selectedOption: String,
val isRentalOneWay: Bool,
val details: RentalDetails,
val request: CarRentalRequest,
val account: RentalAccount
)
Example:
CarRentalAddToCart("chrysler_pacifica_or_similar",
false,
RentalDetails,
CarRentalRequest,
RentalAccount
)
5.3 Rental Details
RentalDetails(val ancillaryItems: Bool,
val stepNumber: Int?,
val travelersCount: Int?,
val title: String?,
val url: URL
)
Example:
RentalDetails(
false,
3,
6,
"extras",
url
)
5.4 Car Rental Request
CarRentalRequest(val carCode: String?,
val startLocation: RentalLocation,
val dropOffLocation: RentalLocation?,
val startTimestamp: TimeInterval,
val endTimestamp: TimeInterval
)
Example:
fun calculateFutureTimestamp(currentTime: Long, hoursToAdd: Int): Timestamp {
val calendar = Calendar.getInstance()
calendar.timeInMillis = currentTime
calendar.add(Calendar.HOUR_OF_DAY, hoursToAdd)
return Timestamp(calendar.time.time)
}
val start = calculateFutureTimestamp(1702821600, 0)
val end = calculateFutureTimestamp(1703685600, 0)
var rentalLocation = RentalLocation("YNG", "Youngstown Municipal Airport, Vienna, OH, US-(YNG)")
CarRentalRequest(
start,
end,
rentalLocation,
"F"
)
5.5 Rental Account
RentalAccount(val accountType: AccountType,
val affiliateNumber: String?,
val countryOfResidence: String?,
val age: Decimal
)
5.6 Rental Location
RentalLocation(val title: String, val code: String)
Example:
RentalLocation("YNG", "Youngstown Municipal Airport, Vienna, OH, US-(YNG)")
5.7 Invoice
Invoice(
val amount: Double,
val tax: Double,
val shipping: Double,
val totalDiscount: Double?,
val 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, iftotalDiscount
property is not null, it must be greater than or equal to 0.0.
5.8 Customer
Customer(
val email: String,
val phone: String
)
💬email
, phone
properties are required to be non-empty otherwise this event will not be tracked.
5.9 Product
Product(
val productId: String,
val skuId: String,
val price: Double,
val quantity: Long
)
💬productId
, skuId
properties are required to be non-empty and price
, quantity
properties are required to be greater than or equal to 0 otherwise this event will not be tracked.
5.10 Order
Order(
val orderId: String,
val invoice: Invoice,
val paymentMethod: String?,
val products: List<Product>,
val customer: Customer,
val coupons: List<String>?,
val 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 Currency
enum class Currency {
USD,
KRW,
AED,
LTL,
ARS,
MAD,
AUD,
MXN,
BGN,
MYR,
BOB,
NOK,
BRL,
NZD,
CAD,
PEN,
CHF;
PHP,
CLP,
PKR,
CNY,
PLN,
COP,
RON,
CZK,
RSD,
DKK,
RUB,
EGP,
SAR,
EUR,
SEK,
GBP,
SGD,
HKD,
THB,
HRK,
TRY,
HUF,
TWD,
IDR,
UAH,
ILS,
VEF,
INR,
VND,
JPY,
ZAR
}
5.12 LogLevel
enum class LogLevel {
none,
debug,
info
}
6. Change Log
Version | Release Date | Details |
1.2.0 | 01.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