Skip to content

Commit

Permalink
Fix review issues
Browse files Browse the repository at this point in the history
  • Loading branch information
XanderZhu committed Sep 28, 2023
1 parent cc0032a commit 54d7f00
Show file tree
Hide file tree
Showing 27 changed files with 57 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.hyperskill.app.android.sentry.domain.model.manager

import io.sentry.Sentry
import io.sentry.SentryLevel
import io.sentry.SpanStatus
import io.sentry.android.core.SentryAndroid
import io.sentry.android.fragment.FragmentLifecycleIntegration
Expand All @@ -18,7 +17,10 @@ import org.hyperskill.app.sentry.domain.model.manager.SentryManager
import org.hyperskill.app.sentry.domain.model.transaction.HyperskillSentryTransaction
import org.hyperskill.app.sentry.domain.model.transaction.HyperskillSentryTransactionKeyValues

class SentryManagerImpl(private val buildKonfig: BuildKonfig) : SentryManager {
class SentryManagerImpl(
private val buildKonfig: BuildKonfig,
private val minLogLevel: HyperskillSentryLevel = HyperskillSentryLevel.min(buildKonfig.buildVariant)
) : SentryManager {
private val currentTransactionsMap = mutableMapOf<Int, PlatformHyperskillSentryTransaction>()

override fun setup() {
Expand All @@ -35,10 +37,10 @@ class SentryManagerImpl(private val buildKonfig: BuildKonfig) : SentryManager {
enableAutoFragmentLifecycleTracing = true
)
)
options.setDiagnosticLevel(minLogLevel.toSentryLevel())

if (BuildConfig.DEBUG) {
options.setDebug(true)
options.setDiagnosticLevel(SentryLevel.WARNING)
options.tracesSampleRate = 1.0
} else {
options.setDebug(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ final class SentryManager: shared.SentryManager {

#if DEBUG
options.debug = true
options.diagnosticLevel = .info
options.diagnosticLevel = .debug

options.tracesSampleRate = 1
#else
options.tracesSampleRate = 0.3
options.diagnosticLevel = .info
#endif

// HTTP Client Errors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package org.hyperskill.app.auth.injection

import org.hyperskill.app.auth.presentation.AuthSocialFeature.Action
import org.hyperskill.app.auth.presentation.AuthSocialFeature.Message
import org.hyperskill.app.auth.presentation.AuthSocialFeature.State
import org.hyperskill.app.auth.presentation.AuthSocialFeature.Action as AuthSocialAction
import org.hyperskill.app.auth.presentation.AuthSocialFeature.Message as AuthSocialMessage
import org.hyperskill.app.auth.presentation.AuthSocialFeature.State as AuthSocialState
import org.hyperskill.app.auth.presentation.AuthSocialWebViewFeature.Action as AuthSocialWebViewAction
import org.hyperskill.app.auth.presentation.AuthSocialWebViewFeature.Message as AuthSocialWebViewMessage
import org.hyperskill.app.auth.presentation.AuthSocialWebViewFeature.State as AuthSocialWebViewState
import org.hyperskill.app.auth.view.mapper.AuthSocialErrorMapper
import ru.nobird.app.presentation.redux.feature.Feature
import org.hyperskill.app.auth.presentation.AuthSocialWebViewFeature.Action as WebViewAction
import org.hyperskill.app.auth.presentation.AuthSocialWebViewFeature.Message as WebViewMessage
import org.hyperskill.app.auth.presentation.AuthSocialWebViewFeature.State as WebViewState

interface AuthSocialComponent {
val authSocialFeature: Feature<State, Message, Action>
val authSocialFeature: Feature<AuthSocialState, AuthSocialMessage, AuthSocialAction>
val authSocialErrorMapper: AuthSocialErrorMapper
val authSocialWebViewFeature: Feature<WebViewState, WebViewMessage, WebViewAction>
val authSocialWebViewFeature: Feature<AuthSocialWebViewState, AuthSocialWebViewMessage, AuthSocialWebViewAction>
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import ru.nobird.app.presentation.redux.feature.ReduxFeature

object AuthSocialWebViewFeatureBuilder {
private const val LOG_TAG = "AuthSocialWebViewFeature"

fun build(
logger: Logger,
buildVariant: BuildVariant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import ru.nobird.app.presentation.redux.feature.ReduxFeature

object DebugFeatureBuilder {
private const val LOG_TAG = "DebugFeature"

fun build(
debugInteractor: DebugInteractor,
appInteractor: AppInteractor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import ru.nobird.app.presentation.redux.feature.Feature
import ru.nobird.app.presentation.redux.feature.ReduxFeature

internal object HomeFeatureBuilder {

private const val LOG_TAG = "HomeFeature"

fun build(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ class SentryLogWriter(
Severity.Info -> sentryInteractor.captureMessage(formattedMessage, HyperskillSentryLevel.INFO)
Severity.Warn -> sentryInteractor.captureMessage(formattedMessage, HyperskillSentryLevel.WARNING)
Severity.Error -> sentryInteractor.captureMessage(formattedMessage, HyperskillSentryLevel.ERROR)
Severity.Debug -> sentryInteractor.captureMessage(formattedMessage, HyperskillSentryLevel.DEBUG)
Severity.Verbose, Severity.Assert -> {
Severity.Debug, Severity.Verbose, Severity.Assert -> {
// no op
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import org.hyperskill.app.sentry.domain.interactor.SentryInteractor

object LoggerBuilder {
private const val LOG_TAG = "HYPERSKILL_APP"

fun build(
buildVariant: BuildVariant,
sentryInteractor: SentryInteractor
): Logger =
Logger(
config = StaticConfig(
logWriterList = listOf(
platformLogWriter(),
logWriterList = listOfNotNull(
if (buildVariant == BuildVariant.RELEASE) null else platformLogWriter(),
SentryLogWriter(sentryInteractor)
),
minSeverity = if (buildVariant == BuildVariant.RELEASE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package org.hyperskill.app.logging.inject
import co.touchlab.kermit.Logger
import org.hyperskill.app.core.injection.AppGraph

class LoggerComponentImpl(private val appGraph: AppGraph) : LoggerComponent {
override val logger: Logger
get() = LoggerBuilder.build(
appGraph.commonComponent.buildKonfig.buildVariant,
appGraph.sentryComponent.sentryInteractor
)
class LoggerComponentImpl(appGraph: AppGraph) : LoggerComponent {

override val logger: Logger = LoggerBuilder.build(
appGraph.commonComponent.buildKonfig.buildVariant,
appGraph.sentryComponent.sentryInteractor
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private class LoggableStateReducer<State, Message, Action>(
if (initialState == newState) {
"reduce(\nmessage=$message,\nstate=$initialState\n)\nActions=$actions\nNew state = SAME"
} else {
"reduce(\nmessage=$message,\nstate=PREVIOUS\n)\nActions=$actions\nNew state = $newState"
"reduce(\nmessage=$message,\nstate=$initialState\n)\nActions=$actions\nNew state = $newState"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import ru.nobird.app.presentation.redux.feature.ReduxFeature

object AppFeatureBuilder {
private const val LOG_TAG = "AppFeature"

fun build(
initialState: State?,
appInteractor: AppInteractor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import ru.nobird.app.presentation.redux.feature.ReduxFeature

internal object NotificationsOnboardingFeatureBuilder {
private const val LOG_TAG = "NotificationsOnboardingFeature"

fun build(
analyticInteractor: AnalyticInteractor,
notificationInteractor: NotificationInteractor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import ru.nobird.app.presentation.redux.feature.ReduxFeature

object OnboardingFeatureBuilder {
private const val LOG_TAG = "OnboardingFeature"

fun build(
onboardingInteractor: OnboardingInteractor,
currentProfileStateRepository: CurrentProfileStateRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import ru.nobird.app.presentation.redux.feature.Feature
import ru.nobird.app.presentation.redux.feature.ReduxFeature

object ProfileFeatureBuilder {
private const val LOG_TAG = "ProfileFeatureBuilder"
private const val LOG_TAG = "ProfileFeature"

fun build(
profileInteractor: ProfileInteractor,
currentProfileStateRepository: CurrentProfileStateRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import ru.nobird.app.presentation.redux.feature.ReduxFeature

object ProfileSettingsFeatureBuilder {
private const val LOG_TAG = "ProfileSettingsFeature"

fun build(
profileSettingsInteractor: ProfileSettingsInteractor,
currentProfileStateRepository: CurrentProfileStateRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import ru.nobird.app.presentation.redux.feature.ReduxFeature

internal object ProgressScreenFeatureBuilder {
private const val LOG_TAG = "ProgressScreenFeature"

fun build(
currentStudyPlanStateRepository: CurrentStudyPlanStateRepository,
currentProfileStateRepository: CurrentProfileStateRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import ru.nobird.app.presentation.redux.feature.ReduxFeature

object ProjectSelectionDetailsFeatureBuilder {
private const val LOG_TAG = "ProjectSelectionDetailsFeature"

fun build(
params: ProjectSelectionDetailsParams,
trackRepository: TrackRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import ru.nobird.app.presentation.redux.feature.ReduxFeature

internal object ProjectSelectionListFeatureBuilder {
private const val LOG_TAG = "ProjectSelectionListFeature"

fun build(
params: ProjectSelectionListParams,
trackRepository: TrackRepository,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.hyperskill.app.sentry.domain.model.level

import org.hyperskill.app.core.domain.BuildVariant

/**
* Represents the severity level of an event.
*
Expand All @@ -11,5 +13,14 @@ enum class HyperskillSentryLevel {
INFO,
WARNING,
ERROR,
FATAL
FATAL;

companion object {
fun min(buildVariant: BuildVariant): HyperskillSentryLevel =
if (buildVariant == BuildVariant.RELEASE) {
INFO
} else {
DEBUG
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import ru.nobird.app.presentation.redux.feature.ReduxFeature

internal object StageImplementFeatureBuilder {
private const val LOG_TAG = "StageImplementFeature"

fun build(
projectId: Long,
stageId: Long,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import ru.nobird.app.presentation.redux.feature.ReduxFeature

object StepFeatureBuilder {
private const val LOG_TAG = "StepFeature"

fun build(
stepRoute: StepRoute,
stepInteractor: StepInteractor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import ru.nobird.app.presentation.redux.feature.ReduxFeature

object StepQuizFeatureBuilder {
private const val LOG_TAG = "StepQuizFeature"

fun build(
stepRoute: StepRoute,
problemsLimitReducer: ProblemsLimitReducer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import ru.nobird.app.presentation.redux.feature.ReduxFeature

object StepQuizHintsFeatureBuilder {
private const val LOG_TAG = "StepQuizHintsFeature"

fun build(
stepRoute: StepRoute,
stepQuizHintsInteractor: StepQuizHintsInteractor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import ru.nobird.app.presentation.redux.feature.ReduxFeature

internal object StudyPlanScreenFeatureBuilder {
private const val LOG_TAG = "StudyPlanScreenFeature"

fun build(
analyticInteractor: AnalyticInteractor,
toolbarReducer: GamificationToolbarReducer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import ru.nobird.app.presentation.redux.feature.ReduxFeature

object TopicsRepetitionsFeatureBuilder {
private const val LOG_TAG = "TopicsRepetitionsFeature"

fun build(
topicsRepetitionsInteractor: TopicsRepetitionsInteractor,
currentProfileStateRepository: CurrentProfileStateRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import ru.nobird.app.presentation.redux.feature.ReduxFeature

object TrackSelectionDetailsFeatureBuilder {
private const val LOG_TAG = "TrackSelectionDetailsFeature"

fun build(
params: TrackSelectionDetailsParams,
resourceProvider: ResourceProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import ru.nobird.app.presentation.redux.feature.ReduxFeature

internal object TrackSelectionListFeatureBuilder {
private const val LOG_TAG = "TrackSelectionListFeature"

fun build(
params: TrackSelectionListParams,
analyticInteractor: AnalyticInteractor,
Expand Down

0 comments on commit 54d7f00

Please sign in to comment.