iOS Instrumentation Instructions
The Kontagent iOS SDK is built on top of our REST API; each user action you wish to track is sent to Kontagent via an API call. As such, it is important for you to also familiarize yourself with our REST API. We recommend that you view the REST API specification as you work through the iOS SDK.
Getting Started
Step 1: Download the SDK. (1.2 MB) . Ensure you have an API key for your application. Refer to Setting Up Your First Application for instructions on setting up your application and finding your API key.
Before sending any calls to Kontagent, you must first start a server session:
[Kontagent startSession: <PROD_API_KEY> mode:kKontagentSDKMode_PRODUCTION];Step 2: Add Kontagent.framework to your project.
Step 3: Add the following options to OTHER_LDFLAGS in Xcode:
framework SystemConfigurationframework CoreDataweak_framework CoreTelephonyweak_framework IOKitforce_load "$(PATH_TO_KONTAGENT)/Kontagent.framework/Kontagent"
Step 4: Add DBModel.xcdatamodeld (from Kontagent.framework/Resources/) to project resources.
Setting Up Your Account and Applications
Create QA and Production Apps
Login to your Kontagent account and create 2 application instances. To create an application, refer to the Adding An Application section in Setting Up Your First Application. Create one application instance for QA and one for Production, naming them similar to the following:
- MyApp - QA
- MyApp - Production
Each of these application instances have a unique API key, which is automatically generated when the application is created. Make note of this API key, as you must specify this key when instrumenting your application. The API key you specify also determines which application instance in Kontagent your data is sent to. During the QA phase, you will want to direct your data to your QA application instance by specifying the QA application API key in your calls. Once you go live, change your calls to use your Production API key to send data to your production application instance.
Test Your Instrumentation
During the instrumentation phase, direct your application to send data to our Test Server. Use the Integration Reports tool to generate a QA of your API calls. To send data to the Test Server, simply point all API calls to the Test Server in the startSession method:
[Kontagent startSession: <QA_API_KEY> mode:kKontagentSDKMode_TEST];The parameter mode defines what server you will be sending data to: Test or Production. You can find all necessary constants in Kontagent/KontagentLibTypes.h, Kontagent/KontagentLib.h, and Kontagent/KontagentLibReturn.h.
To stop a session, call the following:
[Kontagent stopSession];The stopSession method will also save all outstanding messages to device storage before session shutdown.
Once data is sent, you can run integration reports and receive immediate feedback on the validity of your instrumentation. Using these tools to validate your instrumentation will help ensure data integrity when data is sent to our production servers. Please note, you should be using your QA API key when testing your non-production instrumentation.
SDK Logging
If you would like to enable/disable SDK logging, include the appropriate line of code from the following:
[Kontagent enableDebug];[Kontagent disableDebug];View and QA Your Test Data
Once you have validated your instrumentation with our Test Server and would like to view your test data, you must send this data to our Production Server. Change the last parameter in startSession to send data to the Production Server:
[Kontagent startSession: <QA_API_KEY> mode:kKontagentSDKMode_PRODUCTION];You can now view your data (by clicking on MyApp - QA) in the Kontagent Dashboard.
Send Your Production Data to Kontagent
During the testing of your instrumentation, you should have been using your QA application (MyApp - QA). When you are ready to send data to our production servers to view in your production application instance (MyApp - Production), simply change the parameters in startSession to point to the Production Server and production application:
[Kontagent startSession: <PROD_API_KEY> mode:kKontagentSDKMode_PRODUCTION];From this point on, you are live, and Kontagent will update your data on an hourly basis. To view your production data, click on MyApp - Production in the Kontagent Dashboard.
Instrumenting API Calls
As the iOS SDK is built on top of our REST API, all required and optional parameters, as well as any constraints, are synonymous with the REST API specification.
The following examples show instrumentation of a inviteSent and pageRequest call:
[Kontagent inviteSent:10 trackingId:[Kontagent generateUniqueTrackingTag] optionalParams:nil];[Kontagent pageRequest:@"adfads" optionalParams:nil];