diff --git a/package-lock.json b/package-lock.json index d1fba0e..67781bd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "@babel/runtime": "^7.17.9", - "@hcaptcha/loader": "^1.2.1" + "@hcaptcha/loader": "^2.0.0" }, "devDependencies": { "@babel/cli": "^7.12.1", @@ -1897,9 +1897,9 @@ } }, "node_modules/@hcaptcha/loader": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@hcaptcha/loader/-/loader-1.2.1.tgz", - "integrity": "sha512-O16E7mAByRR+uuzwtA3ROaOT4Er/TasHRZBTLyhZ2ksMRsmaaXChGkdE/dws4meTJYjcItqZNyc3NpJv9/jgAw==" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@hcaptcha/loader/-/loader-2.0.0.tgz", + "integrity": "sha512-fFQH6ApU/zCCl6Y1bnbsxsp1Er/lKX+qlgljrpWDeFcenpEtoP68hExlKSXECospzKLeSWcr06cbTjlR/x3IJA==" }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", diff --git a/package.json b/package.json index 008498d..dda5ac2 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,6 @@ }, "dependencies": { "@babel/runtime": "^7.17.9", - "@hcaptcha/loader": "^1.2.1" + "@hcaptcha/loader": "^2.0.0" } } diff --git a/src/constants.js b/src/constants.js deleted file mode 100644 index 0812936..0000000 --- a/src/constants.js +++ /dev/null @@ -1,13 +0,0 @@ -export const scopeTag = { - key: 'source', - value: '@hCaptcha/react' -} - -export const breadcrumbMessages = { - mounted: 'hCaptcha component mounted', - expired: 'hCaptcha expired', - unmounted: 'hCaptcha component unmounted', - reset: 'hCaptcha reset', - removed: 'hCaptcha removed' - -} diff --git a/src/index.js b/src/index.js index 01eae4c..f454261 100644 --- a/src/index.js +++ b/src/index.js @@ -1,8 +1,7 @@ import * as React from 'react'; -import { hCaptchaLoader, initSentry } from '@hcaptcha/loader'; +import { hCaptchaLoader } from '@hcaptcha/loader'; import { getFrame, getMountElement } from './utils.js'; -import { breadcrumbMessages, scopeTag } from "./constants"; class HCaptcha extends React.Component { @@ -53,13 +52,6 @@ class HCaptcha extends React.Component { const isApiReady = typeof this._hcaptcha !== 'undefined'; - this.sentryHub = initSentry(this.props.sentry, scopeTag); - - this.sentryHub.addBreadcrumb({ - category: scopeTag.value, - message: breadcrumbMessages.mounted, - }); - /* * Check if hCaptcha has already been loaded, * If Yes, render the captcha @@ -92,11 +84,6 @@ class HCaptcha extends React.Component { // Reset any stored variables / timers when unmounting hcaptcha.reset(captchaId); hcaptcha.remove(captchaId); - - this.sentryHub.addBreadcrumb({ - category: scopeTag.value, - message: breadcrumbMessages.unmounted, - }); } shouldComponentUpdate(nextProps, nextState) { @@ -213,11 +200,6 @@ class HCaptcha extends React.Component { } // Reset captcha state, removes stored token and unticks checkbox hcaptcha.reset(captchaId) - - this.sentryHub.addBreadcrumb({ - category: scopeTag.value, - message: breadcrumbMessages.reset, - }); } removeCaptcha(callback) { @@ -234,17 +216,10 @@ class HCaptcha extends React.Component { hcaptcha.remove(captchaId); callback && callback() }); - - - this.sentryHub.addBreadcrumb({ - category: scopeTag.value, - message: breadcrumbMessages.removed, - }); } handleOnLoad () { this.setState({ isApiReady: true }, () => { - try { const element = getMountElement(this.props.scriptLocation); const frame = getFrame(element); @@ -258,9 +233,6 @@ class HCaptcha extends React.Component { const { onLoad } = this.props; if (onLoad) onLoad(); }); - } catch (error) { - this.sentryHub.captureException(error); - } }); } @@ -289,11 +261,6 @@ class HCaptcha extends React.Component { hcaptcha.reset(captchaId) // If hCaptcha runs into error, reset captcha - hCaptcha if (onExpire) onExpire(); - - this.sentryHub.addBreadcrumb({ - category: scopeTag.value, - message: breadcrumbMessages.expired, - }); } handleError (event) { @@ -346,14 +313,14 @@ class HCaptcha extends React.Component { try { const hcaptcha = this._hcaptcha; const captchaId = this.captchaId; - + if (!this.isReady()) { const onReady = new Promise((resolve, reject) => { - + this._onReady = (id) => { try { const hcaptcha = this._hcaptcha; - + if (opts && opts.async) { hcaptcha.execute(id, opts).then(resolve).catch(reject); } else { @@ -364,13 +331,12 @@ class HCaptcha extends React.Component { } }; }); - + return opts?.async ? onReady : null; } - + return hcaptcha.execute(captchaId, opts); } catch (error) { - this.sentryHub.captureException(error); if (opts && opts.async) { return Promise.reject(error); }