Commit c990ccf
authored
feat(analytics): tag Plausible pageviews with foundation/project/lens (#709)
* feat(analytics): tag Plausible pageviews with foundation/project/lens
PlausibleService now reads ProjectContextService and LensService on every
NavigationEnd, attaching foundation / foundation_name / project /
project_name / lens custom-props to each pageview so the dashboard becomes
filterable and groupable by those dimensions. Previously opaque entries
like /meetings/<id> can now be sliced by their owning foundation/project.
Public /meetings/:numericId routes load project context asynchronously, so
the auto NavigationEnd pageview is deferred for those paths and
MeetingJoinComponent fires one enriched pageview once meeting + project
(and parent foundation when applicable) have resolved. A 2s timeout race
ensures the event still fires when the parent maps to the root project
and is returned as null by initializeParentProject.
No route, redirect, guard, or user-visible behavior changes.
Signed-off-by: Nirav Patel <npatel@linuxfoundation.org>
* fix(analytics): correct past-meeting + slow-parent Plausible attribution
Address two issues raised in PR review:
- Extend deferredPageviewPattern to also match past-meeting occurrence URLs
of the form /meetings/<id>-<13-digit-timestamp> (matches the shape that
isPastMeetingOccurrenceId validates). Previously these paths slipped past
the auto-pageview skip and produced a context-free NavigationEnd event in
addition to the deferred enriched event from MeetingJoinComponent —
double-counting every past-meeting visit.
- Branch buildMeetingPageviewProps on project.parent_uid rather than on
whether parent resolved. When parent_uid is set but the lookup is slow,
the 2s timer race used to fire with parent=null, which mis-attributed
the sub-project under foundation_* and dropped project_* entirely. The
new branch records the sub-project correctly under project_* and leaves
foundation_* empty when unresolved — honest gap vs. data corruption in
the dashboard dimensions this PR is introducing.
Signed-off-by: Nirav Patel <npatel@linuxfoundation.org>
* refactor(analytics): centralize Plausible pageview-context builder
Address review feedback from MRashad26:
- Extract PlausibleService.buildPageviewContext({...}) as the single owner
of the pageview custom-prop schema. Both buildContextProps (service) and
the deferred-pageview callsite in MeetingJoinComponent route through it,
so adding a new dimension never lands in just one of the two callsites.
- trackPage(context?: PlausiblePageviewContext) now auto-prepends
path/url/title via getSanitizedPath/getSanitizedUrl. Callers only supply
context — MeetingJoinComponent no longer touches window.location or
document.title directly, removing the privacy/sanitization-bypass risk
if a future public meeting URL ever carried query-string tokens.
- Drop redundant `return { ...context };` spread on buildContextProps —
the new typed return is PlausiblePageviewContext.
- Name the parent-fetch timeout (PARENT_FETCH_TIMEOUT_MS = 2000) so its
load-bearing role isn't buried as a bare literal.
- Strip multi-paragraph JSDocs and multi-line inline comments added in
this PR per CLAUDE.md ("default to writing no comments. Never write
multi-paragraph docstrings or multi-line comment blocks").
No behavior or data change: same pageview frequency, same custom-prop
values populated under the same conditions. Initial script.onload
pageview now also includes path/url/title in props (previously only via
`u`); strictly additive.
Signed-off-by: Nirav Patel <npatel@linuxfoundation.org>
---------
Signed-off-by: Nirav Patel <npatel@linuxfoundation.org>1 parent a3d54e9 commit c990ccf
3 files changed
Lines changed: 110 additions & 13 deletions
Lines changed: 43 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
| 119 | + | |
118 | 120 | | |
119 | 121 | | |
120 | 122 | | |
| |||
297 | 299 | | |
298 | 300 | | |
299 | 301 | | |
| 302 | + | |
300 | 303 | | |
301 | 304 | | |
302 | 305 | | |
| |||
1128 | 1131 | | |
1129 | 1132 | | |
1130 | 1133 | | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
1131 | 1174 | | |
1132 | 1175 | | |
1133 | 1176 | | |
| |||
Lines changed: 58 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| |||
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
22 | 30 | | |
23 | 31 | | |
24 | 32 | | |
| |||
47 | 55 | | |
48 | 56 | | |
49 | 57 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
| 58 | + | |
| 59 | + | |
55 | 60 | | |
56 | 61 | | |
57 | 62 | | |
58 | 63 | | |
59 | 64 | | |
60 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
61 | 73 | | |
62 | 74 | | |
63 | 75 | | |
64 | 76 | | |
65 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
66 | 95 | | |
67 | 96 | | |
68 | 97 | | |
| |||
117 | 146 | | |
118 | 147 | | |
119 | 148 | | |
120 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
121 | 153 | | |
122 | 154 | | |
123 | 155 | | |
| |||
149 | 181 | | |
150 | 182 | | |
151 | 183 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
157 | 189 | | |
158 | 190 | | |
159 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
160 | 205 | | |
161 | 206 | | |
162 | 207 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
16 | 25 | | |
17 | 26 | | |
18 | 27 | | |
| |||
0 commit comments