Skip to content

Commit

Permalink
tested and ok
Browse files Browse the repository at this point in the history
  • Loading branch information
EsdrasCaleb committed Jul 12, 2024
1 parent 6d08986 commit 57b7b84
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 9 deletions.
36 changes: 33 additions & 3 deletions classes/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,41 @@ class helper {
* @param \core\event\base $event The event.
* @return void
*/
public static function init(\core\event\base $event) {
public static function init(\core\event\base $event=null) {
$config = get_config('tool_sentry');
if ($config->activate) {
unset($config->activate);
\Sentry\init((array)$config);
unset($config->dns);
unset($config->version);
if ($config->ignore_exceptions=="") {
unset($config->ignore_exceptions);
}
if ($config->ignore_transactions=="") {
unset($config->ignore_transactions);
}
if ($config->in_app_exclude=="") {
unset($config->in_app_exclude);
}
if ($config->in_app_include=="") {
unset($config->in_app_include);
}
$config->enable_tracing = boolval($config->enable_tracing);
$config->attach_stacktrace = boolval($config->attach_stacktrace);
$config->send_default_pii = boolval($config->send_default_pii);
$config = (array) $config;

foreach ($config as $name => $value) {
if(is_numeric($value)){
if(strpos($value,'.')) {
$config[$name] = floatval($value);
}
else{
$config[$name] = intval($value);
}
}
}

\Sentry\init($config);
}
}

Expand All @@ -57,7 +87,7 @@ public static function init(\core\event\base $event) {
* @param \core\event\base $event The event.
* @return void
*/
public static function geterros(\core\event\base $event) {
public static function geterros(\core\event\base $event=null) {
$config = get_config('tool_sentry');
if ($config->activate) {
\Sentry\captureLastError();
Expand Down
13 changes: 13 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

function xmldb_tool_sentry_upgrade($oldversion): bool {
global $CFG, $DB;

$dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.

if ($oldversion < 2024071200) {
$DB->delete_records("mdl_config_plugins",[ 'plugin'=>'tool_sentry','name'=>'dns']);
}

return true;
}
6 changes: 3 additions & 3 deletions lang/en/tool_sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
$string['sentry_options_desc'] = "This Change the way the options are sent to sentry";
$string['activate'] = "Activate Sentry Plugin";
$string['activate_desc'] = "Activate Sentry to send information to the configured dns";
$string['dns'] = "Sentry Server DNS";
$string['dns_desc'] = "Sentry server address with auth token";
$string['dsn'] = "Sentry Server DSN";
$string['dsn_desc'] = "Sentry server address with auth token";
$string['privacy:metadata'] = 'The plugin does not store any personal data. However, it send the IP of a user that had an error to the sentry server configured in it.';
$string['release'] = "Sentry Release";
$string['release_desc'] = "Sets the release. If not set, the SDK will try to automatically configure a release out of the box but it's a better idea to manually set it to guarantee that the release is in sync with your deploy integrations.";
Expand Down Expand Up @@ -69,6 +69,6 @@
$string['ignore_transactions'] = "Ignore Transactions";
$string['ignore_transactions_desc'] = "A list of strings that match transaction names that shouldn't be sent to Sentry.";
$string['in_app_include'] = "In App Include";
$string['ignore_transactions_desc'] = "A list of string prefixes of module names that belong to the app. This option takes precedence over in-app-exclude.";
$string['in_app_include_desc'] = "A list of string prefixes of module names that belong to the app. This option takes precedence over in-app-exclude.";
$string['in_app_exclude'] = "In App Exnclude";
$string['in_app_exclude_desc'] = "A list of string prefixes of module names that do not belong to the app, but rather to third-party packages. Modules considered not part of the app will be hidden from stack traces by default.";
5 changes: 3 additions & 2 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
get_string('options_desc', 'tool_sentry')));
$page->add(new admin_setting_configcheckbox('tool_sentry/activate',
get_string('activate', 'tool_sentry'), get_string('activate_desc', 'tool_sentry'), 1));
$page->add(new admin_setting_configtext('tool_sentry/dns', get_string('dns', 'tool_sentry'),
get_string('dns_desc', 'tool_sentry'), 'https://[email protected]/CLIENTCODE'));
$page->add(new admin_setting_configtext('tool_sentry/dsn', get_string('dsn', 'tool_sentry'),
get_string('dsn_desc', 'tool_sentry'), 'https://[email protected]/CLIENTCODE'));
$page->add(new admin_setting_heading('tool_sentry/sentry_options',
get_string('sentry_options', 'tool_sentry'), get_string('sentry_options_desc', 'tool_sentry')));
$page->add(new admin_setting_configtext('tool_sentry/release', get_string('release', 'tool_sentry'),
Expand Down Expand Up @@ -111,3 +111,4 @@

}
}
\tool_sentry\helper::geterros();
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
defined('MOODLE_INTERNAL') || die();

// Plugin version.
$plugin->version = 2024071010;
$plugin->version = 2024071210;

// Required Moodle version.
$plugin->requires = 2018051718; // Requires this Moodle version - at least 3.5 (new messsage system).
Expand Down

0 comments on commit 57b7b84

Please sign in to comment.