Vai al contenuto principale
Repository: https://github.com/KlipFit/kleep-android

Installazione


Questo processo deve essere eseguito una sola volta, la prima volta che è necessario installare l’SDK nel tuo progetto. Fai riferimento alla sezione Aggiornamento per le istruzioni sugli aggiornamenti successivi.
  1. Nel tuo gradle.properties, aggiungi questo token: authToken=jp_9ibcequhrjtge3cmavt2k4sq6a
  2. Nel tuo settings.gradle o settings.gradle.kts, aggiungi le seguenti righe:
// 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. Nel file build.gradle o build.gradle.kts del tuo modulo, aggiungi le seguenti righe per creare la dipendenza:
// *build.gradle*
dependencies {
	implementation 'com.github.KlipFit:kleep-android:version'
}
// *build.gradle.kts*
dependencies {
	implementation("com.github.KlipFit:kleep-android:version")
}

Inizializzazione


Modifica la tua classe Application personalizzata e fornisci applicationContext per l’inizializzazione.
import com.kleep.sdk.KleepResult
import com.kleep.sdk.Kleep

class CustomApplication: Application() {

    override fun onCreate() {
        super.onCreate()
        Kleep.init(applicationContext)
    }
}
Non dimenticare di aggiungere la tua classe Application a Manifest.xml
<application
        android:name=".CustomApplication"
        ...
        >
...
</application>

Importazione


Puoi importare manualmente il modulo all’inizio del tuo MainActivity.kt
import com.kleep.sdk.KleepResult
import com.kleep.sdk.Kleep

Utilizzo


L’SDK include 3 metodi:
metodotempo di caricamento
showPrimo avvio: 250ms
Avvii successivi: 50-250ms
requestSize250ms
track250ms

Metodo 1: requestSize

Questo metodo consente di implementare la logica del CTA. Schema logico Questo schema spiega come aggiornare il CTA che apre Kleep. https://www.figma.com/board/BlurZ01lR3JBQZeTUU98TE/Mobile---CTA-Logic?node-id=0-1&t=ccXWciNziIdfhgew-1 Esempio di implementazione
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()
}

Metodo 2: show

Questo metodo viene chiamato quando si clicca sul CTA. Consente di caricare le diverse schermate. Lo sviluppatore che integra l’SDK deve incorporarle in un bottom sheet.
parametroprioritàdescrizione
productIDobbligatorioIl tuo ID prodotto
retailerobbligatorioNome del retailer
customerIDopzionaleIdentificatore CRM, usato per le analisi
trackingIDopzionaleID usato da un provider di tracciamento esterno
stocksopzionaleUna mappa degli ID variante articolo rispetto al loro stato di disponibilità.
true per disponibile, false (predefinito) per esaurito, emptyMap o non specificato per saltare il controllo.
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()

Metodo 3: track

Questo metodo consente di tracciare eventi personalizzati.
Kleep.track(eventName: String, eventInfo: Map<String, String>)
Vogliamo tracciare 3 eventi:
eventNameTrigger
product_viewedAlla visualizzazione della PDP
product_added_to_cartAll’aggiunta del prodotto al carrello
checkout_completedAlla conferma dell’ordine dopo il pagamento
product_viewed Parametri (CSV) Esempio
{
		productId: str
}
product_added_to_cart Parametri (CSV) Esempio
{
    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 Parametri (CSV) Esempio
{
    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"
				}
	    }
	    ...
    ],
}