Verify Flutter SDK 4 events

このページはまだあなたの言語に翻訳されていません。 現在取り組んでいますので、後でもう一度確認してください。

An event moves through four stages between your track() call and Amplitude's servers. Verify each stage in order. The problem is in the first stage where the event looks wrong.

For problems common to every Amplitude SDK, go to SDK troubleshooting and debugging. If behavior changed after an SDK upgrade, check the Flutter SDK 4 release notes.

Turn on debug logging

Set logLevel to LogLevel.debug while you verify. The default, LogLevel.warn, hides the upload messages this page relies on.

dart
import 'package:amplitude_flutter/constants.dart';

final amplitude = Amplitude(Configuration(
  apiKey: 'AMPLITUDE_API_KEY',
  logLevel: LogLevel.debug,
));
await amplitude.isBuilt;
await amplitude.track(BaseEvent('Debug Check'));

Where the messages appear depends on the platform:

Return logLevel to LogLevel.warn before you ship. Debug output includes event payloads and identifiers.

Check what the SDK captured

With debug logging on, the Flutter plugin logs each call it passes to the native SDK on Android, iOS, and macOS:

text
Track track event: {instanceName: $default_instance, event: {event_type: Sign Up Clicked, event_properties: {plan: starter}, ...}}

On Android, the native SDK then logs Logged event with type: Sign Up Clicked.

If neither line appears:

  • Check that you call track() on the instance you created, not a second Amplitude object with a different instanceName.
  • Look for Skip event for opt out config. (Android) or Skip event based on opt out configuration (iOS, macOS). Opt-out is on. Call setOptOut(false).
  • Check that each Revenue sets price. revenue() drops a Revenue whose price is null without a log line.
  • Check that groupName is a String or List<String>. setGroup() drops any other type without a log line.

Check how plugins transformed the event

Flutter SDK 4 doesn't expose plugins in Dart, so your code can't add, change, or drop events after track(). The platform SDK changes each event in these ways before it uploads:

  • Adds device, app, and location fields, unless you turned them off in trackingOptions or with enableCoppaControl.
  • Adds user_id, device_id, and session_id from the current identity, unless the event sets its own.
  • Sets library to amplitude-flutter/<version>, so you can tell Flutter events apart from native ones.
  • Drops the event if it has neither a user ID nor a device ID, and logs Event is invalid for missing information like userId and deviceId.

To see the final event, inspect the uploaded request as described in Check what the SDK sent.

Check what the SDK sent

The native SDKs don't log the request body. To read it, point serverUrl at an endpoint you control, such as a local proxy that forwards to Amplitude, and inspect the request there. Remove the override when you finish.

dart
final amplitude = Amplitude(Configuration(
  apiKey: 'AMPLITUDE_API_KEY',
  // Android emulator: 10.0.2.2 reaches the host machine. iOS Simulator: use localhost.
  serverUrl: 'http://10.0.2.2:8080/2/httpapi',
));

The native SDKs gzip request bodies when they upload to Amplitude's default URL, and send plain JSON when you set a custom serverUrl. Each request is an HTTP V2 API body: an api_key, an events array of up to flushQueueSize events, and options with min_id_length when you set it.

On Android, debug logs also show upload scheduling. After flushMaxRetries failed attempts, the SDK logs Max retries 5 reached, temporarily stop consuming upload signals. and keeps the events for later.

On web, open the browser Network tab and filter on amplitude. The request goes to api2.amplitude.com or api.eu.amplitude.com, or to your serverUrl.

Check what Amplitude received

Read the upload result

The Flutter SDK doesn't return upload results to Dart. The platform SDK logs the server's response instead. With debug logging on, look for these lines:

Find the event in Amplitude

  1. In Amplitude, open User Lookup and search for the user ID, or for the device ID from await amplitude.getDeviceId().
  2. Open the Activity tab and turn on Live event updates.
  3. Find the event and check its properties, library, and timestamp.

If the upload succeeded but the event isn't on that user, check that the user ID and device ID in the request match what you searched for. Events with an ID shorter than minIdLength arrive without that ID.

これは役に立ちましたか?

For AI agents: a documentation index is available at /docs/llms.txt. Append .md to any page URL for markdown, or send Accept: text/markdown.

このページでは