Skip to content

Make all SuperwallDelegate methods optional#138

Open
yusuftor wants to merge 8 commits intodevelopfrom
yusuf/make-delegate-methods-optional
Open

Make all SuperwallDelegate methods optional#138
yusuftor wants to merge 8 commits intodevelopfrom
yusuf/make-delegate-methods-optional

Conversation

@yusuftor
Copy link
Contributor

@yusuftor yusuftor commented Mar 4, 2026

Summary

  • Give all SuperwallDelegate methods default empty implementations so users only need to override the callbacks they care about
  • Previously 10 methods were abstract and required implementation; now all 15 methods have no-op defaults
  • Update SuperwallKit iOS 4.13.04.14.0, Android 2.7.12.7.4
  • Add TestModeBehavior enum and testModeBehavior property to SuperwallOptions
  • Add 6 new SuperwallEvent types: stripeCheckoutStart, stripeCheckoutSubmit, stripeCheckoutComplete, stripeCheckoutFail (iOS), testModeModalOpen, testModeModalClose (both)

Test plan

  • Verify existing delegate implementations still compile without changes
  • Verify a new delegate subclass can be created with zero overrides
  • flutter analyze passes
  • iOS build succeeds
  • Android build succeeds
  • Test mode with .always works on iOS

Greptile Summary

This PR successfully makes all SuperwallDelegate methods optional by providing default empty implementations, significantly improving the developer experience. Previously, developers had to implement 10 abstract methods even if they didn't need them; now they can create a delegate with zero overrides and only implement the callbacks they care about.

The PR also updates the native SDKs (iOS 4.13.0 → 4.14.0, Android 2.7.1 → 2.7.4) and adds support for test mode behavior configuration and 6 new event types:

  • Test mode: Adds TestModeBehavior enum with four options (automatic, whenEnabledForUser, never, always) properly mapped across all platforms
  • New events: Stripe checkout events (iOS-only: start, submit, complete, fail) and test mode modal events (cross-platform: open, close)

The implementation is thorough with proper enum mappings across Dart, iOS (Swift), and Android (Kotlin). The Pigeon-generated code has been regenerated correctly (v26.1.10). All changes are backward compatible - existing delegate implementations continue to work without modification.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-structured, backward compatible, and thoroughly implemented across all platforms. The main feature (optional delegate methods) is a pure enhancement that doesn't break existing code. Native SDK updates are minor version bumps. The only minor issue is an unused toJson() extension method missing the new field, but this doesn't affect functionality since the actual conversion uses Pigeon's type system directly.
  • No files require special attention

Important Files Changed

Filename Overview
lib/src/public/SuperwallDelegate.dart Makes all 15 delegate methods optional by adding default empty implementations
lib/src/public/SuperwallOptions.dart Adds TestModeBehavior enum and testModeBehavior property; toJson() missing new field but appears unused
lib/src/public/SuperwallEventInfo.dart Adds 6 new event types with proper case mappings
lib/src/public/Superwall.dart Adds _convertTestModeBehavior() helper method with proper enum conversion
ios/Classes/Mappers/OptionsMapper.swift Maps testModeBehavior to iOS SDK enum values correctly
android/src/main/kotlin/com/superwall/superwallkit_flutter/utils/OptionsMapper.kt Maps testModeBehavior to Android SDK enum with proper default handling

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Flutter App] --> B[SuperwallDelegate]
    B --> C{Optional Methods}
    C -->|Before| D[Required: 10 abstract methods]
    C -->|After| E[Optional: 15 methods with defaults]
    
    A --> F[SuperwallOptions]
    F --> G[testModeBehavior]
    G --> H[iOS 4.14.0]
    G --> I[Android 2.7.4]
    
    A --> J[SuperwallEventInfo]
    J --> K[6 New Event Types]
    K --> L[Stripe iOS Only]
    K --> M[Test Mode Both Platforms]
    
    style E fill:#90EE90
    style D fill:#FFB6C6
Loading

Last reviewed commit: 5373050

yusuftor and others added 6 commits March 4, 2026 15:08
Give all abstract methods default empty implementations so users
only need to override the callbacks they care about.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add TestModeBehavior enum and testModeBehavior option to SuperwallOptions
- Add 6 new SuperwallEvent types: stripeCheckoutStart/Submit/Complete/Fail (iOS), testModeModalOpen/Close (both)
- Opt example app out of Flutter UIScene auto-migration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@greptile-apps
Copy link

greptile-apps bot commented Mar 4, 2026

Additional Comments (1)

lib/src/public/SuperwallOptions.dart, line 46
testModeBehavior field missing from serialization

  Map<dynamic, dynamic> toJson() {
    return {
      'paywalls': paywalls.toJson(),
      'networkEnvironment': networkEnvironment.toJson(),
      'isExternalDataCollectionEnabled': isExternalDataCollectionEnabled,
      'localeIdentifier': localeIdentifier,
      'isGameControllerEnabled': isGameControllerEnabled,
      'logging': logging.toJson(),
      'passIdentifiersToPlayStore': passIdentifiersToPlayStore,
      'testModeBehavior': testModeBehavior.index
    };
  }

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant