New in CUX: Mobile Analytics. Analyze real user behavior inside your app. Learn More

Control Android collection and mask content

Control Android collection and mask content

Browse topics

On this page

Control when CUX collects data and which content appears in screenshots. Set this up before you use customer data, then check it on the screens your app actually displays.

Applies to native Android SDK 1.2.0.

Wait before starting collection

If your app requires consent before analytics collection, add the waiting option to your existing initializer:

import io.cux.analytics_sdk.CuxAnalytics
import io.cux.analytics_sdk.logger.CuxLogLevel

CuxAnalytics.init(
    context = application,
    token = "YOUR_MOBILE_PROJECT_TOKEN",
    logLevel = CuxLogLevel.Production,
    needConfirmToStart = true
)

application is your Application instance. Keep one initialization call. Do not initialize with immediate collection and then stop it to simulate a waiting state.

Control data collection

After your app obtains consent, resume collection:

CuxAnalytics.resumeCollectingData()

When the user withdraws consent, stop collection:

CuxAnalytics.stopCollectingData()

You can check the SDK's collection state with CuxAnalytics.isCollectingData(). This reports local collection state, not whether a visit has arrived in CUX.

Keep your app's consent state consistent across launches. Deciding when consent is required remains part of your app's implementation.

Hide sensitive content from screenshots

For an existing Android View, register a mask:

CuxAnalytics.maskView(accountBalanceView)

accountBalanceView is the actual View containing the sensitive content. Register it before that content can be captured.

The SDK masks EditText fields automatically. Check other places where sensitive information appears, including labels, images, confirmations and custom inputs. Automatic input handling is not a guarantee that your whole screen is safe to record.

Mask Jetpack Compose content

Add maskElement() to the relevant composable:

import io.cux.analytics_sdk.composable.maskElement

Text(
    text = accountBalance,
    modifier = Modifier.maskElement()
)

Text and Modifier use your existing Compose imports; accountBalance is the value displayed by your app. Mask a larger region when that is easier to keep correct across changing content or layout.

If the same component needs a stable analytics tag, use maskAndMonitorElement("account_balance"). Keep the tag free of customer data.

Review non-visual data too

Masks affect screenshots. They do not remove data you explicitly send through user properties, custom events or screen labels.

Use an internal ID rather than an email address. Keep names, addresses, payment details and navigation arguments out of analytics labels and parameters.

For WebView, check mobile masking and the web collector's masking separately. Follow Connect Android WebView.

Verify privacy controls

  1. Start the app with collection waiting for consent. Run a test journey and check the expected collection behavior.
  2. Give consent and run the journey again.
  3. Inspect sensitive screens in the resulting screenshots.
  4. Scroll, rotate, open overlays and return to screens with reused content. Check their masks again.
  5. Withdraw consent and confirm collection stops as intended.
  6. Review user properties, labels and custom events for accidental personal data.

Use synthetic test values. If sensitive content appears, correct the integration before using customer data. Continue with Mobile masking and privacy.