fix: codebase review — Android getApplicationId staleness, clean push-payload errors, 32-bit guard (v0.30.3)#495
Open
DennisAlund wants to merge 1 commit into
Open
fix: codebase review — Android getApplicationId staleness, clean push-payload errors, 32-bit guard (v0.30.3)#495DennisAlund wants to merge 1 commit into
DennisAlund wants to merge 1 commit into
Conversation
…guard for data processing options Codebase review fixes (v0.30.2): - Android: getApplicationId now reads the live FacebookSdk.getApplicationId() instead of the app id captured at engine attach, matching iOS (Settings.shared.appID) and the documented behavior. - Android: logPushNotificationOpen returns a clean INVALID_ARGUMENT error when the payload contains a value a Bundle cannot represent (e.g. a list) instead of an opaque platform exception; the message now names the offending key. - Dart: setDataProcessingOptions validates that country/state fit in a signed 32-bit integer (RangeError otherwise) — out-of-range values previously hit a ClassCastException on Android; iOS already guarded natively. - Dart: stop sending explicit nulls over the channel for omitted arguments of setDataProcessingOptions and logPushNotificationOpen, consistent with the rest of the API. - Example: move facebook_app_events from dev_dependencies to dependencies (main.dart imports it) and fix widget lints; analyzer is now clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CqZG34ExQKtZX5QHkD2UFL
4332723 to
1337d9e
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prepares a 0.30.2 release by tightening cross-platform parity and robustness in the Flutter Facebook App Events plugin, with targeted fixes in the Dart API and Android handler plus accompanying tests and version bumps.
Changes:
- Android:
getApplicationIdnow returns the live SDK app id (FacebookSdk.getApplicationId()), avoiding staleness from the logger-captured id. - Dart API: stop sending explicit
nulls for optional arguments onlogPushNotificationOpen/setDataProcessingOptions, and add 32-bit range validation forcountry/state(throwingRangeError). - Android: convert Bundle-incompatible
logPushNotificationOpenpayload values into a cleanINVALID_ARGUMENTerror with an actionable message; add tests and bump versions/changelog for0.30.2.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/facebook_app_events_test.dart | Adds coverage for omitted-null wire shapes and 32-bit RangeError validation. |
| pubspec.yaml | Bumps package version to 0.30.2. |
| lib/facebook_app_events.dart | Updates dartdoc, filters nulls on two method calls, and adds 32-bit guards for setDataProcessingOptions. |
| ios/facebook_app_events.podspec | Bumps iOS podspec version to 0.30.2 to match the Dart package version. |
| example/pubspec.yaml | Moves facebook_app_events to dependencies (used by example code). |
| example/pubspec.lock | Updates the example lockfile to reflect the dependency move and new version. |
| example/lib/main.dart | Makes MyApp constructor const and adds a key parameter. |
| CHANGELOG.md | Adds a 0.30.2 entry documenting the fixes and cleanups. |
| android/src/main/kotlin/id/oddbit/flutter/facebook_app_events/FacebookAppEventsPlugin.kt | Fixes live app-id retrieval and maps Bundle incompatibilities for push payloads to a clean INVALID_ARGUMENT error. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Full-codebase review of the Dart API, Android handler, iOS handler, build configs, tests, and docs. The three layers are in very good shape overall; this PR fixes the handful of genuine parity/robustness issues found, bundled as
0.30.3(rebased on top of the0.30.2toolchain bump from #494).Fixes
Android:
getApplicationIdreturned a stale app idThe handler read
appEventsLogger.applicationId, which is captured when the logger is created inonAttachedToEngine— so app-id changes made programmatically after startup (or an access-token app id) were never reflected, contradicting the dartdoc and diverging from iOS (Settings.shared.appID, which is read live). It now reads the liveFacebookSdk.getApplicationId().Android: opaque error for Bundle-incompatible push payloads
logPushNotificationOpenpayloads are (deliberately) not validated in the Dart layer, butcreateBundleFromMapthrowsIllegalArgumentExceptionfor values aBundlecan't hold (e.g. lists), which surfaced as a genericPlatformException(error, ...)with a stack trace — while iOS accepts the same payload. The handler now catches this and returns a cleanINVALID_ARGUMENT, and the exception message names the offending key and suggests JSON-encoding structured values.Dart:
setDataProcessingOptions32-bit validationThe standard method codec delivers Dart ints larger than 32 bits as
Long, so an out-of-rangecountry/statecaused aClassCastExceptionin the Android handler (call.argument<Int>). The iOS handler already guards this natively (Int32(exactly:)). Per this repo's convention of validating in the Dart layer,setDataProcessingOptionsnow throws aRangeErrorfor values that don't fit in a signed 32-bit integer.Consistency cleanups
setDataProcessingOptionsandlogPushNotificationOpenno longer send explicitnulls over the channel for omitted arguments — every other multi-argument method already filters them via_filterOutNulls.facebook_app_eventsmoved fromdev_dependenciestodependencies(it's imported bylib/main.dart— this was an analyzerdepend_on_referenced_packagesinfo), andMyAppgot aconstconstructor with akeyparameter.flutter analyzeis now clean with zero infos.Release prep (per CONTRIBUTING.md)
pubspec.yamlandios/facebook_app_events.podspecbumped together to0.30.3.CHANGELOG.mdentry added above the0.30.2entry from chore: plumbing upgrade 2026-07-02 #494.Verification
flutter analyze: no issues.flutter test(root): 66/66 passing (re-run after the rebase), including new tests for theRangeErrorguard and the omitted-null wire shapes ofsetDataProcessingOptions/logPushNotificationOpen.flutter test(example): passing.🤖 Generated with Claude Code
https://claude.ai/code/session_01CqZG34ExQKtZX5QHkD2UFL