-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathConsentLevel.cs
More file actions
54 lines (47 loc) · 1.83 KB
/
Copy pathConsentLevel.cs
File metadata and controls
54 lines (47 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#nullable enable
namespace Immutable.Audience
{
/// <summary>
/// How much data the Audience SDK is allowed to collect.
/// </summary>
/// <seealso cref="ImmutableAudience.SetConsent"/>
public enum ConsentLevel
{
/// <summary>
/// No tracking.
/// </summary>
None,
/// <summary>
/// Anonymous tracking. Events carry the device's anonymous ID. Identifying
/// the player via
/// <see cref="ImmutableAudience.Identify(string, IdentityType, System.Collections.Generic.Dictionary{string, object})"/>
/// is rejected at this level.
/// </summary>
Anonymous,
/// <summary>
/// Full tracking. Events may carry a known user ID set via
/// <see cref="ImmutableAudience.Identify(string, IdentityType, System.Collections.Generic.Dictionary{string, object})"/>.
/// </summary>
Full
}
// Strings the SDK emits for ConsentLevel.
internal static class ConsentLevelWireFormat
{
internal const string None = "none";
internal const string Anonymous = "anonymous";
internal const string Full = "full";
}
internal static class ConsentLevelExtensions
{
internal static string ToLowercaseString(this ConsentLevel level) => level switch
{
ConsentLevel.None => ConsentLevelWireFormat.None,
ConsentLevel.Anonymous => ConsentLevelWireFormat.Anonymous,
ConsentLevel.Full => ConsentLevelWireFormat.Full,
_ => throw new System.ArgumentOutOfRangeException(
nameof(level), level, "Unhandled ConsentLevel"),
};
internal static bool CanTrack(this ConsentLevel level) => level != ConsentLevel.None;
internal static bool CanIdentify(this ConsentLevel level) => level == ConsentLevel.Full;
}
}