Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/Packages/Audience/Runtime/AudienceConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,40 @@ public class AudienceConfig
/// </summary>
public bool Debug { get; set; } = false;

/// <summary>
/// Opts into mobile install-attribution signals (iOS ATT / IDFA /
/// SKAdNetwork, Android Advertising ID / Install Referrer). Default
/// <c>false</c>.
/// </summary>
/// <remarks>
/// Two gates control attribution; both must be set for any data to
/// ship:
///
/// 1. Build-time: add <c>AUDIENCE_MOBILE_ATTRIBUTION</c> to Player
/// Settings → Other Settings → Scripting Define Symbols. Controls
/// the AD_ID Android manifest permission, the iOS Privacy Manifest
/// variant (<c>NSPrivacyTracking</c>), and whether native
/// attribution code is compiled into the binary.
///
/// 2. Runtime: this flag. Controls whether attribution data is
/// collected at runtime. Without the define, this setter is a
/// no-op.
///
/// Studios who set neither ship a clean binary — no AD_ID permission,
/// no native attribution code, <c>NSPrivacyTracking = false</c>.
/// </remarks>
public bool EnableMobileAttribution { get; set; } = false;

/// <summary>
/// SKAdNetwork IDs the iOS post-processor injects into <c>Info.plist</c>
/// at build time. Ignored on Android.
/// </summary>
/// <remarks>
/// Read only when <see cref="EnableMobileAttribution"/> and the
/// <c>AUDIENCE_MOBILE_ATTRIBUTION</c> scripting define are both set.
/// </remarks>
public string[]? SKAdNetworkIds { get; set; }

/// <summary>
/// Interval between automatic flushes to the backend, in seconds.
/// </summary>
Expand Down
41 changes: 41 additions & 0 deletions src/Packages/Audience/Tests/Runtime/AudienceConfigTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#nullable enable

using NUnit.Framework;

namespace Immutable.Audience.Tests
{
[TestFixture]
internal class AudienceConfigTests
{
[Test]
public void EnableMobileAttribution_DefaultsToFalse()
{
// Default-off matters: a studio that never opts in must ship a
// clean binary, no AD_ID permission, NSPrivacyTracking false.
var config = new AudienceConfig();
Assert.IsFalse(config.EnableMobileAttribution);
}

[Test]
public void SKAdNetworkIds_DefaultsToNull()
{
var config = new AudienceConfig();
Assert.IsNull(config.SKAdNetworkIds);
}

[Test]
public void EnableMobileAttribution_RoundTrips()
{
var config = new AudienceConfig { EnableMobileAttribution = true };
Assert.IsTrue(config.EnableMobileAttribution);
}

[Test]
public void SKAdNetworkIds_RoundTrips()
{
var ids = new[] { "abc123.skadnetwork", "def456.skadnetwork" };
var config = new AudienceConfig { SKAdNetworkIds = ids };
Assert.AreSame(ids, config.SKAdNetworkIds);
}
}
}
11 changes: 11 additions & 0 deletions src/Packages/Audience/Tests/Runtime/AudienceConfigTests.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading