-
Notifications
You must be signed in to change notification settings - Fork 61
Kit Development
This guide is meant for integration partners who would like add their own SDK or functionality to the mParticle platform. mParticle integrates with over 100 partners in the mobile app ecosystem, and each integration is unique. Whereas most integrations are via our Firehose API, or developed internally for the server-side, the mParticle mobile SDKs are designed to be extensible in the form of "kits" for client-side integrations.
The mParticle Core iOS and Android SDKs are responsible for detecting, initializing, and forwarding data to the kit framework. By default, the Core SDK dependency does not include any kits - each desired kit must be specified as an additional dependency. The kit framework allows you to hook into and listen for mParticle's public APIs as well as crucial application lifecycle events. It's the responsibility of the kit implementation to then map those APIs onto the respective partner APIs. Kits will often include a 3rd-party SDK, or they might just contain a bit of additional functionality.
At runtime, the Core SDKs will receive configuration from the mParticle server, instructing it of which kits it should initialize. In a typical scenario whereby a kit wraps/embeds a 3rd-party SDK, the configuration will include a map of settings, including the API key/credentials that the given SDK needs in order to be initialized. Customers use the mParticle platform UI to enable kits and input their credentials.
In order to build and iterate on your kit, there are a few steps to get the Core SDK and your Kit integrated:
- On Github.com:
- Fork the Core repository: https://github.com/mParticle/mparticle-android-sdk
- Fork the Example Kit repository: https://github.com/mparticle-integrations/mparticle-android-integration-example
-
Clone your fork of the core SDK, and create a branch for your changes:
git clone [email protected]:MYORGANIZATION/mparticle-android-sdk.git cd mparticle-android-sdk/ git checkout -b add-my-company
-
Add your fork of the Example Kit as a submodule to the Core repository:
git submodule add [email protected]:MYORGANIZATION/mparticle-android-integration-example.git kits/COMPANYNAME-kit
-
Edit
./settings-kits.gradle
, adding your kit to the Gradle project:include ( ':kits:COMPANYNAME-kit', ... ) ...
-
Edit the
ServiceProviders
interface in ./android-core/src/main/java/com/mparticle/MParticle.java, adding your kit name and ID as a new constant. -
Edit
KitIntegrationFactory#getKnownIntegrations()
in ./android-kit-base/src/main/java/com/mparticle/kits/KitIntegrationFactory.java, using the newServiceProviders
constant you defined above, and specify the fully-qualified class name if your kit implementation.
-
Deploy your new version of the Core and your kit to your local Maven repository:
./gradlew uploadArchives # deploy the core ./gradlew uploadArchives -c settings-kits.gradle # deploy the kits
-
In a test app, add
mavenLocal()
to therepositories
closure of your build.gradle, abovemavenCentral()
and/orjCenter()
-
Add the kit you deployed to the
dependencies
of your app:dependencies { compile 'com.mparticle:android-COMPANYNAME-kit:4+' }
-
Follow the quick-start guide of the SDK to perform a basic instrumentation of mParticle, using the application key and secret provided to you by mParticle.
You'll want to edit the following files to be specific to your implementation:
-
./build.gradle
to add any necessary dependencies, such as your company's SDK. -
.src/main/java/com/mparticle/kits/ExampleKit.java
- this is where your primary implementation belongs.- Choose the additional interfaces that you need and have this class implement them. See below.
./README.md
./src/main/AndroidManifest.xml
./consumer-proguard.pro
The core of your implementation will live in ExampleKit.java
(renamed for your company). This file must be a subclass of the KitIntegration
class which is made available by the mParticle kit framework. This class provides additional interfaces that you must implement depending on the type of data that your kit can process:
Kits should implement this interface when they require Activity callbacks for any reason.
Kits should implement this interface when their underlying service has the notion of a user with attributes.
Kits should implement this interface in order to listen for eCommerce events.
Kits should implement this listener to ensure they receive events as they are sent into the mParticle SDK.
Kits should implement this interface when they have Google Cloud Messaging/push features.
See the javadocs for more information on the KitIntegration
class and its interfaces.
- Submit a pull request into the kit example repository.
- When ready, an mParticle engineer will create a new repository for your kit and push the code there.