from django.urls import path, include
from rest_framework.routers import DefaultRouter

from .views import AccessLogViewSet, SiteViewSet
from .collect import collect, tag_js

router = DefaultRouter()
router.register(r"analytics/access-logs", AccessLogViewSet, basename="access-log")
router.register(r"analytics/sites", SiteViewSet, basename="analytics-site")

urlpatterns = [
    # Public ingestion + tag — declared before the router so they stay unauthenticated.
    path("analytics/collect", collect, name="analytics-collect"),
    path("analytics/tag.js", tag_js, name="analytics-tag"),
    path("", include(router.urls)),
]
