11package org.gitanimals.gotcha.controller
22
3+ import org.gitanimals.core.auth.InternalAuth
34import org.gitanimals.core.auth.RequiredUserEntryPoints
45import org.gitanimals.core.auth.UserEntryPoint
6+ import org.gitanimals.core.event.EventLogger
57import org.gitanimals.gotcha.app.GotchaFacadeV3
68import org.gitanimals.gotcha.app.response.GotchaResponseV3
79import org.gitanimals.gotcha.controller.response.ErrorResponse
@@ -13,6 +15,8 @@ import org.springframework.web.bind.annotation.*
1315@RestController
1416class GotchaController (
1517 private val gotchaFacadeV3 : GotchaFacadeV3 ,
18+ private val eventLogger : EventLogger ,
19+ private val internalAuth : InternalAuth ,
1620) {
1721
1822 @RequiredUserEntryPoints([UserEntryPoint .GITHUB ])
@@ -26,6 +30,20 @@ class GotchaController(
2630
2731 val gotchaResponses = gotchaFacadeV3.gotcha(token, gotchaType, count)
2832
33+ internalAuth.findUserId()?.let { userId ->
34+ gotchaResponses.forEach { response ->
35+ eventLogger.track(
36+ eventName = " complete_gotcha" ,
37+ distinctId = userId.toString(),
38+ properties = mapOf (
39+ " pet_persona" to response.name,
40+ " cost_point" to gotchaType.point,
41+ " user_id" to userId,
42+ ),
43+ )
44+ }
45+ }
46+
2947 return mapOf (" gotchaResults" to gotchaResponses)
3048 }
3149
0 commit comments