You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Copy file name to clipboardExpand all lines: core-sdk-samples/higgs-shop-sample-app/README.md
+78-1Lines changed: 78 additions & 1 deletion
Display the source diff
Display the rich diff
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
28
28
29
29
Please visit https://docs.mparticle.com/ for more details on setting up an API Key.
30
30
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/).
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)
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.
Copy file name to clipboardExpand all lines: core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/activities/LandingActivity.kt
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -23,8 +23,10 @@ class LandingActivity : AppCompatActivity() {
23
23
setContentView(R.layout.activity_landing)
24
24
MParticle.getInstance()?.logScreen("Landing")
25
25
26
+
val btnCTA = findViewById(R.id.landing_cta) asButton
26
27
if(hasApiKey()) {
27
-
val btnCTA = findViewById(R.id.landing_cta) asButton
28
+
btnCTA.isClickable =true
29
+
btnCTA.alpha =1.0F
28
30
btnCTA.setOnClickListener {
29
31
val event =MPEvent.Builder("Landing Button Click", MParticle.EventType.Other)
30
32
.build()
@@ -33,6 +35,8 @@ class LandingActivity : AppCompatActivity() {
Copy file name to clipboardExpand all lines: core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/fragments/AccountFragment.kt
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -62,8 +62,8 @@ class AccountFragment : Fragment() {
62
62
false-> {
63
63
//no user so login
64
64
val identityRequest =IdentityApiRequest.withEmptyUser()
0 commit comments