Skip to content

Commit 324077c

Browse files
authored
Add clarity initialization in the MainActivity.java (#636)
<!-- Please provide brief information about the PR, what it contains & its purpose, new behaviors after the change. And let us know here if you need any help: https://github.com/microsoft/HydraLab/issues/new --> ## Description <!-- A few words to explain your changes --> We want to leverage clarity to understand the usage data of Hydra Lab client. This can enable data dashboard, error diagnostic, etc. A related update to reflect the change: https://github.com/microsoft/HydraLab/pull/637/files ### Linked GitHub issue ID: # ## Pull Request Checklist <!-- Put an x in the boxes that apply. This is simply a reminder of what we are going to look for before merging your code. --> - [ ] Tests for the changes have been added (for bug fixes / features) - [x] Code compiles correctly with all tests are passed. - [x] I've read the [contributing guide](https://github.com/microsoft/HydraLab/blob/main/CONTRIBUTING.md#making-changes-to-the-code) and followed the recommended practices. - [x] [Wikis](https://github.com/microsoft/HydraLab/wiki) or [README](https://github.com/microsoft/HydraLab/blob/main/README.md) have been reviewed and added / updated if needed (for bug fixes / features) ### Does this introduce a breaking change? *If this introduces a breaking change for Hydra Lab users, please describe the impact and migration path.* - [x] Yes - [ ] No ## How you tested it *Please make sure the change is tested, you can test it by adding UTs, do local test and share the screenshots, etc.* Build and run the app. This integration practice comply with [android-sdk installation](https://learn.microsoft.com/en-us/clarity/mobile-sdk/android-sdk). Please check the type of change your PR introduces: - [ ] Bugfix - [x] Feature - [ ] Technical design - [ ] Build related changes - [ ] Refactoring (no functional changes, no api changes) - [ ] Code style update (formatting, renaming) or Documentation content changes - [ ] Other (please describe): ### Feature UI screenshots or Technical design diagrams *If this is a relatively large or complex change, kick it off by drawing the tech design with PlantUML and explaining why you chose the solution you did and what alternatives you considered, etc...*
1 parent 8313163 commit 324077c

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

android_client/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ dependencies {
6262
implementation 'androidx.core:core-ktx:1.10.1'
6363
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
6464
implementation 'androidx.annotation:annotation-jvm:1.6.0'
65-
implementation 'com.microsoft.clarity:clarity:1.3.3'
65+
implementation 'com.microsoft.clarity:clarity:2.1.1'
6666
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
6767
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
6868
androidTestImplementation 'androidx.test:runner:1.4.0'

android_client/app/src/main/java/com/microsoft/hydralab/android/client/MainActivity.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,17 @@
4343
import android.widget.Switch;
4444
import android.widget.Toast;
4545

46+
import com.microsoft.clarity.Clarity;
47+
import com.microsoft.clarity.ClarityConfig;
48+
import com.microsoft.clarity.models.ApplicationFramework;
49+
import com.microsoft.clarity.models.LogLevel;
4650
import com.microsoft.hydralab.android.client.view.NamedSpinner;
4751

4852
import java.io.File;
4953
import java.text.SimpleDateFormat;
5054
import java.util.ArrayList;
5155
import java.util.Arrays;
56+
import java.util.Collections;
5257
import java.util.Date;
5358
import java.util.List;
5459
import java.util.Locale;
@@ -137,6 +142,23 @@ protected void onCreate(Bundle savedInstanceState) {
137142
mAudioSwitch.setChecked(
138143
PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
139144
.getBoolean(getResources().getResourceEntryName(mAudioSwitch.getId()), false));
145+
initClarity();
146+
}
147+
148+
private void initClarity() {
149+
ClarityConfig config = new ClarityConfig(
150+
"kj0ror1pki",
151+
null, // Default user id
152+
LogLevel.Info,
153+
false, // Disallow metered network usage
154+
true, // Enable web view capturing
155+
Collections.singletonList("*"), // Allowed domains
156+
ApplicationFramework.Native,
157+
Collections.emptyList(),
158+
Collections.emptyList(),
159+
false);
160+
161+
Clarity.initialize(getApplicationContext(), config);
140162
}
141163

142164
@Override

0 commit comments

Comments
 (0)