-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Configure Cocoapods for ios target * 贡献文章中增加构建 iOS * Add sentry for automatic crash report * configure CI * install cocoapods on macos ci * Add ios deployment target * fix compile
- Loading branch information
Showing
23 changed files
with
328 additions
and
77 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
app/shared/app-platform/src/commonMain/kotlin/trace/ErrorReport.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (C) 2024-2025 OpenAni and contributors. | ||
* | ||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. | ||
* Use of this source code is governed by the GNU AGPLv3 license, which can be found at the following link. | ||
* | ||
* https://github.com/open-ani/ani/blob/main/LICENSE | ||
*/ | ||
|
||
package me.him188.ani.app.trace | ||
|
||
import io.sentry.kotlin.multiplatform.Scope | ||
import io.sentry.kotlin.multiplatform.Sentry | ||
import io.sentry.kotlin.multiplatform.SentryLevel | ||
import io.sentry.kotlin.multiplatform.protocol.Breadcrumb | ||
import io.sentry.kotlin.multiplatform.protocol.SentryId | ||
|
||
object ErrorReport { | ||
inline fun captureMessage( | ||
message: String, | ||
level: SentryLevel = SentryLevel.INFO, | ||
crossinline config: Scope.() -> Unit = {} | ||
): SentryId { | ||
return if (Sentry.isEnabled()) { | ||
Sentry.captureMessage(message) { | ||
it.level = level | ||
config(it) | ||
} | ||
} else { | ||
SentryId.EMPTY_ID | ||
} | ||
} | ||
|
||
inline fun breadcrumb( | ||
breadcrumb: Breadcrumb, | ||
config: Breadcrumb.() -> Unit = {} | ||
) = Sentry.addBreadcrumb(breadcrumb.apply(config)) | ||
|
||
inline fun captureException( | ||
throwable: Throwable, | ||
level: SentryLevel = SentryLevel.ERROR, | ||
crossinline config: Scope.() -> Unit = {} | ||
): SentryId { | ||
return if (Sentry.isEnabled()) { | ||
Sentry.captureException(throwable) { | ||
it.level = level | ||
config(it) | ||
} | ||
} else { | ||
SentryId.EMPTY_ID | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/shared/application/src/androidMain/kotlin/platform/Tracing.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (C) 2024-2025 OpenAni and contributors. | ||
* | ||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. | ||
* Use of this source code is governed by the GNU AGPLv3 license, which can be found at the following link. | ||
* | ||
* https://github.com/open-ani/ani/blob/main/LICENSE | ||
*/ | ||
|
||
package me.him188.ani.app.platform | ||
|
||
import io.sentry.kotlin.multiplatform.Sentry | ||
|
||
internal actual fun initializeErrorReport() { | ||
Sentry.init { options -> | ||
CommonTracingInitializer.configureSentryOptions(options) | ||
} | ||
Sentry.configureScope { | ||
CommonTracingInitializer.configureGlobalScope(it) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
app/shared/application/src/commonMain/kotlin/platform/Tracing.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (C) 2024-2025 OpenAni and contributors. | ||
* | ||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. | ||
* Use of this source code is governed by the GNU AGPLv3 license, which can be found at the following link. | ||
* | ||
* https://github.com/open-ani/ani/blob/main/LICENSE | ||
*/ | ||
|
||
package me.him188.ani.app.platform | ||
|
||
import io.sentry.kotlin.multiplatform.Scope | ||
import io.sentry.kotlin.multiplatform.SentryOptions | ||
import me.him188.ani.app.trace.ErrorReport | ||
import me.him188.ani.utils.platform.currentPlatform | ||
|
||
|
||
/** | ||
* Shares initialization logic across platforms. Only used by [initializeErrorReport]. | ||
*/ | ||
internal object CommonTracingInitializer { | ||
fun configureSentryOptions(options: SentryOptions) { | ||
val buildConfig = currentAniBuildConfig | ||
options.dsn = buildConfig.sentryDsn | ||
options.debug = buildConfig.isDebug | ||
options.release = "me.him188.ani@${buildConfig.versionName}" | ||
} | ||
|
||
fun configureGlobalScope(scope: Scope) { | ||
val platform = currentPlatform() | ||
scope.setContext("os", platform.name) | ||
scope.setContext("arch", platform.arch.name) | ||
scope.setContext("version", currentAniBuildConfig.versionName) | ||
} | ||
} | ||
|
||
/** | ||
* Initializes [ErrorReport] for the platform. | ||
*/ | ||
internal expect fun initializeErrorReport() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
app/shared/application/src/skikoMain/kotlin/platform/Tracing.skiko.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (C) 2024-2025 OpenAni and contributors. | ||
* | ||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. | ||
* Use of this source code is governed by the GNU AGPLv3 license, which can be found at the following link. | ||
* | ||
* https://github.com/open-ani/ani/blob/main/LICENSE | ||
*/ | ||
|
||
package me.him188.ani.app.platform | ||
|
||
import io.sentry.kotlin.multiplatform.Sentry | ||
|
||
internal actual fun initializeErrorReport() { | ||
Sentry.init { options -> | ||
CommonTracingInitializer.configureSentryOptions(options) | ||
} | ||
Sentry.configureScope { | ||
CommonTracingInitializer.configureGlobalScope(it) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.