Use -core modules for lightweight location/forms#312
Merged
evan-masseau merged 15 commits intorel/2.3.0from Feb 20, 2026
Merged
Use -core modules for lightweight location/forms#312evan-masseau merged 15 commits intorel/2.3.0from
evan-masseau merged 15 commits intorel/2.3.0from
Conversation
9 tasks
android/src/main/java/com/klaviyoreactnativesdk/KlaviyoReactNativeSdkModule.kt
Show resolved
Hide resolved
evan-masseau
commented
Feb 19, 2026
b5b33ac to
32b8f5f
Compare
Replace unconditional location and forms dependencies with conditional toggles controlled by gradle properties. When klaviyoIncludeLocation or klaviyoIncludeForms is set to false, only the lightweight -core module is included — providing the API surface but no-oping at runtime. - Add includeLocation/includeForms flags to android/build.gradle - Add forms-core and location-core dependency substitutions for local composite builds in both android/ and example/android/ settings.gradle - Document the new Android Module Configuration section in README Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The docs claimed calls would "be no-ops and log a warning" but the actual behavior is that the SDK catches the missing implementation gracefully via safeApply and logs at error level. Updated both location and forms sections to accurately describe the mechanism. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Exception handling now lives in the native Android SDK's -core extension functions via safeApply, so the RN bridge no longer needs its own try/catch wrapper. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The config parsing (getDouble) could throw, and this runs on the UI thread. Wrapping in try/catch prevents an unhandled crash. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… merged Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Uses Registry.isRegistered<FormsProvider>() and Registry.isRegistered<GeofencingProvider>() to expose module availability to the JS layer, matching the iOS approach in PR #313. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
32b8f5f to
cb015d8
Compare
…ming - Restore original Rich Push description mentioning video support for iOS and using "media" instead of "images" - Rename ENABLE_KLAVIYO_LOCATIONS -> ENABLE_KLAVIYO_LOCATION (singular) to match pod name KlaviyoLocation, consistent with ENABLE_KLAVIYO_FORMS Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Change requireFormsAvailable/requireLocationAvailable from throwing to returning boolean (isFormsAvailable/isLocationAvailable), preventing host app crashes when optional modules are excluded - Add platform-specific setup instructions to error messages - Fix unregisterFromInAppForms arrow function to method shorthand - Fix KlaviyoBridge.swift indentation on isFormsAvailable @objc - Revert Rich Push README wording back to master (unintentional change) - Update tests to match the new no-throw behavior Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
bugbot run |
evan-masseau
commented
Feb 20, 2026
- Rename ENABLE_KLAVIYO_FORMS → KLAVIYO_INCLUDE_FORMS - Rename ENABLE_KLAVIYO_LOCATION → KLAVIYO_INCLUDE_LOCATION - Switch from opt-out (!=false) to opt-in (==true) semantics, matching Flutter convention - Revert Rich Push README wording change (not part of this PR) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ssages - Add "Module Configuration" sections to README for Forms and Geofencing with iOS (Podfile) and Android (gradle.properties) instructions - Note that Location module default will flip to excluded in next major version - Change podspec to included-by-default (!=false) for both modules - Update error messages with platform-specific remediation instructions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Safety net in case the TS no-op guards are bypassed — catches MissingKlaviyoModule on registerForInAppForms, unregisterFromInAppForms, registerGeofencing, and unregisterGeofencing to prevent native crashes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
evan-masseau
commented
Feb 20, 2026
| const constants = KlaviyoReactNativeSdk.getConstants?.() ?? {}; | ||
| if (constants.FORMS_AVAILABLE === false) { | ||
| console.error(`[Klaviyo] ${FORMS_UNAVAILABLE_MESSAGE}`); | ||
| throw new Error(FORMS_UNAVAILABLE_MESSAGE); |
Contributor
Author
There was a problem hiding this comment.
This throw would crash the app in production. I dont think we need to be that noisy. console.error is still quite loud and in your face on RN, including a little red error in the app's UI during development.
Prevents callers from being left in a permanently pending state (e.g. loading spinner that never resolves). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ab1470
approved these changes
Feb 20, 2026
amber-klaviyo
approved these changes
Feb 20, 2026
Contributor
amber-klaviyo
left a comment
There was a problem hiding this comment.
Looks good as far as my understanding goes!
belleklaviyo
added a commit
that referenced
this pull request
Mar 6, 2026
* Make Forms and Location pods optional, true on default (#313) * Make Forms and Location pods optional, true on default * Add compiler flag wraps * Remove README updates (for now) * Surface missing module to ts error * Use no-op approach to make forms and location optional modules (#312) Make Forms and Location native modules optional with graceful degradation iOS: KLAVIYO_INCLUDE_FORMS/KLAVIYO_INCLUDE_LOCATION Podfile ENV vars control pod inclusion Android: FORMS_AVAILABLE/LOCATION_AVAILABLE constants, MissingKlaviyoModule catches in bridge JS: Module unavailability logs console.error and no-ops (no throw, no crash) * Bump to 2.3.0 | Swift 5.2.1 | Android 4.3.0 (#317) * Bump to 5.2.1 * unversion pods for testing for now * Point to android release branch * Point to Swift SDK 5.2.1, Android SDK 4.3.0 * Unversion readme links * Run pod install --------- Co-authored-by: Evan C Masseau <5167687+evan-masseau@users.noreply.github.com>
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.
Description
Replace unconditional location and forms dependencies with configurable toggles using
-coremodules. When opted out, only a lightweight-coremodule is included — providing the API surface (compiles) but no implementation (no-ops at runtime). This avoids pulling in heavy transitive dependencies like Google Play Services Location or the forms WebView engine.Supersedes #308 which used the
location-no-permissionsapproach.Due Diligence
Release/Versioning Considerations
PatchContains internal changes or backwards-compatible bug fixes.MinorContains changes to the public API.MajorContains breaking changes.Changelog / Code Overview
Android
klaviyoIncludeLocationandklaviyoIncludeFormsgradle property toggles (defaulttrue). Whenfalse, swap the fulllocation/formsdependency for its-corecounterpart.forms-coreandlocation-coredependency substitution rules for local composite builds.FORMS_AVAILABLEandLOCATION_AVAILABLEnative constants viaRegistry.isRegistered<FormsProvider>()andRegistry.isRegistered<GeofencingProvider>()for runtime detection.iOS
KlaviyoFormsandKlaviyoLocationpod dependencies conditional onKLAVIYO_INCLUDE_FORMSandKLAVIYO_INCLUDE_LOCATIONenv vars (included by default, set to'false'to exclude).'true'.#if canImport(KlaviyoForms)/#if canImport(KlaviyoLocation)guards. AddisFormsAvailableandisLocationAvailablecomputed properties.FORMS_AVAILABLEandLOCATION_AVAILABLEconstants viaconstantsToExport.TypeScript / React Native
isFormsAvailable()andisLocationAvailable()guard functions that check the native constants. When a module is unavailable, logsconsole.errorwith platform-specific setup instructions and returns early (no-op) — no exceptions thrown, preventing host app crashes.Documentation
Test Plan
klaviyoIncludeLocation=false— no location permissions in merged manifestklaviyoIncludeForms=false— forms no-opRelated Issues/Tickets
-coremodule extraction (Plans 1+2)🤖 Generated with Claude Code