-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
219 additions
and
27 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
This file was deleted.
Oops, something went wrong.
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,188 @@ | ||
diff --git a/packages/shared/lib/helpers/sentry.ts b/packages/shared/lib/helpers/sentry.ts | ||
index 69e21214b..6d6a3fb2a 100644 | ||
--- a/packages/shared/lib/helpers/sentry.ts | ||
+++ b/packages/shared/lib/helpers/sentry.ts | ||
@@ -1,14 +1,9 @@ | ||
import { | ||
captureException, | ||
- configureScope, | ||
- init, | ||
- makeFetchTransport, | ||
captureMessage as sentryCaptureMessage, | ||
} from '@sentry/browser'; | ||
-import { BrowserTransportOptions } from '@sentry/browser/types/transports/types'; | ||
|
||
import { VPN_HOSTNAME } from '../constants'; | ||
-import { ApiError } from '../fetch/ApiError'; | ||
import { getUIDHeaders } from '../fetch/headers'; | ||
import { ProtonConfig } from '../interfaces'; | ||
|
||
@@ -61,21 +56,6 @@ export const getContentTypeHeaders = (input: RequestInfo | URL): HeadersInit => | ||
return {}; | ||
}; | ||
|
||
-const sentryFetch = (input: RequestInfo | URL, init?: RequestInit) => { | ||
- return globalThis.fetch(input, { | ||
- ...init, | ||
- headers: { | ||
- ...init?.headers, | ||
- ...getContentTypeHeaders(input), | ||
- ...context.authHeaders, | ||
- }, | ||
- }); | ||
-}; | ||
- | ||
-const makeProtonFetchTransport = (options: BrowserTransportOptions) => { | ||
- return makeFetchTransport(options, sentryFetch); | ||
-}; | ||
- | ||
const isLocalhost = (host: string) => host.startsWith('localhost'); | ||
const isProduction = (host: string) => host.endsWith('.proton.me') || host === VPN_HOSTNAME; | ||
|
||
@@ -94,143 +74,10 @@ function main({ | ||
sessionTracking = false, | ||
sentryConfig = getDefaultSentryConfig(config), | ||
ignore = ({ host }) => isLocalhost(host), | ||
-}: SentryOptions) { | ||
- const { SENTRY_DSN, APP_VERSION } = config; | ||
- const { host, release, environment } = sentryConfig; | ||
- | ||
- // No need to configure it if we don't load the DSN | ||
- if (!SENTRY_DSN || ignore(sentryConfig)) { | ||
- return; | ||
- } | ||
+}: SentryOptions) {} | ||
|
||
- setUID(uid); | ||
- | ||
- // Assumes SENTRY_DSN is: https://111b3eeaaec34cae8e812df705690a36@sentry/11 | ||
- // To get https://[email protected]/api/core/v4/reports/sentry/11 | ||
- const dsn = SENTRY_DSN.replace('sentry', `${host}/api/core/v4/reports/sentry`); | ||
- | ||
- init({ | ||
- dsn, | ||
- release, | ||
- environment, | ||
- normalizeDepth: 5, | ||
- transport: makeProtonFetchTransport, | ||
- autoSessionTracking: sessionTracking, | ||
- // Disable client reports. Client reports are used by sentry to retry events that failed to send on visibility change. | ||
- // Unfortunately Sentry does not use the custom transport for those, and thus fails to add the headers the API requires. | ||
- sendClientReports: false, | ||
- beforeSend(event, hint) { | ||
- const error = hint?.originalException; | ||
- const stack = typeof error === 'string' ? error : error?.stack; | ||
- // Filter out broken ferdi errors | ||
- if (stack && stack.match(/ferdi|franz/i)) { | ||
- return null; | ||
- } | ||
- | ||
- // Not interested in uncaught API errors | ||
- if (error instanceof ApiError) { | ||
- return null; | ||
- } | ||
- | ||
- if (!context.enabled) { | ||
- return null; | ||
- } | ||
- | ||
- // Remove the hash from the request URL and navigation breadcrumbs to avoid | ||
- // leaking the search parameters of encrypted searches | ||
- if (event.request && event.request.url) { | ||
- [event.request.url] = event.request.url.split('#'); | ||
- } | ||
- if (event.breadcrumbs) { | ||
- event.breadcrumbs = event.breadcrumbs.map((breadcrumb) => { | ||
- if (breadcrumb.category === 'navigation' && breadcrumb.data) { | ||
- [breadcrumb.data.from] = breadcrumb.data.from.split('#'); | ||
- [breadcrumb.data.to] = breadcrumb.data.to.split('#'); | ||
- } | ||
- return breadcrumb; | ||
- }); | ||
- } | ||
- | ||
- return event; | ||
- }, | ||
- // Some ignoreErrors and denyUrls are taken from this gist: https://gist.github.com/Chocksy/e9b2cdd4afc2aadc7989762c4b8b495a | ||
- // This gist is suggested in the Sentry documentation: https://docs.sentry.io/clients/javascript/tips/#decluttering-sentry | ||
- ignoreErrors: [ | ||
- // Ignore random plugins/extensions | ||
- 'top.GLOBALS', | ||
- 'canvas.contentDocument', | ||
- 'MyApp_RemoveAllHighlights', | ||
- 'atomicFindClose', | ||
- // See http://toolbar.conduit.com/Developer/HtmlAndGadget/Methods/JSInjection.aspx | ||
- 'conduitPage', | ||
- // https://bugzilla.mozilla.org/show_bug.cgi?id=1678243 | ||
- 'XDR encoding failure', | ||
- 'Request timed out', | ||
- 'No network connection', | ||
- 'Failed to fetch', | ||
- 'NetworkError when attempting to fetch resource.', | ||
- 'webkitExitFullScreen', // Bug in Firefox for iOS. | ||
- 'InactiveSession', | ||
- 'UnhandledRejection', // Happens too often in extensions and we have lints for that, so should be safe to ignore. | ||
- /chrome-extension/, | ||
- /moz-extension/, | ||
- 'TransferCancel', // User action to interrupt upload or download in Drive. | ||
- 'UploadConflictError', // User uploading the same file again in Drive. | ||
- 'UploadUserError', // Upload error on user's side in Drive. | ||
- 'ValidationError', // Validation error on user's side in Drive. | ||
- 'ChunkLoadError', // WebPack loading source code. | ||
- /ResizeObserver loop/, // Chromium bug https://stackoverflow.com/questions/49384120/resizeobserver-loop-limit-exceeded | ||
- // See: http://blog.errorception.com/2012/03/tale-of-unfindable-js-error.html | ||
- 'originalCreateNotification', | ||
- 'http://tt.epicplay.com', | ||
- "Can't find variable: ZiteReader", | ||
- 'jigsaw is not defined', | ||
- 'ComboSearch is not defined', | ||
- 'http://loading.retry.widdit.com/', | ||
- // Facebook borked | ||
- 'fb_xd_fragment', | ||
- // ISP "optimizing" proxy - `Cache-Control: no-transform` seems to reduce this. (thanks @acdha) | ||
- // See http://stackoverflow.com/questions/4113268/how-to-stop-javascript-injection-from-vodafone-proxy | ||
- 'bmi_SafeAddOnload', | ||
- 'EBCallBackMessageReceived', | ||
- // Avast extension error | ||
- '_avast_submit', | ||
- ], | ||
- denyUrls: [ | ||
- // Google Adsense | ||
- /pagead\/js/i, | ||
- // Facebook flakiness | ||
- /graph\.facebook\.com/i, | ||
- // Facebook blocked | ||
- /connect\.facebook\.net\/en_US\/all\.js/i, | ||
- // Woopra flakiness | ||
- /eatdifferent\.com\.woopra-ns\.com/i, | ||
- /static\.woopra\.com\/js\/woopra\.js/i, | ||
- // Chrome extensions | ||
- /extensions\//i, | ||
- /^chrome:\/\//i, | ||
- // Other plugins | ||
- /127\.0\.0\.1:4001\/isrunning/i, // Cacaoweb | ||
- /webappstoolbarba\.texthelp\.com\//i, | ||
- /metrics\.itunes\.apple\.com\.edgesuite\.net\//i, | ||
- ], | ||
- }); | ||
- | ||
- configureScope((scope) => { | ||
- scope.setTag('appVersion', APP_VERSION); | ||
- }); | ||
-} | ||
- | ||
-export const traceError = (...args: Parameters<typeof captureException>) => { | ||
- if (!isLocalhost(window.location.host)) { | ||
- captureException(...args); | ||
- } | ||
-}; | ||
+export const traceError = (...args: Parameters<typeof captureException>) => console.error(...args); | ||
|
||
-export const captureMessage = (...args: Parameters<typeof sentryCaptureMessage>) => { | ||
- if (!isLocalhost(window.location.host)) { | ||
- sentryCaptureMessage(...args); | ||
- } | ||
-}; | ||
+export const captureMessage = (...args: Parameters<typeof sentryCaptureMessage>) => console.log(...args); | ||
|
||
export default main; |
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 |
---|---|---|
|
@@ -76,7 +76,7 @@ export const PROVIDER_REPO_MAP = { | |
basePath: "account/vpn", | ||
apiSubdomain: "account-api", | ||
repoRelativeDistDir: "./dist", | ||
tag: "[email protected].15.1", | ||
tag: "[email protected].16.0", | ||
protonPack: {}, | ||
}, | ||
} as const; | ||
|