Changeset 3038994
- Timestamp:
- 02/21/2024 08:34:04 AM (2 years ago)
- Location:
- gleap/trunk
- Files:
-
- 4 edited
-
README.txt (modified) (1 diff)
-
admin/class-gleap-admin.php (modified) (1 diff)
-
gleap.php (modified) (1 diff)
-
public/class-gleap-public.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gleap/trunk/README.txt
r3008850 r3038994 38 38 39 39 == Changelog == 40 41 = 13.0.2 = 42 * Added action to track events 43 e.g. do_action('gleap_send_custom_event', $event_data); 40 44 41 45 = 13.0.1 = -
gleap/trunk/admin/class-gleap-admin.php
r3008603 r3038994 130 130 $gleap_fields = array( 131 131 Field::make('text', 'gleap_token', 'API key')->set_required(true)->set_help_text("Get your free API key within the <a href=\"https://app.gleap.io/\">Gleap Dashboard.</a>"), 132 Field::make('text', 'gleap_identity_token', 'Identity verification secret')->set_help_text("If you'd like to verify the identity of your users, copy the code from Project -> Settings -> Security to the field above."), 132 Field::make('text', 'gleap_identity_token', 'Identity verification secret')->set_attribute('type', 'password')->set_help_text("If you'd like to verify the identity of your users, copy the code from Project -> Settings -> Security to the field above."), 133 Field::make('text', 'gleap_secret_api_token', 'Secret API token')->set_attribute('type', 'password')->set_help_text("If you'd like to use the Gleap Rest API to send events, copy the code from Project -> Settings -> Security to the field above."), 133 134 Field::make('checkbox', 'gleap_selected_roles_only', 'Enable Gleap only for the selected WP roles') 134 135 ->set_default_value(false) -
gleap/trunk/gleap.php
r3008850 r3038994 17 17 * Plugin Name: Gleap 18 18 * Description: Gleap helps developers build the best software faster. It is your affordable in-app bug reporting tool for apps, websites and industrial applications. 19 * Version: 13.0. 119 * Version: 13.0.2 20 20 * Author: Gleap 21 21 * Author URI: https://www.gleap.io -
gleap/trunk/public/class-gleap-public.php
r3008850 r3038994 54 54 $this->plugin_name = $plugin_name; 55 55 $this->version = $version; 56 } 56 57 add_action('gleap_send_custom_event', array($this, 'send_custom_event')); 58 } 57 59 58 60 /** … … 106 108 } 107 109 110 /** 111 * Send a custom event to Gleap. 112 * 113 * @since 1.0.0 114 * @param array $event_data The data of the event to send. 115 */ 116 public function send_custom_event($event_data) { 117 $secret_api_token = carbon_get_theme_option('gleap_secret_api_token'); 118 119 // Check if the secret API token is set. 120 if (empty($secret_api_token)) { 121 // You can either throw an exception or handle the error appropriately. 122 // For example: 123 // throw new Exception('Gleap secret API token is not set.'); 124 // Or handle it another way, such as logging the error: 125 error_log('Gleap: Cannot send event because secret API token is not set.'); 126 return; 127 } 128 129 $response = wp_remote_post('https://api.gleap.io/admin/track', array( 130 'headers' => array( 131 'Content-Type' => 'application/json', 132 'Api-Token' => $secret_api_token, 133 ), 134 'body' => json_encode(array('events' => array($event_data))), 135 )); 136 137 // Error handling. 138 if (is_wp_error($response)) { 139 // Handle error - log it, notify admin, etc. 140 error_log('Error sending custom event to Gleap: ' . $response->get_error_message()); 141 } 142 } 143 144 108 145 /** 109 146 * Register the JavaScript for the public-facing side of the site. … … 122 159 123 160 $gleap_token = carbon_get_theme_option('gleap_token'); 124 if ($gleap_token) { 125 $gleap_selected_roles_only = carbon_get_theme_option('gleap_selected_roles_only'); 161 162 163 // Apply filter to allow modification of the gleap_token 164 $gleap_token = apply_filters('gleap_modify_token', $gleap_token); 165 166 if ($gleap_token) { 167 $gleap_selected_roles_only = carbon_get_theme_option('gleap_selected_roles_only'); 126 168 if ($gleap_selected_roles_only == true) { 127 169 $user_roles = wp_get_current_user()->roles; … … 137 179 if (is_user_logged_in()) { 138 180 $gleap_identity_token = carbon_get_theme_option('gleap_identity_token'); 181 182 // Apply filter to allow modification of the gleap_identity_token 183 $gleap_identity_token = apply_filters('gleap_modify_identity_token', $gleap_identity_token); 184 139 185 $user_data = get_userdata(get_current_user_id()); 140 186 $login = $user_data->user_login;
Note: See TracChangeset
for help on using the changeset viewer.