Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,19 @@ class ExploreEvents @Inject constructor(
}
)
}

fun exploreFilterApplied(
categoryFilters: List<String>,
regionFilters: List<String>,
ageGroupFilters: List<String>
) {
tracker.track(
eventName = "explore_filter_applied",
properties = JSONObject().apply {
put("category_filters", categoryFilters)
put("region_filters", regionFilters)
put("age_group_filters", ageGroupFilters)
}
)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요거 이미 함수는 만들어져있어서 commonEvents 내에 있는 함수로 사용 부탁드립니다!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정했습니다!

}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,25 @@ fun ExploreFilterSection(
onFilterReset = { tempFilterState.reset() },
onSave = {
isFilterBottomSheetVisible = false

val categoryFilters = filterItems.categories.filter { tempFilterState.categories[it.id] == true }.map { it.name }
val regionFilters = filterItems.regions.filter { tempFilterState.regions[it.id] == true }.map { it.name }
val ageGroupFilters = filterItems.ages.filter { tempFilterState.ages[it.id] == true }.map { it.name }
val isLocalReviewEnabled = filterItems.properties.firstOrNull()?.let { tempFilterState.properties[it.id] == true } ?: false
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

firstOrNull()을 사용한 방식이 취약할 수 있습니다.

현재 코드는 properties의 첫 번째 항목이 로컬 리뷰라고 가정하고 있습니다. 만약 속성의 순서가 변경되거나 로컬 리뷰 앞에 다른 속성이 추가되면 조용히 오동작할 수 있습니다.

Line 110에서 FilterCategory.LOCAL_REVIEW enum을 사용하는 것을 보면, 위치가 아닌 타입/카테고리로 로컬 리뷰 속성을 식별하는 방식이 더 안전할 것 같습니다.

다음과 같이 개선하는 것을 고려해보세요:

val isLocalReviewEnabled = filterItems.properties
    .find { /* 로컬 리뷰를 식별하는 조건, 예: it.category == FilterCategory.LOCAL_REVIEW */ }
    ?.let { tempFilterState.properties[it.id] == true } 
    ?: false
🤖 Prompt for AI Agents
In
app/src/main/java/com/spoony/spoony/presentation/explore/component/ExploreFilterSection.kt
around line 93, using properties.firstOrNull() to assume the first property is
the local review is fragile; instead locate the property by its category/type:
replace the firstOrNull() call with a search (e.g., find { it.category ==
FilterCategory.LOCAL_REVIEW } or whatever field identifies local review), then
check tempFilterState.properties[it.id] == true and fall back to false if not
found; ensure the enum FilterCategory.LOCAL_REVIEW is referenced correctly and
adjust null-safety accordingly.


tracker.commonEvents.filterApplied(
pageApplied = "explore",
localReviewFilter = isLocalReviewEnabled
)

if (categoryFilters.isNotEmpty() || regionFilters.isNotEmpty() || ageGroupFilters.isNotEmpty()) {
tracker.exploreEvents.exploreFilterApplied(
categoryFilters = categoryFilters,
regionFilters = regionFilters,
ageGroupFilters = ageGroupFilters
)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요렇게 하면 이벤트가 2개 심겨요!! 위에도 말씀드렸지만 이미 만들어져있는 commonEvents.filterApplied로 심어주세요..!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정했습니다!


onAction(ExploreAction.ApplyFilter(tempFilterState.toPersistent()))
},
onToggleFilter = { id, type ->
Expand Down