@@ -12,7 +12,6 @@ import androidx.core.content.ContextCompat
12
12
import androidx.webkit.ProxyConfig
13
13
import androidx.webkit.ProxyController
14
14
import androidx.webkit.WebViewFeature
15
- import com.google.protobuf.ByteString
16
15
import internalsdk.SessionModel
17
16
import internalsdk.SessionModelOpts
18
17
import io.flutter.embedding.engine.FlutterEngine
@@ -23,14 +22,17 @@ import io.lantern.model.dbadapter.DBAdapter
23
22
import kotlinx.coroutines.CoroutineScope
24
23
import kotlinx.coroutines.Dispatchers
25
24
import kotlinx.coroutines.launch
25
+ import kotlinx.serialization.json.add
26
26
import kotlinx.serialization.json.buildJsonArray
27
27
import kotlinx.serialization.json.buildJsonObject
28
28
import kotlinx.serialization.json.put
29
+ import kotlinx.serialization.json.putJsonArray
29
30
import org.getlantern.lantern.BuildConfig
30
31
import org.getlantern.lantern.LanternApp
31
32
import org.getlantern.lantern.activity.WebViewActivity
32
33
import org.getlantern.lantern.model.InAppBilling
33
34
import org.getlantern.lantern.model.Utils
35
+ import org.getlantern.lantern.plausible.Plausible
34
36
import org.getlantern.lantern.util.AutoUpdater
35
37
import org.getlantern.lantern.util.LanternProxySelector
36
38
import org.getlantern.lantern.util.PaymentsUtil
@@ -135,6 +137,13 @@ class SessionModel internal constructor(
135
137
result.success(LanternApp .getInAppBilling().isPlayStoreAvailable())
136
138
}
137
139
140
+ " trackUserAction" -> {
141
+ val props: Map <String , String > = mapOf (" title" to call.argument(" title" )!! )
142
+ Plausible .event(
143
+ call.argument(" name" )!! , url = call.argument(" url" )!! , props = props
144
+ )
145
+ }
146
+
138
147
else -> super .doOnMethodCall(call, result)
139
148
}
140
149
}
@@ -199,7 +208,10 @@ class SessionModel internal constructor(
199
208
}
200
209
201
210
fun setUserIdAndToken (userId : Long , token : String ) {
202
- model.invokeMethod(" setUserIdAndToken" , Arguments (mapOf (" userId" to userId, " token" to token)))
211
+ model.invokeMethod(
212
+ " setUserIdAndToken" ,
213
+ Arguments (mapOf (" userId" to userId, " token" to token))
214
+ )
203
215
}
204
216
205
217
fun setUserPro (isPro : Boolean ) {
@@ -381,20 +393,26 @@ class SessionModel internal constructor(
381
393
// this ends up in memory out of exception
382
394
CoroutineScope (Dispatchers .IO ).launch {
383
395
try {
396
+ val start = System .currentTimeMillis()
384
397
val appsList = appsDataProvider.listOfApps()
385
398
// First add just the app names to get a list quickly
386
399
val apps = buildJsonArray {
387
400
appsList.forEach { app ->
388
401
add(
389
402
buildJsonObject {
390
- val byte = ByteString .copyFrom( app.icon)
403
+ val byte = app.icon!!
391
404
put(" packageName" , app.packageName)
392
405
put(" name" , app.name)
393
- put(" icon" , byte.toByteArray().toUByteArray().joinToString(" , " ))
406
+ putJsonArray(" icon" ) {
407
+ byte.toUByteArray().forEach { add(it.toInt()) }
408
+ }
394
409
}
395
410
)
396
411
}
397
412
}
413
+ val end = System .currentTimeMillis()
414
+ Logger .debug(TAG , " Time taken to get app data: ${end - start} ms" )
415
+
398
416
model.invokeMethod(
399
417
" updateAppsData" ,
400
418
Arguments (mapOf (" appsList" to apps.toString()))
0 commit comments