AnalyticsKt

public final class AnalyticsKt


Summary

Public methods

static final @NonNull FirebaseAnalytics

Accessing this object for Kotlin apps has changed; see the migration guide.

static final void
logEvent(
    @NonNull FirebaseAnalytics receiver,
    @NonNull String name,
    @ExtensionFunctionType @NonNull Function1<@NonNull ParametersBuilderUnit> block
)

This method is deprecated. Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.

static final void
setConsent(
    @NonNull FirebaseAnalytics receiver,
    @ExtensionFunctionType @NonNull Function1<@NonNull ConsentBuilderUnit> block
)

This method is deprecated. Migrate to use the KTX API from the main module: https://firebase.google.com/docs/android/kotlin-migration.

Public methods

getAnalytics

public static final @NonNull FirebaseAnalytics getAnalytics(@NonNull Firebase receiver)

Accessing this object for Kotlin apps has changed; see the migration guide.

Returns the FirebaseAnalytics instance of the default FirebaseApp.

Deprecation Notice: The Kotlin extensions (KTX) APIs have been added to their respective main modules, and the Kotlin extension (KTX) APIs in com.google.firebase.firebase-analytics-ktx are now deprecated. As early as April 2024, we'll no longer release KTX modules. For details, see the FAQ about this initiative.,

logEvent

public static final void logEvent(
    @NonNull FirebaseAnalytics receiver,
    @NonNull String name,
    @ExtensionFunctionType @NonNull Function1<@NonNull ParametersBuilderUnit> block
)

Fluent version of FirebaseAnalytics.logEvent.

Example use:

Firebase.analytics.logEvent("myEvent") {
param(Params.VALUE, 3.99)
param(Params.CURRENCY, "USD")
}

Deprecation Notice: The Kotlin extensions (KTX) APIs have been added to their respective main modules, and the Kotlin extension (KTX) APIs in com.google.firebase.firebase-analytics-ktx are now deprecated. As early as April 2024, we'll no longer release KTX modules. For details, see the FAQ about this initiative.,

setConsent

public static final void setConsent(
    @NonNull FirebaseAnalytics receiver,
    @ExtensionFunctionType @NonNull Function1<@NonNull ConsentBuilderUnit> block
)

Fluent version of FirebaseAnalytics.setConsent.

Example use:

Firebase.analytics.setConsent {
adStorage = ConsentStatus.GRANTED
analyticsStorage = ConsentStatus.GRANTED
}

Deprecation Notice: The Kotlin extensions (KTX) APIs have been added to their respective main modules, and the Kotlin extension (KTX) APIs in com.google.firebase.firebase-analytics-ktx are now deprecated. As early as April 2024, we'll no longer release KTX modules. For details, see the FAQ about this initiative.,