Remove ethicalads #20766
could definitely bikeshed what percentage visible counts as an impression... do we know what the threshold for ethicalads was? if so that will allow for some consistency if anyone compares to historic reporting.
i think that's what EA mentioned, "as soon as it was on the screen"
Getting ahead for a minute, but there are actions outside of code to be done from what I understand, I have sent @JacobCoffee a list of such items.
Update:
Goals (Sponsor Impression, Sponsor Click) and Custom properties ( sponsor and placement) is setup on Plausible
- both goals are custom events, unscoped
- existing displayed translation continues to stay.
ive exported the EA data, working through the other steps
@claude review
🔴 Infra and one-time sponsors with origin "remote" lose admin-set footer and sidebar flags every hour, and the sync never restores them. The reset at tasks.py:48-51 filters only on Sponsor.origin == "remote". _sync_sponsor returns None for infra_sponsor or one_time before re-applying flags. Fix: leave locally-managed sponsors out of the reset, e.g. add Sponsor.infra_sponsor == false(), Sponsor.one_time == false() to the filter. That matches the skip in _sync_sponsor. Reset-then-skip only matters for a sponsor first created by the API and later flagged infra or one-time in the admin.
<details>
<summary>Why this was flagged</summary>
This needs a sponsor first created by update_pypi_sponsors, which sets origin = "remote", and later marked one_time or infra_sponsor in the admin, where footer/sidebar are editable BooleanFields (warehouse/admin/views/sponsors.py:54,58). The hourly task runs the bulk update at warehouse/sponsors/tasks.py:48-51 and clears footer and sidebar on every remote row. Next, _sync_sponsor (tasks.py:83-85) returns None for that sponsor, with the comment "infra and one-time sponsors are managed locally", so neither loop sets the flags again. A one-time sponsor drops out of request.sponsors["footer"]. Any such sponsor with sidebar=True drops out of the new sidebar placement within an hour of the admin's edit. On the base branch these sponsors were skipped entirely, and flags set in the admin persisted. The PR description says manual sponsors keep their admin settings, but this filter treats locally-managed remote sponsors as API-managed.
Verification: In warehouse/sponsors/tasks.py, lines 48-50 clear the flags on every remote row with no exclusion. _sync_sponsor (lines 86-89) then returns None before writing anything for these rows. Both loops continue on None (lines 54-56, 60-62), so the cleared flags are never set again. This is a regression from the base.
</details>
<!-- bhfn:1:normal -->
🔴 Sponsors that are no longer, or never were, in python.org's sidebar flight can now show up in the PyPI sidebar rotation. The new list at warehouse/sponsors/__init__.py:38 takes every active row with sidebar set, but that flag never affected display before. The sync only clears it where origin == "remote", so rows from populate-db (origin "pythondotorg") and infra sponsors keep it. Fix: clear the old flag before the sidebar goes live, e.g. a data migration that sets sidebar=False on all rows (the next sync sets the flight members again). Also make populate_db seed sidebar: False. [also at: warehouse/sponsors/tasks.py:50 - Visitors may see former or infra sponsors in the new project and organization sidebar. Old rows can still carry sidebar=True, and the hourly sync never clears them.]
<details>
<summary>Why this was flagged</summary>
Before this change the sidebar column did not drive any rendering. warehouse sponsors populate-db (warehouse/cli/sponsors.py, run by Makefile:171) seeds 14 rows with "sidebar": True and "origin": "pythondotorg". They include Google (infra_sponsor: True) and former sponsors such as Slack, Corning, Latacora and Cockroach Labs. update_pypi_sponsors (tasks.py:48-51) resets sidebar only where Sponsor.origin == "remote". _sync_sponsor returns before setting origin for infra and one-time rows, and it never touches rows missing from the API. Nothing resets is_active either. So any such row that is still active keeps sidebar=True, lands in request.sponsors["sidebar"] (__init__.py:38), and is rendered by sidebar-sponsor-logo.html:6 on project and organization pages, where sponsor_controller.js picks one at random. In any dev DB built with make initdb, all 14 show up.
Verification: Triggers when the sponsors table holds active rows with sidebar=True and an origin other than "remote", such as rows seeded by populate-db or infra sponsors. warehouse/sponsors/__init__.py:38 filters only on is_active. The reset at tasks.py:47-49 clears only rows with origin "remote", and _sync_sponsor returns None for infra_sponsor or one_time.
</details>
<!-- bhfn:1:normal -->
6515fd6bd27080bd94b1b4a01ee1d17c81c513ce
one time migration to clear out "maybe" stale flags, the hourly job update_pypi_sponsors then sets them from python.org sponsor list.
Manual, infra and one-time sponsors don't get their flag back automatically, an admin has to enable it.
1108cda76923404e83999a96e6bc3d934b7c9d5d (test in 1a036dbd09e65775843b172a13f90a311d6ebbbd)
the reset now skips infra and one-time sponsors (same as _sync_sponsor), so a remote sponsor later marked as infra / one-time keeps the footer and sidebar flags set in the admin.
one (sad) side effect of the new migration is that people with seeded dev databases lose their sidebar flags after this migration. sponsors populate-db skips sponsors that already exist, so running it again does not restore them, workaround I have is to use UPDATE sponsors SET sidebar = true WHERE name IN (...). If anyone has a better idea to avoid this let me know.
This is not an issue for anyone setting up from scratch, as make initdb runs the seed after migrations.
@Alc-Alc can you please post some screenshots of what the different logos look like?
Also - wlll logos always have text under?
@Alc-Alc can you please post some screenshots of what the different logos look like?
Here are some logos that are in my seeded data.
<img width="280" alt="image" src="https://github.com/user-attachments/assets/cd1b73cb-84ae-41c7-b57b-afc00be47ba4" />
<img width="280" alt="image" src="https://github.com/user-attachments/assets/43a08927-9e19-4d7a-bfd5-c0f05be34f65" />
<img width="280" alt="image" src="https://github.com/user-attachments/assets/2532e1f4-a00d-4309-9aa3-f37cb8e37e3d" />
<img width="280" alt="image" src="https://github.com/user-attachments/assets/01173f25-9ff6-43b9-a534-205849382a84" />
<img width="280" alt="image" src="https://github.com/user-attachments/assets/4673b185-a3ff-43af-a78f-133b1e7d5cb0" />
Also - wlll logos always have text under?
Yes, they will show whatever description is returned by the API, which (I have not tested this part) depends on the "Describe as sponsor" setting in python.org admin page. If it's checked you get the "visionary sponsor" text (Nvidia / Bloomberg in above example). If not you will get custom text set by the sponsor (Google in above example).
<img width="790" height="458" alt="image" src="https://github.com/user-attachments/assets/b24134cf-8b9d-4d11-9428-d3b2fb4ba3d4" />
I am not sure if that can be empty in python.org itself, in which case there will be no text to display, @JacobCoffee can you please confirm this 🙂, I don't have admin page access, so had to guess this part with local setup.
PS: If you are wondering why some sponsors (Anthropic and HRT) in my examples have no text, that is because my seed data has no text for them. In production we have an hourly job that pulls in data from python.org, so that shouldn't happen there.
Does that answer your questions?
@Alc-Alc ya empty description can come through the API, seems this PR handles it tho
@nlhkabu can you re-review?
Ok, just in case, can we rewrite the CSS so we have equal margins with text and without?
Ok, just in case, can we rewrite the CSS so we have equal margins with text and without?
Done(?) in 071a619c43a6bfe4c7be012ae6bac8487d06a1c7
| Without text | With text |
|---|---|
| <img width="368" alt="image" src="https://github.com/user-attachments/assets/5db81211-09d9-4d47-aa1b-2761a51b232e" /> | <img width="368" alt="image" src="https://github.com/user-attachments/assets/799dbc10-e287-44c4-bacc-955726667ea0" />|
Approved these changes.
nlhkabu
Alc-Alc
Removes EthicalAds from PyPI and replaces the PSF sponsor sidebar placement it served with one rendered by Warehouse, tracked through the PSF's Plausible at analytics.python.org so sponsor reporting continues. Partially Closes #20761
includes.sidebar-sponsor-logoroute and view, hasn't been used in the in past year, 0 hits.rel="sponsored noopener"and with no eligible sponsors nothing is rendered.sponsor_controller.jsreveals one sponsor at random in the browser, so rotation still works under the 1-day CDN cache.props: {sponsor, placement: "pypi-sidebar"}:-
Sponsor Impression: once per page view, when the placement is 50% visible,interactive: false.-
Sponsor Click: on click; the link works without analytics.<img width="700" alt="image" src="https://github.com/user-attachments/assets/a6fa52d2-42af-4f9d-ac20-8666cd179294" />
"Professional Grade" Screencaps
| Desktop | Mobile |
|---|---|
| <img height="400" alt="image" src="https://github.com/user-attachments/assets/3faf6d3d-fd1f-4fb4-874a-77d6cc31a2ca" /> | <img height="400" alt="image" src="https://github.com/user-attachments/assets/0feb78b1-c7ce-4e1e-b944-dc16ceb9af88" /> |
Note the network tab.
| Before | After |
|---|---|
| <img height="200" alt="image" src="https://github.com/user-attachments/assets/e2a7dc6e-8683-413e-8e23-0b1612c162ae" /> | <img height="200" alt="image" src="https://github.com/user-attachments/assets/258b2208-85a9-427e-8289-aee57d88ff6f" /> |
CSP Check
- *.ethicalads.io from connect-src, img-src, script-src and style-src, ethicalads.blob.core.windows.net from img-src
Before
After