Skip to content

Commit 3ea4d79

Browse files
committed
feat(audience-sdk): add EnableMobileAttribution + SKAdNetworkIds config (SDK-305)
Entry-point ticket for the mobile attribution stretch work. Adds two opt-in surfaces; downstream tickets (SDK-306/308/309/315) wire them up: - AudienceConfig.EnableMobileAttribution (default false): runtime gate for whether attribution data is collected and emitted on game_launch. - AudienceConfig.SKAdNetworkIds: optional list, read by the iOS post-processor at build time when the scripting define is set. XML doc on EnableMobileAttribution documents the two-gate model: studios opt in via both the AUDIENCE_MOBILE_ATTRIBUTION scripting define and this runtime flag. Without the define, no AD_ID permission, no native attribution code, NSPrivacyTracking false; with define + flag false, native code compiled in but no data collected; with both, full flow.
1 parent 05d4190 commit 3ea4d79

3 files changed

Lines changed: 90 additions & 0 deletions

File tree

src/Packages/Audience/Runtime/AudienceConfig.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,44 @@ public class AudienceConfig
4949
/// </summary>
5050
public bool Debug { get; set; } = false;
5151

52+
/// <summary>
53+
/// Opts the build into mobile install-attribution signals (iOS ATT /
54+
/// IDFA / SKAdNetwork, Android Advertising ID / Install Referrer).
55+
/// </summary>
56+
/// <remarks>
57+
/// Two gates control attribution. Both must be set for any attribution
58+
/// data to ship.
59+
///
60+
/// Build-time gate: the <c>AUDIENCE_MOBILE_ATTRIBUTION</c> scripting
61+
/// define (Player Settings → Other Settings → Scripting Define
62+
/// Symbols). It controls whether the AD_ID Android permission is
63+
/// injected into the manifest, which iOS Privacy Manifest variant is
64+
/// selected (<c>NSPrivacyTracking</c> true vs false), and whether the
65+
/// native ATT / IDFA / GAID / Install Referrer code paths are
66+
/// compiled into the binary.
67+
///
68+
/// Runtime gate: this flag. With the define set but the flag false,
69+
/// native code is compiled in but no attribution data is collected.
70+
/// With both set, the SDK emits attribution signals on
71+
/// <c>game_launch</c>.
72+
///
73+
/// A studio that never wants attribution sets neither and ships a
74+
/// clean binary with no AD_ID permission, <c>NSPrivacyTracking</c>
75+
/// false, and no native attribution code.
76+
/// </remarks>
77+
public bool EnableMobileAttribution { get; set; } = false;
78+
79+
/// <summary>
80+
/// Optional list of SKAdNetwork IDs to inject into the iOS
81+
/// <c>Info.plist</c> at build time.
82+
/// </summary>
83+
/// <remarks>
84+
/// Read by the iOS post-processor only when the
85+
/// <c>AUDIENCE_MOBILE_ATTRIBUTION</c> scripting define is set. Ignored
86+
/// otherwise. Has no effect on Android.
87+
/// </remarks>
88+
public string[]? SKAdNetworkIds { get; set; }
89+
5290
/// <summary>
5391
/// Interval between automatic flushes to the backend, in seconds.
5492
/// </summary>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#nullable enable
2+
3+
using NUnit.Framework;
4+
5+
namespace Immutable.Audience.Tests
6+
{
7+
[TestFixture]
8+
internal class AudienceConfigTests
9+
{
10+
[Test]
11+
public void EnableMobileAttribution_DefaultsToFalse()
12+
{
13+
// Default-off matters: a studio that never opts in must ship a
14+
// clean binary, no AD_ID permission, NSPrivacyTracking false.
15+
var config = new AudienceConfig();
16+
Assert.IsFalse(config.EnableMobileAttribution);
17+
}
18+
19+
[Test]
20+
public void SKAdNetworkIds_DefaultsToNull()
21+
{
22+
var config = new AudienceConfig();
23+
Assert.IsNull(config.SKAdNetworkIds);
24+
}
25+
26+
[Test]
27+
public void EnableMobileAttribution_RoundTrips()
28+
{
29+
var config = new AudienceConfig { EnableMobileAttribution = true };
30+
Assert.IsTrue(config.EnableMobileAttribution);
31+
}
32+
33+
[Test]
34+
public void SKAdNetworkIds_RoundTrips()
35+
{
36+
var ids = new[] { "abc123.skadnetwork", "def456.skadnetwork" };
37+
var config = new AudienceConfig { SKAdNetworkIds = ids };
38+
Assert.AreSame(ids, config.SKAdNetworkIds);
39+
}
40+
}
41+
}

src/Packages/Audience/Tests/Runtime/AudienceConfigTests.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)