Skip to content

Commit 4ec262b

Browse files
committed
docs: explain ad injection logic in AdConfig
- Clarified AdFrequency usage - Clarified AdPlacementInterval usage - Added a usage example
1 parent 7f8be1b commit 4ec262b

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

lib/src/models/remote_config/ad_config.dart

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ part 'ad_config.g.dart';
1717
/// This model is part of the overall [AppConfig] and is used to control
1818
/// how ads are integrated into the application's feed or other content areas
1919
/// based on the user's authentication status or subscription level.
20+
///
21+
/// **Ad Injection Logic Explained:**
22+
///
23+
/// - __`AdFrequency`__: This determines *how often* an ad *can* be injected relative to the number of primary content items. For example, an `adFrequency` of 5 means an ad *could* be placed after every 5 primary items. It sets the overall density of ads in the feed.
24+
///
25+
/// - __`AdPlacementInterval`__: This sets a *minimum number of primary items* that must appear *before* the *first* ad is placed. It prevents ads from appearing right at the very beginning of the feed, ensuring the user sees some initial content first.
26+
///
27+
/// So, `AdFrequency` controls the spacing of ads *throughout* the feed (after the initial interval), while `AdPlacementInterval` controls where the *very first* ad can appear.
28+
///
29+
/// Think of it like this:
30+
///
31+
/// - `AdPlacementInterval` = 3: No ads will appear in the first 3 primary items.
32+
/// - `AdFrequency` = 5: After the first 3 items, an ad *could* appear after item #5, then potentially after item #10, #15, etc.
2033
/// {@endtemplate}
2134
@immutable
2235
@JsonSerializable(
@@ -40,26 +53,22 @@ class AdConfig extends Equatable {
4053
factory AdConfig.fromJson(Map<String, dynamic> json) =>
4154
_$AdConfigFromJson(json);
4255

43-
/// The frequency at which ads should appear for guest users
44-
/// (e.g., every N items).
56+
/// See class documentation for details on AdFrequency.
4557
final int guestAdFrequency;
4658

47-
/// The minimum number of non-ad items that must appear between ads
48-
/// for guest users.
59+
/// See class documentation for details on AdPlacementInterval.
4960
final int guestAdPlacementInterval;
5061

51-
/// The frequency at which ads should appear for authenticated users.
62+
/// See class documentation for details on AdFrequency.
5263
final int authenticatedAdFrequency;
5364

54-
/// The minimum number of non-ad items that must appear between ads
55-
/// for authenticated users.
65+
/// See class documentation for details on AdPlacementInterval.
5666
final int authenticatedAdPlacementInterval;
5767

58-
/// The frequency at which ads should appear for premium users.
68+
/// See class documentation for details on AdFrequency.
5969
final int premiumAdFrequency;
6070

61-
/// The minimum number of non-ad items that must appear between ads
62-
/// for premium users.
71+
/// See class documentation for details on AdPlacementInterval.
6372
final int premiumAdPlacementInterval;
6473

6574
/// Converts this [AdConfig] instance to a JSON map.

0 commit comments

Comments
 (0)