Tracking Internal Modules
This section exposes the implementation modules behind request recording, Redis-backed counting, ORM snapshots, and cabinet analytics widgets.
App config
codex_django.tracking.apps
Django app configuration for the reusable tracking package.
Classes
TrackingConfig
Bases: AppConfig
Register the tracking runtime and optional cabinet declarations.
Source code in src/codex_django/tracking/apps.py
6 7 8 9 10 11 12 13 14 15 16 | |
Functions
ready()
Import dashboard providers/declarations after Django app loading.
Source code in src/codex_django/tracking/apps.py
13 14 15 16 | |
Settings
codex_django.tracking.settings
Settings helpers for the tracking runtime.
Classes
TrackingSettings
dataclass
Resolved tracking settings with conservative defaults.
Source code in src/codex_django/tracking/settings.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
Functions
get_tracking_settings()
Return normalized CODEX_TRACKING/legacy CABINET_TRACKING settings.
Source code in src/codex_django/tracking/settings.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
Middleware
codex_django.tracking.middleware
Middleware for page-view tracking.
Classes
PageTrackingMiddleware
Record eligible GET responses without affecting request handling.
Source code in src/codex_django/tracking/middleware.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
Functions
Recorder
codex_django.tracking.recorder
Request recorder used by the tracking middleware.
Classes
TrackingRecorder
Convert a Django request into a tracking counter update.
Source code in src/codex_django/tracking/recorder.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
Functions
record(request)
staticmethod
Record one page view for the current request.
Source code in src/codex_django/tracking/recorder.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
Selector
codex_django.tracking.selector
Read-only analytics selectors for tracking data.
Classes
TrackingAnalyticsContext
dataclass
Dashboard-ready tracking analytics payload.
Source code in src/codex_django/tracking/selector.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
Functions
as_dict()
Return the context as template-friendly keys.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A plain dictionary keyed the same way cabinet templates and widget |
dict[str, Any]
|
providers expect to receive tracking analytics payloads. |
Source code in src/codex_django/tracking/selector.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
TrackingSelector
Read page tracking analytics from Redis and flushed database rows.
Source code in src/codex_django/tracking/selector.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
Functions
daily_counts(date_str=None)
staticmethod
Return path counters for a single day.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date_str
|
str | None
|
Optional ISO date string. Defaults to the current local day when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, int]
|
A mapping of request path to total page views. Redis snapshots |
dict[str, int]
|
override ORM snapshot values when both are present. |
Source code in src/codex_django/tracking/selector.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
top_pages(date_str=None, limit=10)
staticmethod
Return the highest-traffic pages for one day.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date_str
|
str | None
|
Optional ISO date string. Defaults to the current local day when omitted. |
None
|
limit
|
int
|
Maximum number of rows to return. |
10
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
A list of |
list[dict[str, Any]]
|
descending view count and then by path. |
Source code in src/codex_django/tracking/selector.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
unique_visitors(date_str=None)
staticmethod
Return the approximate unique visitor count for one day.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date_str
|
str | None
|
Optional ISO date string. Defaults to the current local day when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
The HyperLogLog-backed unique visitor estimate stored in Redis for |
int
|
the selected day. |
Source code in src/codex_django/tracking/selector.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
total_views(date_str=None)
staticmethod
Return total page views for one day.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date_str
|
str | None
|
Optional ISO date string. Defaults to the current local day when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
The sum of all page views for the selected day. |
Source code in src/codex_django/tracking/selector.py
125 126 127 128 129 130 131 132 133 134 135 136 137 | |
multi_day_totals(days=None)
staticmethod
Return daily total views for a trailing analytics window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
days
|
int | None
|
Optional number of days to include. Falls back to
|
None
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
A chronologically ordered list of |
list[dict[str, Any]]
|
dictionaries for each day in the requested window. |
Source code in src/codex_django/tracking/selector.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
get_analytics_context(days=None)
staticmethod
Build cabinet-ready widget payloads for tracking analytics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
days
|
int | None
|
Optional number of trailing days to use for chart aggregation. Falls back to the configured analytics window. |
None
|
Returns:
| Type | Description |
|---|---|
TrackingAnalyticsContext
|
A typed |
TrackingAnalyticsContext
|
and table widgets for cabinet dashboards or analytics pages. |
Source code in src/codex_django/tracking/selector.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
Functions
Dashboard providers
codex_django.tracking.providers
DashboardSelector providers for reusable tracking widgets.
Classes
Functions
provide_tracking_analytics(request)
Expose tracking analytics widgets to the cabinet dashboard.
Source code in src/codex_django/tracking/providers.py
12 13 14 15 16 | |
Cabinet declarations
codex_django.tracking.cabinet
Cabinet declarations for the reusable tracking app.
Classes
Functions
ORM models
codex_django.tracking.models
Database models for flushed tracking snapshots.
Classes
PageView
Bases: Model
Aggregated daily page view counts flushed from Redis.
Source code in src/codex_django/tracking/models.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
Admin integration
codex_django.tracking.admin
Django admin integration for tracking snapshots.
Classes
PageViewAdmin
Bases: ModelAdmin
Inspect flushed page view snapshots.
Source code in src/codex_django/tracking/admin.py
10 11 12 13 14 15 16 17 | |
Flush helpers
codex_django.tracking.flush
Flush Redis tracking counters into database snapshots.
Functions
flush_page_views(date_str=None)
Upsert one day's Redis counters into PageView snapshots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date_str
|
str | None
|
Optional ISO date string identifying the day to flush. Defaults to the current local day when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
The number of path counters written to the database snapshot table. |
Source code in src/codex_django/tracking/flush.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
Flush management command
codex_django.tracking.management.commands.flush_page_views
Management command for flushing tracking counters.
Classes
Command
Bases: BaseCommand
Flush Redis page-view counters into the database.
Source code in src/codex_django/tracking/management/commands/flush_page_views.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
URLs and views
codex_django.tracking.urls
URL patterns for reusable tracking cabinet views.
Functions
codex_django.tracking.views
Cabinet views for tracking analytics.
Classes
Functions
tracking_analytics_view(request)
Render the reusable cabinet analytics page for tracking data.
Source code in src/codex_django/tracking/views.py
14 15 16 17 18 19 20 21 | |