@@ -140,13 +140,11 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
140140 override fun onResume () {
141141 super .onResume()
142142 Log .d(TAG , " onResume" )
143- app.trackScreen(" Main" )
144143 }
145144
146145 override fun onPause () {
147146 super .onPause()
148147 Log .d(TAG , " onPause" )
149- app.clearScreen()
150148 this .lastPauseTime = System .currentTimeMillis()
151149 }
152150
@@ -169,7 +167,6 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
169167 // ACTION_VIEW means that somebody had the app installed, and scanned the barcode with
170168 // a separate barcode app anyway (or opened the QR code URL in a browser)
171169 intent.action == Intent .ACTION_VIEW -> {
172- app.trackEvent(" Setup" , " action-view" )
173170 if (app.lastProxy != null && isVpnConfigured()) {
174171 Log .i(TAG , " Showing prompt for ACTION_VIEW intent" )
175172
@@ -201,17 +198,14 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
201198 // RC setup API, used by ADB to enable/disable without prompts.
202199 // Permission required, checked for via activity-alias in the manifest
203200 isRCIntent && intent.action == ACTIVATE_INTENT -> {
204- app.trackEvent(" Setup" , " rc-activate" )
205201 launch { connectToVpnFromUrl(intent.data!! ) }
206202 }
207203 isRCIntent && intent.action == DEACTIVATE_INTENT -> {
208- app.trackEvent(" Setup" , " rc-deactivate" )
209204 disconnect()
210205 }
211206
212207 intent.action == " android.intent.action.MAIN" -> {
213208 // The app is being opened - nothing to do here
214- app.trackEvent(" Setup" , " ui-opened" )
215209 }
216210
217211 else -> Log .w(TAG , " Ignoring unknown intent. Action ${
@@ -320,7 +314,6 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
320314 }
321315
322316 private fun scanCode () {
323- app.trackEvent(" Button" , " scan-code" )
324317 startActivityForResult(Intent (this , ScanActivity ::class .java), SCAN_REQUEST )
325318 }
326319
@@ -332,7 +325,6 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
332325
333326 withContext(Dispatchers .Main ) { updateUi() }
334327
335- app.trackEvent(" Button" , " start-vpn" )
336328 val vpnIntent = VpnService .prepare(this )
337329 Log .i(TAG , if (vpnIntent != null ) " got intent" else " no intent" )
338330 val vpnNotConfigured = vpnIntent != null
@@ -382,15 +374,12 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
382374 mainState = MainState .DISCONNECTING
383375 updateUi()
384376
385- app.trackEvent(" Button" , " stop-vpn" )
386377 startService(Intent (this , ProxyVpnService ::class .java).apply {
387378 action = STOP_VPN_ACTION
388379 })
389380 }
390381
391382 private suspend fun reconnect (lastProxy : ProxyConfig ) {
392- app.trackEvent(" Button" , " reconnect" )
393-
394383 withContext(Dispatchers .Main ) {
395384 mainState = MainState .CONNECTING
396385 updateUi()
@@ -414,7 +403,6 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
414403 e.printStackTrace()
415404
416405 withContext(Dispatchers .Main ) {
417- app.trackEvent(" Setup" , " reconnect-failed" )
418406 mainState = MainState .FAILED
419407 updateUi()
420408 }
@@ -427,14 +415,12 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
427415 }
428416
429417 private fun resetAfterFailure () {
430- app.trackEvent(" Button" , " try-again" )
431418 currentProxyConfig = null
432419 mainState = MainState .DISCONNECTED
433420 updateUi()
434421 }
435422
436423 private fun openDocs () {
437- app.trackEvent(" Button" , " open-docs" )
438424 launchBrowser(" httptoolkit.tech/docs/guides/android" )
439425 }
440426
@@ -457,8 +443,6 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
457443 }
458444
459445 private fun testInterception () {
460- app.trackEvent(" Button" , " test-interception" )
461-
462446 val certIsSystemTrusted = whereIsCertTrusted(
463447 this .currentProxyConfig!! // Safe!! because you can only run tests while connected
464448 ) == " system"
@@ -520,20 +504,17 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
520504 Log .i(TAG , " Installing cert" )
521505 ensureCertificateTrusted(currentProxyConfig!! )
522506 } else if (requestCode == INSTALL_CERT_REQUEST ) {
523- app.trackEvent(" Setup" , " installed-cert-successfully" )
524507 startVpn()
525508 } else if (requestCode == SCAN_REQUEST && data != null ) {
526509 val url = data.getStringExtra(SCANNED_URL_EXTRA )!!
527510 launch { connectToVpnFromUrl(url) }
528511 } else if (requestCode == PICK_APPS_REQUEST ) {
529- app.trackEvent(" Setup" , " picked-apps" )
530512 val unselectedApps = data!! .getStringArrayExtra(UNSELECTED_APPS_EXTRA )!! .toSet()
531513 if (unselectedApps != app.uninterceptedApps) {
532514 app.uninterceptedApps = unselectedApps
533515 if (isVpnActive()) startVpn()
534516 }
535517 } else if (requestCode == PICK_PORTS_REQUEST ) {
536- app.trackEvent(" Setup" , " picked-ports" )
537518 val selectedPorts = data!! .getIntArrayExtra(SELECTED_PORTS_EXTRA )!! .toSet()
538519 if (selectedPorts != app.interceptedPorts) {
539520 app.interceptedPorts = selectedPorts
@@ -561,7 +542,6 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
561542 // via prompt. We redo the manual step regardless: either (on modern Android) manual is
562543 // required so this is just reshowing the instructions, or it was automated but that's not
563544 // working for some reason, in which case manual setup is a best-effort fallback.
564- app.trackEvent(" Setup" , " cert-install-failed" )
565545 launch { promptToManuallyInstallCert(currentProxyConfig!! .certificate, repeatPrompt = true ) }
566546 } else {
567547 Sentry .capture(" Non-OK result $resultCode for requestCode $requestCode " )
@@ -613,7 +593,6 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
613593 e.printStackTrace()
614594
615595 withContext(Dispatchers .Main ) {
616- app.trackEvent(" Setup" , " connect-failed" )
617596 mainState = MainState .FAILED
618597 updateUi()
619598 }
@@ -633,11 +612,9 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
633612 private fun ensureCertificateTrusted (proxyConfig : ProxyConfig ) {
634613 val existingTrust = whereIsCertTrusted(proxyConfig)
635614 if (existingTrust == null ) {
636- app.trackEvent(" Setup" , " installing-cert" )
637615 Log .i(TAG , " Certificate not trusted, prompting to install" )
638616
639617 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .R ) {
640- app.trackEvent(" Setup" , " installing-cert-manually" )
641618 // Android 11+, with no trusted cert: we need to download the cert to Downloads and
642619 // then tell the user how to install it manually:
643620 launch { promptToManuallyInstallCert(proxyConfig.certificate) }
@@ -646,14 +623,12 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
646623 // CA store. Notably, if the cert is already installed as a system cert but
647624 // disabled, this will get triggered, and will enable the cert, rather than adding
648625 // a normal user cert.
649- app.trackEvent(" Setup" , " installing-cert-automatically" )
650626 val certInstallIntent = KeyChain .createInstallIntent()
651627 certInstallIntent.putExtra(EXTRA_NAME , " HTTP Toolkit CA" )
652628 certInstallIntent.putExtra(EXTRA_CERTIFICATE , proxyConfig.certificate.encoded)
653629 startActivityForResult(certInstallIntent, INSTALL_CERT_REQUEST )
654630 }
655631 } else {
656- app.trackEvent(" Setup" , " existing-$existingTrust -cert" )
657632 Log .i(TAG , " Certificate already trusted, continuing" )
658633 onActivityResult(INSTALL_CERT_REQUEST , RESULT_OK , null )
659634 }
0 commit comments