-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d9309f
commit 70be06d
Showing
7 changed files
with
136 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,43 @@ | ||
# mparticle-android-sample-app-internal | ||
This repo contains a Kotlin Android Application that implements and demonstrates the functionality of the mParticle Android SDK. | ||
<img src="https://static.mparticle.com/sdk/mp_logo_black.svg" width="280"><br> | ||
|
||
# mParticle Android Sample Apps | ||
|
||
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) | ||
|
||
Hello! This is the mParticle Android Sample Apps Repository. We've built a collection of fully functional sample apps that provide a best practice approach to integrate with our [mParticle Android SDK](https://github.com/mparticle/mparticle-android-sdk) and other services we provide. | ||
|
||
## Getting Started | ||
|
||
This repository serves as directory of individual, self-contained, Sample Apps. Each application is a full project with working code, detailed implementation documentation and an integrated CI/CD pipeline via Github Actions. | ||
|
||
Our recommenation is to fork or download the entire repository and open a specific project in Android Studio or editor of choice. This will provide full project settings, including linting. | ||
|
||
**NOTE** These Sample Apps require a mParticle account with an API key. | ||
|
||
While the code might run and build without mParticle credentials, the SDKs will not upload events to our servers and will generate errors. | ||
|
||
Please visit [our docs](https://docs.mparticle.com/guides/getting-started/create-an-input) for more details on setting up an API Key. | ||
|
||
### Sample Apps Directory | ||
|
||
Below is a list of sample apps, with a brief description of their intended use case. Please navigate to an individual Sample App's README.md file for specific use cases and implementation details. | ||
|
||
| App Name | Path | Description | | ||
| ---------- | -------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | | ||
| Higgs Shop | [core-sdk-samples/higgs-shop-sample-app](core-sdk-samples/higgs-shop-sample-app) | An example of an e-commerce application | | ||
|
||
## Contributing | ||
|
||
Thank you for thinking about contributing to the mParticle Sample Apps Project. | ||
|
||
Please review the [CONTRIBUTING.md](CONTRIBUTING.md) file for details. | ||
|
||
## Support | ||
|
||
<[email protected]> | ||
|
||
## License | ||
|
||
The mParticle Android SDK is available under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0). See the LICENSE file for more info. | ||
|
||
THE MPARTICLE SAMPLE APPS, INCLUDING ANY ASSOCIATED MPARTICLE APIs AND MPARTICLE SDKs, ARE PROVIDED ON AN “AS-IS” BASIS, AND MPARTICLE HEREBY DISCLAIMS ANY AND ALL WARRANTIES OF ANY KIND, WHETHER EXPRESS, IMPLIED (EITHER IN FACT OR BY OPERATION OF LAW), OR STATUTORY, AS TO ANY MATTER WHATSOEVER, INCLUDING, BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUALITY, ACCURACY, TITLE, AND NON-INFRINGEMENT. MPARTICLE DOES NOT WARRANT THAT THE MPARTICLE SAMPLE APP, INCLUDING ANY ASSOCIATED, MPARTICLE SDKs OR MPARTICLE APIs, ARE ERROR-FREE OR THAT OPERATION THEREOF WILL BE SECURE OR UNINTERRUPTED. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,10 +28,87 @@ While the code might run and build without mParticle credentials, the SDKs will | |
|
||
Please visit https://docs.mparticle.com/ for more details on setting up an API Key. | ||
|
||
## Events used in this app | ||
|
||
To make things simple yet declarative, this application has been built in such a way to keep event tracking close to the components that might logically trigger them rather than a fully DRY implementation. We've opted to be more repetitive so examples are consise and documented as necessary. | ||
|
||
Please feel free to also visit our [Doc Site](https://docs.mparticle.com/) to gain more familiarity with some of the more advanced features of mParticle. | ||
|
||
### Screen Views | ||
|
||
In cases where it is necessary to track visitors as they navigate your Android Application, mParticle offers [Screen View Tracking](https://docs.mparticle.com/developers/sdk/android/screen-tracking/). | ||
|
||
For example | ||
|
||
```kotlin | ||
val screenInfo = HashMap<String, String>() | ||
screenInfo["rating"] = "5" | ||
screenInfo["property_type"] = "hotel" | ||
|
||
MParticle.getInstance().logScreen("Destination Details", screenInfo) | ||
``` | ||
|
||
In some cases, we fire a _Commerce Event_ instead of a _Page View_ to track more e-Commerce related attributes. | ||
|
||
### Custom Events | ||
|
||
Most often, you will need to use [Custom Events](https://docs.mparticle.com/developers/sdk/android/event-tracking/#custom-events) to track events in a way that is unique to your use case. mParticle provides types of _Custom Events_ ranging from Navigation Events to Social Media Engagement and are mostly used to organize your data in a way that makes sense to you. | ||
|
||
Many of our components in `/src/components` make use of these events, particularly the `NavigationMenuItem` Component. | ||
|
||
### Commerce Events | ||
|
||
This Sample App emulates a simple e-Commerce application and makes heavy use of mParticle's [Commerce Events](https://docs.mparticle.com/developers/sdk/android/commerce-tracking/). | ||
|
||
Some events used in this application: | ||
|
||
- Add To Cart | ||
- Remove From Cart | ||
- Product Detail | ||
- Product Impression | ||
- Checkout | ||
- Purchase | ||
|
||
Most _Commerce Events_ follow a similar pattern, requiring that you first generate an **mParticle Product** Object, which then gets passed into the `logEvent` method. | ||
|
||
You should map your own product attributes to be consistent with your [Data Plan](https://docs.mparticle.com/guides/data-master/introduction/) if you are leveraging that feature. Using Data Plans ensures data consistency within an app and across devices. | ||
|
||
```kotlin | ||
// 1. Create the products | ||
val product = Product.Builder("Double Room - Econ Rate", "econ-1", 100.00) | ||
.quantity(4.0) | ||
.build() | ||
|
||
// 2. Summarize the transaction | ||
val attributes = TransactionAttributes("foo-transaction-id") | ||
.setRevenue(430.00) | ||
.setTax(30.00) | ||
|
||
// 3. Log the purchase event | ||
val event = CommerceEvent.Builder(Product.PURCHASE, product) | ||
.transactionAttributes(attributes) | ||
.build() | ||
MParticle.getInstance().logEvent(event) | ||
``` | ||
|
||
## Discovering Events | ||
|
||
As a developer, sometimes the best way to learn is to just dig into the code or your debugging tools. To that end, this sample app ships with a verbose logger that you can view details of what our SDK is doing within Android Studio's logcat. | ||
|
||
### Live Stream | ||
|
||
To verify that your events have arrived at mParticle's servers, or to compare your Android Events from that of our other SDKs, you can also visit our [Live Stream](https://docs.mparticle.com/guides/platform-guide/live-stream/). | ||
|
||
This will not only show your data as it enters mParticle, but also as your data is forwarded to our various partner services and integrations (if enabled). | ||
|
||
## Development Notes | ||
|
||
This project is built in Kotlin and follows MVVM design patterns and uses Retrofit (networking), Room (ORM/database), and Glide (image loading) | ||
|
||
## Support | ||
|
||
<[email protected]> | ||
|
||
## License | ||
|
||
The mParticle Web SDK is available under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0). See the LICENSE file for more info. | ||
The mParticle Android SDK is available under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0). See the LICENSE file for more info. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+73.4 KB
core-sdk-samples/higgs-shop-sample-app/app/src/main/res/font/lato_regular.ttf
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters