Skip to content

Commit 4f0c481

Browse files
authored
feat: Migrate OneTrust kit (#672)
* feat: migrate onetrust-kit from submodule to regular directory * feat: relocate onetrust-kit to kits/onetrust/onetrust-5 Made-with: Cursor * feat: add onetrust-5 to settings-kits.gradle Made-with: Cursor * fix: use version 202411 from OneTrust SDK dependency (com.onetrust.cmp:native-sdk:202411.2.0.0) Made-with: Cursor * fix: OneTrust kit uses path without version (kits/onetrust/onetrust) Made-with: Cursor * Add nosemgrep to onetrust gradlew to fix Semgrep CI Made-with: Cursor * disable AVD cache because of the issues in CI
1 parent a661266 commit 4f0c481

21 files changed

Lines changed: 751 additions & 22 deletions

.github/workflows/instrumented-tests.yml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,30 +40,17 @@ jobs:
4040
java-version: "17"
4141
- name: Gradle cache
4242
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a #v2.9.0
43-
- name: AVD cache
44-
uses: actions/cache@v5
45-
id: avd-cache
46-
with:
47-
path: |
48-
~/.android/avd/*
49-
~/.android/adb*
50-
key: avd-29
51-
- name: create AVD and generate snapshot for caching
52-
if: steps.avd-cache.outputs.cache-hit != 'true'
53-
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b #v2.35.0
54-
with:
55-
api-level: 28
56-
force-avd-creation: false
57-
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
58-
disable-animations: false
59-
script: echo "Generated AVD snapshot for caching."
43+
# AVD cache disabled: causes indefinite hangs on emulator shutdown (see
44+
# ReactiveCircus/android-emulator-runner#373, #385, #362; WordPress/gutenberg#66771)
6045
- name: Enable KVM group perms
6146
run: |
6247
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
6348
sudo udevadm control --reload-rules
6449
sudo udevadm trigger --name-match=kvm
6550
- name: "Run Instrumented Tests (${{ inputs.display_name }})"
6651
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b #v2.35.0
52+
env:
53+
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL: 60
6754
with:
6855
api-level: 28
6956
force-avd-creation: false

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
[submodule "kits/foresee-kit"]
1414
path = kits/foresee-kit
1515
url = git@github.com:mparticle-integrations/mparticle-android-integration-foresee.git
16-
[submodule "kits/onetrust-kit"]
17-
path = kits/onetrust-kit
18-
url = git@github.com:mparticle-integrations/mparticle-android-integration-onetrust.git
1916
[submodule "kits/pilgrim-kit"]
2017
path = kits/pilgrim-kit
2118
url = git@github.com:mparticle-integrations/mparticle-android-integration-pilgrim.git

.trunk/trunk.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ lint:
8383
- kits/kochava/kochava-5/**
8484
- kits/leanplum/leanplum-7/**
8585
- kits/localytics/localytics-6/**
86+
- kits/onetrust/onetrust/**
8687
- kits/optimizely/optimizely-3/**
8788
- kits/radar/radar-3/**
8889
- kits/rokt/rokt/**

kits/onetrust-kit

Lines changed: 0 additions & 1 deletion
This file was deleted.

kits/onetrust/onetrust/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## OneTrust Kit Integration
2+
3+
[See here for more information](https://github.com/mParticle/mparticle-android-sdk/wiki/Kit-Development) on how to use this example to write a new kit.
4+
5+
This repository contains the [OneTrust](https://www.onetrust.com) integration for the [mParticle Android SDK](https://github.com/mParticle/mparticle-android-sdk).
6+
7+
### Adding the integration
8+
9+
1. Add the kit dependency to your app's build.gradle:
10+
11+
```groovy
12+
dependencies {
13+
implementation 'com.mparticle:android-onetrust-kit:5+'
14+
// Implement the SDK version that corresponds to the published version you're using'
15+
implementation 'com.onetrust.cmp:native-sdk:X.X.0.0'
16+
17+
// Example:
18+
implementation 'com.onetrust.cmp:native-sdk:202308.1.0.0'
19+
}
20+
}
21+
```
22+
_Note: OneTrust is unique in their versioning and in that you must specify your version used from a constrained list in their UI. This necessitates that we cannot pin the version of the OneTrust SDK in this kit. Therefore you must pin the correct version in the build.gradle file of your application. For more information on this checkout this [OneTrust Guide for Adding the SDK to an Android App](https://developer.onetrust.com/onetrust/docs/adding-sdk-to-app-android)_
23+
24+
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 `"<REPLACE ME> detected"` in the output of `adb logcat`.
25+
3. Reference mParticle's integration docs below to enable the integration.
26+
27+
### Documentation
28+
29+
[OneTrust integration](https://docs.mparticle.com/integrations/onetrust/event/)
30+
31+
### License
32+
33+
[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
buildscript {
2+
ext.kotlin_version = '2.0.20'
3+
if (!project.hasProperty('version') || project.version.equals('unspecified')) {
4+
project.version = '+'
5+
}
6+
7+
repositories {
8+
google()
9+
mavenLocal()
10+
mavenCentral()
11+
}
12+
13+
dependencies {
14+
classpath 'com.android.tools.build:gradle:8.1.4'
15+
classpath 'com.mparticle:android-kit-plugin:' + project.version
16+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
17+
}
18+
}
19+
20+
plugins {
21+
id "org.sonarqube" version "3.5.0.2730"
22+
id "org.jlleitschuh.gradle.ktlint" version "13.0.0"
23+
}
24+
25+
sonarqube {
26+
properties {
27+
property "sonar.projectKey", "mparticle-android-integration-onetrust"
28+
property "sonar.organization", "mparticle"
29+
property "sonar.host.url", "https://sonarcloud.io"
30+
}
31+
}
32+
33+
apply plugin: 'org.jlleitschuh.gradle.ktlint'
34+
apply plugin: 'kotlin-android'
35+
apply plugin: 'com.mparticle.kit'
36+
37+
android {
38+
namespace 'com.mparticle.kits.onetrust'
39+
buildFeatures {
40+
buildConfig = true
41+
}
42+
defaultConfig {
43+
minSdkVersion 21
44+
}
45+
compileOptions {
46+
sourceCompatibility JavaVersion.VERSION_17
47+
targetCompatibility JavaVersion.VERSION_17
48+
}
49+
kotlinOptions {
50+
jvmTarget = '17'
51+
}
52+
testOptions {
53+
unitTests.all {
54+
jvmArgs += ['--add-opens', 'java.base/java.lang=ALL-UNNAMED']
55+
}
56+
}
57+
}
58+
59+
dependencies {
60+
testImplementation fileTree(dir: 'libs', include: ['*.jar'])
61+
//note that compileOnly requires kit users to define the dependency themselves
62+
compileOnly 'com.onetrust.cmp:native-sdk:202411.2.0.0'
63+
// Add as testImplementation so tests can load OneTrustKit class
64+
testImplementation 'com.onetrust.cmp:native-sdk:202411.2.0.0'
65+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TODO: Add rules to exclude your SDK classes from proguard in implementing apps
71.8 KB
Loading
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# OneTrust Kit Manual Test Procedure
2+
## Environments
3+
### mParticle Environment
4+
Has a number of purposes configured and, in the connection to the OneTrust output has them mapped to the different categories/purposes and vendors (of all types) in OneTrusts, that are listed in our UI as:
5+
6+
- Purpose Consent mapping
7+
- IAB Vendor Consent Mapping
8+
- Google Vendor Consent Mapping
9+
- General (SDK) Vendor Consent Mapping
10+
11+
##### Sample Configuration
12+
![image](assets/connection-settings.png)
13+
14+
### OneTrust Environment
15+
Has a IAB TCF 2.2 template with a number of purposes and vendors assigned to the application.
16+
17+
Those would be mapped to the mParticle purposes as explained above.
18+
19+
### Testing Process
20+
The kit should be manually tested by following this process:
21+
22+
1. Connect a test application to a testing environment that has been configured as per above in both mParticle and OneTrust.
23+
1. Start the application.
24+
1. Get the OneTrust banner or preference centre centre to show.
25+
1. Accept all purposes and vendors.
26+
1. Ensure a batch is sent from the application i.e. by triggering an event.
27+
1. Verify:
28+
- In the user profile at mParticle, that you can see via Activity > User Activity > [Search the profile] > Information tab, under "Consent and Compliance", all purposes should be consented (Look under "Consented" column, where all configured purposes should have `true`).
29+
1. Get the OneTrust banner or preference centre centre to show.
30+
1. Reject all purposes and vendors.
31+
1. Ensure a batch is sent from the application i.e. by triggering an event.
32+
1. Verify:
33+
- In the user profile at mParticle, that you can see via Activity > User Activity > [Search the profile] > Information tab, under "Consent and Compliance", all purposes should be not consented (Look under "Consented" column, where all configured purposes should have `false`).
34+
1. Get the OneTrust banner or preference centre centre to show.
35+
1. Alternate accepting and rejecting purposes and vendors e.g. accept the first, reject the second, accept the third, reject the fourth, etc.
36+
1. Ensure a batch is sent from the application i.e. by triggering an event.
37+
1. Verify:
38+
- In the user profile at mParticle, that you can see via Activity > User Activity > [Search the profile] > Information tab, under "Consent and Compliance", ensure that all purposes consent state match those set in OneTrust banner or preference centre.
39+
1. Get the OneTrust banner or preference centre centre to show.
40+
1. Toggle the consent state set previously i.e. reject where accepted and accept where rejected.
41+
1. Ensure a batch is sent from the application i.e. by triggering an event.
42+
1. Verify:
43+
- In the user profile at mParticle, that you can see via Activity > User Activity > [Search the profile] > Information tab, under "Consent and Compliance", ensure that all purposes consent state match those set in OneTrust banner or preference centre.
44+
45+
The testing is successfull if the "Verify" steps are all positive.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
android.enableJetifier=true
2+
android.useAndroidX=true
3+
org.gradle.daemon=true
4+
org.gradle.jvmargs=-Xmx2560m

0 commit comments

Comments
 (0)