Skip to content

Feature/preloading schedule#434

Merged
yusuftor merged 12 commits intodevelopfrom
feature/preloading-schedule
Feb 24, 2026
Merged

Feature/preloading schedule#434
yusuftor merged 12 commits intodevelopfrom
feature/preloading-schedule

Conversation

@yusuftor
Copy link
Collaborator

@yusuftor yusuftor commented Feb 16, 2026

Changes in this pull request

  • Adds support for prioritised campaign preloading

Checklist

  • All unit tests pass.
  • All UI tests pass.
  • Demo project builds and runs on iOS.
  • Demo project builds and runs on Mac Catalyst.
  • Demo project builds and runs on visionOS.
  • I added/updated tests or detailed why my change isn't tested.
  • I added an entry to the CHANGELOG.md for any breaking changes, enhancements, or bug fixes.
  • I have run swiftlint in the main directory and fixed any issues.
  • I have updated the SDK documentation as well as the online docs.
  • I have reviewed the contributing guide

Greptile Summary

This PR adds support for prioritized campaign preloading. When a campaign is marked as prioritized via the prioritizedCampaignId field in the config, its paywalls are preloaded before all other paywalls, with a 5-second delay between the prioritized and general preloading stages to avoid resource contention.

Key changes:

  • Added prioritizedCampaignId optional field to Config model with proper encoding/decoding
  • Updated preloadAllPaywalls() to check for prioritized campaigns and preload them first
  • Refactored getActiveTreatmentPaywallIds by removing unused synchronous variant and updating async method name
  • Added comprehensive test coverage for the new field and encoding/decoding behavior
  • Updated all existing tests to use the renamed async method

The implementation is clean and leverages existing caching infrastructure to prevent duplicate preloading operations.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is well-tested with comprehensive coverage, follows existing architectural patterns, and properly leverages the existing caching infrastructure. The changes are additive and backward-compatible with proper optional handling.
  • No files require special attention

Important Files Changed

Filename Overview
Sources/SuperwallKit/Config/Models/Config.swift Added prioritizedCampaignId optional field with proper encoding/decoding - clean implementation
Sources/SuperwallKit/Config/ConfigLogic.swift Removed unused synchronous method, renamed async method for clarity - refactoring improves consistency
Sources/SuperwallKit/Config/ConfigManager.swift Implements prioritized campaign preloading with 5-second delay between stages - logic is sound with proper caching
Tests/SuperwallKitTests/Config/Models/PaywallPreloadingTests.swift New test file with comprehensive tests for prioritizedCampaignId serialization - excellent test coverage

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[preloadAllPaywalls called] --> B{prioritizedCampaignId exists?}
    B -->|Yes| C[Filter triggers by campaign groupId]
    B -->|No| G[Get all treatment paywall IDs]
    C --> D[Get treatment paywall IDs for prioritized triggers]
    D --> E[Remove presented paywall ID]
    E --> F[Preload prioritized paywalls]
    F --> F1[Sleep 5 seconds]
    F1 --> G
    G --> H[Remove presented paywall ID]
    H --> I[Preload remaining paywalls]
    I --> J[End]
    
    style F fill:#90EE90
    style I fill:#87CEEB
    style F1 fill:#FFD700
Loading

Last reviewed commit: fa1332d

yusuftor added 4 commits June 4, 2025 16:45
And renamed `getAllActiveTreatmentPaywallIds` to `getActiveTreatmentPaywallIds`, and removed the old `getActiveTreatmentPaywallIds`. This means that when someone calls `preloadPaywalls(forPlacements:)`
@yusuftor yusuftor marked this pull request as ready for review February 16, 2026 13:50
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

12 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

12 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

yusuftor and others added 6 commits February 16, 2026 16:22
Replaces the preloading schedule model with a simple prioritizedCampaignId
on the config. When set, the SDK preloads the prioritized campaign's
paywalls first (with a 5s delay), then preloads the rest.

- Remove PaywallPreloading, PreloadingStep, PreloadablePlacement models
- Add prioritizedCampaignId to Config
- Update ConfigManager.preloadAllPaywalls() to use prioritized campaign
- Update tests for new approach

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When switching API keys, the cached config from the old key persists and
can cause incorrect test mode activation due to bundleIdConfig mismatch.
Store the last-used API key and clear config, enrichment, and test mode
caches when it changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yusuftor yusuftor merged commit a162809 into develop Feb 24, 2026
2 checks passed
@yusuftor yusuftor deleted the feature/preloading-schedule branch February 24, 2026 12:14
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