Skip to content

Commit d0e8868

Browse files
feat!: DVC-8021 rename public interfaces from DVC to DevCycle (#160)
* feat!: Rename public interfaces from DVC to DevCycle * fix: update more DVC refrences * fix: Kotlin example app imports * feat: update version to 2.0.0 * fix: revert DevCycleClient class protections * fix: pr cleanup items * fix: tests * fix: update more logs with DevCycle
1 parent 0e708c5 commit d0e8868

File tree

30 files changed

+310
-317
lines changed

30 files changed

+310
-317
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ hs_err_pid*
2626
src/.DS_Store
2727
.DS_Store
2828
local.properties
29-
secret-keys.gpg
29+
secret-keys.gpg
30+
31+
build/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This version of the DevCycle Android Client SDK supports a minimum Android API V
1313
The SDK can be installed into your Android project by adding the following to _build.gradle_:
1414

1515
```yaml
16-
implementation("com.devcycle:android-client-sdk:1.8.0")
16+
implementation("com.devcycle:android-client-sdk:2.0.0")
1717
```
1818

1919
## Usage

android-client-sdk/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
}
77

88
group = "com.devcycle"
9-
version = "1.8.0"
9+
version = "2.0.0"
1010

1111
android {
1212
compileSdk 33
@@ -24,7 +24,7 @@ android {
2424
buildConfigField 'String', 'VERSION_NAME', "\"$version\""
2525
}
2626

27-
namespace 'com.devcycle'
27+
namespace 'com.devcycle'
2828

2929
buildFeatures {
3030
buildConfig = true

android-client-sdk/src/main/java/com/devcycle/sdk/android/api/DVCCallback.kt

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.devcycle.sdk.android.api
2+
3+
interface DevCycleCallback<T> {
4+
fun onSuccess(result: T)
5+
fun onError(t: Throwable)
6+
}
7+
8+
@Deprecated("DVCCallback is deprecated, use DevCycleCallback instead")
9+
typealias DVCCallback<T> = DevCycleCallback<T>

android-client-sdk/src/main/java/com/devcycle/sdk/android/api/DVCClient.kt renamed to android-client-sdk/src/main/java/com/devcycle/sdk/android/api/DevCycleClient.kt

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import com.devcycle.sdk.android.eventsource.*
77
import com.devcycle.sdk.android.exception.DVCRequestException
88
import com.devcycle.sdk.android.listener.BucketedUserConfigListener
99
import com.devcycle.sdk.android.model.*
10-
import com.devcycle.sdk.android.util.DVCLogger
10+
import com.devcycle.sdk.android.util.DevCycleLogger
1111
import com.devcycle.sdk.android.util.DVCSharedPrefs
1212
import com.devcycle.sdk.android.util.LogLevel
1313
import kotlinx.coroutines.*
@@ -26,16 +26,16 @@ import kotlin.coroutines.CoroutineContext
2626

2727
/**
2828
* Main entry point for SDK user
29-
* The class is constructed by calling DVCClient.builder(){builder options}.build()
29+
* The class is constructed by calling DevCycleClient.builder(){builder options}.build()
3030
*
3131
* All methods that make requests to the APIs or access [config] and [user] are [Synchronized] to
3232
* ensure thread-safety
3333
*/
34-
class DVCClient private constructor(
34+
class DevCycleClient private constructor(
3535
private val context: Context,
3636
private val sdkKey: String,
3737
private var user: PopulatedUser,
38-
options: DVCOptions?,
38+
options: DevCycleOptions?,
3939
apiUrl: String,
4040
eventsUrl: String,
4141
private val customLifecycleHandler: Handler? = null,
@@ -77,7 +77,7 @@ class DVCClient private constructor(
7777
if (cachedConfig != null) {
7878
config = cachedConfig
7979
isConfigCached.set(true)
80-
DVCLogger.d("Loaded config from cache")
80+
DevCycleLogger.d("Loaded config from cache")
8181
observable.configUpdated(config)
8282
}
8383

@@ -97,7 +97,7 @@ class DVCClient private constructor(
9797
}
9898

9999
} catch (t: Throwable) {
100-
DVCLogger.e(t, "DevCycle SDK Failed to Initialize!")
100+
DevCycleLogger.e(t, "DevCycle SDK Failed to Initialize!")
101101
throw t
102102
}
103103
}
@@ -113,7 +113,7 @@ class DVCClient private constructor(
113113
private val onPauseApplication = fun () {
114114
coroutineScope.launch {
115115
withContext(Dispatchers.IO) {
116-
DVCLogger.d("Closing Realtime Updates connection")
116+
DevCycleLogger.d("Closing Realtime Updates connection")
117117
eventSource?.close()
118118
}
119119
}
@@ -124,7 +124,7 @@ class DVCClient private constructor(
124124
coroutineScope.launch {
125125
withContext(Dispatchers.IO) {
126126
eventSource?.close()
127-
DVCLogger.d("Attempting to restart Realtime Updates connection")
127+
DevCycleLogger.d("Attempting to restart Realtime Updates connection")
128128
initEventSource()
129129
refetchConfig(false, null, null)
130130
}
@@ -134,7 +134,7 @@ class DVCClient private constructor(
134134

135135
private fun initEventSource () {
136136
if (disableRealtimeUpdates) {
137-
DVCLogger.i("Realtime Updates disabled via initialization parameter")
137+
DevCycleLogger.i("Realtime Updates disabled via initialization parameter")
138138
return
139139
}
140140
if (config?.sse?.url == null) { return }
@@ -169,7 +169,7 @@ class DVCClient private constructor(
169169
return executorService
170170
}
171171

172-
fun onInitialized(callback: DVCCallback<String>) {
172+
fun onInitialized(callback: DevCycleCallback<String>) {
173173
if (isInitialized.get()) {
174174
callback.onSuccess("Config loaded")
175175
return
@@ -195,11 +195,11 @@ class DVCClient private constructor(
195195
*/
196196
@JvmOverloads
197197
@Synchronized
198-
fun identifyUser(user: DVCUser, callback: DVCCallback<Map<String, BaseConfigVariable>>? = null) {
198+
fun identifyUser(user: DevCycleUser, callback: DevCycleCallback<Map<String, BaseConfigVariable>>? = null) {
199199
flushEvents()
200200

201-
val updatedUser: PopulatedUser = if (this@DVCClient.user.userId == user.userId) {
202-
this@DVCClient.user.copyUserAndUpdateFromDVCUser(user)
201+
val updatedUser: PopulatedUser = if (this@DevCycleClient.user.userId == user.userId) {
202+
this@DevCycleClient.user.copyUserAndUpdateFromDevCycleUser(user)
203203
} else {
204204
val anonId: String? = dvcSharedPrefs.getString(DVCSharedPrefs.AnonUserIdKey);
205205
PopulatedUser.fromUserParam(user, context, anonId)
@@ -208,7 +208,7 @@ class DVCClient private constructor(
208208

209209
if (isExecuting.get()) {
210210
configRequestQueue.add(UserAndCallback(updatedUser, callback))
211-
DVCLogger.d("Queued identifyUser request for user_id %s", updatedUser.userId)
211+
DevCycleLogger.d("Queued identifyUser request for user_id %s", updatedUser.userId)
212212
return
213213
}
214214

@@ -236,13 +236,13 @@ class DVCClient private constructor(
236236
*/
237237
@JvmOverloads
238238
@Synchronized
239-
fun resetUser(callback: DVCCallback<Map<String, BaseConfigVariable>>? = null) {
239+
fun resetUser(callback: DevCycleCallback<Map<String, BaseConfigVariable>>? = null) {
240240
val newUser: PopulatedUser = PopulatedUser.buildAnonymous()
241241
latestIdentifiedUser = newUser
242242

243243
if (isExecuting.get()) {
244244
configRequestQueue.add(UserAndCallback(newUser, callback))
245-
DVCLogger.d("Queued resetUser request for new anonymous user")
245+
DevCycleLogger.d("Queued resetUser request for new anonymous user")
246246
return
247247
}
248248

@@ -264,7 +264,7 @@ class DVCClient private constructor(
264264
}
265265
}
266266

267-
fun close(callback: DVCCallback<String>? = null) {
267+
fun close(callback: DevCycleCallback<String>? = null) {
268268
coroutineScope.launch {
269269
withContext(Dispatchers.IO) {
270270
eventSource?.close()
@@ -362,7 +362,7 @@ class DVCClient private constructor(
362362
try {
363363
eventQueue.queueAggregateEvent(event)
364364
} catch(e: IllegalArgumentException) {
365-
e.message?.let { DVCLogger.e(it) }
365+
e.message?.let { DevCycleLogger.e(it) }
366366
}
367367
}
368368
return variable
@@ -396,9 +396,9 @@ class DVCClient private constructor(
396396
*
397397
* [event] instance of an event object to submit
398398
*/
399-
fun track(event: DVCEvent) {
399+
fun track(event: DevCycleEvent) {
400400
if (eventQueue.isClosed.get()) {
401-
DVCLogger.d("DVC sdk has been closed, skipping call to track")
401+
DevCycleLogger.d("DevCycle SDK has been closed, skipping call to track")
402402
return
403403
}
404404
if(!disableCustomEventLogging){
@@ -412,7 +412,7 @@ class DVCClient private constructor(
412412
* [callback] optional callback to be notified on success or failure
413413
*/
414414
@JvmOverloads
415-
fun flushEvents(callback: DVCCallback<String>? = null) {
415+
fun flushEvents(callback: DevCycleCallback<String>? = null) {
416416
coroutineScope.launch {
417417
withContext(coroutineContext) {
418418
val result = eventQueue.flushEvents()
@@ -434,7 +434,7 @@ class DVCClient private constructor(
434434
*/
435435
while (!configRequestQueue.isEmpty()) {
436436
var latestUserAndCallback: UserAndCallback = configRequestQueue.remove()
437-
val callbacks: MutableList<DVCCallback<Map<String, BaseConfigVariable>>> =
437+
val callbacks: MutableList<DevCycleCallback<Map<String, BaseConfigVariable>>> =
438438
mutableListOf()
439439

440440
if (latestUserAndCallback.callback != null) {
@@ -489,17 +489,17 @@ class DVCClient private constructor(
489489
observable.configUpdated(config)
490490
dvcSharedPrefs.saveConfig(config!!, user)
491491
isConfigCached.set(false)
492-
DVCLogger.d("A new config has been fetched for $user")
492+
DevCycleLogger.d("A new config has been fetched for $user")
493493

494-
this@DVCClient.user = user
494+
this@DevCycleClient.user = user
495495
saveUser()
496496

497497
if (checkIfEdgeDBEnabled(config!!, enableEdgeDB)) {
498498
if (!user.isAnonymous) {
499499
try {
500500
request.saveEntity(user)
501501
} catch (exception: DVCRequestException) {
502-
DVCLogger.e("Error saving user entity for $user. Error: $exception")
502+
DevCycleLogger.e("Error saving user entity for $user. Error: $exception")
503503
}
504504
}
505505
}
@@ -509,11 +509,11 @@ class DVCClient private constructor(
509509
sse: Boolean = false,
510510
lastModified: Long? = null,
511511
etag: String? = null,
512-
callback: DVCCallback<Map<String, BaseConfigVariable>>? = null
512+
callback: DevCycleCallback<Map<String, BaseConfigVariable>>? = null
513513
) {
514514
if (isExecuting.get()) {
515515
configRequestQueue.add(UserAndCallback(latestIdentifiedUser, callback))
516-
DVCLogger.d("Queued refetchConfig request")
516+
DevCycleLogger.d("Queued refetchConfig request")
517517
return
518518
}
519519

@@ -531,88 +531,87 @@ class DVCClient private constructor(
531531
}
532532
}
533533
}
534-
535534
}
536535

537536
private fun checkIfEdgeDBEnabled(config: BucketedUserConfig, enableEdgeDB: Boolean): Boolean {
538537
return if (config.project?.settings?.edgeDB?.enabled == true) {
539538
enableEdgeDB
540539
} else {
541-
DVCLogger.d("EdgeDB is not enabled for this project. Only using local user data.")
540+
DevCycleLogger.d("EdgeDB is not enabled for this project. Only using local user data.")
542541
return false
543542
}
544543
}
545544

546-
class DVCClientBuilder {
545+
class DevCycleClientBuilder {
547546
private var context: Context? = null
548547
private var customLifecycleHandler: Handler? = null
549548
private var sdkKey: String? = null
550549
private var user: PopulatedUser? = null
551-
private var options: DVCOptions? = null
550+
private var options: DevCycleOptions? = null
552551
private var logLevel: LogLevel = LogLevel.ERROR
553-
private var logger: DVCLogger.Logger = DVCLogger.DebugLogger()
552+
private var logger: DevCycleLogger.Logger = DevCycleLogger.DebugLogger()
554553
private var apiUrl: String = DVCApiClient.BASE_URL
555554
private var eventsUrl: String = DVCEventsApiClient.BASE_URL
556555

557-
private var dvcUser: DVCUser? = null
556+
private var dvcUser: DevCycleUser? = null
558557

559558
private var dvcSharedPrefs: DVCSharedPrefs? = null
560559

561-
fun withContext(context: Context): DVCClientBuilder {
560+
fun withContext(context: Context): DevCycleClientBuilder {
562561
this.context = context
563562
return this
564563
}
565564

566-
internal fun withHandler(handler: Handler): DVCClientBuilder {
565+
internal fun withHandler(handler: Handler): DevCycleClientBuilder {
567566
this.customLifecycleHandler = handler
568567
return this
569568
}
570569

571-
fun withSDKKey(sdkKey: String): DVCClientBuilder {
570+
fun withSDKKey(sdkKey: String): DevCycleClientBuilder {
572571
this.sdkKey = sdkKey
573572
return this
574573
}
575574

576575
@Deprecated("Use withSDKKey() instead")
577-
fun withEnvironmentKey(environmentKey: String): DVCClientBuilder {
576+
fun withEnvironmentKey(environmentKey: String): DevCycleClientBuilder {
578577
this.sdkKey = environmentKey
579578
return this
580579
}
581580

582-
fun withUser(user: DVCUser): DVCClientBuilder {
581+
fun withUser(user: DevCycleUser): DevCycleClientBuilder {
583582
this.dvcUser = user
584583
return this
585584
}
586585

587-
fun withOptions(options: DVCOptions): DVCClientBuilder {
586+
fun withOptions(options: DevCycleOptions): DevCycleClientBuilder {
588587
this.options = options
589588
return this
590589
}
591590

592-
fun withLogLevel(logLevel: LogLevel): DVCClientBuilder {
591+
fun withLogLevel(logLevel: LogLevel): DevCycleClientBuilder {
593592
this.logLevel = logLevel
594593
return this
595594
}
596595

597-
fun withLogger(logger: DVCLogger.Logger): DVCClientBuilder {
596+
fun withLogger(logger: DevCycleLogger.Logger): DevCycleClientBuilder {
598597
this.logger = logger
599598
return this
600599
}
601600

602601
@TestOnly
603-
@JvmSynthetic internal fun withApiUrl(apiUrl: String): DVCClientBuilder {
602+
@JvmSynthetic internal fun withApiUrl(apiUrl: String): DevCycleClientBuilder {
604603
this.apiUrl = apiUrl
605604
this.eventsUrl = apiUrl
606605
return this
607606
}
608607

609-
fun build(): DVCClient {
608+
fun build(): DevCycleClient {
610609
requireNotNull(context) { "Context must be set" }
611610
require(!(sdkKey == null || sdkKey == "")) { "SDK key must be set" }
612611
requireNotNull(dvcUser) { "User must be set" }
613612

614613
if (logLevel.value > 0) {
615-
DVCLogger.start(logger)
614+
DevCycleLogger.start(logger)
616615
}
617616

618617
dvcSharedPrefs = DVCSharedPrefs(context!!);
@@ -621,18 +620,21 @@ class DVCClient private constructor(
621620

622621
this.user = PopulatedUser.fromUserParam(dvcUser!!, context!!, anonId)
623622

624-
return DVCClient(context!!, sdkKey!!, user!!, options, apiUrl, eventsUrl, customLifecycleHandler)
623+
return DevCycleClient(context!!, sdkKey!!, user!!, options, apiUrl, eventsUrl, customLifecycleHandler)
625624
}
626625
}
627626

628627
companion object {
629628
@JvmStatic
630-
fun builder(): DVCClientBuilder {
631-
return DVCClientBuilder()
629+
fun builder(): DevCycleClientBuilder {
630+
return DevCycleClientBuilder()
632631
}
633632
}
634633

635634
init {
636635
saveUser()
637636
}
638-
}
637+
}
638+
639+
@Deprecated("DVCClient is deprecated, use DevCycleClient instead")
640+
typealias DVCClient = DevCycleClient

0 commit comments

Comments
 (0)