-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from codex-team/nuxt-support
feat: nuxt, captureError method, perevent multiple sending
- Loading branch information
Showing
13 changed files
with
127 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import log from './logger'; | ||
import log from '../utils/log'; | ||
|
||
/** | ||
* Sends AJAX request and wait for some time. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import log from './logger'; | ||
import log from '../utils/log'; | ||
import type { CatcherMessage } from '@/types'; | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
import type { CatcherMessage } from './catcher-message'; | ||
import type { HawkInitialSettings } from './hawk-initial-settings'; | ||
import type { HawkJavaScriptEvent } from './event'; | ||
import type { VueIntegrationData, NuxtIntegrationData, NuxtIntegrationAddons, JavaScriptCatcherIntegrations } from './integrations'; | ||
|
||
export type { | ||
CatcherMessage, | ||
HawkInitialSettings, | ||
HawkJavaScriptEvent | ||
HawkJavaScriptEvent, | ||
VueIntegrationData, | ||
NuxtIntegrationData, | ||
NuxtIntegrationAddons, | ||
JavaScriptCatcherIntegrations | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import log from './log'; | ||
|
||
/** | ||
* Symbol to mark error as processed by Hawk | ||
*/ | ||
const errorSentShadowProperty = Symbol('__hawk_processed__'); | ||
|
||
/** | ||
* Check if the error has alrady been sent to Hawk. | ||
* | ||
* Motivation: | ||
* Some integrations may catch errors on their own side and then normally re-throw them down. | ||
* In this case, Hawk will catch the error again. | ||
* We need to prevent this from happening. | ||
* | ||
* @param error - error object | ||
*/ | ||
export function isErrorProcessed(error: unknown): boolean { | ||
if (typeof error !== 'object' || error === null) { | ||
return false; | ||
} | ||
|
||
return error[errorSentShadowProperty] === true; | ||
} | ||
|
||
/** | ||
* Add non-enumerable property to the error object to mark it as processed. | ||
* | ||
* @param error - error object | ||
*/ | ||
export function markErrorAsProcessed(error: unknown): void { | ||
try { | ||
if (typeof error !== 'object' || error === null) { | ||
return; | ||
} | ||
|
||
Object.defineProperty(error, errorSentShadowProperty, { | ||
enumerable: false, // Prevent from beight collected by Hawk | ||
value: true, | ||
writable: true, | ||
configurable: true, | ||
}); | ||
} catch (e) { | ||
log('Failed to mark error as processed', 'error', e); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters