Set custom attribute
Custom Attributes is a feature that allows you to configure your desired Key-Value format data for your Capture’s Screenshot feature. By configuring Key-Value data via DeployGate SDK, you can save Captures linked with that Key-Value data. This feature allows developers to specify the data they want to collect when errors occur, which improves feedback quality.
System Requirements
The Custom Attributes feature requires to use a specific version or later of the DeployGate Android Client App and the DeployGate SDK. The required version varies depending on the feature you want to use.
Feature | Android Client App Version | DeployGate SDK Version |
---|---|---|
Screenshot Feature | v1.17.0 or later | v4.8.0 or later |
Replay Feature | v1.20.1 or later | v4.8.0 or later |
Enabling
Custom Attributes can be enabled from DeployGate SDK’s DeployGate.getRuntimeExtra()
or DeployGate.getBuildEnvironment()
.
CustomAttributes buildEnvironmentAttrs = DeployGate.getBuildEnvironment();
// BuildConfig.BUILD_TYPE -> release
buildEnvironmentAttrs.putString("build_type", BuildConfig.BUILD_TYPE);
// BuildConfig.FLAVOR -> devreal
buildEnvironmentAttrs.putString("flavor", BuildConfig.FLAVOR);
CustomAttributes runtimeExtraAttrs = DeployGate.getRuntimeExtra();
runtimeExtraAttrs.putString("string", "value");
runtimeExtraAttrs.putInt("int", 123);
runtimeExtraAttrs.putBoolean("boolean", true);
runtimeExtraAttrs.putFloat("float", 1.23f);
runtimeExtraAttrs.putDouble("double", 1.23);
runtimeExtraAttrs.putLong("long", 123L);
Deleting
You can delete saved values at any time.
CustomAttributes attrs = DeployGate.getRuntimeExtra(); // もしくは DeployGate.getBuildEnvironment();
// Set values
attrs.putString("string", "value");
// Delete values
attrs.remove("string");
attrs.removeAll();
## Other Limitations
Other Limitations
For more information about limitations and specifications, please visit the DeployGate [Android SDK Document](./../../developer-tools/android-sdk/index.md).
## How to Use
If you have a simple E-commerce app that allows users to log in and shop, you might want to identify the circumstances surrounding a specific error or event to help with the QA process. For example, knowing which user encountered a problem, their membership status, and which product they were viewing could help you to find an issue’s cause.
You can use `DeployGate.getRuntimeExtra();` to specify Custom Attributes, like these variables. You can incorporate the following code into your app so that login_user_id、last_access_item_id, and user_rank are associated with saved Captures.
```java
CustomAttributes attrs = DeployGate.getRuntimeExtra();
attrs.putInt("login_user_id", 123);
attrs.putInt("last_access_item_id", 456);
attrs.putString("user_rank", "Premium");
Other information can also help diagnose errors, such as an app running in a production, test, or development environment. When saving static values, such as build environments, please use DeployGate.getBuildEnvironment();
to enable Custom Attributes.
CustomAttributes attrs = DeployGate.getBuildEnvironment();
attrs.putString("build_type", BuildConfig.BUILD_TYPE); // Release
attrs.putString("flavor", BuildConfig.FLAVOR); // Staging
attrs.putString("api_endpoint", BuildConfig.API_ENDPOINT); // https://staging.example.com/api
These examples illustrate how Custom Attributes can add crucial information to Captures and aid with debugging and error investigations.