Skip to content

feat: complete native App Events SDK coverage (0.28.0)#487

Merged
DennisAlund merged 10 commits into
mainfrom
feat/complete-native-sdk-coverage
May 30, 2026
Merged

feat: complete native App Events SDK coverage (0.28.0)#487
DennisAlund merged 10 commits into
mainfrom
feat/complete-native-sdk-coverage

Conversation

@DennisAlund

Copy link
Copy Markdown
Member

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; no v19 exists 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-safe ProductAvailability / ProductCondition enums.
  • setPushNotificationToken(String) — iOS setPushNotificationsDeviceToken, Android setPushNotificationsRegistrationId.
  • 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; use clearUserData()). Documented in the README.

Behavior change:

  • New explicit setDebugLoggingEnabled(bool) on both platforms, and the hidden debug-logging side effect is removed from setAdvertiserTracking on 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 their eventName* constants.

Design notes

  • Closed-set values are modeled as type-safe Dart enums; each carries a stable wire token (Enum.name) that the native handlers map to the SDK enum. (Note: Android's ProductAvailability.AVALIABLE_FOR_ORDER constant is historically misspelled — the Kotlin mapper handles this; the Dart name stays availableForOrder.)
  • Enums extracted to lib/src/enums.dart, standard-event helpers to lib/src/standard_events.dart, both re-exported — no import changes for consumers.
  • Removed unused GraphRequest/GraphResponse imports from the Android plugin.

Reviewing

Commits are grouped by layer (Dart API / Android / iOS / tests+docs) for easier review.

clearUserDataForType is the one method that introduces an iOS/Android asymmetry (Android no-op). Kept per design decision; easy to drop if preferred.

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.
  • New methods demonstrated in example/lib/main.dart.
  • ⚠️ Native (Kotlin/Swift) code was verified against the Facebook SDK 18.0.2 headers/source but not compiled in CI here — worth a device build before release.

Release

Additive minor → 0.28.0. pubspec.yaml and ios/facebook_app_events.podspec bumped together per CONTRIBUTING.md; CHANGELOG.md updated.

🤖 Generated with Claude Code

DennisAlund and others added 4 commits May 29, 2026 15:56
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>
Copilot AI review requested due to automatic review settings May 29, 2026 07:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread lib/src/standard_events.dart
- 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

Copy link
Copy Markdown
Member Author

Reviewed Copilot's feedback with my own scrutiny. Both findings were valid and are now fixed in a20ff13:

  1. iOS push token (compile bug). handleSetPushNotificationToken passed a String to AppEvents.shared.setPushNotificationsDeviceToken, whose only overload takes Data — it would not compile against FBSDK 18.x. Switched to the string overload setPushNotificationsDeviceTokenString(_:), which is also what the Dart dartdoc already documented as the iOS mapping.

  2. logSpentCredits dartdoc reference. The doc referenced [currency] but the method had no such parameter (broken dartdoc reference). Since this is a ROAS event like logDonate — which already exposes currency — I added the currency parameter (routed through paramNameCurrency) rather than dropping the doc text, keeping the two ROAS helpers consistent. Updated the existing unit test to cover it.

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 clearUserDataForType no-op) and found nothing else actionable.

Note: flutter isn't available in this environment, so I couldn't re-run flutter test/flutter analyze here — worth confirming in CI. The Dart change is minimal and the test mirrors the new parameter; the iOS change still needs a device build as already flagged in the PR description.


Generated by Claude Code

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.

Comment thread test/facebook_app_events_test.dart Outdated
DennisAlund and others added 3 commits May 30, 2026 16:26
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

Comment thread lib/src/standard_events.dart
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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

Comment thread lib/facebook_app_events.dart Outdated
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated no new comments.

@DennisAlund DennisAlund merged commit 94d0aca into main May 30, 2026
2 checks passed
@DennisAlund DennisAlund deleted the feat/complete-native-sdk-coverage branch May 30, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants