-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: send impression and push primer analytics events (RMCCX-6936, R…
…MCCX-6937)
- Loading branch information
1 parent
df463db
commit 391fb13
Showing
20 changed files
with
272 additions
and
190 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
analytics/src/main/java/com/rakuten/tech/mobile/analytics/RatTracker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.rakuten.tech.mobile.analytics | ||
|
||
class RatTracker { | ||
companion object { | ||
fun event(type: String, parameters: Map<String, Any>): Event = Event(type, parameters) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
.../src/main/java/com/rakuten/tech/mobile/inappmessaging/runtime/manager/AnalyticsManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.rakuten.tech.mobile.inappmessaging.runtime.manager | ||
|
||
import com.rakuten.tech.mobile.inappmessaging.runtime.BuildConfig | ||
import com.rakuten.tech.mobile.inappmessaging.runtime.EventTrackerHelper | ||
import com.rakuten.tech.mobile.inappmessaging.runtime.RmcHelper | ||
import com.rakuten.tech.mobile.inappmessaging.runtime.data.repositories.HostAppInfoRepository | ||
|
||
internal enum class AnalyticsEvent(val iamName: String?, val rmcName: String?) { | ||
IMPRESSION("_rem_iam_impressions", "_rem_rmc_iam_impressions"), | ||
PUSH_PRIMER(null, "_rem_rmc_iam_pushprimer"), | ||
} | ||
|
||
internal enum class AnalyticsKey(val key: String) { | ||
EVENT_NAME("eventName"), | ||
CUSTOM_ATTRIBUTES("customAttributes"), | ||
CAMPAIGN_ID("campaign_id"), | ||
SUBS_ID("subscription_id"), | ||
DEVICE_ID("device_id"), | ||
TIMESTAMP("timestamp"), | ||
CUSTOM_PARAM("cp"), | ||
ACCOUNT("acc"), | ||
APP_ID("aid"), | ||
IMPRESSIONS("impressions"), | ||
PUSH_PERMISSION("push_permission"), | ||
} | ||
|
||
internal object AnalyticsManager { | ||
|
||
/** | ||
* Sends the event [analyticsEvent]. For RMC, the event is sent to both the host app account and SDK account. | ||
* This method attaches common metadata to the event such as Device Id etc., so only add custom information that is | ||
* specific to the event on [data]. | ||
*/ | ||
@SuppressWarnings("LongMethod") | ||
@JvmStatic | ||
fun sendEvent(analyticsEvent: AnalyticsEvent, campaignId: String, data: MutableMap<String, Any>) { | ||
// Common metadata | ||
data[AnalyticsKey.CAMPAIGN_ID.key] = campaignId | ||
data[AnalyticsKey.SUBS_ID.key] = HostAppInfoRepository.instance().getSubscriptionKey() | ||
data[AnalyticsKey.DEVICE_ID.key] = HostAppInfoRepository.instance().getDeviceId() | ||
|
||
val params = hashMapOf<String, Any>() | ||
params[AnalyticsKey.CUSTOM_PARAM.key] = data | ||
|
||
if (RmcHelper.isRmcIntegrated()) { | ||
if (analyticsEvent.rmcName == null) { | ||
return | ||
} | ||
|
||
val paramsCopy = HashMap<String, Any>(params) | ||
paramsCopy[AnalyticsKey.ACCOUNT.key] = BuildConfig.IAM_RAT_ACC | ||
paramsCopy[AnalyticsKey.APP_ID.key] = BuildConfig.IAM_RAT_AID | ||
|
||
EventTrackerHelper.sendEvent(analyticsEvent.rmcName, params) | ||
EventTrackerHelper.sendEvent(analyticsEvent.rmcName, paramsCopy) | ||
} else { | ||
if (analyticsEvent.iamName == null) { | ||
return | ||
} | ||
|
||
EventTrackerHelper.sendEvent(analyticsEvent.iamName, params) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 4 additions & 13 deletions
17
...n/java/com/rakuten/tech/mobile/inappmessaging/runtime/manager/PushPrimerTrackerManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
inappmessaging/src/test/java/com/rakuten/tech/mobile/analytics/RatTracker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.rakuten.tech.mobile.analytics | ||
|
||
class RatTracker { | ||
companion object { | ||
fun event(type: String, parameters: Map<String, Any>): Event = Event(type, parameters) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.