Problem/Motivation

One feature that was requested would be to add a new setting to Piwik PRO module dashboard where existing pages could be added.
These pages would then appear in the dashboard in a separate block/segment and their stats would be always displayed (They would be pinned).

Issue fork piwik_pro-3575167

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

hartsak created an issue. See original summary.

immoreel made their first commit to this issue’s fork.

immoreel’s picture

This patch adds the "Pinned Pages" feature to the Piwik PRO Dashboard.

Important: This patch is based on the branch from issue #3560912 (Dashboard overhaul)
and should be applied on top of that branch, or merged after #3560912 is committed.

Features

- Pin pages from node edit form: A "Piwik PRO" section appears in the sidebar
of node edit pages with a "Pin to dashboard" checkbox
- Pinned Pages widget: Shows a table at the top of the dashboard with statistics
for all pinned pages (Page Views, Visitors, Bounce Rate)
- URL-based matching: Statistics are fetched from Piwik PRO by matching page URLs

Technical changes

- New service: `PinnedPagesManager` for CRUD operations on pinned node IDs
- New API endpoint: `/api/piwik-dashboard/pinned-pages`
- New method: `PiwikApiClient::fetchPinnedPages()` with URL filtering
- Config schema updated with `pinned_node_ids` sequence
- Form alter hook adds checkbox to node edit form
- Dashboard template and JS updated with pinned pages widget

Files changed

- `piwik_pro_dashboard.module` - Form alter hooks
- `piwik_pro_dashboard.services.yml` - PinnedPagesManager service
- `piwik_pro_dashboard.routing.yml` - New API route
- `config/schema/piwik_pro_dashboard.schema.yml` - pinned_node_ids field
- `src/Service/PinnedPagesManager.php` - New service (new file)
- `src/Service/PiwikApiClient.php` - fetchPinnedPages method
- `src/Controller/ApiController.php` - getPinnedPages endpoint
- `templates/piwik-dashboard.html.twig` - Pinned pages widget
- `js/dashboard.js` - Fetch and render pinned pages
- `css/dashboard.css` - Table styling

immoreel’s picture

The pin to dashboard option in the sidebar.
another screenshot

Table of pinned pages in the dashboard
screenshot

frazile’s picture

Status: Active » Needs work

Hey, we merged the overhaul ticket, but we additionally did some refactoring of the code base. Could you take a look at the merge request and check the conflicts?

immoreel’s picture

I've resolved the merge conflicts and rewrote fetchPinnedPages() to use sendQuery(), also getPinnedPages now uses parseRange() / handleApiRequest() helpers

immoreel’s picture

Status: Needs work » Needs review
hartsak’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.