Skip to content

Commit d340453

Browse files
committed
sanitizer moved from addons
1 parent 4fd8372 commit d340453

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

example/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,10 @@ <h2>Test Vue integration: &lt;test-component&gt;</h2>
223223
})
224224
</script>
225225
</section>
226-
<script src="assets/hawk.js"></script>
227226
<script src="sample-errors.js"></script>
228-
<script>
227+
<script type="module">
228+
import HawkCatcher from '../src';
229+
229230
window.hawk = new HawkCatcher({
230231
token: 'eyJpbnRlZ3JhdGlvbklkIjoiNWU5OTE1MzItZTdiYy00ZjA0LTliY2UtYmIzZmE5ZTUwMTg3Iiwic2VjcmV0IjoiMTBlMTA4MjQtZTcyNC00YWFkLTkwMDQtMzExYTU1OWMzZTIxIn0=',
231232
// collectorEndpoint: 'ws://localhost:3000/ws',

src/catcher.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,9 @@ export default class Catcher {
261261
const isAlreadySentError = isErrorProcessed(error);
262262

263263
if (isAlreadySentError) {
264-
log('Error already sent', 'warn');
265-
264+
/**
265+
* @todo add debug build and log this case
266+
*/
266267
return;
267268
} else {
268269
markErrorAsProcessed(error);
@@ -274,7 +275,7 @@ export default class Catcher {
274275
* If this event caught by integration (Vue or other), it can pass extra addons
275276
*/
276277
if (integrationAddons) {
277-
this.appendIntegrationAddons(errorFormatted, integrationAddons);
278+
this.appendIntegrationAddons(errorFormatted, Sanitizer.sanitize(integrationAddons));
278279
}
279280

280281
this.sendErrorFormatted(errorFormatted);
@@ -286,7 +287,7 @@ export default class Catcher {
286287
return;
287288
}
288289

289-
log('Internal error ლ(´ڡ`ლ)', 'error', e);
290+
log('Unable to send error. Seems like it is Hawk internal bug. Please, report it here: https://github.com/codex-team/hawk.javascript/issues/new', 'warn', e);
290291
}
291292
}
292293

src/integrations/vue.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import Sanitizer from './../modules/sanitizer';
2-
import type { VueIntegrationAddons } from '@hawk.so/types';
1+
import type { JsonNode, VueIntegrationAddons } from '@hawk.so/types';
32

43
interface VueIntegrationOptions {
54
/**
@@ -102,7 +101,7 @@ export class VueIntegration {
102101
* Fill props
103102
*/
104103
if (vm.$options && vm.$options.propsData) {
105-
addons.props = Sanitizer.sanitize(vm.$options.propsData);
104+
addons.props = vm.$options.propsData;
106105
}
107106

108107
/**
@@ -112,7 +111,7 @@ export class VueIntegration {
112111
addons.data = {};
113112

114113
Object.entries(vm._data).forEach(([key, value]) => {
115-
addons.data![key] = Sanitizer.sanitize(value);
114+
addons.data![key] = value as JsonNode;
116115
});
117116
}
118117

@@ -124,7 +123,7 @@ export class VueIntegration {
124123

125124
Object.entries(vm._computedWatchers).forEach(([key, watcher]) => {
126125
// eslint-disable-next-line @typescript-eslint/no-explicit-any
127-
addons.computed![key] = Sanitizer.sanitize((watcher as {[key: string]: any}).value);
126+
addons.computed![key] = (watcher as {[key: string]: any}).value;
128127
});
129128
}
130129

src/utils/log.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,15 @@ export default function log(msg: string, type = 'log', args?: any, style = 'colo
2424
return;
2525
}
2626

27-
const editorLabelText = `Hawk JavaScript.js ${VERSION}`;
27+
const editorLabelText = `Hawk (${VERSION})`;
2828
const editorLabelStyle = `line-height: 1em;
29-
color: #006FEA;
29+
color: #fff;
3030
display: inline-block;
31-
font-size: 11px;
3231
line-height: 1em;
33-
background-color: #fff;
34-
padding: 4px 9px;
35-
border-radius: 30px;
36-
border: 1px solid rgba(56, 138, 229, 0.16);
37-
margin: 4px 5px 4px 0;`;
32+
background-color: rgba(0,0,0,.7);
33+
padding: 3px 5px;
34+
border-radius: 3px;
35+
margin-right: 2px`;
3836

3937
try {
4038
if (['time', 'timeEnd'].includes(type)) {

0 commit comments

Comments
 (0)