Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ naming:
MatchingDeclarationName:
active: true
ConstructorParameterNaming:
active: false
active: true
FunctionNaming:
active: true
excludes:
Expand Down
17 changes: 9 additions & 8 deletions backend/src/main/kotlin/com/moneat/ai/AiModels.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.moneat.ai

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import org.jetbrains.exposed.v1.core.Table
import org.jetbrains.exposed.v1.datetime.timestamp
Expand Down Expand Up @@ -99,9 +100,9 @@ data class AiResponse(
val message: String = "",
val actions: List<AiAction> = emptyList(),
val clarifications: List<AiClarification> = emptyList(),
val data_queries: List<AiDataQuery> = emptyList(),
@SerialName("data_queries") val dataQueries: List<AiDataQuery> = emptyList(),
val links: List<AiLink> = emptyList(),
val context_needed: List<String> = emptyList()
@SerialName("context_needed") val contextNeeded: List<String> = emptyList()
)

@Serializable
Expand Down Expand Up @@ -166,9 +167,9 @@ data class ActionResult(
data class OpenAiChatRequest(
val model: String,
val messages: List<OpenAiMessage>,
val max_tokens: Int = 2048,
@SerialName("max_tokens") val maxTokens: Int = 2048,
val temperature: Double = 0.3,
val response_format: OpenAiResponseFormat? = null
@SerialName("response_format") val responseFormat: OpenAiResponseFormat? = null
)

@Serializable
Expand All @@ -192,12 +193,12 @@ data class OpenAiChatResponse(
@Serializable
data class OpenAiChoice(
val message: OpenAiMessage,
val finish_reason: String? = null
@SerialName("finish_reason") val finishReason: String? = null
)

@Serializable
data class OpenAiUsage(
val prompt_tokens: Int = 0,
val completion_tokens: Int = 0,
val total_tokens: Int = 0
@SerialName("prompt_tokens") val promptTokens: Int = 0,
@SerialName("completion_tokens") val completionTokens: Int = 0,
@SerialName("total_tokens") val totalTokens: Int = 0
)
4 changes: 2 additions & 2 deletions backend/src/main/kotlin/com/moneat/ai/OpenAiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ object OpenAiClient {
OpenAiChatRequest(
model = model,
messages = messages,
max_tokens = maxTokens,
maxTokens = maxTokens,
temperature = 0.3,
response_format = OpenAiResponseFormat(type = "json_object")
responseFormat = OpenAiResponseFormat(type = "json_object")
)

val response =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import io.ktor.http.HttpHeaders
import io.ktor.http.encodeURLParameter
import io.ktor.serialization.kotlinx.json.json
import io.ktor.server.config.ApplicationConfig
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import mu.KotlinLogging
Expand All @@ -56,8 +57,8 @@ private val logger = KotlinLogging.logger {}

@Serializable
data class GitHubAccessTokenResponse(
val access_token: String,
val token_type: String,
@SerialName("access_token") val accessToken: String,
@SerialName("token_type") val tokenType: String,
val scope: String
)

Expand Down Expand Up @@ -174,7 +175,7 @@ class OAuthService {
}

val tokenData: GitHubAccessTokenResponse = tokenResponse.body()
val accessToken = tokenData.access_token
val accessToken = tokenData.accessToken

// Fetch user info
val userResponse: HttpResponse =
Expand Down
48 changes: 26 additions & 22 deletions backend/src/main/kotlin/com/moneat/events/models/SentryModels.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.moneat.events.models

import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationException
import kotlinx.serialization.descriptors.PrimitiveKind
Expand Down Expand Up @@ -195,7 +196,7 @@ data class EnvelopeItem(

@Serializable
data class SentryEvent(
val event_id: String? = null,
@SerialName("event_id") val eventId: String? = null,
@Serializable(with = FlexibleTimestampSerializer::class)
val timestamp: Double? = null,
val level: String? = null,
Expand All @@ -215,7 +216,7 @@ data class SentryEvent(
val breadcrumbs: JsonArray? = null,
val request: JsonObject? = null,
val fingerprint: List<String>? = null,
val server_name: String? = null,
@SerialName("server_name") val serverName: String? = null,
val threads: JsonObject? = null
)

Expand Down Expand Up @@ -323,11 +324,12 @@ object FlexibleTimestampSerializer : KSerializer<Double?> {

@Serializable
data class SentryTransaction(
val event_id: String? = null,
@SerialName("event_id") val eventId: String? = null,
val type: String? = null,
val transaction: String? = null,
@Serializable(with = FlexibleTimestampSerializer::class)
val start_timestamp: Double? = null,
@SerialName("start_timestamp")
val startTimestamp: Double? = null,
@Serializable(with = FlexibleTimestampSerializer::class)
val timestamp: Double? = null,
val platform: String? = null,
Expand All @@ -339,7 +341,7 @@ data class SentryTransaction(
val contexts: JsonObject? = null,
val spans: List<SentrySpan>? = null,
val sdk: SdkInfo? = null,
val server_name: String? = null,
@SerialName("server_name") val serverName: String? = null,
val request: JsonObject? = null,
@Serializable(with = BreadcrumbsSerializer::class)
val breadcrumbs: JsonArray? = null,
Expand All @@ -348,13 +350,14 @@ data class SentryTransaction(

@Serializable
data class SentrySpan(
val span_id: String? = null,
val parent_span_id: String? = null,
val trace_id: String? = null,
@SerialName("span_id") val spanId: String? = null,
@SerialName("parent_span_id") val parentSpanId: String? = null,
@SerialName("trace_id") val traceId: String? = null,
val op: String? = null,
val description: String? = null,
@Serializable(with = FlexibleTimestampSerializer::class)
val start_timestamp: Double? = null,
@SerialName("start_timestamp")
val startTimestamp: Double? = null,
@Serializable(with = FlexibleTimestampSerializer::class)
val timestamp: Double? = null,
val status: String? = null,
Expand Down Expand Up @@ -393,11 +396,11 @@ data class StackFrame(
val module: String? = null,
val lineno: Int? = null,
val colno: Int? = null,
val abs_path: String? = null,
val context_line: String? = null,
val pre_context: List<String>? = null,
val post_context: List<String>? = null,
val in_app: Boolean? = null,
@SerialName("abs_path") val absPath: String? = null,
@SerialName("context_line") val contextLine: String? = null,
@SerialName("pre_context") val preContext: List<String>? = null,
@SerialName("post_context") val postContext: List<String>? = null,
@SerialName("in_app") val inApp: Boolean? = null,
val vars: JsonObject? = null
)

Expand All @@ -406,33 +409,34 @@ data class UserInfo(
val id: String? = null,
val email: String? = null,
val username: String? = null,
val ip_address: String? = null
@SerialName("ip_address") val ipAddress: String? = null
)

@Serializable
data class SentryReplayEvent(
val replay_id: String? = null,
val segment_id: Int? = null,
@SerialName("replay_id") val replayId: String? = null,
@SerialName("segment_id") val segmentId: Int? = null,
@Serializable(with = FlexibleTimestampSerializer::class)
val timestamp: Double? = null,
@Serializable(with = FlexibleTimestampSerializer::class)
val replay_start_timestamp: Double? = null,
@SerialName("replay_start_timestamp")
val replayStartTimestamp: Double? = null,
val urls: List<String>? = null,
val error_ids: List<String>? = null,
val trace_ids: List<String>? = null,
@SerialName("error_ids") val errorIds: List<String>? = null,
@SerialName("trace_ids") val traceIds: List<String>? = null,
val platform: String? = null,
val environment: String? = null,
val release: String? = null,
val user: UserInfo? = null,
val contexts: JsonObject? = null,
val sdk: SdkInfo? = null,
val tags: Map<String, String>? = null,
val replay_type: String? = null
@SerialName("replay_type") val replayType: String? = null
)

@Serializable
data class SentryFeedback(
val event_id: String? = null,
@SerialName("event_id") val eventId: String? = null,
val timestamp: String? = null,
val platform: String? = null,
val level: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class DashboardQueryHelper(
val userEmail = obj["user_email"]?.jsonPrimitive?.contentOrNull
val userUsername = obj["user_username"]?.jsonPrimitive?.contentOrNull
return if (userId != null || userEmail != null || userUsername != null) {
UserInfo(id = userId, email = userEmail, username = userUsername, ip_address = null)
UserInfo(id = userId, email = userEmail, username = userUsername, ipAddress = null)
} else {
null
}
Expand Down Expand Up @@ -213,7 +213,7 @@ class DashboardQueryHelper(
}

fun parseTraceContext(contexts: String): JsonObject? {
return suspendRunCatching {
return runCatching {
val contextsJson = json.parseToJsonElement(contexts) as? JsonObject ?: return null
contextsJson["trace"] as? JsonObject
}.getOrElse { _ ->
Expand Down
Loading
Loading