Skip to content

Core configuration

The configuration types used for SDK initialization. CoreConfig holds the app identifier, automatic token refresh, logging, and network policy, and you create it with CoreConfigBuilder. A configuration cannot be changed once it is created.

Configuration options

Setting Setter method Type Default value Description
App identifier CreateBuilder() string — (required) The app identifier registered on the Hive platform.
Automatic token refresh SetAutoRefresh() bool true Whether to refresh the token automatically when a 401 response is received.
Minimum log level SetMinLevel() LogLevel LogLevel.Info Outputs only logs at this level or higher.
Console output SetEnableConsole() bool true Whether to output logs to the engine console.
PII masking SetEnablePiiMasking() bool true Whether to mask personal information in logs.
Masking exception keys SetAllowlist() params string[] 10 by default Additional keys to exclude from masking.
Request timeout SetTimeoutMillis() int 30000 The request timeout in milliseconds. It must be greater than 0.
Maximum retry count SetMaxRetries() int 3 The maximum number of retries for transient failures. It must be 0 or greater.
Backoff base delay SetBackoffBaseMs() int 1000 The base delay of exponential backoff in milliseconds. It must be greater than 0.
Maximum Retry-After wait SetRetryAfterMaxWaitMs() int 60000 The maximum time in milliseconds to wait for the Retry-After value sent by the server. If the value exceeds this, the call fails immediately without waiting. It must be greater than 0.

For most items, the default values are fine, so specify only the items you want to change.

using Hive.Axyl.Core;

var config = CoreConfig.CreateBuilder("{appId}")
    .SetTimeoutMillis(10000)
    .Build();

CoreConfig

class — namespace Hive.Axyl.Core

A read-only configuration object created by CoreConfigBuilder.

CreateBuilder

Creates a new CoreConfigBuilder with the specified app identifier.

static CoreConfigBuilder CreateBuilder(string appId)
Parameter Type Required Description
appId string Required The app identifier registered on the Hive platform. It is sent in the X-App-Id header of every server request and is also used to separate areas of the device's secure storage. It cannot be an empty string or whitespace.
It is not the store bundle identifier

appId is the value registered on the Hive platform. Even for the same app, the build for each platform is registered as a separate app, so it must exactly match the registered value. The SDK reports the store bundle identifier to the server separately.

  • Returns: CoreConfigBuilder

Properties

The configuration values are held in four groups.

Property Type Values it holds
App AppOptions AppId
Auth AuthOptions AutoRefresh
Log LogOptions MinLevel, EnableConsole, EnablePiiMasking, Allowlist
Network NetworkOptions TimeoutMillis, MaxRetries, BackoffBaseMs, RetryAfterMaxWaitMs

Each group type is read-only, and the property names and meanings are the same as in the Configuration options table.

string appId = config.App.AppId;
int timeout = config.Network.TimeoutMillis;

CoreConfigBuilder

class — namespace Hive.Axyl.Core

A builder that creates CoreConfig. Every SetXxx() method returns the builder itself, so you can chain calls. For the items you can specify and their default values, see Configuration options.

Build

Validates all settings and creates CoreConfig.

CoreConfig Build()
  • Returns: CoreConfig

Exceptions

  • ArgumentException: When appId is null, an empty string, or whitespace
  • ArgumentOutOfRangeException: When a numeric setting is outside its valid range. For the ranges, see the descriptions in Configuration options.

Enums

LogLevel

The severity of a log. The larger the value, the more severe the log, and only logs at MinLevel or higher are output.

C# member Value Description
Debug 0 Detailed diagnostic information to check during development.
Info 1 A general informational message.
Warn 2 A situation that needs attention.
Error 3 A situation in which an error occurred but the SDK can keep working.
Fatal 4 A serious error that can stop the SDK from working.

Connect log collection

To send SDK logs to a destination other than the engine console, implement and register ILogSink. Use it to record SDK logs in the app's error collection tool or file logger as well.

Logs are delivered after they pass through PII masking and the minimum level filter.

using Hive.Axyl.Core;

sealed class FileLogSink : ILogSink
{
    public void Emit(LogEntry entry)
    {
        // entry.Level, entry.Category, entry.Message ...
    }
}

// Call it after HiveBootstrap.Initialize.
HiveCore.AddLogSink(new FileLogSink());

ILogSink

interface — namespace Hive.Axyl.Core

An interface that exports logs to a specific destination.

Emit can be called from any thread, so the implementation must ensure thread safety itself. If you need to update the UI, hand the work off to the main thread inside the implementation.

  • void Emit(LogEntry entry): A method that exports a single log entry to this destination. It is called after PII masking and the minimum level filter.

LogEntry

struct — namespace Hive.Axyl.Core

The log entry passed to Emit. It cannot be changed after it is created.

Property Type Required Description
TimestampMs long Required The time when the log was created. It is in Unix epoch milliseconds (UTC).
Level LogLevel Required The severity of this entry.
Category string Required The name of the subsystem that created the log. Example: Transport, Auth, Session.
Message string Required A human-readable log message. It is in English.
Context IReadOnlyDictionary<string, object>? Optional Key-value information attached to the entry. If there is no additional information, it is null.
TraceId string? Optional An identifier that traces the request.

PII masking

If EnablePiiMasking is true, the values in Context whose keys are not in the allowlist are replaced with *** before they are passed to Emit. Key names are not case-sensitive.

The default allowlist consists of the following 10 keys. You can add keys with SetAllowlist(), but you cannot remove the default items.

errorCode, errorMessage, category, timestamp, traceId, requestId, durationMs, method, url, statusCode