Created
April 3, 2018 06:53
-
-
Save adrianhall/acc8b61d74c13adef73951b5a64713d9 to your computer and use it in GitHub Desktop.
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
package com.shellmonger.apps.familyphotos.services | |
import android.content.Context | |
import android.util.Log | |
import com.amazonaws.auth.CognitoCachingCredentialsProvider | |
import com.amazonaws.mobile.config.AWSConfiguration | |
import com.amazonaws.mobileconnectors.pinpoint.PinpointConfiguration | |
import com.amazonaws.mobileconnectors.pinpoint.PinpointManager | |
class AWSAnalyticsService(context: Context) : AnalyticsService { | |
private val TAG = this::class.java.simpleName | |
private val pinpointManager: PinpointManager | |
override fun startSession() { | |
with (pinpointManager) { | |
sessionClient.startSession() | |
analyticsClient.submitEvents() | |
} | |
} | |
override fun stopSession() { | |
with (pinpointManager) { | |
sessionClient.stopSession() | |
analyticsClient.submitEvents() | |
} | |
} | |
override fun recordEvent(type: String) { | |
with (pinpointManager.analyticsClient) { | |
val event = createEvent(type) | |
recordEvent(event) | |
submitEvents() | |
} | |
} | |
init { | |
Log.d(TAG, "constructor - context = ${context}") | |
val awsConfiguration = AWSConfiguration(context) | |
val credentialsProvider = CognitoCachingCredentialsProvider(context, awsConfiguration) | |
val pinpointConfiguration = PinpointConfiguration(context, credentialsProvider, awsConfiguration) | |
pinpointManager = PinpointManager(pinpointConfiguration) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment