Commit 56a3ec2
authored
🐛 Fixed attribution on links in email-only posts (#26899)
refs
https://linear.app/ghost/issue/ONC-1569/post-attribution-for-links-in-emails-seems-to-be-broken-on-pro
closes
https://linear.app/ghost/issue/ONC-1568/email-only-post-attribution-incorrectly-resolves-to-url-type-instead
## Problem
Attribution for links in email-only posts does not correctly resolve to
the post itself. For example, if a free member clicks a link in an
email-only post they received, then upgrade to a paid membership within
the same browser session, the newly created subscription should be
attributed to the email only post. Currently though, the subscription
would be attributed as a `url` and, depending on the link, the URL might
be the `/email/:uuid` route of the post, or the Homepage.
## Root cause
In
`/ghost/core/core/server/services/member-attribution/url-translator.js`,
Ghost had previously been filtering out email only posts, because the
Post.findOne() query implicitly filters to only `published` posts, while
an email-only post will have a status of `sent`.
## Fix
Updated the query in the url-translator to filter for
`status:[published,sent]` and `type:[post,page]`. With this change, the
attribution correctly resolves to the `post` itself, rather than the
generic `url`.
There is also a change to the attribution builder to support this: since
email only post's don't have a URL registered in the URL service, the
`attribution_url` was being set to `null`. This adds a conditional to
check if the post is email only, and if so, it sets the
`attribution_url` to `/email/:uuid` for the post.
Finally, it also updated the link on the members page to the post to
point to the Post Analytics, rather than the post on the frontend. This
change is made for regular `published` posts in addition to the `sent`
posts for consistency.
### Files changed
- **`url-translator.js`** — Added fallback `findOne` query with
`status:sent` for email-only posts; added `/email/:uuid/` URL for sent
posts
- **`attribution-builder.js`** — Use `/email/:uuid/` URL when resolving
attribution for email-only posts at read time1 parent 0c65075 commit 56a3ec2
File tree
5 files changed
+93
-4
lines changed- ghost
- admin/app/components/member
- core
- core/server/services/member-attribution
- test
- e2e-server/services
- unit/server/services/member-attribution
5 files changed
+93
-4
lines changedLines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
19 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
20 | 26 | | |
21 | 27 | | |
22 | 28 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
Lines changed: 15 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
131 | 144 | | |
132 | 145 | | |
133 | 146 | | |
134 | 147 | | |
135 | | - | |
| 148 | + | |
136 | 149 | | |
137 | 150 | | |
138 | 151 | | |
| |||
Lines changed: 67 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 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 | + | |
188 | 255 | | |
189 | 256 | | |
190 | 257 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
| |||
0 commit comments