Skip to content

Commit

Permalink
Add clarity initialization in the MainActivity.java (#636)
Browse files Browse the repository at this point in the history
<!-- 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...*
  • Loading branch information
hydraxman committed Jan 25, 2024
1 parent 8313163 commit 324077c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion android_client/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ dependencies {
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.annotation:annotation-jvm:1.6.0'
implementation 'com.microsoft.clarity:clarity:1.3.3'
implementation 'com.microsoft.clarity:clarity:2.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
androidTestImplementation 'androidx.test:runner:1.4.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,17 @@
import android.widget.Switch;
import android.widget.Toast;

import com.microsoft.clarity.Clarity;
import com.microsoft.clarity.ClarityConfig;
import com.microsoft.clarity.models.ApplicationFramework;
import com.microsoft.clarity.models.LogLevel;
import com.microsoft.hydralab.android.client.view.NamedSpinner;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -137,6 +142,23 @@ protected void onCreate(Bundle savedInstanceState) {
mAudioSwitch.setChecked(
PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
.getBoolean(getResources().getResourceEntryName(mAudioSwitch.getId()), false));
initClarity();
}

private void initClarity() {
ClarityConfig config = new ClarityConfig(
"kj0ror1pki",
null, // Default user id
LogLevel.Info,
false, // Disallow metered network usage
true, // Enable web view capturing
Collections.singletonList("*"), // Allowed domains
ApplicationFramework.Native,
Collections.emptyList(),
Collections.emptyList(),
false);

Clarity.initialize(getApplicationContext(), config);
}

@Override
Expand Down

0 comments on commit 324077c

Please sign in to comment.