@@ -341,6 +341,7 @@ object RequestManager {
341341 needPaywalls : Boolean ,
342342 isNew : Boolean ,
343343 forceRegistration : Boolean = false,
344+ userId : UserId ? = null,
344345 ): ApphudUser ? =
345346 suspendCancellableCoroutine { continuation ->
346347 if (! canPerformRequest()) {
@@ -351,7 +352,7 @@ object RequestManager {
351352 }
352353
353354 if (currentUser == null || forceRegistration) {
354- registration(needPaywalls, isNew, forceRegistration) { customer, error ->
355+ registration(needPaywalls, isNew, forceRegistration, userId ) { customer, error ->
355356 if (continuation.isActive) {
356357 continuation.resume(customer)
357358 }
@@ -368,6 +369,7 @@ object RequestManager {
368369 needPaywalls : Boolean ,
369370 isNew : Boolean ,
370371 forceRegistration : Boolean = false,
372+ userId : UserId ? = null,
371373 completionHandler : (ApphudUser ? , ApphudError ? ) -> Unit ,
372374 ) {
373375 if (! canPerformRequest()) {
@@ -383,7 +385,7 @@ object RequestManager {
383385 .path(" customers" )
384386 .build()
385387
386- val request = buildPostRequest(URL (apphudUrl.url), mkRegistrationBody(needPaywalls, isNew))
388+ val request = buildPostRequest(URL (apphudUrl.url), mkRegistrationBody(needPaywalls, isNew, userId ))
387389 val httpClient = getOkHttpClient(request, ! fallbackMode)
388390 try {
389391 val serverResponse = performRequestSync(httpClient, request)
@@ -968,6 +970,7 @@ object RequestManager {
968970 private fun mkRegistrationBody (
969971 needPaywalls : Boolean ,
970972 isNew : Boolean ,
973+ userId : UserId ? = null,
971974 ): RegistrationBody {
972975 val deviceIds = storage.deviceIdentifiers
973976 val idfa = deviceIds[0 ]
@@ -992,7 +995,7 @@ object RequestManager {
992995 idfv = if (ApphudUtils .optOutOfTracking || appSetId.isEmpty()) null else appSetId,
993996 idfa = if (ApphudUtils .optOutOfTracking || idfa.isEmpty()) null else idfa,
994997 android_id = if (ApphudUtils .optOutOfTracking || androidId.isEmpty()) null else androidId,
995- user_id = ApphudInternal .userId,
998+ user_id = userId ? : ApphudInternal .userId,
996999 device_id = ApphudInternal .deviceId,
9971000 time_zone = TimeZone .getDefault().id,
9981001 is_sandbox = this .applicationContext.isDebuggable(),
0 commit comments