Skip to content

Commit

Permalink
feat: sentry error reporting
Browse files Browse the repository at this point in the history
Debugging TizenBrew can be hard (can't really use DevTools because of TizenBrew Service, can't debug service properly) and that is why I'm adding sentry error reporting, which could potentionally help me catch and fix errors.
  • Loading branch information
reisxd committed Aug 31, 2024
1 parent 2d7dc0d commit 5818013
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tizenbrew-app/TizenBrew/config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns:tizen="http://tizen.org/ns/widgets" xmlns="http://www.w3.org/ns/widgets" id="https://tizentube.vercel.app" version="1.3.4" viewmodes="maximized">
<widget xmlns:tizen="http://tizen.org/ns/widgets" xmlns="http://www.w3.org/ns/widgets" id="https://tizentube.vercel.app" version="1.3.5" viewmodes="maximized">
<access origin="*" subdomains="true"></access>
<tizen:app-control>
<tizen:src name="index.html" reload="disable"/>
Expand Down
7 changes: 7 additions & 0 deletions tizenbrew-app/TizenBrew/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

<html>
<head>
<script src="https://browser.sentry-cdn.com/6.0.0/bundle.min.js" crossorigin="anonymous"></script>
<script>
Sentry.init({
dsn: "https://[email protected]/gt/2",
tracesSampleRate: 0.01,
});
</script>
<title>TizenBrew</title>

<script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script>
Expand Down
168 changes: 168 additions & 0 deletions tizenbrew-app/TizenBrew/service/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tizenbrew-app/TizenBrew/service/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"dependencies": {
"@sentry/node": "^4.6.6",
"adbhost": "^0.0.2",
"express": "^4.19.2",
"node-fetch": "^2.7.0",
Expand Down
11 changes: 11 additions & 0 deletions tizenbrew-app/TizenBrew/service/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
// TizenBrew Standalone Service
// I wish I've seen running Node.JS on Tizen way before...

const Sentry = require('@sentry/node');

Sentry.init({ dsn: 'https://[email protected]:8001/1' });

Sentry.configureScope(scope => {
scope.setTag('platformVersion', tizen.systeminfo.getCapability("http://tizen.org/feature/platform.version"));
scope.setTag('nodeVersion', process.version);
});

global.Sentry = Sentry;

module.exports.onStart = function () {
console.log('Service started.');
const adbhost = require('adbhost');
Expand Down
3 changes: 2 additions & 1 deletion tizenbrew-app/TizenBrew/service/serviceLauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function startService(module, pkg) {
let sandbox = {};

Object.getOwnPropertyNames(global).forEach(prop => {
const disAllowed = ['services', 'module', 'global', 'inDebug', 'currentClient', 'currentModule'];
const disAllowed = ['services', 'module', 'global', 'inDebug', 'currentClient', 'currentModule', 'Sentry'];
// Node.js v4.4.3 does not have Array.prototype.includes...
if (disAllowed.indexOf(prop) >= 0) return;
sandbox[prop] = global[prop];
Expand All @@ -29,6 +29,7 @@ function startService(module, pkg) {
try {
vm.runInContext(script, global.services.get(pkg).context);
} catch (e) {
global.Sentry.captureException(e);
global.services.get(pkg).hasCrashed = true;
global.services.get(pkg).error = e;
}
Expand Down

0 comments on commit 5818013

Please sign in to comment.