Privacy and diagnostic consent
Start diagnostics off, save and withdraw consent safely, review collected data and redaction limits, and verify your app's privacy controls.
By NativeWatch Updated
Offer optional diagnostics as an explicit, initially unselected choice. Explain what is collected, why it helps, who receives it and how to withdraw. Keep the app usable when someone declines.
Start with reporting off
Set these values before the SDK boots, using your project's actual key:
NATIVEWATCH_ENABLED=true
NATIVEWATCH_REQUIRE_CONSENT=true
NATIVEWATCH_KEY=nw_your_project_key
NATIVEWATCH_URL=https://native.watch
Fresh native mobile consent is denied. The PHP setting also makes desktop and ordinary browser-preview reporting require a persisted choice. Rebuild the mobile plugin after upgrades; PHP configuration alone cannot update native handlers that start before PHP.
Use NativeWatch::hasConsent() to display the confirmed choice. Do not automatically grant consent at application boot, after login or merely because the user dismissed a dialog.
Save the choice and check the result
Validate the submitted granted field with ['required', 'boolean'] in a Laravel form request. Protect the form with your normal CSRF/session controls and apply the app's authorization rules. In the action handling that validated choice:
use Illuminate\Validation\ValidationException;
use ZXN\NativeWatch\Core\Laravel\NativeWatch;
if (! NativeWatch::setConsent($request->boolean('granted'))) {
throw ValidationException::withMessages([
'granted' => 'Your diagnostic choice could not be saved. Please retry.',
]);
}
Show success only after setConsent() returns true. Pass false for withdrawal. The SDK persists denial before clearing pending reports, user scope and buffered activity. A later grant starts a new consent interval; leftover reports from the previous interval are ineligible for delivery. A request already dispatched cannot be recalled, and previously uploaded data needs a separate deletion or retention process.
The choice belongs to the installation. Decide explicitly how shared devices or account changes affect it. A missing native plugin or failed bridge must remain a visible save failure, not an invented enabled state.
Review the actual payload
Errors can include messages, stack paths, source excerpts, breadcrumbs, release/environment, app and runtime details, and custom context. Activity signals can include request paths, outgoing URLs, slow-query SQL, jobs, cache keys and mail metadata. Each activity entry counts as an event.
send_default_pii is false by default and limits automatic personal fields such as device names. It does not remove identity or content you explicitly attach, and it does not make an event anonymous.
The recursive scrubber redacts values under sensitive keys such as password, token and authorization. It is not a general detector for personal data in exception text, SQL, source code or URLs. Inspect representative test payloads and add application-specific filtering where needed.
Publish the configuration to review these settings:
php artisan vendor:publish --tag=nativewatch-config
Set source_code_lines to 0 to omit PHP source excerpts. Disable unnecessary log breadcrumbs and activity signals through their configuration. Keep local consent/outbox files and CI-uploaded symbols out of public storage and version control.
Match disclosures to collection
Your privacy notice and store declarations should describe the data actually sent, its purpose, recipients and retention. Include third-party SDK behavior. Apple's App Review Guidelines and Google Play's User Data policy explain their disclosure and consent requirements. Assess the rules applicable to your app and audience; a platform permission or a store form does not itself record this SDK's diagnostic choice.
Test refusal and withdrawal
Verify a fresh installation stays off across relaunch. Trigger a development error while denied and confirm no local report is queued. Opt in, capture again and match the received UUID. Then capture offline, withdraw, reconnect and grant again: the earlier event must not arrive. Use offline delivery verification and test save failures as well as the successful path.