Przejdź do głównej treści
Repozytorium: https://github.com/KlipFit/kleep-android

Instalacja


Proces ten należy wykonać tylko raz, przy pierwszej instalacji SDK w projekcie. W celu zapoznania się z instrukcjami dotyczącymi kolejnych aktualizacji prosimy o zajrzenie do sekcji Aktualizacja.
  1. W pliku gradle.properties dodaj ten token: authToken=jp_9ibcequhrjtge3cmavt2k4sq6a
  2. W pliku settings.gradle lub settings.gradle.kts dodaj następujące linie:
// for *settings.gradle*

dependencyResolutionManagement {
*// ...*
    repositories {
        *// ...*
~~~~        maven {
            url "https://jitpack.io"
            credentials { username authToken }
        }
    }
}
// for *settings.gradle.kts*

*dependencyResolutionManagement {
// ...
    repositories {
	      // ... 
        maven {
            url = uri("https://jitpack.io")
            credentials(PasswordCredentials::class) {
                val authToken: String by settings
                username = authToken*
            }
        *}
    }
}*
  1. W pliku build.gradle lub build.gradle.kts modułu dodaj następujące linie, aby utworzyć zależność:
// *build.gradle*
dependencies {
	implementation 'com.github.KlipFit:kleep-android:version'
}
// *build.gradle.kts*
dependencies {
	implementation("com.github.KlipFit:kleep-android:version")
}

Inicjalizacja


Edytuj swoją niestandardową klasę Application i podaj applicationContext do inicjalizacji.
import com.kleep.sdk.KleepResult
import com.kleep.sdk.Kleep

class CustomApplication: Application() {

    override fun onCreate() {
        super.onCreate()
        Kleep.init(applicationContext)
    }
}
Nie zapomnij dodać swojej klasy Application do Manifest.xml
<application
        android:name=".CustomApplication"
        ...
        >
...
</application>

Import


Możesz ręcznie zaimportować moduł na początku pliku MainActivity.kt
import com.kleep.sdk.KleepResult
import com.kleep.sdk.Kleep

Użycie


SDK zawiera 3 metody:
metodaczas ładowania
showPierwsze uruchomienie: 250ms
Kolejne uruchomienia: 50-250ms
requestSize250ms
track250ms

Metoda 1: requestSize

Ta metoda umożliwia implementację logiki CTA. Schemat logiki Ten schemat wyjaśnia, jak aktualizować CTA otwierające Kleep. https://www.figma.com/board/BlurZ01lR3JBQZeTUU98TE/Mobile---CTA-Logic?node-id=0-1&t=ccXWciNziIdfhgew-1 Przykład implementacji
Kleep.builder(this, onResult = {
	when (it) {
	    is KleepResult.NotSupported -> {
	        // Handle the NotSupported case
	    }
	
	    is KleepResult.NoRecommendationYet -> {
	        // Handle the NoRecommendationYet case
	    }
	
	    is KleepResult.RecommendationFound -> {
	        val resultText = it.size
	        val variantId = it.variantId
	        Toast.makeText(this, resultText, Toast.LENGTH_SHORT).show()         
      }

      else -> {

      }
    }
})
	.setPackageName(packageName)         // optional
	.setLang(DEFAULT_LANGUAGE)           // required: "fr", "en", "es", "it", "pt", "nl"
	.setProductId("1234")                // required
	.setRetailer("retailer_name")        // required
	.setTrackingId("uuid")               // empty if non-existent 
	.setCustomerId("unique_customer_id") // optional
	.requestSize()
package com.kleep.sdk

/**
 * Interface with the Kleep SDK in order to compute the recommended size of a product given some user information
 */
interface KleepDialogBuilder {
    /**
     * Set the package name, not required
     * @return interface of the SDK builder
     */
    fun setPackageName(packageName: String): KleepDialogBuilder
    
    /**
     * Set the language to use: required (default to FR)
     * Values supported: "fr", "en", "es", "it", "pt", "nl"
     * @return interface of the SDK builder
     */
    fun setLang(lang: String): KleepDialogBuilder

    /**
     * Set product ID, required to compute the recommended size.
     * @return interface of the SDK builder
     */
    fun setProductId(productId: String): KleepDialogBuilder

    /**
     * Set tracking id, required. Should represent unique tracking id.
     * Should be an empty string if the tracking id does not exist.
     *
     * @return interface of the SDK builder
     */
    fun setTrackingId(tracking_id: String): KleepDialogBuilder

    /**
     * Set customer id, optonal. Should represent customer id linked to backend.
     * Should be an empty string if the tracking id does not exist.
     *
     * @return interface of the SDK builder
     */
    fun setCustomerId(customer_id: String): KleepDialogBuilder
    
    /**
     * Set retail name (mandatory), required for stock/similar_products requests.
     *
     * @return interface of the SDK builder
     */
    fun setRetailer(retailerName: String): KleepDialogBuilder
    
    /**
     * Sets the stock availability for items.
     * Providing an empty map or omitting this function disables stock checking.
     *
     * @return interface of the SDK builder
     */
    fun setStocks(stocks: Map<String, Boolean>): KleepDialogBuilder

    /**
     * Display the Kleep UI inside a BottomSheet, so the user can fill a survey or take 2 pictures
     * in order to compute and display the recommended size to the user
     */
    fun show()

    /**
     * Get the latest recommended size for the last viewed user.
     * As it's an async process and take several seconds,
		 * the result will be give by the onResult listener , provided to the SDK builder
     */
    fun requestSize()
}

Metoda 2: show

Ta metoda jest wywoływana po kliknięciu CTA. Umożliwia załadowanie różnych ekranów. Programista integrujący SDK powinien umieścić je w bottom sheet.
parametrpriorytetopis
productIDwymaganyIdentyfikator Twojego produktu
retailerwymaganyNazwa sprzedawcy
customerIDopcjonalnyIdentyfikator CRM, używany do analityki
trackingIDopcjonalnyID używany przez zewnętrznego dostawcę śledzenia
stocksopcjonalnyMapa identyfikatorów wariantów produktów i ich stanu magazynowego.
true oznacza dostępny, false (domyślnie) oznacza niedostępny, emptyMap lub brak parametru pomija sprawdzenie.
Kleep.builder(this, onResult = {
	when (it) {
	    is KleepResult.NotSupported -> {
	        // Handle the NotSupported case
	    }
	
	    is KleepResult.NoRecommendationYet -> {
	        // Handle the NoRecommendationYet casem
	    }
	
	    is KleepResult.RecommendationFound -> {
	        val resultText = it.size
	        val variantId = it.variantId
	        // addToCart(variantId)
	        
	        Toast.makeText(this, resultText, Toast.LENGTH_SHORT).show()
      }

      else -> {

      }
    }
})
	.setPackageName(packageName)         // optional
	.setLang(DEFAULT_LANGUAGE)           // required: "fr", "en", "es", "it", "pt", "nl"
	.setProductId("1234")                // required
	.setRetailer("retailer_name")        // required
	.setTrackingId("tracking_id")        // optional
	.setCustomerId("unique_customer_id") // optional
	.setStocks(stocks: Map<String, Boolean>) // optional
	.show()

Metoda 3: track

Ta metoda umożliwia śledzenie niestandardowych zdarzeń.
Kleep.track(eventName: String, eventInfo: Map<String, String>)
Chcemy śledzić 3 zdarzenia:
eventNameWyzwalacz
product_viewedPo wyświetleniu strony produktu (PDP)
product_added_to_cartPo dodaniu produktu do koszyka
checkout_completedPo potwierdzeniu zamówienia po płatności
product_viewed Parametry (CSV) Przykład
{
		productId: str
}
product_added_to_cart Parametry (CSV) Przykład
{
    productId: str,
    variantId: str,
    cart: [
	    {
		    productId: "123ABC456",
		    variantId: "123ABC456-00R",
				sku: "XYZ",
		    size: "S",
		    quantity: 2,
		    price: {
						amount: "50",
				    currencyCode: "EUR"		    
		    }
	    },
	    {
		    productId: "123ABC456",
		    variantId: "123ABC456-00R",
		    sku: "XYZ",
		    size: "S",
		    quantity: 1,
		    price: {
				    amount: "40",
				    currencyCode: "USD"
				}
	    }
	    ...
    ],
}
checkout_completed Parametry (CSV) Przykład
{
    orderId: "000001",
    cart: [
	    {
		    lineItemId: "000001#1",
		    productId: "123ABC456",
		    variantId: "123ABC456-00R",
				sku: "XYZ",
		    size: "S",
		    quantity: 2,
		    price: {
						amount: "50",
				    currencyCode: "EUR"		    
		    }
	    },
	    {
			  lineItemId: "000000#2",
		    productId: "123ABC456",
		    variantId: "123ABC456-00R",
		    sku: "XYZ",
		    size: "S",
		    quantity: 1,
		    price: {
				    amount: "40",
				    currencyCode: "USD"
				}
	    }
	    ...
    ],
}