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
26 changes: 23 additions & 3 deletions src/Packages/Audience/Runtime/AudienceConfig.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#nullable enable

using System;

namespace Immutable.Audience
{
// Configuration passed to ImmutableAudience.Init.
public class AudienceConfig
{
// Studio API key.
public string PublishableKey { get; set; }
// Studio API key. Required — Init throws if null.
public string? PublishableKey { get; set; }

// Initial consent level.
public ConsentLevel Consent { get; set; } = ConsentLevel.None;

// Distribution platform the game is running on.
public string DistributionPlatform { get; set; }
public string? DistributionPlatform { get; set; }

// Enable debug logging.
public bool Debug { get; set; } = false;
Expand All @@ -20,5 +24,21 @@ public class AudienceConfig

// Flush as soon as this many events are queued.
public int FlushSize { get; set; } = Constants.DefaultFlushSize;

// Optional error callback.
public Action<AudienceError>? OnError { get; set; }

// Directory the SDK uses for identity, consent, and queued events.
// Unity hooks populate this from Application.persistentDataPath.
public string? PersistentDataPath { get; set; }

// Library version sent on every message.
public string PackageVersion { get; set; } = Constants.LibraryVersion;

// Maximum time Shutdown waits for the final flush.
public int ShutdownFlushTimeoutMs { get; set; } = 2_000;

// Test seam for HttpTransport; not part of the public API.
internal System.Net.Http.HttpMessageHandler? HttpHandler { get; set; }
}
}
16 changes: 16 additions & 0 deletions src/Packages/Audience/Runtime/ConsentLevel.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

namespace Immutable.Audience
{
// How much data the Audience SDK is allowed to collect.
Expand All @@ -10,4 +12,18 @@ public enum ConsentLevel
// Full tracking, including identity.
Full
}

internal static class ConsentLevelExtensions
{
// Throws on unknown casts rather than emitting null: a null value
// would poison the backend consent log.
internal static string ToLowercaseString(this ConsentLevel level) => level switch
{
ConsentLevel.None => "none",
ConsentLevel.Anonymous => "anonymous",
ConsentLevel.Full => "full",
_ => throw new System.ArgumentOutOfRangeException(
nameof(level), level, "Unhandled ConsentLevel"),
};
}
}
1 change: 1 addition & 0 deletions src/Packages/Audience/Runtime/Core/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal static class Constants
internal const int MaxBatchSize = 100;
internal const int StaleEventDays = 30;
internal const int MaxFieldLength = 256; // Backend schema limit.
internal const int ControlPlaneRequestTimeoutSeconds = 30;

internal const string LibraryName = "com.immutable.audience";
internal const string LibraryVersion = "0.1.0";
Expand Down
Loading
Loading