Skip to content

Commit 70be06d

Browse files
authored
feat: add in readme changes (#13)
1 parent 6d9309f commit 70be06d

File tree

7 files changed

+136
-7
lines changed

7 files changed

+136
-7
lines changed

README.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,43 @@
1-
# mparticle-android-sample-app-internal
2-
This repo contains a Kotlin Android Application that implements and demonstrates the functionality of the mParticle Android SDK.
1+
<img src="https://static.mparticle.com/sdk/mp_logo_black.svg" width="280"><br>
2+
3+
# mParticle Android Sample Apps
4+
5+
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
6+
7+
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.
8+
9+
## Getting Started
10+
11+
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.
12+
13+
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.
14+
15+
**NOTE** These Sample Apps require a mParticle account with an API key.
16+
17+
While the code might run and build without mParticle credentials, the SDKs will not upload events to our servers and will generate errors.
18+
19+
Please visit [our docs](https://docs.mparticle.com/guides/getting-started/create-an-input) for more details on setting up an API Key.
20+
21+
### Sample Apps Directory
22+
23+
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.
24+
25+
| App Name | Path | Description |
26+
| ---------- | -------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
27+
| Higgs Shop | [core-sdk-samples/higgs-shop-sample-app](core-sdk-samples/higgs-shop-sample-app) | An example of an e-commerce application |
28+
29+
## Contributing
30+
31+
Thank you for thinking about contributing to the mParticle Sample Apps Project.
32+
33+
Please review the [CONTRIBUTING.md](CONTRIBUTING.md) file for details.
34+
35+
## Support
36+
37+
38+
39+
## License
40+
41+
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.
42+
43+
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.

core-sdk-samples/higgs-shop-sample-app/README.md

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,87 @@ While the code might run and build without mParticle credentials, the SDKs will
2828

2929
Please visit https://docs.mparticle.com/ for more details on setting up an API Key.
3030

31+
## Events used in this app
32+
33+
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.
34+
35+
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.
36+
37+
### Screen Views
38+
39+
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/).
40+
41+
For example
42+
43+
```kotlin
44+
val screenInfo = HashMap<String, String>()
45+
screenInfo["rating"] = "5"
46+
screenInfo["property_type"] = "hotel"
47+
48+
MParticle.getInstance().logScreen("Destination Details", screenInfo)
49+
```
50+
51+
In some cases, we fire a _Commerce Event_ instead of a _Page View_ to track more e-Commerce related attributes.
52+
53+
### Custom Events
54+
55+
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.
56+
57+
Many of our components in `/src/components` make use of these events, particularly the `NavigationMenuItem` Component.
58+
59+
### Commerce Events
60+
61+
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/).
62+
63+
Some events used in this application:
64+
65+
- Add To Cart
66+
- Remove From Cart
67+
- Product Detail
68+
- Product Impression
69+
- Checkout
70+
- Purchase
71+
72+
Most _Commerce Events_ follow a similar pattern, requiring that you first generate an **mParticle Product** Object, which then gets passed into the `logEvent` method.
73+
74+
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.
75+
76+
```kotlin
77+
// 1. Create the products
78+
val product = Product.Builder("Double Room - Econ Rate", "econ-1", 100.00)
79+
.quantity(4.0)
80+
.build()
81+
82+
// 2. Summarize the transaction
83+
val attributes = TransactionAttributes("foo-transaction-id")
84+
.setRevenue(430.00)
85+
.setTax(30.00)
86+
87+
// 3. Log the purchase event
88+
val event = CommerceEvent.Builder(Product.PURCHASE, product)
89+
.transactionAttributes(attributes)
90+
.build()
91+
MParticle.getInstance().logEvent(event)
92+
```
93+
94+
## Discovering Events
95+
96+
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.
97+
98+
### Live Stream
99+
100+
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/).
101+
102+
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).
103+
104+
## Development Notes
105+
106+
This project is built in Kotlin and follows MVVM design patterns and uses Retrofit (networking), Room (ORM/database), and Glide (image loading)
107+
31108
## Support
32109

33110
34111

35112
## License
36113

37-
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.
114+
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.

core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/activities/LandingActivity.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ class LandingActivity : AppCompatActivity() {
2323
setContentView(R.layout.activity_landing)
2424
MParticle.getInstance()?.logScreen("Landing")
2525

26+
val btnCTA = findViewById(R.id.landing_cta) as Button
2627
if(hasApiKey()) {
27-
val btnCTA = findViewById(R.id.landing_cta) as Button
28+
btnCTA.isClickable = true
29+
btnCTA.alpha = 1.0F
2830
btnCTA.setOnClickListener {
2931
val event = MPEvent.Builder("Landing Button Click", MParticle.EventType.Other)
3032
.build()
@@ -33,6 +35,8 @@ class LandingActivity : AppCompatActivity() {
3335
startActivity(intent)
3436
}
3537
} else {
38+
btnCTA.isClickable = false
39+
btnCTA.alpha = 0.3F
3640
showBlankAPIKeyAlert()
3741
}
3842
}

core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/fragments/AccountFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ class AccountFragment : Fragment() {
6262
false -> {
6363
//no user so login
6464
val identityRequest = IdentityApiRequest.withEmptyUser()
65-
.email("higgs@example.com")
66-
.customerId("123456")
65+
.email("higgs@mparticle.com")
66+
.customerId("higgs123456")
6767
.build()
6868
MParticle.getInstance()?.Identity()?.login(identityRequest)?.addSuccessListener {
6969
accountViewModel.login()
Binary file not shown.

core-sdk-samples/higgs-shop-sample-app/app/src/main/res/layout/fragment_account.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
android:text="@string/account_title"
1818
android:textColor="@color/white"
1919
android:textStyle="bold"
20+
android:fontFamily="@font/lato_regular"
2021
android:textSize="24sp"
2122
/>
2223
<com.google.android.material.textfield.TextInputLayout
@@ -54,7 +55,7 @@
5455
android:layout_height="wrap_content"
5556
android:text="@string/account_disclaimer"
5657
android:textColor="@color/white"
57-
app:fontFamily="sans-serif"
58+
app:fontFamily="@font/lato_regular"
5859
android:alpha=".6"
5960
android:gravity="center"
6061
android:layout_marginBottom="100dp"

core-sdk-samples/higgs-shop-sample-app/app/src/main/res/values/themes.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,27 @@
1010
<item name="colorSecondaryVariant">@color/gray_999999</item>
1111
<!-- Status bar color. -->
1212
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
13+
<item name="android:fontFamily">@font/lato_regular</item>
1314
</style>
1415

1516
<!-- Splash/Landing theme -->
1617
<style name="Theme.mParticle.SampleApp.Splash" parent="Theme.AppCompat.NoActionBar">
1718
<item name="android:windowBackground">@drawable/background_gradient</item>
1819
<item name="android:windowIsTranslucent">true</item>
20+
<item name="android:fontFamily">@font/lato_regular</item>
1921
</style>
2022

2123
<!-- Button theme -->
2224
<style name="Theme.mParticle.SampleApp.Button">
2325
<item name="colorPrimary">@color/blue_4079FE</item>
2426
<item name="colorOnPrimary">@color/white</item>
2527
<item name="android:textColor">@color/white</item>
28+
<item name="android:fontFamily">@font/lato_regular</item>
2629
</style>
2730

2831
<!-- TextInputLayout theme -->
2932
<style name="Theme.mParticle.SampleApp.TextInputLayout" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
33+
<item name="android:fontFamily">@font/lato_regular</item>
3034
<item name="android:textColorHint">@color/white</item>
3135
<item name="android:textColor">@color/white</item>
3236
<item name="android:textSize">16sp</item>
@@ -48,6 +52,7 @@
4852

4953
<style name="TextAppearance.AppTheme.TextInputLayout.HintTextAlt" parent="TextAppearance.MaterialComponents.Subtitle2">
5054
<item name="android:textColor">@color/white</item>
55+
<item name="android:fontFamily">@font/lato_regular</item>
5156
</style>
5257

5358
<!-- TextInputEditText theme -->
@@ -81,6 +86,7 @@
8186
<item name="android:paddingEnd">15dp</item>
8287
<item name="android:textColor">@color/white</item>
8388
<item name="android:textSize">16sp</item>
89+
<item name="android:fontFamily">@font/lato_regular</item>
8490
</style>
8591

8692

0 commit comments

Comments
 (0)