Get Plugin SystemSettings in Tracker hook newVisitorInformation throws error

When using SystemSetting in a custom Plugin, i can’t get the value in hook newVisitorInformation, the following error occurs:

“CoreAdminHome_PluginSettingChangeNotAllowed”

following code:


    public function getListHooksRegistered()
    {
        return array(
            'Tracker.newVisitorInformation' => 'logCustomData',
        );
    }


 public function logCustomData(array &$visitorInfo)
    {

        if (empty($visitorInfo['location_latitude']) || empty($visitorInfo['location_longitude'])) {
                return;
        }

        $settings = new Settings('Weather');
        $aid = $settings->aid->getValue();

        if (empty($aid)) {
                return;
        }

        $api_url = EXTERNAL_API_URL . '?aid=' $aid;

        $response = \Piwik\Http::sendHttpRequest($api_url, 6);
        $response = json_decode($response);

       $visitorInfo['custom_data'] = $response['custom_data']';

    }

Additonally i need to query an external api to get custom data, any better way for doing this?

Regards

Hi pebosi, thanks for feedback. It fails because the settings check for user permission. I think in Tracker they should not check for permission. I created (and fixed) the ticket: Allow Plugin Settings to be loaded within Tracker flow · Issue #4924 · matomo-org/matomo · GitHub
please check with latest git master. Hope it helps!