Skip to content

Commit

Permalink
Add sentry JS dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
M0rgan01 committed Jun 14, 2024
1 parent dc60c45 commit 6983b0b
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 5 deletions.
3 changes: 3 additions & 0 deletions js/sentry-8.2.1.min.js

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions js/sentry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/

Sentry.init({
dsn: "https://[email protected]/4507254110552064",
});

document.getElementById("submitErrorReport").addEventListener("click", function () {
const errorsElements = document.getElementById("infoError");
if (errorsElements) {
const childNodes = errorsElements.childNodes;
let messages = '';
childNodes.forEach((node, index) => {
if (node.nodeType === Node.TEXT_NODE && index > 0) {
messages += node.textContent.trim() + '\n';
}
});

const eventId = Sentry.captureMessage(messages, "error");
const userEmail = document.getElementById("userEmail");
const errorDescription = document.getElementById("errorDescription");

Sentry.captureUserFeedback({
event_id: eventId,
email: userEmail.value,
comments: errorDescription.value,
});

userEmail.value = "";
errorDescription.value = "";

$('#errorModal').modal('hide')
}
});
36 changes: 36 additions & 0 deletions views/templates/block/activityLog.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,42 @@
<div id="errorDuringUpgrade" class="col-xs-12" style="display:none;">
<h4>{{ 'Errors'|trans({}, 'Modules.Autoupgrade.Admin') }}</h4>
<div id="infoError" class="processing"></div>
<button id="reportErrorButton" class="btn btn-warning" style="margin-top: 10px;" data-toggle="modal" data-target="#errorModal">
{{ 'Report a bug'|trans({}, 'Modules.Autoupgrade.Admin') }}
</button>
</div>

<div id="errorModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h3 class="modal-title">
{{ 'Give feedbacks'|trans({}, 'Modules.Autoupgrade.Admin') }}
</h3>
</div>
<div class="modal-body">
<label for="userEmail">
{{ 'Email'|trans({}, 'Modules.Autoupgrade.Admin') }}
</label>
<input id="userEmail" type="text" class="form-control" placeholder="{{ 'Email'|trans({}, 'Modules.Autoupgrade.Admin') }}" style="display: block; margin-bottom: 10px;">
<label for="errorDescription">
{{ 'Description'|trans({}, 'Modules.Autoupgrade.Admin') }}
</label>
<textarea id="errorDescription" rows="3" placeholder="{{ 'Give us details about the error'|trans({}, 'Modules.Autoupgrade.Admin') }}"></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" style="text-transform: uppercase;">
{{ 'Cancel'|trans({}, 'Modules.Autoupgrade.Admin') }}
</button>
<button id="submitErrorReport" type="button" class="btn btn-primary">
{{ 'Send a bug report'|trans({}, 'Modules.Autoupgrade.Admin') }}
</button>
</div>
</div>
</div>
</div>
</div>
</div>
Expand Down
12 changes: 7 additions & 5 deletions views/templates/main.twig
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@

<script>
var jQueryVersionPS = parseInt($().jquery.replace(/\./g, ""));
var jQueryVersionPS = parseInt($().jquery.replace(/\./g, ""));
</script>
<script src="{{ psBaseUri }}modules/autoupgrade/js/jquery-1.6.2.min.js"></script>
<script src="{{ psBaseUri }}modules/autoupgrade/js/sentry-8.2.1.min.js"></script>
<script>
if (jQueryVersionPS >= 162) {
jq162 = jQuery.noConflict(true);
}
if (jQueryVersionPS >= 162) {
jq162 = jQuery.noConflict(true);
}
</script>
<link type="text/css" rel="stylesheet" href="{{ psBaseUri }}modules/autoupgrade/css/styles.css" />
<div class="bootstrap" id="informationBlock">
Expand Down Expand Up @@ -40,6 +41,7 @@

<script src="{{ psBaseUri }}modules/autoupgrade/js/jquery.xml2json.js"></script>
<script>
var input = {{ jsParams|json_encode|raw }};
var input = {{ jsParams|json_encode|raw }};
</script>
<script src="{{ psBaseUri }}modules/autoupgrade/js/upgrade.js"></script>
<script src="{{ psBaseUri }}modules/autoupgrade/js/sentry.js"></script>

0 comments on commit 6983b0b

Please sign in to comment.