You are here

public static function ShareaholicUtilities::log_event in Share Buttons, Related Posts, Content Analytics - Shareaholic 7.3

Same name and namespace in other branches
  1. 8 utilities.php \ShareaholicUtilities::log_event()

This is a wrapper for the Event API

Parameters

string $event_name the name of the event:

array $extra_params any extra data points to be included:

10 calls to ShareaholicUtilities::log_event()
ShareaholicAdmin::update_check in ./admin.php
Sends an event when the user has updated the Drupal module
ShareaholicHttp::send_with_wp in lib/social-share-counts/wordpress_http.php
ShareaholicUtilities::accept_terms_of_service in ./utilities.php
Accepts the terms of service by setting the variable to true
ShareaholicUtilities::get_or_create_api_key in ./utilities.php
Returns the api key or creates a new one.
ShareaholicUtilities::has_bad_response in ./utilities.php
Checks bad response and logs errors if any

... See full list

File

./utilities.php, line 707

Class

ShareaholicUtilities

Code

public static function log_event($event_name = 'Default', $extra_params = false) {
  $event_metadata = array(
    'plugin_version' => self::get_version(),
    'api_key' => self::get_option('api_key'),
    'domain' => $GLOBALS['base_url'],
    'language' => $GLOBALS['language']->language,
    'stats' => self::get_stats(),
    'diagnostics' => array(
      'php_version' => phpversion(),
      'drupal_version' => self::get_drupal_version(),
      'theme' => variable_get('theme_default', $GLOBALS['theme']),
      'active_plugins' => module_list(),
    ),
    'features' => array(
      'share_buttons' => self::get_option('share_buttons'),
      'recommendations' => self::get_option('recommendations'),
    ),
  );
  if ($extra_params) {
    $event_metadata = array_merge($event_metadata, $extra_params);
  }
  $event_api_url = self::API_URL . '/api/events';
  $event_params = array(
    'name' => "Drupal:" . $event_name,
    'data' => json_encode($event_metadata),
  );
  $options = array(
    'method' => 'POST',
    'headers' => array(
      'Content-Type' => 'application/json',
    ),
    'body' => $event_params,
  );
  ShareaholicHttp::send($event_api_url, $options, true);
}