基本機能の移行 #
SDKの初期化 #
主な変更点 #
setup
メソッドのパラメータが変更になりました。また、パラメータ指定方式にはビルダーパターンが採用されています。setSiteHostName
は廃止され、契約ドメインの設定はsetup
パラメータに組み込まれました。
サンプルコード #
v5.0 #
try Rtoaster.setup(RtoasterSetupParameter.Builder()
.trackingId("RTA-xxxx-xxxxxxxxxxxx")
.password("abcdefghijkl")
.defaultConnectionAuthorizationStatus(.authorized)
.hostName("https://www.brainpad.co.jp")
.build()
)
v4.x #
Rtoaster.setup(
withAccountId: "RTA-xxxx-xxxxxxxxxxxx",
basicUsername: "RTA-xxxx-xxxxxxxxxxxx",
basicPassword: "abcdefghijkl",
pushEnvironmentType: PushDisabled,
defaultAuthorizationStatus: RtoasterAuthorizationStatusAuthorized
)
v5.0 #
Rtoaster.setup(RtoasterSetupParameter {
application(this)
trackingId("RTA-xxxx-xxxxxxxxxxxx")
password("abcdefghijkl")
defaultConnectionAuthorizationStatus(Rtoaster.ConnectionAuthorizationStatus.Authorized)
hostName("https://www.brainpad.co.jp")
})
v4.x #
Rtoaster.setup(
this,
"RTA-xxxx-xxxxxxxxxxxx",
"RTA-xxxx-xxxxxxxxxxxx",
"abcdefghijkl",
Rtoaster.PushEnvironmentType.Disabled,
Rtoaster.AuthorizationStatus.Authorized
)
ユーザーIDの設定・取得 #
主な変更点 #
- メソッド名が変更になりました。
サンプルコード #
オプトアウト・オプトイン #
主な変更点 #
optIn
メソッドのパラメータが変更され、呼び出し直前にsetUserId
メソッドを呼び出す必要があります。
サンプルコード #
トラッキング処理の移行 #
主な変更点 #
track
メソッドのパラメータが変更になりました。また、パラメータ指定方式にはビルダーパターンが採用されています。- コールバックの形式が変更されています。
サンプルコード #
カスタム変数の利用 #
カスタム変数 app_1
に "A"
を設定し、トラッキングを行っているサンプルです。
v5.0 #
let customValues = [
"app_1": "A"
]
do {
try Rtoaster.track(.Builder()
.location(Location("testLocation"))
.values(TrackingValues.Builder()
.customValues(customValues)
.build()
)
.build()
).onFailure { [weak self] error in
print("Communication error: \(error.toMap())")
}
} catch {
print("Parameter error: \(error.toMap())")
}
v4.x #
let customValues = [
"app_1": "A"
]
Rtoaster.track(
withLocation: "testLocation",
withAppKeys: customValues,
withCompletionHandler: { [self] result in
if let error = result.error {
print("error: \(error)")
}
}
)
v5.0 #
val customValues = mapOf(
"app_1" to "A"
)
try {
Rtoaster.track(TrackingParameter {
location(Location("testLocation"))
values(TrackingValues {
customValues(customValues)
})
}).onFailure {
Log.d("Rtoaster", "Communication error", it)
}
} catch (e: Exception) {
Log.d("Rtoaster", "Parameter error", e)
}
v4.x #
val customValues = mapOf(
"app_1" to "A"
)
try {
Rtoaster.track(
"testLocation",
null,
HashMap<String, String>(customValues)
) { exception ->
Log.d("Rtoaster", "Communication error", exception)
}
} catch (e: Exception) {
Log.d("Rtoaster", "Parameter error", e)
}
アイテムコードとセッションID指定 #
閲覧学習のためにアイテムコードとレコメンド結果から受け取ったセッションIDを指定しているサンプルです。
v5.0 #
do {
let trackingValues = try BrowsingValues.Builder()
.itemCode("item_12345") // アイテムコード
.sessionId(SessionId("xxyyxxyyxxyyxxyyxxyyxxyy")) // 効果測定ID
.build()
try Rtoaster.track(.Builder()
.location(Location("testLocation"))
.values(trackingValues)
.build()
).onFailure { [weak self] error in
print("Communication error: \(error.toMap())")
}
} catch {
print("Parameter error: \(error.toMap())")
}
v4.x #
let customValues = [
"item_code": "item_12345", // アイテムコード
"_rt.sid": "xxyyxxyyxxyyxxyyxxyyxxyy" // 効果測定ID
]
Rtoaster.track(
withLocation: "testLocation",
withAppKeys: customValues,
withCompletionHandler: { [self] result in
if let error = result.error {
print("error: \(error)")
}
}
)
v5.0 #
val trackingValues = BrowsingValues {
itemCode("item_12345") // アイテムコード
sessionId(SessionId("xxyyxxyyxxyyxxyyxxyyxxyy")) // 効果測定ID
}
try {
Rtoaster.track(TrackingParameter {
location(Location("testLocation"))
values(trackingValues)
}).onFailure {
Log.d("Rtoaster", "Communication error", it)
}
} catch (e: Exception) {
Log.d("Rtoaster", "Parameter error", e)
}
v4.x #
val customValues = mapOf(
"item_code" to "item_12345" // アイテムコード
"_rt.sid" to "xxyyxxyyxxyyxxyyxxyyxxyy" // 効果測定ID
)
try {
Rtoaster.track(
"testLocation",
null,
HashMap<String, String>(customValues)
) { exception ->
Log.d("Rtoaster", "Communication error", exception)
}
} catch (e: Exception) {
Log.d("Rtoaster", "Parameter error", e)
}
残留カート情報の収集 #
残留カート情報を設定しているサンプルです。
v5.0 #
do {
let trackingValues = try CartValues.Builder()
.cartItemCodes(["item_12345"]) // アイテムコード
.build()
try Rtoaster.track(.Builder()
.location(Location("testLocation"))
.values(trackingValues)
.build()
).onFailure { [weak self] error in
print("Communication error: \(error.toMap())")
}
} catch {
print("Parameter error: \(error.toMap())")
}
v4.x #
let customValues = [
"item1_code": "item_12345" // アイテムコード
]
Rtoaster.track(
withLocation: "testLocation",
withAppKeys: customValues,
withCompletionHandler: { [self] result in
if let error = result.error {
print("error: \(error)")
}
}
)
v5.0 #
val trackingValues = CartValues {
.cartItemCodes(setOf("item_12345"))
}
try {
Rtoaster.track(TrackingParameter {
location(Location("testLocation"))
values(trackingValues)
}).onFailure {
Log.d("Rtoaster", "Communication error", it)
}
} catch (e: Exception) {
Log.d("Rtoaster", "Parameter error", e)
}
v4.x #
val customValues = mapOf(
"item1_code" to "item_12345" // アイテムコード
)
try {
Rtoaster.track(
"testLocation",
null,
HashMap<String, String>(customValues)
) { exception ->
Log.d("Rtoaster", "Communication error", exception)
}
} catch (e: Exception) {
Log.d("Rtoaster", "Parameter error", e)
}
購買学習 #
購買学習を行うサンプルです。
v5.0 #
do {
let trackingValues = PurchasingValues.Builder()
.purchasingItems([
try PurchasingValues.PurchasingItem(
itemCode: "item_12345", // アイテムコード
price: 1000 // アイテムの単価
)
])
.build()
try Rtoaster.track(.Builder()
.location(Location("testLocation"))
.values(trackingValues)
.build()
).onFailure { [weak self] error in
print("Communication error: \(error.toMap())")
}
} catch {
print("Parameter error: \(error.toMap())")
}
v4.x #
let customValues = [
"item1_code": "item_12345", // アイテムコード
"item1_price": "1000" // アイテムの単価
]
Rtoaster.track(
withLocation: "testLocation",
withAppKeys: customValues,
withCompletionHandler: { [self] result in
if let error = result.error {
print("error: \(error)")
}
}
)
v5.0 #
val trackingValues = PurshasingValues {
.purchasingItems(
arrayListOf(
PurchasingValues.PurchasingItem("item_12345")
)
)
}
try {
Rtoaster.track(TrackingParameter {
location(Location("testLocation"))
values(trackingValues)
}).onFailure {
Log.d("Rtoaster", "Communication error", it)
}
} catch (e: Exception) {
Log.d("Rtoaster", "Parameter error", e)
}
v4.x #
val customValues = mapOf(
"item1_code" to "item_12345" // アイテムコード
)
try {
Rtoaster.track(
"testLocation",
null,
HashMap<String, String>(customValues)
) { exception ->
Log.d("Rtoaster", "Communication error", exception)
}
} catch (e: Exception) {
Log.d("Rtoaster", "Parameter error", e)
}
レコメンド処理の移行 #
主な変更点 #
trackRecommend
メソッドはtrack
メソッドとrecommend
メソッドに分割されました。recommend
メソッドはトラッキングを行っていることが前提となります。- 1回のトラッキングごとに
recommend
メソッドを呼び出せるのは1回だけです。
サンプルコード #
v5.0 #
do {
let recommendationValues = try RecommendationValues.Builder()
.itemCodes(["item_12345"])
.build()
try Rtoaster.track(.Builder() // レコメンドするためのトラッキング
.location(Location("top_page"))
.build()
)
.onFailure { err in
print("Tracking error: \(error.toMap())")
}
.recommend(.Builder()
.elementIds(["element_1"])
.values(recommendationValues)
.build()
)
.onSuccess { result in
print("SUCCESS: Recommendation")
print(result)
}
.onFailure { err in
print("Recommendation error: \(error.toMap())")
}
} catch {
print("Parameter error: \(error.toMap())")
}
v4.x #
let recommendAppKeys = [
"item1_code": "item_12345"
]
Rtoaster.trackRecommend(
withElementIds: ["element_1"],
withLocation: "top_page",
withAppKeys: [:],
withRecommendAppKeys: recommendAppKeys,
withTargetItems: [:],
withOmittedItems: [],
withCompletionHandler: { [self] result in
print(result)
}
)
v5.0 #
val recommendationValues = RecommendationValues {
itemCodes(arrayOf("item_12345").toSet())
}
try {
Rtoaster.track(TrackingParameter { // レコメンドするためのトラッキング
location(Location("testLocation"))
}).onFailure {
Log.d("Rtoaster", "Tracking error", it)
}.recommend(RecommendationParameter {
elementIds("element_1")
values(recommendationValues)
}).onSuccess {
for (result in it.results) {
Log.d("Rtoaster", "Content: ${result.contents.toString()}")
}
}.onFailure {
Log.d("Rtoaster", "Recommendation error", it)
}
} catch (Exception e) {
Log.e("Rtoaster", "Recommendation Error", e)
}
v4.x #
val customValues = mapOf(
"item1_code" to "item_12345"
)
try {
Rtoaster.trackRecommend(
"top_page",
arrayOf("element_1").asList(),
emptyMap<String, String>() as java.util.HashMap<String, String>,
customValues.toMap() as java.util.HashMap<String, String>,
emptyMap<String, String>() as java.util.HashMap<String, String>,
emptyArray<String>().asList() as ArrayList<String>,
object : Rtoaster.RecommendListener {
override fun onResult(contents: List<HashMap<String?, String?>?>?) {
if (contents != null) {
for (content in contents) {
// サンプルのため、ログに出力するのみ
Log.d("Recommended Content", content.toString())
}
}
}
override fun onError(exception: RtoasterInvalidParameterException?) {
Log.e("Rtoaster", "onError", exception)
}
}
)
} catch (Exception e) {
Log.e("Rtoaster", "trackRecommend Error", e)
}
アプリポップアップ・アプリアンケート #
主な変更点 #
- アプリポップアップおよびアプリアンケート専用のメソッドは廃止されました。
recommend
メソッドの結果に対して、view
メソッドを呼び出すとコンテンツの種類に応じてポップアップまたはアンケートが自動的に表示されます。
廃止されたメソッド #
機能 | メソッド名 |
---|---|
ポップアップの表示 | presentRecommendPopup |
trackAndPresentRecommendPopup | |
アンケートの表示 | presentQuestionnairePopup |
trackAndPresentQuestionnairePopup |
変更されたメソッド #
すべてのポップアップを閉じる #
v5.0 | v4.x |
---|---|
Rtoaster.closeAllViews | Rtoaster.closeAllPopup |