Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "kits/apteligent-kit"]
path = kits/apteligent-kit
url = git@github.com:mParticle-integrations/mparticle-android-integration-apteligent.git
[submodule "kits/branch-kit"]
path = kits/branch-kit
url = git@github.com:mParticle-integrations/mparticle-android-integration-branch.git
[submodule "kits/button-kit"]
path = kits/button-kit
url = git@github.com:mparticle-integrations/mparticle-android-integration-button.git
Expand Down
4 changes: 4 additions & 0 deletions .mobsf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- "**/src/test/**"
- "**/example/**"
- "**/*-example/**"
- "**/SampleApplication/**"

ignore-rules:
- webview_javascript_interface # Intentional: JS bridge for mParticle WebView SDK; workspace token controls access
Expand All @@ -27,3 +28,6 @@
- android_certificate_pinning
- android_ssl_pinning
- accept_self_signed_certificate
- android_manifest_well_known_assetlinks # Sample apps use third-party domains (e.g. Branch mp-fortune.app.link)
- android_task_hijacking1 # Sample apps; targetSdk in build.gradle
- android_task_hijacking2 # Sample apps; targetSdk in build.gradle
Comment on lines 30 to +33
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add just that kit's test app path to the ignore list?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore-paths in mobsfscan doesn't exclude manifest files from scanning — they're checked separately. So we need to keep the ignore-rules for these three findings.

1 change: 1 addition & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ lint:
- kits/apptentive/apptentive-6/**
- kits/appsflyer/appsflyer-6/**
- kits/apptimize/apptimize-3/**
- kits/branch/branch-5/**
- kits/braze/braze-38/**
- kits/clevertap/clevertap-7/**
- kits/comscore/comscore-6/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal object CustomDataParser {
try {
if (value != null) parseValueGuarded(value) else null
} catch (e: Exception) {
Log.e(LogTag("pParticle"), "Unable to parse value: $value")
Log.e(LogTag("pParticle"), "Unable to parse custom data value")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is intentional. MobSF flagged this as android_kotlin_logging because $value can contain user-provided data

value
}

Expand Down
1 change: 0 additions & 1 deletion kits/branch-kit
Submodule branch-kit deleted from 22f5de
23 changes: 23 additions & 0 deletions kits/branch/branch-5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Branch Kit Integration

This repository contains the [Branch](https://www.branch.io/) integration for the [mParticle Android SDK](https://github.com/mParticle/mparticle-android-sdk).

### Adding the integration

1. Add the kit dependency to your app's build.gradle:

```groovy
dependencies {
implementation 'com.mparticle:android-branch-kit:5+'
}
```
2. Follow the mParticle Android SDK [quick-start](https://github.com/mParticle/mparticle-android-sdk), then rebuild and launch your app, and verify that you see `"Branch Metrics detected"` in the output of `adb logcat`.
3. Reference mParticle's integration docs below to enable the integration.

### Documentation

[Branch integration](https://docs.mparticle.com/integrations/branch-metrics/event/)

### License

[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
9 changes: 9 additions & 0 deletions kits/branch/branch-5/SampleApplication/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
14 changes: 14 additions & 0 deletions kits/branch/branch-5/SampleApplication/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
##mParticle-Branch Example

###Overview

This sample app demonstrates:

• How to use the mParticle and Branch in a simple Android application.

• How to create and share Branch links in your app.

• How to Branch deep links are handled in an app when using branch with mParticle.

• How event tracking is handled in mParticle and Branch.

1 change: 1 addition & 0 deletions kits/branch/branch-5/SampleApplication/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
43 changes: 43 additions & 0 deletions kits/branch/branch-5/SampleApplication/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apply plugin: 'com.android.application'

android {
compileSdk = 34
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.mparticle.branchsample"
minSdk = 25
targetSdk = 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/proguard/androidx-annotations.pro'
exclude 'META-INF/versions/9/module-info.class'
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'com.android.installreferrer:installreferrer:2.2'

// Local project dependency
api project(':local-mParticle-Branch-kit')

// Uncomment below to use published version instead
// implementation 'com.mparticle:android-branch-kit:5+'

testImplementation 'junit:junit:4.13.2'

androidTestImplementation('androidx.test.espresso:espresso-core:3.5.1', {
exclude group: 'androidx.test', module: 'runner'
})
}
16 changes: 16 additions & 0 deletions kits/branch/branch-5/SampleApplication/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.mparticle.branchsample;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.mparticle.branchsample", appContext.getPackageName());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.mparticle.branchsample"
xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:name=".SampleApplication"
android:allowBackup="true"
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity
android:name=".activities.SplashActivity"
android:exported="true"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="mp-fortune.app.link" /> <!-- Custom App link - Live -->
<data android:scheme="https" android:host="mp-fortune.test-app.link" />
</intent-filter>
</activity>

<activity
android:name=".activities.HomeActivity"
android:exported="true"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package com.mparticle.branchsample;

import android.app.Application;

import com.mparticle.AttributionError;
import com.mparticle.AttributionListener;
import com.mparticle.AttributionResult;
import com.mparticle.MParticle;
import com.mparticle.MParticleOptions;

import org.json.JSONObject;

import io.branch.referral.Branch;

public class SampleApplication extends Application implements AttributionListener {

Check warning on line 15 in kits/branch/branch-5/SampleApplication/app/src/main/java/com/mparticle/branchsample/SampleApplication.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

A Singleton implementation was detected. Make sure the use of the Singleton pattern is required and the implementation is the right one for the context.

See more on https://sonarcloud.io/project/issues?id=mParticle_mparticle-android-sdk&issues=AZzZV2CQztpHVdMFfVwL&open=AZzZV2CQztpHVdMFfVwL&pullRequest=666
private IBranchEvents branchEventCallback;
private static SampleApplication instance;

@Override
public void onCreate() {
super.onCreate();
instance = this;

Check failure on line 22 in kits/branch/branch-5/SampleApplication/app/src/main/java/com/mparticle/branchsample/SampleApplication.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the enclosing method "static" or remove this set.

See more on https://sonarcloud.io/project/issues?id=mParticle_mparticle-android-sdk&issues=AZzZV2CQztpHVdMFfVwM&open=AZzZV2CQztpHVdMFfVwM&pullRequest=666
MParticleOptions options = MParticleOptions.builder(this)
.credentials("REPLACE_ME_WITH_API_KEY", "REPLACE_ME_WITH_API_SECRET")
.attributionListener(this)
//Set an instance of AttributionListener
//this instance will continually be called whenever
//there is new attribution/deep linking information.
//It is essentially equivalent to the Branch SDK's BranchReferralInitListener class
//that is passed to the Branch SDK's initSession() API.
.logLevel(MParticle.LogLevel.VERBOSE)
.build();

MParticle.start(options);
}

public static void setBranchEventCallback(IBranchEvents branchEventCallback) {
instance.branchEventCallback = branchEventCallback;
}


/**
* A few typical scenarios where this callback would be invoked:
* <p>
* (1) Base case:
* - User does not tap on a link, and then opens the app (either after a fresh install or not)
* - This block will be invoked with Branch Metrics' response indicating that this user did not tap on a link.
* <p>
* (2) Deferred deep link:
* - User without the app installed taps on a link
* - User is redirected from Branch Metrics to the App Store and installs the app
* - User opens the app
* - This block will be invoked with Branch Metrics' response containing the details of the link
* <p>
* (3) Deep link with app installed:
* - User with the app already installed taps on a link
* - Application opens directly to an Activity via a link click, mParticle forwards the launch URI etc to Branch
* - This callback will be invoked with Branch Metrics' response containing the details of the link
* <p>
* If the user navigates away from the app without killing it, this callback could be invoked several times:
* once for the initial launch, and then again each time the user taps on a link to re-open the app.
*
* <p>
* This method is equivalent to {@link io.branch.referral.Branch#initSession(Branch.BranchReferralInitListener)}.
* This will return deep links params if the app is opened by a link click otherwise a JSONObject with ""+clicked_branch_link = false".
* The below example shows how you can message this to your Activities listening for Branch deep link params.
* </p>
*
* @param attributionResult
**/
@Override
public void onResult(AttributionResult attributionResult) {
//this will be invoked for
if (attributionResult.getServiceProviderId() == MParticle.ServiceProviders.BRANCH_METRICS) {
JSONObject params = attributionResult.getParameters();
// The Branch SDK will return a response for all new session/app opens, even
// if the user did not click a branch link.
// The parameters supported by the Branch SDK are documented here:
// https://github.com/BranchMetrics/android-branch-deep-linking#branch-provided-data-parameters-in-initsession-callback
// For eg:
// if (params.optBoolean("+clicked_branch_link", false)) {

Check warning on line 81 in kits/branch/branch-5/SampleApplication/app/src/main/java/com/mparticle/branchsample/SampleApplication.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=mParticle_mparticle-android-sdk&issues=AZzZV2CQztpHVdMFfVwN&open=AZzZV2CQztpHVdMFfVwN&pullRequest=666
// //handle the Branch link click
// }
if (branchEventCallback != null) {
branchEventCallback.onBranchInitialised(params);
}
}
}

@Override
public void onError(AttributionError attributionError) {
//if the Branch SDK returns an error, it will be surfaced here.
if (branchEventCallback != null) {
branchEventCallback.onBranchInitialised(new JSONObject());
}
}

public interface IBranchEvents {
void onBranchInitialised(JSONObject params);
}
}
Loading
Loading