From 7f0e34866b80185c67eecb522a40f762c9572763 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 11:41:36 -0500 Subject: [PATCH] Generated Docs for "Attach lifecycle listeners internally in initialize method (#131)* Internalize the lifecycle listener attachment.* Mark the public property to be deprecated and replace with a no-op implementation to avoid duplicate listeners.* Update readme instructions, migration guide.---------Co-authored-by: Evan Masseau <>" (#136) * Auto generate documentation PRs (#124) Automate all the things Co-authored-by: Evan Masseau <> * Minor README and Documentation Updates (#121) * Fixed SDK name in license section * Fixed appearance of some of the advanced section after seeing it on the dokka html * Other grammar/spelling fixes --------- Co-authored-by: Evan Masseau <> * Add note about anonymous profiles to readme (#127) --------- Co-authored-by: Evan Masseau <> * Wrap public methods in try/catch (#129) Added safety checks around public API methods to prevent throwing exceptions that would otherwise crash the host application --------- Co-authored-by: Evan Masseau <> * Logging (#130) - Enable logging in published SDK - Added level-aware logging with a configurable threshold from code or manifest file. - Added warning level - Threshold has a default based on debug/release, can be configured from code and from manifest - Updated tests, removed some old log related test code from earlier build variants/flavors - Adjusted log levels throughout the code --------- Co-authored-by: Evan Masseau <> * Attach lifecycle listeners internally in initialize method (#131) * Internalize the lifecycle listener attachment. * Mark the public property to be deprecated and replace with a no-op implementation to avoid duplicate listeners. * Update readme instructions, migration guide. --------- Co-authored-by: Evan Masseau <> * Generated docs for e9598b0288a1780e926fdf8ead41836031bc6eaf --------- Co-authored-by: Evan C Masseau <5167687+evan-masseau@users.noreply.github.com> Co-authored-by: github-actions --- MIGRATION_GUIDE.md | 11 + README.md | 42 ++- docs/2.0.0/index.html | 36 ++- docs/2.0.0/navigation.html | 178 ++++++++---- docs/2.0.0/scripts/pages.json | 2 +- .../-base-model/-base-model.html | 2 +- .../-base-model/get.html | 2 +- .../-base-model/index.html | 12 +- .../-base-model/set-property.html | 2 +- .../-base-model/set.html | 2 +- .../-base-model/to-map.html | 2 +- .../-event/-event.html | 2 +- .../-event/index.html | 6 +- .../-event/set-property.html | 2 +- .../-profile/-profile.html | 2 +- .../-profile/index.html | 6 +- .../-profile/set-property.html | 2 +- .../com.klaviyo.analytics.model/index.html | 6 +- .../-api-request/index.html | 2 +- .../-api-request/url.html | 2 +- .../com.klaviyo.analytics/-klaviyo/index.html | 6 +- .../-klaviyo/initialize.html | 2 +- .../-klaviyo/lifecycle-callbacks.html | 5 +- .../-klaviyo/reset-profile.html | 2 +- docs/2.0.0/sdk/analytics/navigation.html | 178 ++++++++---- .../-config/get-manifest-int.html | 76 ++++++ .../-config/index.html | 34 +++ .../-config/is-debug-build.html | 76 ++++++ .../-klaviyo-config/get-manifest-int.html | 76 ++++++ .../-klaviyo-config/index.html | 34 +++ .../-klaviyo-config/is-debug-build.html | 76 ++++++ .../-level/-assert/index.html | 80 ++++++ .../-level/-debug/index.html | 80 ++++++ .../-level/-error/index.html | 80 ++++++ .../-level/-info/index.html | 80 ++++++ .../-level/-none/index.html | 80 ++++++ .../-level/-verbose/index.html | 80 ++++++ .../-level/-warning/index.html | 80 ++++++ .../-level/entries.html | 76 ++++++ .../com.klaviyo.core.config/-level/index.html | 243 +++++++++++++++++ .../-level/value-of.html | 76 ++++++ .../-level/values.html | 76 ++++++ .../-lifecycle-exception.html | 76 ++++++ .../-lifecycle-exception/index.html | 100 +++++++ .../-log/-level/-assert/index.html | 80 ++++++ .../-log/-level/-debug/index.html | 80 ++++++ .../-log/-level/-error/index.html | 80 ++++++ .../-log/-level/-info/index.html | 80 ++++++ .../-log/-level/-none/index.html | 80 ++++++ .../-log/-level/-verbose/index.html | 80 ++++++ .../-log/-level/-warning/index.html | 80 ++++++ .../-log/-level/entries.html | 76 ++++++ .../-log/-level/index.html | 258 ++++++++++++++++++ .../-log/-level/value-of.html | 76 ++++++ .../-log/-level/values.html | 76 ++++++ .../com.klaviyo.core.config/-log/index.html | 55 +++- .../-log/log-level.html | 76 ++++++ .../com.klaviyo.core.config/-log/warning.html | 76 ++++++ .../get-application-info-compat.html | 76 ++++++ .../get-manifest-int.html | 76 ++++++ .../core/com.klaviyo.core.config/index.html | 62 ++++- .../-no-op-lifecycle-callbacks/index.html | 190 +++++++++++++ .../on-activity-created.html | 76 ++++++ .../on-activity-destroyed.html | 76 ++++++ .../on-activity-paused.html | 76 ++++++ .../on-activity-resumed.html | 76 ++++++ .../on-activity-save-instance-state.html | 76 ++++++ .../on-activity-started.html | 76 ++++++ .../on-activity-stopped.html | 76 ++++++ .../com.klaviyo.core.lifecycle/index.html | 15 + .../-invalid-registration/index.html | 2 +- .../core/com.klaviyo.core/-k-log/-k-log.html | 76 ++++++ .../core/com.klaviyo.core/-k-log/debug.html | 76 ++++++ .../core/com.klaviyo.core/-k-log/error.html | 76 ++++++ .../core/com.klaviyo.core/-k-log/index.html | 228 ++++++++++++++++ .../core/com.klaviyo.core/-k-log/info.html | 76 ++++++ .../com.klaviyo.core/-k-log/log-level.html | 76 ++++++ .../sdk/core/com.klaviyo.core/-k-log/log.html | 76 ++++++ .../core/com.klaviyo.core/-k-log/verbose.html | 76 ++++++ .../core/com.klaviyo.core/-k-log/warning.html | 76 ++++++ .../sdk/core/com.klaviyo.core/-k-log/wtf.html | 76 ++++++ .../-klaviyo-exception/index.html | 2 +- .../-missing-config/index.html | 2 +- .../-missing-registration/index.html | 2 +- .../com.klaviyo.core/-registry/index.html | 15 + .../-registry/unregister.html | 76 ++++++ .../sdk/core/com.klaviyo.core/index.html | 82 ++++-- docs/2.0.0/sdk/core/com.klaviyo.core/log.html | 76 ++++++ .../sdk/core/com.klaviyo.core/safe-apply.html | 76 ++++++ .../sdk/core/com.klaviyo.core/safe-call.html | 76 ++++++ docs/2.0.0/sdk/core/navigation.html | 178 ++++++++---- .../-log-fixture/-log-fixture.html | 76 ++++++ .../-log-fixture/debug.html | 76 ++++++ .../-log-fixture/error.html | 76 ++++++ .../-log-fixture/index.html | 213 +++++++++++++++ .../-log-fixture/info.html | 76 ++++++ .../-log-fixture/log-level.html | 76 ++++++ .../-log-fixture/verbose.html | 76 ++++++ .../-log-fixture/warning.html | 76 ++++++ .../-log-fixture/wtf.html | 76 ++++++ .../fixtures/com.klaviyo.fixtures/index.html | 8 +- docs/2.0.0/sdk/fixtures/navigation.html | 178 ++++++++---- docs/2.0.0/sdk/push-fcm/navigation.html | 178 ++++++++---- .../java/com/klaviyo/analytics/Klaviyo.kt | 117 ++++---- .../analytics/ProfileOperationQueue.kt | 52 ++++ .../java/com/klaviyo/analytics/UserInfo.kt | 2 +- .../analytics/networking/KlaviyoApiClient.kt | 30 +- .../networking/requests/KlaviyoApiRequest.kt | 2 +- .../klaviyo/analytics/DevicePropertiesTest.kt | 2 + .../java/com/klaviyo/analytics/KlaviyoTest.kt | 110 ++++---- .../analytics/KlaviyoUninitializedTest.kt | 121 ++++++++ .../networking/KlaviyoApiClientTest.kt | 8 +- sdk/build.gradle | 11 +- .../debug/java/com/klaviyo/core/Console.kt | 16 -- .../src/debug/java/com/klaviyo/core/Logger.kt | 67 ----- .../src/main/java/com/klaviyo/core/KLog.kt | 109 ++++++++ .../java/com/klaviyo/core/KlaviyoException.kt | 17 ++ .../main/java/com/klaviyo/core/LogLevel.kt | 17 ++ .../main/java/com/klaviyo/core/Registry.kt | 22 +- .../java/com/klaviyo/core/config/Config.kt | 3 + .../com/klaviyo/core/config/KlaviyoConfig.kt | 56 ++++ .../main/java/com/klaviyo/core/config/Log.kt | 46 ++++ .../core/lifecycle/KlaviyoLifecycleMonitor.kt | 2 +- .../core/lifecycle/NoOpLifecycleCallbacks.kt | 21 ++ .../core/model/SharedPreferencesDataStore.kt | 2 +- .../core/networking/KlaviyoNetworkMonitor.kt | 4 +- .../release/java/com/klaviyo/core/Logger.kt | 11 - .../test/java/com/klaviyo/core/KLogTest.kt | 77 ++++++ .../java/com/klaviyo/core/RegistryTest.kt | 21 +- .../klaviyo/core/config/KlaviyoConfigTest.kt | 2 + .../lifecycle/KlaviyoLifecycleMonitorTest.kt | 14 +- .../model/SharedPreferencesDataStoreTest.kt | 6 +- .../networking/KlaviyoNetworkMonitorTest.kt | 4 +- .../testLocalDebug/java/android/util/Log.java | 20 -- .../java/android/util/MockLog.kt | 33 --- .../java/com/klaviyo/core/LoggerTest.kt | 54 ---- .../java/com/klaviyo/fixtures/BaseTest.kt | 2 +- .../java/com/klaviyo/fixtures/LogFixture.kt | 23 ++ .../main/java/com/klaviyo/fixtures/Logger.kt | 28 -- .../klaviyo/pushFcm/KlaviyoNotification.kt | 6 +- .../com/klaviyo/pushFcm/KlaviyoPushService.kt | 2 +- .../klaviyo/pushFcm/KlaviyoRemoteMessage.kt | 64 +---- 142 files changed, 7403 insertions(+), 782 deletions(-) create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-config/get-manifest-int.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-config/is-debug-build.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-klaviyo-config/get-manifest-int.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-klaviyo-config/is-debug-build.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-level/-assert/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-level/-debug/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-level/-error/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-level/-info/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-level/-none/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-level/-verbose/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-level/-warning/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-level/entries.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-level/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-level/value-of.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-level/values.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-lifecycle-exception/-lifecycle-exception.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-lifecycle-exception/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-log/-level/-assert/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-log/-level/-debug/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-log/-level/-error/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-log/-level/-info/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-log/-level/-none/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-log/-level/-verbose/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-log/-level/-warning/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-log/-level/entries.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-log/-level/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-log/-level/value-of.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-log/-level/values.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-log/log-level.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/-log/warning.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/get-application-info-compat.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.config/get-manifest-int.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.lifecycle/-no-op-lifecycle-callbacks/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.lifecycle/-no-op-lifecycle-callbacks/on-activity-created.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.lifecycle/-no-op-lifecycle-callbacks/on-activity-destroyed.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.lifecycle/-no-op-lifecycle-callbacks/on-activity-paused.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.lifecycle/-no-op-lifecycle-callbacks/on-activity-resumed.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.lifecycle/-no-op-lifecycle-callbacks/on-activity-save-instance-state.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.lifecycle/-no-op-lifecycle-callbacks/on-activity-started.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core.lifecycle/-no-op-lifecycle-callbacks/on-activity-stopped.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core/-k-log/-k-log.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core/-k-log/debug.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core/-k-log/error.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core/-k-log/index.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core/-k-log/info.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core/-k-log/log-level.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core/-k-log/log.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core/-k-log/verbose.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core/-k-log/warning.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core/-k-log/wtf.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core/-registry/unregister.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core/log.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core/safe-apply.html create mode 100644 docs/2.0.0/sdk/core/com.klaviyo.core/safe-call.html create mode 100644 docs/2.0.0/sdk/fixtures/com.klaviyo.fixtures/-log-fixture/-log-fixture.html create mode 100644 docs/2.0.0/sdk/fixtures/com.klaviyo.fixtures/-log-fixture/debug.html create mode 100644 docs/2.0.0/sdk/fixtures/com.klaviyo.fixtures/-log-fixture/error.html create mode 100644 docs/2.0.0/sdk/fixtures/com.klaviyo.fixtures/-log-fixture/index.html create mode 100644 docs/2.0.0/sdk/fixtures/com.klaviyo.fixtures/-log-fixture/info.html create mode 100644 docs/2.0.0/sdk/fixtures/com.klaviyo.fixtures/-log-fixture/log-level.html create mode 100644 docs/2.0.0/sdk/fixtures/com.klaviyo.fixtures/-log-fixture/verbose.html create mode 100644 docs/2.0.0/sdk/fixtures/com.klaviyo.fixtures/-log-fixture/warning.html create mode 100644 docs/2.0.0/sdk/fixtures/com.klaviyo.fixtures/-log-fixture/wtf.html create mode 100644 sdk/analytics/src/main/java/com/klaviyo/analytics/ProfileOperationQueue.kt create mode 100644 sdk/analytics/src/test/java/com/klaviyo/analytics/KlaviyoUninitializedTest.kt delete mode 100644 sdk/core/src/debug/java/com/klaviyo/core/Console.kt delete mode 100644 sdk/core/src/debug/java/com/klaviyo/core/Logger.kt create mode 100644 sdk/core/src/main/java/com/klaviyo/core/KLog.kt create mode 100644 sdk/core/src/main/java/com/klaviyo/core/LogLevel.kt create mode 100644 sdk/core/src/main/java/com/klaviyo/core/lifecycle/NoOpLifecycleCallbacks.kt delete mode 100644 sdk/core/src/release/java/com/klaviyo/core/Logger.kt create mode 100644 sdk/core/src/test/java/com/klaviyo/core/KLogTest.kt delete mode 100644 sdk/core/src/testLocalDebug/java/android/util/Log.java delete mode 100644 sdk/core/src/testLocalDebug/java/android/util/MockLog.kt delete mode 100644 sdk/core/src/testLocalDebug/java/com/klaviyo/core/LoggerTest.kt create mode 100644 sdk/fixtures/src/main/java/com/klaviyo/fixtures/LogFixture.kt delete mode 100644 sdk/fixtures/src/main/java/com/klaviyo/fixtures/Logger.kt diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index c43cca836..7482f6dad 100644 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -2,6 +2,17 @@ This document provides guidance on how to migrate from the old version of the SDK to a newer version. It will be updated as new versions are released including deprecations or breaking changes. +## 2.1.0 Deprecations +#### Deprecated `Klaviyo.lifecycleCallbacks` +In an effort to reduce setup code required to integrate the Klaviyo Android SDK, we have deprecated the public property +`Klaviyo.lifecycleCallbacks` and will now register for lifecycle callbacks automatically upon `initialize`. +It is no longer required to have this line in your `Application.onCreate()` method: +```kotlin +registerActivityLifecycleCallbacks(Klaviyo.lifecycleCallbacks) +``` +For version 2.1.x, `Klaviyo.lifecycleCallbacks` has been replaced with a no-op implementation to avoid duplicative +listeners, and will be removed altogether in the next major release. + ## 2.0.0 Breaking Changes #### Removed `EventType` in favor of `EventMetric`. The reasoning is explained below, see [1.4.0 Deprecations](#140-deprecations) for details and code samples. diff --git a/README.md b/README.md index 543374ac8..58205ac78 100644 --- a/README.md +++ b/README.md @@ -73,9 +73,12 @@ send them timely push notifications via [FCM (Firebase Cloud Messaging)](https:/ The SDK must be initialized with the short alphanumeric [public API key](https://help.klaviyo.com/hc/en-us/articles/115005062267#difference-between-public-and-private-api-keys1) for your Klaviyo account, also known as your Site ID. We require access to the `applicationContext` so the -SDK can be responsive to changes in network conditions and persist data via -`SharedPreferences`. You must also register the Klaviyo SDK for activity lifecycle -callbacks per the example code, so we can gracefully manage background processes. +SDK can be responsive to changes in application state and network conditions, and access `SharedPreferences` to +persist data. Upon initialize, the SDK registers listeners for your application's activity lifecycle callbacks, +to gracefully manage background processes. + +`Klaviyo.initialize()` **must** be called before any other SDK methods can be invoked. We recommend initializing from +the earliest point in your application code, such as the `Application.onCreate()` method. ```kotlin // Application subclass @@ -90,18 +93,10 @@ class YourApplication : Application() { // Initialize is required before invoking any other Klaviyo SDK functionality Klaviyo.initialize("KLAVIYO_PUBLIC_API_KEY", applicationContext) - - // Required for the SDK to properly respond to lifecycle changes such as app backgrounding - registerActivityLifecycleCallbacks(Klaviyo.lifecycleCallbacks) } } ``` -`Klaviyo.initialize()` **must** be called before any other SDK methods can be invoked. -Because we require lifecycle callbacks, it is necessary to subclass -[`Application`](https://developer.android.com/reference/android/app/Application) -to initialize and register callbacks in `Application.onCreate`. - ## Profile Identification The SDK provides methods to identify profiles via the [Create Client Profile API](https://developers.klaviyo.com/en/reference/create_client_profile). @@ -449,6 +444,31 @@ extensions such as `import com.klaviyo.pushFcm.KlaviyoRemoteMessage.body` to acc We also provide an `Intent.appendKlaviyoExtras(RemoteMessage)` extension method, which attaches the data to your notification intent that the Klaviyo SDK requires in order to track opens when you call `Klaviyo.handlePush(intent)`. +## Troubleshooting +The SDK contains logging at different levels from `verbose` to `assert`. By default, the SDK logs at the `error` level +in a production environment and at the `warning` level in a debug environment. You can change the log level by adding +the following metadata tag to your manifest file. +* `0` = disable logging entirely +* `1` = `Verbose` and above +* `2` = `Debug` and above +* `3` = `Info` and above +* `4` = `Warning` and above +* `5` = `Error` and above +* `6` = `Assert` only + +```xml + + + + + + + + +``` + ## Contributing See the [contributing guide](.github/CONTRIBUTING.md) to learn how to contribute to the Klaviyo Android SDK. We welcome your feedback in the [discussion](https://github.com/klaviyo/klaviyo-android-sdk/discussions) diff --git a/docs/2.0.0/index.html b/docs/2.0.0/index.html index d7899d796..44cdd19a6 100644 --- a/docs/2.0.0/index.html +++ b/docs/2.0.0/index.html @@ -103,13 +103,13 @@

Installation

Initialization

-

The SDK must be initialized with the short alphanumeric public API key for your Klaviyo account, also known as your Site ID. We require access to the applicationContext so the SDK can be responsive to changes in network conditions and persist data via SharedPreferences. You must also register the Klaviyo SDK for activity lifecycle callbacks per the example code, so we can gracefully manage background processes.

+

The SDK must be initialized with the short alphanumeric public API key for your Klaviyo account, also known as your Site ID. We require access to the applicationContext so the SDK can be responsive to changes in application state and network conditions, and access SharedPreferences to persist data. Upon initialize, the SDK registers listeners for your application's activity lifecycle callbacks, to gracefully manage background processes.

+

Klaviyo.initialize() must be called before any other SDK methods can be invoked. We recommend initializing from the earliest point in your application code, such as the Application.onCreate() method.

-
// Application subclass 
import android.app.Application
import com.klaviyo.analytics.Klaviyo

class YourApplication : Application() {
override fun onCreate() {
super.onCreate()

/* ... */

// Initialize is required before invoking any other Klaviyo SDK functionality
Klaviyo.initialize("KLAVIYO_PUBLIC_API_KEY", applicationContext)

// Required for the SDK to properly respond to lifecycle changes such as app backgrounding
registerActivityLifecycleCallbacks(Klaviyo.lifecycleCallbacks)
}
}
+
// Application subclass 
import android.app.Application
import com.klaviyo.analytics.Klaviyo

class YourApplication : Application() {
override fun onCreate() {
super.onCreate()

/* ... */

// Initialize is required before invoking any other Klaviyo SDK functionality
Klaviyo.initialize("KLAVIYO_PUBLIC_API_KEY", applicationContext)
}
}
-

Klaviyo.initialize() must be called before any other SDK methods can be invoked. Because we require lifecycle callbacks, it is necessary to subclass Application to initialize and register callbacks in Application.onCreate.

Profile Identification

The SDK provides methods to identify profiles via the Create Client Profile API. A profile can be identified by any combination of the following: