Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins can send usage data #1150

Merged
merged 1 commit into from
May 27, 2015
Merged

Conversation

gturri
Copy link
Contributor

@gturri gturri commented May 15, 2015

They just need to register to the PLUGIN_USAGE_DATA event, and then to add
either a simple string, or an array of key / value. For example:

function register(Doku_Event_Handler $controller) {
  $controller->register_hook('PLUGIN_USAGE_DATA', 'AFTER', $this, 'usage_data');
}

function usage_data(&$event){
  $event->data['my_plugin_name'] = 'my usage data';

  //or: $event->data['my_plugin_name'] = array ('k1' => 'v1', 'k2' => 'v2');
}

return $data;
}

private function _add_plugin_usage_data(&$data){
Copy link
Collaborator

Choose a reason for hiding this comment

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

should be protected

@splitbrain
Copy link
Collaborator

I think the event name is not adhering to our naming scheme https://www.dokuwiki.org/devel:events_list#naming_structure. Though I am not 100% sure we have one for plugins. PLUGIN_POPULARITY_DATA_SETUP maybe?

They just need to register to the PLUGIN_USAGE_DATA event, and then to add
either a simple string, or an array of key / value. For example:

    function register(Doku_Event_Handler $controller) {
      $controller->register_hook('PLUGIN_USAGE_DATA', 'AFTER', $this, 'usage_data');
    }

    function usage_data(&$event){
      $event->data['my_plugin_name'] = 'my usage data';

      //or: $event->data['my_plugin_name'] = array ('k1' => 'v1', 'k2' => 'v2');
    }
@gturri
Copy link
Contributor Author

gturri commented May 27, 2015

Thanks for this feedback. Here is an update.

splitbrain added a commit that referenced this pull request May 27, 2015
@splitbrain splitbrain merged commit 35462ed into dokuwiki:master May 27, 2015
@scrutinizer-notifier
Copy link

The inspection completed: 1 updated code elements

@gturri
Copy link
Contributor Author

gturri commented May 27, 2015

Thanks!

I just documented this feature on https://www.dokuwiki.org/devel:plugin_programming_tips#sending_popularity_data

@gturri gturri deleted the autosubmit_plugin3 branch May 27, 2015 05:54
@Klap-in
Copy link
Collaborator

Klap-in commented May 27, 2015

Can you document the event also at https://www.dokuwiki.org/devel:event:PLUGIN_POPULARITY_DATA_SETUP
so that it is added to https://www.dokuwiki.org/devel:events_list as well.
Thanks!

@gturri
Copy link
Contributor Author

gturri commented May 27, 2015

Done

gturri added a commit to gturri/nspages that referenced this pull request May 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants