Skip to content

Conversation

@AltamashShaikh
Copy link
Contributor

@AltamashShaikh AltamashShaikh commented Aug 22, 2025

Description

Initial PR to send scheduled reports to a Slack channel, currently we support only Slack and Email

Issue No

#PG-4491

Steps to Replicate the Issue

  1. Clone this repository under plugins directory as git clone [email protected]:matomo-org/plugin-Slack.git Slack
  2. Activate the plugin ./console plugin:activate Slack
  3. Now checkout to this branch
  4. Try to create a new ScheduledReport, select "Slack" as "Send report via" option
  5. You would notice, that the Slack Channel ID is disabled, as we haven't added the OAuth token
  6. Add the OAuth token, token is added in keeper under plugins team - "Slack OAuth Bot Token - test"
  7. Configure it and try step 4 again
  8. You will see an option to Enter Slack Channel Id now
  9. Add the channelID for Slack
  10. Save the report and you can schedule the report from UI
image 11. Send the report and it should send a report to the specified Slack channel

Checklist

  • [✔] Tested locally or on demo2/demo3?
  • [✔] New test case added/updated?
  • [✔] Are all newly added texts included via translation?
  • [✔] Are text sanitized properly? (Eg use of v-text v/s v-html for vue)
  • [✔] Version bumped?

@AltamashShaikh AltamashShaikh added the Needs Review For pull requests that need a code review. label Aug 22, 2025
@AltamashShaikh AltamashShaikh requested a review from a team August 22, 2025 12:11
Copy link
Contributor

@snake14 snake14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks alright overall. There's a lot to review. I left a few comments.

My biggest concern is whether this is going to be an open-source or premium plugin since it's in the matomo-org organisation and has GPL license throughout.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very screenshot heavy. Could some of the test cases be DOM comparison instead? Maybe that would solve the issue of some of the test cases being tightly coupled (dependent on previous test cases)?

Copy link
Contributor

@james-hill-matomo james-hill-matomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this as new code, then later realised it's based off existing plugins.

This would have been great if it was presented as a few extra PRs - e.g. one to setup up the repo with phpcs, .github etc, and a separate PR for the actual code.

I do think this makes sense as a separate repo now I've seen it.

Great work!

@AltamashShaikh
Copy link
Contributor Author

Looks alright overall. There's a lot to review. I left a few comments.

My biggest concern is whether this is going to be an open-source or premium plugin since it's in the matomo-org organisation and has GPL license throughout.

@snake14 I confirmed it with Stan, it is going to be an open-source plugin.

@AltamashShaikh
Copy link
Contributor Author

@james-hill-matomo @snake14 Updated the PR description with steps to test this.

Copy link
Contributor

@james-hill-matomo james-hill-matomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking close, only required change is a "You" -> "Your". One of us (me or Jacob) also needs to do a good local test.

Copy link
Contributor

@james-hill-matomo james-hill-matomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ability to trigger an immediate sending of the report is a great feature.

I can't get it to work though. I created a new channel, and invited the bot into it.

Clicking the test button (before and after creating things in the slack) gives a successful response, but no message arrives in slack.

I added a comment in JIRA about how scheduled reports was originally aimed at a single person, which isn't really making sense as we're extending it in this direction.

@james-hill-matomo
Copy link
Contributor

@AltamashShaikh Please update the dashboard https://github.com/innocraft/plugin-build-dashboard

@AltamashShaikh
Copy link
Contributor Author

@james-hill-matomo @snake14 I noticed that we need to show display options when reportType is PDF, so updated the code for that, but that won't work unless matomo-org/matomo#23546 is merged.
image

@AltamashShaikh
Copy link
Contributor Author

Copy link
Contributor

@james-hill-matomo james-hill-matomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested OK in dev when I learned what a slack channel ID is.

Possibly out of scope, but the error message "Please specify a value for 'description'. " isn't very enlightening if you don't tick any of the Statistics Included boxes at the bottom of the page:

image

@james-hill-matomo
Copy link
Contributor

Has to wait for core PR

@AltamashShaikh
Copy link
Contributor Author

Has to wait for core PR

@james-hill-matomo If I don't specify any report and description is set, I get Please specify a value for 'reports' error

* Adds PHPStan to Slack plugin

* Changed the level to 8

* Bumped phpstan level up to 5

Can bump the level that high with (almost) no errors.

* Don't check github action with phpstan

* Test changes for multiple channels

* Reverted changes

* Adds the multiple channel logic back

* Fixes for pre-push hook to work locally

* Changes to work on all branches and reduced the phpstan level to 5 for both created and updated

* Force to 8 to ensure github action is working

* test for GH action

* More fixes around pre-push and reverted to level 5

* Changed level to 5 for update

* Get correct branch for comparison

* PHPStan work correctly with DDEV

* Fixed context of cd for non ddev phpstan

* Changes for pre-push to work for non-dev

---------

Co-authored-by: James Hill <[email protected]>
Comment on lines +41 to +43
fi
# Use ddev if setup (overridding local setup)
if command -v ddev >/dev/null 2>&1; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was causing issues for me since I have both php and ddev installed.

Suggested change
fi
# Use ddev if setup (overridding local setup)
if command -v ddev >/dev/null 2>&1; then
# Use ddev if setup (overridding local setup)
elif command -v ddev >/dev/null 2>&1; then

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@james-hill-matomo Looks good to me this suggestion, what about you ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AltamashShaikh @snake14 I'd rather ddev was the first choice, but even more than that I'm happy to merge this as is, as it'll probably never matter anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything works for me, having ddev first should also work

@AltamashShaikh
Copy link
Contributor Author

@james-hill-matomo @snake14 Are we good to merge this PR ? We won't be releasing the plugin this week hopefully next release cycle, when we have all the FAQs and helptext ready.

@james-hill-matomo
Copy link
Contributor

@james-hill-matomo @snake14 Are we good to merge this PR ? We won't be releasing the plugin this week hopefully next release cycle, when we have all the FAQs and helptext ready.

I'm OK to merge this.

I've got various UI complaints (no way for users to know what a Slack Channel ID is without looking up FAQs, no feedback if you put in an invalid slack channel ID, confusing error message if you don't choose any of the Statistics Included options - but this is to the standard of the UI in general so I won't insist on fixes.

@AltamashShaikh AltamashShaikh merged commit 13b71a2 into 5.x-dev Sep 1, 2025
8 checks passed
@AltamashShaikh AltamashShaikh deleted the PG-4491-schedule-report-slack branch September 1, 2025 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review For pull requests that need a code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants