| 1 |
<div class="wrap"> |
| 2 |
<h2>BugSnag Settings</h2> |
| 3 |
|
| 4 |
<p> |
| 5 |
BugSnag automatically detects errors & crashes on your WordPress site, plugins & themes. |
| 6 |
</p> |
| 7 |
|
| 8 |
<p> |
| 9 |
Errors are sent to your <a href="https://app.bugsnag.com">BugSnag Dashboard</a> for you to view and debug, and we'll also notify you by email, chat, sms or create a ticket in your issue tracking system if you use one. We'll also show you exactly how many times each error occurred, and how many users were impacted by each crash. |
| 10 |
</p> |
| 11 |
|
| 12 |
<form method="post"> |
| 13 |
<?php if (empty($this->apiKey)) { ?> |
| 14 |
<!-- API Key Prompt --> |
| 15 |
<div style="max-width: 560px; border: 1px solid #e6db55; padding: 0 10px 12px; background: #fffbcc"> |
| 16 |
<h3>Please configure your BugSnag API Key to enable this plugin</h3> |
| 17 |
|
| 18 |
<p> |
| 19 |
Sign up for a <a href="https://app.bugsnag.com/user/new">BugSnag Account</a> and create a project with type <i>WordPress</i>,<br> |
| 20 |
you'll then be shown your API Key, which you should paste here: |
| 21 |
</p> |
| 22 |
|
| 23 |
<div style="margin-bottom: 10px;"> |
| 24 |
<input type="text" id="bugsnag_api_key" name="bugsnag_api_key" style="width: 80%; float: left;" placeholder="Bugsnag API Key" autofocus="autofocus" /> |
| 25 |
<input type="submit" class="button-primary" value="<?php _e('Save') ?>" style="width: 15%; float: right;" /> |
| 26 |
</div> |
| 27 |
|
| 28 |
<div style="clear: both"></div> |
| 29 |
</div> |
| 30 |
<?php } else { ?> |
| 31 |
<!-- Full Settings Form --> |
| 32 |
<table class="form-table"> |
| 33 |
<!-- API Key --> |
| 34 |
<tr valign="top"> |
| 35 |
<th scope="row"> |
| 36 |
<label for="bugsnag_api_key">BugSnag API Key</label> |
| 37 |
</th> |
| 38 |
<td> |
| 39 |
<input type="text" id="bugsnag_api_key" name="bugsnag_api_key" value="<?php echo $this->apiKey ?>" class="regular-text code" /><br> |
| 40 |
|
| 41 |
<p class="description"> |
| 42 |
You can find your API Key on your <a href="https://app.bugsnag.com">BugSnag Dashboard</a>. |
| 43 |
</p> |
| 44 |
</td> |
| 45 |
</tr> |
| 46 |
|
| 47 |
<tr valign="top"> |
| 48 |
<th> |
| 49 |
<label for="bugsnag_notify_severities">Notify BugSnag About</label> |
| 50 |
</th> |
| 51 |
<td> |
| 52 |
<select name="bugsnag_notify_severities" id="bugsnag_notify_severities"> |
| 53 |
<?php $this->renderOption('Crashes & errors', 'fatal,error', $this->notifySeverities); ?> |
| 54 |
<?php $this->renderOption('Crashes, errors & warnings', 'fatal,error,warning', $this->notifySeverities); ?> |
| 55 |
<?php $this->renderOption('Crashes, errors, warnings & info messages', 'fatal,error,warning,info', $this->notifySeverities); ?> |
| 56 |
</select> |
| 57 |
</td> |
| 58 |
</tr> |
| 59 |
|
| 60 |
<!-- Redacted Keys --> |
| 61 |
<tr valign="top"> |
| 62 |
<th> |
| 63 |
<label for="bugsnag_redacted_keys">BugSnag Redacted Keys</label> |
| 64 |
</th> |
| 65 |
<td> |
| 66 |
<textarea id="bugsnag_redacted_keys" name="bugsnag_redacted_keys" class="regular-text redacted_keys" style="height: 150px;"><?php echo $this->redactedKeys; ?></textarea> |
| 67 |
<p class="description"> |
| 68 |
The information to remove from BugSnag reports, one per line. |
| 69 |
Use this if you want to ensure you don't send sensitive data such as passwords, and credit card numbers to our servers. |
| 70 |
</p> |
| 71 |
</td> |
| 72 |
</tr> |
| 73 |
|
| 74 |
<!-- App Version --> |
| 75 |
<tr valign="top"> |
| 76 |
<th scope="row"> |
| 77 |
<label for="bugsnag_app_version">App Version</label> |
| 78 |
</th> |
| 79 |
<td> |
| 80 |
<input type="text" id="bugsnag_app_version" name="bugsnag_app_version" value="<?php echo $this->appVersion; ?>" class="regular-text" /> |
| 81 |
<p class="description"> |
| 82 |
Set the version of your application. This will be used to group errors by release. |
| 83 |
</p> |
| 84 |
</td> |
| 85 |
</tr> |
| 86 |
|
| 87 |
<!-- Notify Endpoint --> |
| 88 |
<tr valign="top"> |
| 89 |
<th scope="row"> |
| 90 |
<label for="bugsnag_notify_endpoint">Notify Endpoint</label> |
| 91 |
</th> |
| 92 |
<td> |
| 93 |
<input type="text" id="bugsnag_notify_endpoint" name="bugsnag_notify_endpoint" value="<?php echo $this->notifyEndpoint; ?>" class="regular-text code" placeholder="https://notify.bugsnag.com" /> |
| 94 |
<p class="description"> |
| 95 |
Custom endpoint URL for error notifications. Leave blank to use the default BugSnag endpoint. |
| 96 |
</p> |
| 97 |
</td> |
| 98 |
</tr> |
| 99 |
|
| 100 |
<!-- Release Stage --> |
| 101 |
<tr valign="top"> |
| 102 |
<th scope="row"> |
| 103 |
<label for="bugsnag_release_stage">Release Stage</label> |
| 104 |
</th> |
| 105 |
<td> |
| 106 |
<input type="text" id="bugsnag_release_stage" name="bugsnag_release_stage" value="<?php echo $this->releaseStageConfig; ?>" class="regular-text" placeholder="production" /> |
| 107 |
<p class="description"> |
| 108 |
The release stage (e.g., production, staging, development). Leave blank to auto-detect from WordPress environment. |
| 109 |
</p> |
| 110 |
</td> |
| 111 |
</tr> |
| 112 |
</table> |
| 113 |
|
| 114 |
<div class="submit"> |
| 115 |
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /> |
| 116 |
</div> |
| 117 |
<?php } ?> |
| 118 |
|
| 119 |
<!-- Common form stuff --> |
| 120 |
<?php wp_nonce_field('update-options'); ?> |
| 121 |
<input type="hidden" name="action" value="update" /> |
| 122 |
<input type="hidden" name="page_options" value="bugsnag_api_key,bugsnag_notify_severities,bugsnag_redacted_keys,bugsnag_app_version,bugsnag_notify_endpoint,bugsnag_release_stage" /> |
| 123 |
</form> |
| 124 |
</div> |
| 125 |
|
| 126 |
<?php if (!empty($this->apiKey)) { ?> |
| 127 |
<div> |
| 128 |
<h2>Test your connection to BugSnag</h2> |
| 129 |
|
| 130 |
<p>Use this button to send a test event that can be viewed in <a href="https://app.bugsnag.com">your BugSnag Dashboard</a>.</p> |
| 131 |
|
| 132 |
<p>Note - any <a href="https://docs.bugsnag.com/platforms/php/wordpress/configuration-options/">configuration options</a> applied in code will not be applied to this test event.</p> |
| 133 |
|
| 134 |
<button id="bugsnag-test" class="button-secondary"> |
| 135 |
<?php _e('Test BugSnag Connection') ?> |
| 136 |
</button> |
| 137 |
</div> |
| 138 |
<?php } ?> |
| 139 |
|
| 140 |
<script type="text/javascript"> |
| 141 |
jQuery(document).ready(function($) { |
| 142 |
$('#bugsnag-test').click(function(e) { |
| 143 |
e.stopPropagation(); |
| 144 |
e.preventDefault(); |
| 145 |
|
| 146 |
var data = { |
| 147 |
action: 'test_bugsnag', |
| 148 |
bugsnag_api_key: $('#bugsnag_api_key').val(), |
| 149 |
bugsnag_notify_severities: $('#bugsnag_notify_severities').val(), |
| 150 |
bugsnag_redacted_keys: $('#bugsnag_redacted_keys').val(), |
| 151 |
bugsnag_app_version: $('#bugsnag_app_version').val(), |
| 152 |
bugsnag_notify_endpoint: $('#bugsnag_notify_endpoint').val(), |
| 153 |
bugsnag_release_stage: $('#bugsnag_release_stage').val(), |
| 154 |
_wpnonce: '<?php echo wp_create_nonce('test_bugsnag_nonce'); ?>' |
| 155 |
}; |
| 156 |
|
| 157 |
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php |
| 158 |
$.post(ajaxurl, data, function(response) { |
| 159 |
alert('Sent notification. Visit https://app.bugsnag.com/ to see it in your dashboard'); |
| 160 |
}); |
| 161 |
}); |
| 162 |
}); |
| 163 |
</script> |