Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump runner from 1.4.0 to 1.5.2 #300

Open
wants to merge 6 commits into
base: chore/dependabot
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions android-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ task coreSdkJavadocs(type: Javadoc) {
exclude {
String filePath = it.toString()
filePath.contains('/com/mparticle/internal/') ||
filePath.contains('/com/mparticle/kits/')
filePath.contains('/com/mparticle/kits/') ||
filePath.contains('/com/mparticle/modernization/')
}
}
}
Expand All @@ -135,6 +136,8 @@ dependencies {
api 'androidx.annotation:annotation:[1.0.0,)'
compileOnly 'androidx.core:core:[1.3.2, )'

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'

api 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'

lintPublish project( path: ':tooling:custom-lint-rules', configuration: 'lintBuild')
Expand All @@ -153,7 +156,7 @@ dependencies {

androidTestImplementation project(':testutils')
if (useOrchestrator()) {
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:runner:1.5.2'
androidTestUtil 'androidx.test:orchestrator:1.4.2'
}
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.mparticle.modernization

internal abstract class MParticleCallback<S, E> {
var isSuccessFul: Boolean = false
var isCompleted: Boolean = false

fun onSuccess(result: S) {
isSuccessFul = true
isCompleted = true
}

fun onError(error: E) {
isSuccessFul = false
isCompleted = true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.mparticle.modernization

import com.mparticle.modernization.core.MParticleMediator
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

internal fun MParticleMediator.launch(block: suspend CoroutineScope.() -> Unit) {
this.coroutineScope.launch(this.coroutineDispatcher) { block }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.mparticle.modernization.config

internal interface UploadingConfiguration
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.mparticle.modernization.core

import com.mparticle.MParticleOptions
import com.mparticle.modernization.eventlogging.MParticleEventLogging
import com.mparticle.modernization.identity.MParticleIdentity
import com.mparticle.modernization.kit.MParticleKitManager
import com.mparticle.modernization.uploading.MParticleDataUploader

internal class MParticle private constructor(private val options: MParticleOptions) {
private var mediator: MParticleMediator = MParticleMediator()

init {
mediator.configure(options)
}

companion object {
private var _instance: MParticle? = null

@Throws(Exception::class)
fun getInstance(): MParticle = _instance ?: throw Exception("MParticle must be started before getting the instance")

fun start(options: MParticleOptions) {
_instance = MParticle(options)
}
}

fun KitManager(): MParticleKitManager? = mediator.kitManager as MParticleKitManager?
fun Identity(): MParticleIdentity? = mediator.identity as MParticleIdentity?
fun EventLogging(): MParticleEventLogging? = mediator.eventLogging
fun DataUploading(): MParticleDataUploader? = mediator.dataUploader
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.mparticle.modernization.core

internal interface MParticleComponent
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.mparticle.modernization.core

import com.mparticle.MParticleOptions
import com.mparticle.modernization.eventlogging.MParticleEventLogging
import com.mparticle.modernization.eventlogging.example.MParticleEventLoggingImpl
import com.mparticle.modernization.identity.InternalIdentity
import com.mparticle.modernization.identity.example.MParticleIdentityImpl
import com.mparticle.modernization.kit.KitManagerInternal
import com.mparticle.modernization.kit.MParticleKit
import com.mparticle.modernization.kit.MParticleKitManagerImpl
import com.mparticle.modernization.kit.example.MpKit
import com.mparticle.modernization.uploading.MParticleDataUploader
import com.mparticle.modernization.uploading.MParticleDataUploaderImpl
import com.mparticle.modernization.uploading.MParticleUploadingStrategy
import kotlinx.coroutines.CloseableCoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.asCoroutineDispatcher
import java.util.concurrent.Executors

internal class MParticleMediator {
internal var eventLogging: MParticleEventLogging? = null
internal var identity: InternalIdentity? = null
internal var kitManager: KitManagerInternal? = null
internal var dataUploader: MParticleDataUploader? = null

private var kits: MutableList<MParticleKit> = mutableListOf()
private var mParticleUploadingStrategies: List<MParticleUploadingStrategy> = listOf()

internal lateinit var coroutineScope: CoroutineScope
internal lateinit var coroutineDispatcher: CloseableCoroutineDispatcher

fun configure(options: MParticleOptions) {
coroutineScope = CoroutineScope(SupervisorJob())
coroutineDispatcher = Executors.newCachedThreadPool().asCoroutineDispatcher()
kits = registerKits(options)
registerComponent(MParticleKitManagerImpl(kits))
registerComponent(MParticleIdentityImpl(this))
registerComponent(MParticleEventLoggingImpl(this))
registerComponent(MParticleDataUploaderImpl(this, mParticleUploadingStrategies, null))
}

private fun registerKits(options: MParticleOptions): MutableList<MParticleKit> =
mutableListOf(MpKit(this))

private fun registerComponent(component: MParticleComponent) {
when (component) {
is InternalIdentity -> identity = component
is KitManagerInternal -> kitManager = component
is MParticleEventLogging -> eventLogging = component
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.mparticle.modernization.data

import com.mparticle.internal.messages.BaseMPMessage

internal class MParticleDataRepository {

suspend fun updateSession(data: BaseMPMessage) {}

suspend fun insertBreadcrumb(data: BaseMPMessage) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.mparticle.modernization.eventlogging

import com.mparticle.BaseEvent
import com.mparticle.modernization.core.MParticleComponent
import org.jetbrains.annotations.NotNull
import org.jetbrains.annotations.Nullable
import java.math.BigDecimal

internal interface MParticleEventLogging : MParticleComponent {
// All common, commerce, screen, pushRegistration, notification, notificationOpened and NetworkPerformance events should be logged with the same function
/**
* Log an event - TODO review EventBuilder to be able to build all type of events
* @param event to log
*/
fun logEvent(@NotNull event: BaseEvent)

/**
* Leave breadcrumb
* @param breadcrumb
*/
fun leaveBreadcrumb(@NotNull breadcrumb: String)

/**
* Log an error
* @param message
* @param params optional by default null
*/
fun logError(@NotNull message: String, @Nullable params: Map<String, String>? = null)

/**
* Log lifetime value increase
* @param valueIncreased
* @param eventName optional by default null
* @param params optional by default null
*/
fun logLtvIncrease(
@NotNull valueIncreased: BigDecimal,
@Nullable eventName: String? = null,
@Nullable params: Map<String, String>? = null
)

/**
* Log exception
* @param exception
* @param message optional by default null
* @param params optional by default null
*/
fun logException(
@NotNull exception: Exception,
@Nullable message: String? = null,
@Nullable params: Map<String, String>? = null
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.mparticle.modernization.eventlogging.example

import com.mparticle.BaseEvent
import com.mparticle.modernization.core.MParticleMediator
import com.mparticle.modernization.eventlogging.MParticleEventLogging
import java.math.BigDecimal

internal class MParticleEventLoggingImpl(private val mediator: MParticleMediator) :
MParticleEventLogging {

override fun logEvent(event: BaseEvent) {
TODO("Not yet implemented")
}

override fun leaveBreadcrumb(breadcrumb: String) {
mediator.kitManager?.leaveBreadcrumb(breadcrumb)
}

override fun logError(message: String, params: Map<String, String>?) {
TODO("Not yet implemented")
}

override fun logLtvIncrease(
valueIncreased: BigDecimal,
eventName: String?,
params: Map<String, String>?
) {
TODO("Not yet implemented")
}

override fun logException(
exception: Exception,
message: String?,
params: Map<String, String>?
) {
TODO("Not yet implemented")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.mparticle.modernization.identity

import com.mparticle.identity.IdentityApiResult
import com.mparticle.modernization.MParticleCallback

internal open class IdentityCallback : MParticleCallback<IdentityApiResult, Throwable>()
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package com.mparticle.modernization.identity

import com.mparticle.identity.IdentityApiRequest
import com.mparticle.identity.IdentityApiResult
import com.mparticle.identity.MParticleUser
import com.mparticle.modernization.MParticleCallback
import com.mparticle.modernization.core.MParticleComponent
import org.jetbrains.annotations.NotNull
import org.jetbrains.annotations.Nullable

internal interface MParticleIdentity : MParticleComponent {

/**
* Login
* @param callback
*/
fun login(@NotNull callback: IdentityCallback)

/**
* Logout
* @param callback
*/
fun logout(@NotNull callback: IdentityCallback)

/**
* Returns the user by id or the current user if [mpId] is null
* @param mpId if null returns the current user, if not the user by id
* @param callback
*/
fun getUser(@Nullable mpId: Long?, @NotNull callback: IdentityCallback)

/**
* Return all users
* @param callback
*/
fun getUsers(@NotNull callback: MParticleCallback<List<MParticleUser>, Unit>)

/**
* Returns the user by id or the current user if [mpId] is null
* @param mpId if null returns the current user, if not the user by id
* @return identityApiResult
*/
suspend fun getUser(@Nullable mpId: Long?): IdentityApiResult

/**
* Return all users
* @return mParicleUsers in a list
*/
suspend fun getUsers(): List<MParticleUser>

/**
* Login
* @return identityApiResult
*/
suspend fun login(): IdentityApiResult

/**
* Logout
* @return identityApiResult
*/
suspend fun logout(): IdentityApiResult
}

internal interface InternalIdentity : MParticleIdentity {
/**
* Identify api request call
* @param request
* @return identityApiResult
*/
suspend fun identify(@NotNull request: IdentityApiRequest): IdentityApiResult

/**
* Modify api request call
* @param request
* @return identityApiResult
*/
suspend fun modify(@NotNull request: IdentityApiRequest): IdentityApiResult

/**
* Logout api request call
* @param request
* @return identityApiResult
*/
suspend fun logout(@NotNull request: IdentityApiRequest): IdentityApiResult

/**
* Login api request call
* @param request
* @return identityApiResult
*/
suspend fun login(@NotNull request: IdentityApiRequest): IdentityApiResult
}

internal interface IdentityListener
Loading