Commit
·
c56d2a1
1
Parent(s):
a59cff0
Only log to media_clicks when user_id is provided
Browse files- Skip media_clicks logging if user_id is None or empty
- Regular MongoDB logging (api_calls, image_uploads, colorizations) always happens regardless of user_id
- This ensures media_clicks only tracks authenticated/identified users
- app/database.py +10 -1
app/database.py
CHANGED
|
@@ -317,7 +317,16 @@ def log_media_click(
|
|
| 317 |
endpoint_path: Optional[str] = None,
|
| 318 |
default_category_id: Optional[str] = None,
|
| 319 |
) -> bool:
|
| 320 |
-
"""Log media clicks into the admin MongoDB (media_clicks collection).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
try:
|
| 322 |
db = get_admin_database()
|
| 323 |
if db is None:
|
|
|
|
| 317 |
endpoint_path: Optional[str] = None,
|
| 318 |
default_category_id: Optional[str] = None,
|
| 319 |
) -> bool:
|
| 320 |
+
"""Log media clicks into the admin MongoDB (media_clicks collection).
|
| 321 |
+
|
| 322 |
+
Only logs if user_id is provided. If user_id is None or empty, returns False without logging.
|
| 323 |
+
Regular MongoDB logging (api_calls, image_uploads, colorizations) always happens regardless.
|
| 324 |
+
"""
|
| 325 |
+
# Only log to media_clicks if user_id is provided
|
| 326 |
+
if not user_id or (isinstance(user_id, str) and not user_id.strip()):
|
| 327 |
+
logger.debug("Skipping media click log - user_id not provided")
|
| 328 |
+
return False
|
| 329 |
+
|
| 330 |
try:
|
| 331 |
db = get_admin_database()
|
| 332 |
if db is None:
|