Package 

Object Elo


  • 
    public class Elo
    
                        

    The entry point for the Elo SDK.

    Configure once early in your app lifecycle (typically Application.onCreate), then call loadAd from anywhere to fetch a contextual ad based on the surrounding chat history.

    class MyApp : Application() {
        override fun onCreate() {
            super.onCreate()
            Elo.configure(
                context = this,
                publisherId = "YOUR_PUBLISHER_ID",
                adUnitId = "YOUR_AD_UNIT_ID",
            )
        }
    }

    For COPPA/TFUA flags, log level, and other options, use the configure overload that takes a full EloConfiguration.

    Mirrors iOS Sources/EloAds/Elo.swift.

    • Method Detail

      • configure

        @JvmOverloads() final static Unit configure(Context context, String publisherId, String adUnitId, Boolean shareGeoLocation, Integer geoLocationPrecision)

        Configure the SDK.

        Convenience overload of configure for the common case — default options.

        The geo-sharing controls are mirrored here (unlike every other option) because passive geo sharing is on by default and the opt-out should be visible at the simplest entry point. Anything else (COPPA/TFUA flags, log level) is deliberately not mirrored — build an EloConfiguration and call configure(context, configuration) instead.

      • configure

        @JvmOverloads() final static Unit configure(Context context, String publisherId, String adUnitId, Boolean shareGeoLocation)

        Configure the SDK.

        Convenience overload of configure for the common case — default options.

        The geo-sharing controls are mirrored here (unlike every other option) because passive geo sharing is on by default and the opt-out should be visible at the simplest entry point. Anything else (COPPA/TFUA flags, log level) is deliberately not mirrored — build an EloConfiguration and call configure(context, configuration) instead.

      • configure

        @JvmOverloads() final static Unit configure(Context context, String publisherId, String adUnitId)

        Configure the SDK.

        Convenience overload of configure for the common case — default options.

        The geo-sharing controls are mirrored here (unlike every other option) because passive geo sharing is on by default and the opt-out should be visible at the simplest entry point. Anything else (COPPA/TFUA flags, log level) is deliberately not mirrored — build an EloConfiguration and call configure(context, configuration) instead.

      • disable

         final static Unit disable()

        Pause new ad requests without tearing down the SDK.

      • setShareGeoLocation

         final static Unit setShareGeoLocation(Boolean enabled)

        Enable or disable Prebid-style passive geo sharing for future ad requests without reconfiguring the SDK.

        When enabled, the SDK may attach an already-authorized last-known location as OpenRTB device.geo. It never requests location permission itself — with no location permission granted, geo is simply omitted.

        Sharing is on by default since 0.1.8. This runtime toggle does not survive shutdown: a later configure restores the configuration's value (default on), so apps that opt out at runtime must opt out again after reconfiguring. Prefer EloConfiguration.shareGeoLocation = false for a durable opt-out.

      • setUserIdentifier

         final static Unit setUserIdentifier(String identifier)

        Identify the signed-in user with your own stable identifier.

        By default every ad request carries an anonymous, per-install visitor_id the SDK generates (anon_<UUID>). Setting an identifier replaces that value on all subsequent ad requests and tracking pings, so delivery, frequency capping, and reporting follow the account rather than the install.

        Elo.setUserIdentifier(account.id)  // sign-in
        Elo.setUserIdentifier(null)        // sign-out

        Notes:

        • Call it once the user is known, and pass null on sign-out. The order relative to configure does not matter. shutdown clears it; re-configuring does not, since a config refresh is not a sign-out.

        • The anonymous id is kept in storage untouched underneath, so clearing the identifier restores the sameanon_<UUID> the install had before.

        • It is persisted, encrypted at rest — one record with the user data, sealed with AES-GCM under an Android Keystore key. It survives a process restart, so you don't re-set it each launch. Requests made before you first set it use the anonymous id.

        • It survives a sign-out too, so clear it yourself when the user signs out — otherwise the next person on the device inherits it. Calling this from a single auth-state hook covers sign-in, sign-out, and a mid-session account switch in one place.

        • An ad keeps whichever identity it was requested under for its whole lifetime, so an impression firing after a sign-out is still reported against the request that fetched it.

        • Whitespace is trimmed; a blank string clears the identifier. Values longer than 256 characters (Unicode code points) are ignored with a warning.

        • Send an identifier your own systems use, not an email address or other directly identifying value — this id reaches Elo's ad server as the user's identity for targeting.

        Mirrors iOS Elo.setUserIdentifier.

      • setUserData

         final static Unit setUserData(EloUserData userData)

        Share what you know about the signed-in user with ad requests.

        Age, gender, email, and phone ride along on every subsequent ad request as an optional user object. They are recorded for upcoming targeting features and have no effect on ad selection today. Nothing is sent when you never call this.

        Elo.setUserData(EloUserData(age = 34, gender = EloGender.FEMALE, email = account.email))
        Elo.setUserData(null)  // sign-out

        Notes:

        • Pass contact details as they are. They travel over HTTPS and are SHA-256 hashed at the ad server before anything is stored; do not hash them yourself.

        • The SDK does not validate what you set. The server normalizes each field and drops what it can't use. Give a phone number its country code (E.164) or the server discards it.

        • Each call replaces the whole object. Null clears it, as does an object with no field set.

        • Persisted, encrypted at rest (AES-GCM under an Android Keystore key), as one record with the identifier. It survives a sign-out, so clear it yourself when the user signs out, or the previous account's details keep riding requests on this device indefinitely. shutdown erases the stored copy; re-configuring does not.

        • Set it from the same auth-state hook as setUserIdentifier. The two are written as one record, and that hook is also what keeps a persisted copy from going stale when the user changes their email or phone.

        • Never joins tracking pings. The ad server discards it under COPPA, TFUA, or GDPR.

        • Transmitting an email and phone to Elo is a disclosure obligation — see PRIVACY.md.

        Mirrors iOS Elo.setUserData.

      • setUserIdentity

         final static Unit setUserIdentity(String userIdentifier, EloUserData userData)

        Set both halves of the user's identity in one write.

        Prefer this to calling setUserIdentifier and setUserData in sequence whenever both are changing — a sign-in, a sign-out, or an account switch. The two are persisted as one record, so two calls leave an intermediate state on disk: switching from account A to account B stores (B, A's contact details) until the second call lands, and an ad request or a process kill in that window sends or retains one account's PII under the other's identifier. This overload has no such window.

        // sign-in / account switch
        Elo.setUserIdentity(account.id, account.eloUserData)
        // sign-out
        Elo.setUserIdentity(null, null)

        Each parameter behaves exactly as its single-field setter does, including the identifier's trimming and length rules: an identifier rejected for length leaves the stored one in place, and the user data is still applied.

        Mirrors iOS Elo.setUserIdentity.

      • setDebugObserver

        @JvmOverloads() final static Unit setDebugObserver(Function1<EloDebugEvent, Unit> observer, Boolean capturePayloads)

        Observe the SDK's internal debug events — ad operations and tracking outcomes.

        The SDK stores none of this. It reports each EloDebugEvent as it happens and keeps no history, so an observer that wants a recent-loads list or tracking totals records them itself. With no observer attached the SDK does no debug work at all.

        observer may be called from any thread, and is never called while the SDK holds an internal lock, so it is safe to call back into Elo from it. Unlike setListener it is held strongly; pass null to clear it.

        This is a process-level switch, independent of configure and shutdown, so set it once (for example at app startup).

        Set capturePayloads to also report each operation's redacted request payload and decoded ad response (EloDebugEvent.RequestPayloadCaptured and EloDebugEvent.ResponsePayloadCaptured). Off by default. Message content is always dropped, but the request payload retains the advertising id, precise geolocation, consent strings, and any user data set via setUserData — including the plain email address and phone number — so privacy contracts stay inspectable. Enable it only in development/debug builds, and never log or transmit the captured payloads off the device.

        This is a debugging aid for sample apps and in-app diagnostics, not a stable analytics pipeline — use setListener for ad lifecycle callbacks in production. Mirrors iOS Elo.setDebugObserver.

      • setDebugObserver

        @JvmOverloads() final static Unit setDebugObserver(Function1<EloDebugEvent, Unit> observer)

        Observe the SDK's internal debug events — ad operations and tracking outcomes.

        The SDK stores none of this. It reports each EloDebugEvent as it happens and keeps no history, so an observer that wants a recent-loads list or tracking totals records them itself. With no observer attached the SDK does no debug work at all.

        observer may be called from any thread, and is never called while the SDK holds an internal lock, so it is safe to call back into Elo from it. Unlike setListener it is held strongly; pass null to clear it.

        This is a process-level switch, independent of configure and shutdown, so set it once (for example at app startup).

        Set capturePayloads to also report each operation's redacted request payload and decoded ad response (EloDebugEvent.RequestPayloadCaptured and EloDebugEvent.ResponsePayloadCaptured). Off by default. Message content is always dropped, but the request payload retains the advertising id, precise geolocation, consent strings, and any user data set via setUserData — including the plain email address and phone number — so privacy contracts stay inspectable. Enable it only in development/debug builds, and never log or transmit the captured payloads off the device.

        This is a debugging aid for sample apps and in-app diagnostics, not a stable analytics pipeline — use setListener for ad lifecycle callbacks in production. Mirrors iOS Elo.setDebugObserver.

      • loadAd

        @JvmOverloads() final static AdResult loadAd(List<ChatMessage> messages)

        Load an ad for the given chat context.

        maxHeight and maxWidth describe the space the ad will get; the server picks a format that fits and EloAdView renders it. null means unbounded. Values are rounded down to whole dp.

      • trackBrowserOpened

         final static Unit trackBrowserOpened(EloAd ad)

        Report that your in-app browser opened the ad's click URL. Call it from your own browser, together with trackBrowserClosed, when you open clicks yourself instead of letting the system open them; the pair reports how long the user stayed on the advertiser's page.

        override fun onAdDidReceiveClick(ad: EloAd) {
            Elo.trackBrowserOpened(ad)
            browser.open(ad.clickUrl, onClose = { Elo.trackBrowserClosed(ad) })
        }

        A repeated open before the close is ignored.

      • trackBrowserClosed

         final static Unit trackBrowserClosed(EloAd ad)

        Report that your in-app browser closed. Sends the time since the matching trackBrowserOpened, including any time the app spent in the background. A close without an open is ignored.

      • shutdown

         final static Unit shutdown()

        Tear down the SDK. Cancels any in-flight loadAd and clears state.