feat: complete native App Events SDK coverage (0.28.0)#487
Conversation
Adds logProductItem (with ProductAvailability/ProductCondition enums), setPushNotificationToken, setFlushBehavior/getFlushBehavior (FlushBehavior enum), getUserData, getUserID, clearUserDataForType (FacebookUserDataField enum) and setDebugLoggingEnabled. Adds the remaining Meta standard-event convenience helpers. Enums and helpers are extracted to lib/src/ and re-exported (no import changes for consumers). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Implements logProductItem, setPushNotificationToken, setFlushBehavior/getFlushBehavior, getUserData, getUserID and setDebugLoggingEnabled. clearUserDataForType is a documented no-op (no per-field clear on Android). Removes the hidden debug-logging side effect from setAdvertiserTracking and drops unused GraphRequest/GraphResponse imports. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Implements logProductItem, setPushNotificationToken, setFlushBehavior/getFlushBehavior, getUserData, getUserID, clearUserDataForType and setDebugLoggingEnabled (via Settings logging behaviors), mapping the Dart enum wire tokens to the native FBSDK enums. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds Dart unit tests for every new method, demonstrates them in the example app, documents the clearUserDataForType Android no-op in the README, and bumps pubspec.yaml + podspec to 0.28.0 with a CHANGELOG entry. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR expands facebook_app_events to cover more native Facebook App Events SDK APIs across Dart, Android, and iOS, while bumping the package to 0.28.0 and documenting the Android/iOS behavior divergence for per-field user-data clearing.
Changes:
- Adds native-mirroring APIs for product item logging, push token registration, flush behavior, user data getters, per-field user data clearing, and explicit debug logging.
- Adds Dart-only standard event convenience helpers and type-safe enums re-exported from the public library.
- Updates tests, example app, README, changelog, and version metadata for the 0.28.0 release.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
lib/facebook_app_events.dart |
Adds public API constants and native-mirroring methods. |
lib/src/enums.dart |
Adds type-safe enums and flush behavior token parsing. |
lib/src/standard_events.dart |
Adds Dart standard-event convenience extension methods. |
android/src/main/kotlin/id/oddbit/flutter/facebook_app_events/FacebookAppEventsPlugin.kt |
Adds Android handlers for the new native-mirroring methods and decouples debug logging from advertiser tracking. |
ios/facebook_app_events/Sources/facebook_app_events/FacebookAppEventsPlugin.swift |
Adds iOS handlers for the new native-mirroring methods. |
test/facebook_app_events_test.dart |
Adds Dart channel-level tests for new APIs, enums, and standard-event helpers. |
example/lib/main.dart |
Demonstrates new APIs in the sample app and makes the UI scrollable. |
README.md |
Documents the Android no-op behavior for clearUserDataForType. |
CHANGELOG.md |
Adds the 0.28.0 release notes. |
pubspec.yaml |
Bumps package version to 0.28.0. |
ios/facebook_app_events.podspec |
Bumps podspec version to 0.28.0. |
example/pubspec.lock |
Updates the example’s resolved local package version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- iOS: use setPushNotificationsDeviceTokenString for the String token overload (setPushNotificationsDeviceToken takes Data and would fail to compile), matching the documented Dart->iOS mapping. - Dart: add the currency parameter to logSpentCredits so the dartdoc [currency] reference resolves and the ROAS event mirrors logDonate; cover it in the existing test. https://claude.ai/code/session_011RbXF3u6F2j1NmjJ5jhUkN
|
Reviewed Copilot's feedback with my own scrutiny. Both findings were valid and are now fixed in
Beyond these two, I went over the rest of the diff (enum⇄token mappers on both platforms, the debug-logging decouple, the new getters, and the Android Note: Generated by Claude Code |
Flutter 3.44 requires Android Gradle Plugin >= 8.6.0, but the example's settings.gradle still pinned AGP 8.1.1 (and Kotlin 1.8.22), failing the example APK build at configuration time. Align with the plugin module and Gradle wrapper (AGP 8.9.2 / Kotlin 2.3.10 / Gradle 8.11.1). Pre-existing latent issue surfaced by the Flutter upgrade. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Reverts the push-token change from a20ff13. The ObjC selector setPushNotificationsDeviceTokenString: is renamed in Swift to setPushNotificationsDeviceToken(_:) via NS_SWIFT_NAME (verified in FBSDKAppEvents.h), so it is overloaded with the Data variant and a String argument resolves to the String overload. The symbol setPushNotificationsDeviceTokenString does not exist in Swift and would fail to compile. Added a comment to prevent re-fixing. Not caught by CI because only the Android example is built. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses Copilot review (discussion_r3328457632): the getter tests now stub a platform return value and assert it is propagated, so a regression dropping or mis-typing the returned String would fail (matching the getFlushBehavior round-trip test). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add channel-argument tests for logAddedPaymentInfo, logCompletedTutorial, logContact, logCustomizeProduct, logFindLocation, and logSchedule so wrong event-name constants or parameter wiring are caught before release. https://claude.ai/code/session_01CqPhERLBvcMXzqkz1VswT3
The dartdoc referenced setPushNotificationsDeviceTokenString, which does not exist in Swift: NS_SWIFT_NAME renames that ObjC selector to setPushNotificationsDeviceToken(_:), the symbol the plugin actually calls. Documents the real Swift method (String overload) and notes the ObjC origin. Addresses Copilot review comment 3328481126. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
Completeness pass following the audit of dependency currency and native-SDK coverage. The libs are already up to date (Facebook SDK pinned to the latest major,
18.x, on both platforms; nov19exists yet) and the three layers were already in 1:1 sync — so this PR focuses on closing the API-coverage gaps while preserving the explicit Dart ↔ Kotlin ↔ Swift mapping.Purely additive except one intentional, documented behavior change (debug-logging decouple, below).
What's new
Native-mirroring methods (all three layers):
logProductItem(...)— product-catalog item logging, with type-safeProductAvailability/ProductConditionenums.setPushNotificationToken(String)— iOSsetPushNotificationsDeviceToken, AndroidsetPushNotificationsRegistrationId.setFlushBehavior(FlushBehavior)/getFlushBehavior()— auto vs explicit-only flushing.getUserData(),getUserID()getters.clearUserDataForType(FacebookUserDataField)— functional on iOS; no-op on Android (no native per-field clear; useclearUserData()). Documented in the README.Behavior change:
setDebugLoggingEnabled(bool)on both platforms, and the hidden debug-logging side effect is removed fromsetAdvertiserTrackingon Android (it previously flipped on verbose logging in debug builds — a surprise and an iOS/Android inconsistency).Standard-event convenience helpers (Dart-only, routed through
logEvent):logAchievedLevel,logAddedPaymentInfo,logCompletedTutorial,logSearched,logSpentCredits,logUnlockedAchievement,logContact,logCustomizeProduct,logDonate,logFindLocation,logSchedule,logSubmitApplication, plus theireventName*constants.Design notes
Enum.name) that the native handlers map to the SDK enum. (Note: Android'sProductAvailability.AVALIABLE_FOR_ORDERconstant is historically misspelled — the Kotlin mapper handles this; the Dart name staysavailableForOrder.)lib/src/enums.dart, standard-event helpers tolib/src/standard_events.dart, both re-exported — no import changes for consumers.GraphRequest/GraphResponseimports from the Android plugin.Reviewing
Commits are grouped by layer (Dart API / Android / iOS / tests+docs) for easier review.
Testing
flutter test— all 45 Dart unit tests pass (15 new, covering every new method, enum⇄token round-trips, and standard-event routing).flutter analyze— clean for the package and the example app.example/lib/main.dart.Release
Additive minor → 0.28.0.
pubspec.yamlandios/facebook_app_events.podspecbumped together perCONTRIBUTING.md;CHANGELOG.mdupdated.🤖 Generated with Claude Code