atatus_flutter_plugin 1.0.5
atatus_flutter_plugin: ^1.0.5 copied to clipboard
Flutter bindings and tools for utilizing atatus Mobile SDks
example/lib/main.dart
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
// This product includes software developed at Atatus (https://www.atatus.com/).
// Copyright 2016-Present Atatus, Inc.
import 'package:atatus_flutter_plugin/atatus_flutter_plugin.dart';
import 'package:atatus_session_replay/atatus_session_replay.dart';
import 'package:atatus_tracking_http_client/atatus_tracking_http_client.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'backend_traces_screen.dart';
import 'example_app.dart';
void main() async {
await dotenv.load();
final configuration = AtatusConfiguration(
licenseKey: dotenv.get('ATATUS_LICENSE_KEY', fallback: ''),
env: dotenv.get('ATATUS_ENV', fallback: ''),
appName: 'atatus_example',
service: 'com.atatus.example.flutter',
version: '1.2.3',
nativeCrashReportEnabled: true,
serverUrl: dotenv.get('ATATUS_SERVER_URL', fallback: 'http://127.0.0.1:8099'),
uploadFrequency: UploadFrequency.frequent,
batchSize: BatchSize.small,
// Requests to these hosts get tracing headers, linking the app's
// resources to the backend traces (local server via ngrok, or 10.0.2.2
// from an Android emulator).
firstPartyHosts: [backendHost, emulatorBackendHost],
loggingConfiguration: AtatusLoggingConfiguration(),
rumConfiguration: AtatusRumConfiguration(
sessionSamplingRate: 100.0,
traceSampleRate: 100.0,
traceContextInjection: TraceContextInjection.all,
detectLongTasks: true,
reportFlutterPerformance: true,
actionEventMapper: (event) {
if (event.action.target?.name == 'Test Action') {
event.action.target?.name = 'Replaced';
}
return event;
},
)
);
// Tracks dart:io HttpClient requests as RUM resources.
configuration.enableHttpTracking();
// Session Replay masking only images and text inputs; other text and
// touches are recorded as-is.
configuration.enableSessionReplay(
AtatusSessionReplayConfiguration(
replaySampleRate: 100.0,
textAndInputPrivacyLevel: TextAndInputPrivacyLevel.maskAllInputs,
imagePrivacyLevel: ImagePrivacyLevel.maskAll,
touchPrivacyLevel: TouchPrivacyLevel.show,
),
);
// Cleartext makes the native uploader HTTP-only, so enable it only for an
// http:// intake (e.g. a local test server); https:// uploads fail with it.
if (configuration.serverUrl?.startsWith('http://') ?? false) {
configuration.additionalConfig['_atatus.needsClearTextHttp'] = true;
}
final atatusSdk = AtatusSdk.instance;
atatusSdk.sdkVerbosity = CoreLoggerLevel.debug;
AtatusSdk.runApp(configuration, TrackingConsent.granted, () async {
return runApp(const ExampleApp());
});
}