UmamiOptionsBuilder

A DSL-style builder for constructing UmamiOptions instances, providing a flexible way to configure the Umami client.

This builder allows setting various properties such as the API endpoint, tracking parameters, and technical configurations like the HTTP client engine and coroutine scope. After configuring the desired options, the internal build method is called to create an immutable UmamiOptions object.

Example usage:

val umami = Umami(websiteId = "your-website-id") {
baseUrl("https://my.umami.instance")
hostname("myapp.com")
// ... other configurations
}

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
var baseUrl: Url

The base URL of the Umami API endpoint. Defaults to "https://cloud.umami.is".

Link copied to clipboard
var coroutineScope: CoroutineScope

The coroutine scope for background tasks. Defaults to Dispatchers.Default.

Link copied to clipboard

The maximum number of events to hold in the queue. Defaults to EVENT_QUEUE_CAPACITY.

Link copied to clipboard

A suspendable map for managing custom HTTP headers. Defaults to InMemoryHeaders.

Link copied to clipboard

The hostname of the website being tracked (e.g., "myapp.com").

Link copied to clipboard
var httpClientEngine: HttpClientEngine

The Ktor HTTP client engine for network requests. Defaults to the platform's default engine.

Link copied to clipboard
var ip: Ip?

The IP address of the user.

Link copied to clipboard

The language of the user's browser, in IETF language tag format (e.g., "en-US").

Link copied to clipboard

The logger for internal library messages. Defaults to DefaultUmamiLogger.

Link copied to clipboard

The screen size of the user's device (e.g., "1920x1080").

Link copied to clipboard

The user agent string of the client. Defaults to a generated value.

Functions

Link copied to clipboard
fun baseUrl(value: String)

Sets the base URL of the Umami API from a string.

Link copied to clipboard
fun hostname(value: String)

Sets the hostname of the website being tracked.

Link copied to clipboard
fun ip(value: String)

Sets the IP address of the user.

Link copied to clipboard
fun language(value: String)

Sets the language of the user's browser from an IETF language tag string.

Link copied to clipboard
fun screenSize(value: String)

Sets the screen size from a string in "widthxheight" format (e.g., "1920x1080").

fun screenSize(width: Int, height: Int)

Sets the screen size from explicit width and height values.