#docs #guides #Setup #Flutter #Dart
Flutter Setup Guide
You have an account, and you have an app ID. Now let's include the TelemetryClient Package in your Flutter application
Prerequisites
- You’ll need a TelemetryDeck account. Sign up for free if you don’t have one yet.
- You’ll need a TelemetryDeck App ID. Create a new app if you don’t have one yet.
- Follow the installing instructions on pub.dev.
Initialization
Initialize the TelemetryClient like so:
void main() {
// ensure the platform channels are available
WidgetsFlutterBinding.ensureInitialized();
// configure and start the client
Telemetrydecksdk.start(
const TelemetryManagerConfiguration(
appID: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
),
);
runApp(const MyApp());
}
Permission for internet access
Sending signals requires access to the internet so the following permissions should be granted. You can also take this from Flutter’s Cross-platform HTTP networking guide.
Android
Change the app’s AndroidManifest.xml
to include:
<uses-permission android:name="android.permission.INTERNET" />
macOS
Set the com.apple.security.network.client
entitlement to true
in the macos/Runner/DebugProfile.entitlements
and macos/Runner/Release.entitlements
files. You can also do this in Xcode by selecting the macos
target, then the Signing & Capabilities
tab, and checking Outgoing connections (Client)
for both the Release and Debug targets of your app.
Sending signals
Send a signal using the following method:
Telemetrydecksdk.send("signal_type")
Signals with additional attributes
Append any number of custom attributes to a signal:
Telemetrydecksdk.send("signal_type",
additionalPayload: {"attributeName": "value"});
}
Stop sending signals
Prevent signals from being sent using the stop method:
Telemetrydecksdk.stop()
In order to restart sending events, you will need to call the start
method again.
Test mode
If your app’s build configuration is set to “Debug”, all signals sent will be marked as testing signals. In the Telemetry Viewer app, activate Test Mode to see those.
If you want to manually control whether test mode is active, you can set the testMode
field:
Telemetrydecksdk.start(TelemetryManagerConfiguration(
appID: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
testMode: true));
Custom Server
A tiny subset of our customers will want to use a custom signal ingestion server or a custom proxy server. To do so, you can pass the URL of the custom server to the TelemetryManagerConfiguration
:
Telemetrydecksdk.start(TelemetryManagerConfiguration(
appID: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
apiBaseURL: "https://nom.telemetrydeck.com"));
Logging output
By default, some logs helpful for monitoring TelemetryDeck are printed out to the native console of each platform. You can enable additional logs by setting the debug
field to true
:
void main() {
Telemetrydecksdk.start(TelemetryManagerConfiguration(
appID: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
debug: true));
}
For more advanced configuration options, programmatic usage and information about signals, parameters and all other aspects of the SDK, check out the README file.