Skip to content

Commit

Permalink
[FO-768] 앱 os type, version code, version name 를 header값 추적 (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkyoungdeok authored Nov 19, 2023
1 parent 602f350 commit 4b6aa0e
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class GlobalExceptionHandler(
builder.setContent(ex.message)
builder.addEmbeds(embed)
builder.addEmbeds(exchange.request.parseBodyToEmbed())
builder.addEmbeds(exchange.request.parseUserAgentToEmbed())
webhookClient.send(builder.build())

val response = CommonResponse.fail(ex.message, ex.javaClass.simpleName)
Expand Down Expand Up @@ -86,6 +87,7 @@ class GlobalExceptionHandler(
builder.setContent(ErrorCode.COMMON_NULL_PARAMETER.errorMsg)
builder.addEmbeds(embed)
builder.addEmbeds(exchange.request.parseBodyToEmbed())
builder.addEmbeds(exchange.request.parseUserAgentToEmbed())
webhookClient.send(builder.build())

val errorResponse = CommonResponse.fail(data, ErrorCode.COMMON_NULL_PARAMETER)
Expand Down Expand Up @@ -141,6 +143,7 @@ class GlobalExceptionHandler(
builder.setContent(ErrorCode.COMMON_INVALID_PARAMETER.errorMsg)
builder.addEmbeds(embed)
builder.addEmbeds(exchange.request.parseBodyToEmbed())
builder.addEmbeds(exchange.request.parseUserAgentToEmbed())
webhookClient.send(builder.build())

val errorResponse = CommonResponse
Expand Down Expand Up @@ -170,6 +173,7 @@ class GlobalExceptionHandler(
builder.setContent("서버에서 정의하지 않은 서버입니다.")
builder.addEmbeds(embed)
builder.addEmbeds(exchange.request.parseBodyToEmbed())
builder.addEmbeds(exchange.request.parseUserAgentToEmbed())
webhookClient.send(builder.build())

val errorResponse = CommonResponse.fail(e.message, e::class.java.simpleName)
Expand Down Expand Up @@ -200,4 +204,19 @@ class GlobalExceptionHandler(
String(bytes)
}
}

private fun ServerHttpRequest.parseUserAgentToEmbed(): WebhookEmbed {
val userAgent = this.headers["User-Agent"]?.joinToString(", ") ?: "Unknown User-Agent"
return WebhookEmbed(
null,
null,
userAgent,
null,
null,
null,
WebhookEmbed.EmbedTitle("User-Agent", null),
null,
emptyList()
)
}
}

0 comments on commit 4b6aa0e

Please sign in to comment.