Skip to content

Commit

Permalink
Merge pull request #197 from hyperskill/release/1.2
Browse files Browse the repository at this point in the history
Release 1.2
  • Loading branch information
ivan-magda authored Oct 10, 2022
2 parents 2fb63a6 + 849eb68 commit c0a1275
Show file tree
Hide file tree
Showing 99 changed files with 1,266 additions and 348 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import by.kirich1409.viewbindingdelegate.viewBinding
import io.sentry.Breadcrumb
import io.sentry.Sentry
import io.sentry.SentryLevel
import org.hyperskill.app.android.HyperskillApp
import org.hyperskill.app.android.R
import org.hyperskill.app.android.auth.view.ui.navigation.AuthFlow
Expand All @@ -21,6 +23,7 @@ import org.hyperskill.app.android.core.view.ui.dialog.LoadingProgressDialogFragm
import org.hyperskill.app.android.core.view.ui.dialog.dismissIfExists
import org.hyperskill.app.android.core.view.ui.navigation.requireRouter
import org.hyperskill.app.android.databinding.FragmentAuthEmailBinding
import org.hyperskill.app.android.sentry.domain.model.SentryBreadcrumbKeyValues
import org.hyperskill.app.auth.presentation.AuthCredentialsFeature
import org.hyperskill.app.auth.presentation.AuthCredentialsViewModel
import org.hyperskill.app.auth.view.mapper.AuthCredentialsErrorMapper
Expand Down Expand Up @@ -79,12 +82,14 @@ class AuthCredentialsFragment :
viewBinding.passwordEditText.setOnEditorActionListener { _, actionId, _ ->
var handled = false
if (actionId == EditorInfo.IME_ACTION_SEND) {
logSigningToSentry()
authCredentialsViewModel.onNewMessage(AuthCredentialsFeature.Message.SubmitFormClicked)
handled = true
}
handled
}
viewBinding.signInWithEmailMaterialButton.setOnClickListener {
logSigningToSentry()
authCredentialsViewModel.onNewMessage(AuthCredentialsFeature.Message.ClickedSignInEventMessage)
authCredentialsViewModel.onNewMessage(AuthCredentialsFeature.Message.SubmitFormClicked)
}
Expand Down Expand Up @@ -121,10 +126,25 @@ class AuthCredentialsFragment :
override fun onAction(action: AuthCredentialsFeature.Action.ViewAction) {
when (action) {
is AuthCredentialsFeature.Action.ViewAction.CompleteAuthFlow -> {
val breadcrumb = Breadcrumb().apply {
category = SentryBreadcrumbKeyValues.CATEGORY_AUTH_CREDENTIALS
message = "Signed in with log/pas"
level = SentryLevel.INFO
}
Sentry.addBreadcrumb(breadcrumb)

(parentFragment as? AuthFlow)?.onAuthSuccess(action.isNewUser)
}
is AuthCredentialsFeature.Action.ViewAction.CaptureError ->
Sentry.captureException(action.error)
is AuthCredentialsFeature.Action.ViewAction.CaptureError -> {
val breadcrumb = Breadcrumb().apply {
category = SentryBreadcrumbKeyValues.CATEGORY_AUTH_CREDENTIALS
message = "Sign in with log/pas failed"
level = SentryLevel.ERROR
}
Sentry.addBreadcrumb(breadcrumb)

Sentry.captureMessage("AuthCredentials: ${action.error}", SentryLevel.ERROR)
}
}
}

Expand All @@ -144,6 +164,14 @@ class AuthCredentialsFragment :
}

if (formState is AuthCredentialsFeature.FormState.Error) {
val breadcrumb = Breadcrumb().apply {
category = SentryBreadcrumbKeyValues.CATEGORY_AUTH_CREDENTIALS
message = "Sign in with log/pas failed"
level = SentryLevel.INFO
setData("form_state_error", formState.credentialsError.toString())
}
Sentry.addBreadcrumb(breadcrumb)

showError(authCredentialsErrorMapper.getAuthCredentialsErrorText(formState.credentialsError))
} else {
hideError()
Expand All @@ -168,4 +196,13 @@ class AuthCredentialsFragment :
viewBinding.passwordTextInputLayout.error = null
viewBinding.authEmailErrorMsgTextView.text = null
}

private fun logSigningToSentry() {
val breadcrumb = Breadcrumb().apply {
category = SentryBreadcrumbKeyValues.CATEGORY_AUTH_CREDENTIALS
message = "Signing in with log/pas"
level = SentryLevel.INFO
}
Sentry.addBreadcrumb(breadcrumb)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import com.google.android.gms.common.api.ApiException
import com.google.android.gms.common.api.CommonStatusCodes
import com.google.android.gms.common.api.Scope
import com.google.android.material.snackbar.Snackbar
import io.sentry.Breadcrumb
import io.sentry.Sentry
import io.sentry.SentryLevel
import org.hyperskill.app.SharedResources
import org.hyperskill.app.android.BuildConfig
import org.hyperskill.app.android.HyperskillApp
Expand All @@ -28,6 +30,7 @@ import org.hyperskill.app.android.core.view.ui.dialog.LoadingProgressDialogFragm
import org.hyperskill.app.android.core.view.ui.dialog.dismissIfExists
import org.hyperskill.app.android.core.view.ui.navigation.requireRouter
import org.hyperskill.app.android.databinding.FragmentAuthSocialBinding
import org.hyperskill.app.android.sentry.domain.model.SentryBreadcrumbKeyValues
import org.hyperskill.app.auth.domain.model.AuthSocialError
import org.hyperskill.app.auth.domain.model.SocialAuthProvider
import org.hyperskill.app.auth.presentation.AuthSocialFeature
Expand Down Expand Up @@ -61,6 +64,8 @@ class AuthSocialFragment :
private val viewBinding by viewBinding(FragmentAuthSocialBinding::bind)
private val authMaterialCardViewsAdapter: DefaultDelegateAdapter<AuthSocialCardInfo> = DefaultDelegateAdapter()

private var currentSocialAuthProvider: SocialAuthProvider? = null

private val loadingProgressDialogFragment: DialogFragment =
LoadingProgressDialogFragment.newInstance()

Expand All @@ -71,7 +76,7 @@ class AuthSocialFragment :
val authCode = account.serverAuthCode
onSuccess(authCode!!, SocialAuthProvider.GOOGLE)
} catch (e: ApiException) {
Sentry.captureException(e)
logSignInErrorToSentry(null, e)

val message = if (e.statusCode == CommonStatusCodes.NETWORK_ERROR)
resourceProvider.getString(SharedResources.strings.connection_error)
Expand All @@ -96,7 +101,16 @@ class AuthSocialFragment :
}

private fun onSocialClickListener(social: AuthSocialCardInfo) {
currentSocialAuthProvider = social.socialAuthProvider
authSocialViewModel.onNewMessage(AuthSocialFeature.Message.ClickedSignInWithSocialEventMessage(social.socialAuthProvider))

val breadcrumb = Breadcrumb().apply {
category = SentryBreadcrumbKeyValues.CATEGORY_AUTH_SOCIAL
message = "Signing in with ${social.socialAuthProvider.title}"
level = SentryLevel.INFO
}
Sentry.addBreadcrumb(breadcrumb)

val authSocialWebViewFragment = AuthSocialWebViewFragment.newInstance(social.socialAuthProvider)
when (social) {
AuthSocialCardInfo.GOOGLE -> {
Expand Down Expand Up @@ -132,10 +146,17 @@ class AuthSocialFragment :
override fun onAction(action: AuthSocialFeature.Action.ViewAction) {
when (action) {
is AuthSocialFeature.Action.ViewAction.CompleteAuthFlow -> {
val breadcrumb = Breadcrumb().apply {
category = SentryBreadcrumbKeyValues.CATEGORY_AUTH_SOCIAL
message = "Signed in with ${currentSocialAuthProvider?.title ?: "None"}"
level = SentryLevel.INFO
}
Sentry.addBreadcrumb(breadcrumb)

(parentFragment as? AuthFlow)?.onAuthSuccess(action.isNewUser)
}
is AuthSocialFeature.Action.ViewAction.ShowAuthError -> {
Sentry.captureException(action.originalError)
logSignInErrorToSentry(action.socialError, action.originalError,)
view?.snackbar(message = authSocialErrorMapper.getAuthSocialErrorText(action.socialError), Snackbar.LENGTH_LONG)
}
}
Expand Down Expand Up @@ -163,12 +184,27 @@ class AuthSocialFragment :

override fun onError(error: AuthSocialError, originalError: Throwable?) {
if (originalError != null) {
Sentry.captureException(originalError)
logSignInErrorToSentry(error, originalError)
}
view?.snackbar(message = authSocialErrorMapper.getAuthSocialErrorText(error), Snackbar.LENGTH_LONG)
}

override fun onSuccess(authCode: String, provider: SocialAuthProvider) {
authSocialViewModel.onNewMessage(AuthSocialFeature.Message.AuthWithSocial(authCode = authCode, socialAuthProvider = provider))
}

private fun logSignInErrorToSentry(socialError: AuthSocialError?, originalError: Throwable) {
val breadcrumb = Breadcrumb().apply {
category = SentryBreadcrumbKeyValues.CATEGORY_AUTH_SOCIAL
message = "Sign in failed with ${currentSocialAuthProvider?.title ?: "None"}"
level = SentryLevel.ERROR
}
Sentry.addBreadcrumb(breadcrumb)

if (socialError != null) {
Sentry.captureMessage("AuthSocial: $socialError, $originalError", SentryLevel.ERROR)
} else {
Sentry.captureMessage("AuthSocial: $originalError", SentryLevel.ERROR)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ import org.hyperskill.app.track.injection.PlatformTrackComponent
import org.hyperskill.app.track.injection.PlatformTrackComponentImpl
import org.hyperskill.app.track.injection.TrackComponent
import org.hyperskill.app.track.injection.TrackComponentImpl
import org.hyperskill.app.user_storage.injection.UserStorageComponent
import org.hyperskill.app.user_storage.injection.UserStorageComponentImpl

class AndroidAppComponentImpl(
private val application: Application,
Expand Down Expand Up @@ -226,4 +228,7 @@ class AndroidAppComponentImpl(

override fun buildPlatformPlaceholderNewUserComponent(placeholderNewUserComponent: PlaceholderNewUserComponent): PlatformPlaceholderNewUserComponent =
PlatformPlaceholderNewUserComponentImpl(placeholderNewUserComponent)

override fun buildUserStorageComponent(): UserStorageComponent =
UserStorageComponentImpl(this)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.hyperskill.app.android.sentry.domain.model

object SentryBreadcrumbKeyValues {
const val CATEGORY_AUTH_SOCIAL = "auth_social"
const val CATEGORY_AUTH_CREDENTIALS = "auth_social_credentials"
}
4 changes: 2 additions & 2 deletions gradle/app.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
minSdk = '24'
targetSdk = '31'
compileSdk = '31'
versionName = '1.1.1'
versionCode = '15'
versionName = '1.2'
versionCode = '16'
4 changes: 2 additions & 2 deletions gradle/release-notes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
What to Test:
1. Add submission validation ALTAPPS-231
2. Fix onboarding screen disappears after one sign in attempt ALTAPPS-301
1. Fix crash NoClassDefFoundError Failed resolution of: Ljava/time/Instant ALTAPPS-329
2. Fix user_id in analytics events doesn't reset after log out ALTAPPS-295
43 changes: 43 additions & 0 deletions iosHyperskillApp/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ platform :ios do
],
}

configurations = {
"iosHyperskillApp" => "Release",
}

after_all do |lane, options|
clean_build_artifacts
end
Expand Down Expand Up @@ -133,6 +137,9 @@ platform :ios do
scheme: scheme,
)

# Add BETA_PROFILE to SWIFT_ACTIVE_COMPILATION_CONDITIONS -> build -> remove
update_beta_profile_compilation_condition(scheme: scheme, configurations: configurations, should_remove: false)

begin
gym(
scheme: "#{scheme}",
Expand All @@ -152,6 +159,7 @@ platform :ios do
provisioning_profile_mapping: lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING],
scheme: scheme,
)
update_beta_profile_compilation_condition(scheme: scheme, configurations: configurations, should_remove: true)
end

firebase_app_distribution(
Expand Down Expand Up @@ -361,6 +369,41 @@ platform :ios do
"v. #{version} (#{build})"
end

# Adds or removes BETA_PROFILE to project SWIFT_ACTIVE_COMPILATION_CONDITIONS
def update_beta_profile_compilation_condition(options)
require "xcodeproj"

target_name = options[:target] || "iosHyperskillApp"
scheme = options[:scheme]
configurations = options[:configurations]
should_remove = options[:should_remove] || false

UI.user_error!("Wrong scheme parameter") if scheme.nil?
UI.user_error!("Wrong configurations parameter") if configurations.nil?

configuration_name = configurations[scheme]
UI.user_error!("No configuration found for scheme #{scheme}") if configuration_name.nil?

UI.message "Updating BETA_PROFILE build setting for scheme=#{scheme}, configuration=#{configuration_name}."

project = Xcodeproj::Project.open("../iosHyperskillApp.xcodeproj")

target = project.targets.find { |it| it.name == target_name }
UI.user_error!("Can't find target for name #{target_name}") if target.nil?

build_configuration = target.build_configurations.find { |it| it.name == configuration_name }
UI.user_error!("Can't find build configuration for name #{configuration_name}") if build_configuration.nil?

old_build_setting = build_configuration.build_settings["SWIFT_ACTIVE_COMPILATION_CONDITIONS"]
new_build_setting = should_remove ? old_build_setting.chomp("BETA_PROFILE").strip() : "#{old_build_setting} BETA_PROFILE"

build_configuration.build_settings["SWIFT_ACTIVE_COMPILATION_CONDITIONS"] = new_build_setting

project.save()

UI.message "Finished updating BETA_PROFILE build setting. Current SWIFT_ACTIVE_COMPILATION_CONDITIONS=#{new_build_setting}."
end

# App Store Connect

desc "Creates new iOS app on both the Apple Developer Portal and App Store Connect"
Expand Down
6 changes: 4 additions & 2 deletions iosHyperskillApp/fastlane/release-notes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
What to Test:
1. Add submission validation ALTAPPS-231
2. Fix onboarding screen disappears after one sign in attempt ALTAPPS-301
1. UI improvements ALTAPPS-254
2. Fix infinite loading after log out ALTAPPS-294
3. Fix user_id in analytics events doesn't reset after log out ALTAPPS-295
4. Support debug mode for DEBUG and BETA profiles builds using fastlane ALTAPPS-338
Loading

0 comments on commit c0a1275

Please sign in to comment.