twill icon indicating copy to clipboard operation
twill copied to clipboard

* | Dashboard: add Fathom Analytics support

Open agnonym opened this issue 1 year ago • 5 comments

Description

Twill dashboard allows only Google Analytics as analytics solution.

This PR add Fathom Analytics support (https://usefathom.com)

To enable Fathom Analytics service, the following configuration is needed:

    'dashboard' => [
        'analytics' => [
            'enabled' => true,
            'service' => 'fathom',
            'fathom' => [
                'api_token' => '11222233333',
                'site_id' => 'FATHOMSITEID',
            ],
        ],
    ],

Procedure to get an API token: https://usefathom.com/api

agnonym avatar Jun 08 '23 15:06 agnonym

Hello @agnonym, I don't believe we should be adding code for Fathom to Twill, but I agree we should allow people to use whatever analytics they want. So instead of adding Fathom, we should just remove the Google code (or make it conditional to the existence of a Google Analytics config) and teach (in the docs) people how to add Google or Fathom to the Dashboard.

antonioribeiro avatar Nov 27 '23 13:11 antonioribeiro

Hi @antonioribeiro, I totally agree with you! If I may make a suggestion, maybe Twill should allow to plug widgets on the dashboard, widgets provided by extra packages (Google Analytics, Fathom Analytics, ...) or custom code in your project.

agnonym avatar Nov 27 '23 13:11 agnonym

Hey @agnonym, sorry for taking long to reply. You can create plugin-like (Composer installable) packages for Twill as Capsules already, here's an example. I'm not sure how deep we would have to go in order to plug something into the Dashboard, as I see it's also touching a .vue file, but it may be worth the try and if we need to change a .vue file in order to allow a Capsule to plug into it, I believe it could be approved.

antonioribeiro avatar Jan 29 '24 14:01 antonioribeiro

Hi @antonioribeiro, I haven't had the chance to work with Twill Capsules yet. However, upon reviewing the code, using Capsules could be a viable option for implementing a "Dashboard Widget" feature. One potential approach could involve introducing an additional attribute in the twill.capsules.list configuration, such as 'dashboard' => true. And maybe creating a dedicated class akin to Twill Block Component classes, implementing a method in the Capsule ServiceProvider, ...

Enhancing the Dashboard Controller seems relatively straightforward, invoking the declared Capsules and retrieve the data, potentially even rendering the view directly for simplicity. As for the Dashboard View, maintaining it as Blade code, with each section employing A17 Vue components, could be a practical solution. The decision to use pure Vue within the Blade could be left to the discretion of each Capsule. In an initial iteration, arranging the widgets in the right column below or above the drafts, ordered based on the declaration sequence of the Capsules, could be a simple yet effective layout. Of course, there's room to explore additional features, such as switching between the right and left columns, configuring the width percentage for each widget, and so on.

I'm unsure whether you or the Twill team are interested in delving deeper into this topic. If you value my opinion, I'm usually available on Discord for further discussion.

agnonym avatar Jan 29 '24 17:01 agnonym

@agnonym, speak for myself here, but I believe the idea from the beginning was to have a plugin system on Twill, when we created Capsules it became the natural way to try to make this happen, as Capsules were also decoupled from Twill. You can already do a lot with them, but if what we need to have even more "low level" plugins on Twill depends only on some minor changes to Twill, like adding new properties to the capsules list, I believe the Core team will probably not have a problem with introducing them, and I can surely help too

antonioribeiro avatar Jan 29 '24 17:01 antonioribeiro