Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Initialization settings:
| `vue` | Vue constructor | optional | Pass Vue constructor to set up the [Vue integration](#integrate-to-vue-application) |
| `disableGlobalErrorsHandling` | boolean | optional | Do not initialize global errors handling |
| `disableVueErrorHandler` | boolean | optional | Do not initialize Vue errors handling |
| `consoleTracking` | boolean | optional | Initialize console logs tracking |
| `beforeSend` | function(event) => event | optional | This Method allows you to filter any data you don't want sending to Hawk |

Other available [initial settings](types/hawk-initial-settings.d.ts) are described at the type definition.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hawk.so/javascript",
"type": "commonjs",
"version": "3.2.4",
"version": "3.2.5",
"description": "JavaScript errors tracking for Hawk.so",
"files": [
"dist"
Expand Down
18 changes: 14 additions & 4 deletions src/catcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ export default class Catcher {
*/
private readonly disableVueErrorHandler: boolean = false;

/**
* Console log handler
*/
private readonly consoleTracking: boolean;

/**
* Catcher constructor
*
Expand All @@ -111,6 +116,7 @@ export default class Catcher {
this.context = settings.context || undefined;
this.beforeSend = settings.beforeSend;
this.disableVueErrorHandler = settings.disableVueErrorHandler ?? false;
this.consoleTracking = settings.consoleTracking ?? true;

if (!this.token) {
log(
Expand All @@ -136,7 +142,9 @@ export default class Catcher {
},
});

initConsoleCatcher();
if (this.consoleTracking) {
initConsoleCatcher();
}

/**
* Set global handlers
Expand Down Expand Up @@ -237,7 +245,9 @@ export default class Catcher {
* Add error to console logs
*/

addErrorEvent(event);
if (this.consoleTracking) {
addErrorEvent(event);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
addErrorEvent(event);
this.cosnoleTracker.addErrorEvent(event);

}

/**
* Promise rejection reason is recommended to be an Error, but it can be a string:
Expand Down Expand Up @@ -503,7 +513,7 @@ export default class Catcher {
const userAgent = window.navigator.userAgent;
const location = window.location.href;
const getParams = this.getGetParams();
const consoleLogs = getConsoleLogStack();
const consoleLogs = this.consoleTracking && getConsoleLogStack();

const addons: JavaScriptAddons = {
window: {
Expand All @@ -522,7 +532,7 @@ export default class Catcher {
addons.RAW_EVENT_DATA = this.getRawData(error);
}

if (consoleLogs.length > 0) {
if (consoleLogs && consoleLogs.length > 0) {
addons.consoleOutput = consoleLogs;
}

Expand Down
5 changes: 5 additions & 0 deletions src/types/hawk-initial-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,9 @@ export interface HawkInitialSettings {
* Used by @hawk.so/nuxt since Nuxt has own error hook.
*/
disableVueErrorHandler?: boolean;

/**
* Console log handler
*/
consoleTracking?: boolean;
}