Skip to content

Commit

Permalink
- Completely remove Sentry from Firefox extension bundle
Browse files Browse the repository at this point in the history
- Update highlights.js
  • Loading branch information
Rustem Mussabekov committed Jun 28, 2024
1 parent 3d6b18b commit f7efeb2
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 61 deletions.
4 changes: 2 additions & 2 deletions build/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ module.exports = ({ production, filename='[name].[contenthash]', sentry={} }, {

new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(production?'production':'development'),
'process.env.SENTRY_RELEASE': JSON.stringify(process.env.SENTRY_RELEASE),
RAINDROP_ENVIRONMENT: JSON.stringify('browser')
RAINDROP_ENVIRONMENT: JSON.stringify('browser'),
'process.env.SENTRY_RELEASE': JSON.stringify(production && !sentry?.disabled? process.env.SENTRY_RELEASE : undefined)
}),

//HTML
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "app",
"version": "5.6.39",
"version": "5.6.41",
"description": "All-in-one bookmark manager",
"author": "Rustem Mussabekov",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/config/csp.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
hosts: 'https://app.raindrop.io https://*.sentry.io https://sentry.io https://raindrop.onfastspring.com'
hosts: 'https://app.raindrop.io https://raindrop.onfastspring.com '+(process.env.SENTRY_RELEASE ? 'https://*.sentry.io https://sentry.io' : '')
}
9 changes: 6 additions & 3 deletions src/config/vendors.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export default {
sentry: {
const vendors = {}

if (process.env.SENTRY_RELEASE)
vendors.sentry = {
dsn: 'https://c647a147102b4de68dd9dd8690e06840@o199199.ingest.sentry.io/5264532'
}
}

export default vendors
9 changes: 5 additions & 4 deletions src/data/sagas/common.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as Sentry from '@sentry/minimal'
import { put, takeEvery } from 'redux-saga/effects'
import ApiError from '../modules/error'

Expand Down Expand Up @@ -29,7 +28,9 @@ function* checkAuth(action={}) {

//Send additional info to 3rd-party scripts
function thirdPartyUserUpdate({ user: { _id, email } }) {
Sentry.configureScope(scope => {
scope.setUser({ id: _id, email })
})
if (RAINDROP_ENVIRONMENT != 'browser' || process.env.SENTRY_RELEASE) {
require('@sentry/minimal').configureScope(scope => {
scope.setUser({ id: _id, email })
})
}
}
5 changes: 3 additions & 2 deletions src/data/sagas/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { all, spawn, delay, call } from 'redux-saga/effects'
import ApiError from '../modules/error'
import * as Sentry from '@sentry/minimal'

import common from './common'
import user from './user'
Expand Down Expand Up @@ -28,7 +27,9 @@ function* failSafe(saga) {

if (typeof e != 'object' ||
e instanceof ApiError == false)
Sentry.captureException(e)
if (RAINDROP_ENVIRONMENT != 'browser' || process.env.SENTRY_RELEASE) {
require('@sentry/minimal').captureException(e)
}

yield delay(1000)
}
Expand Down
35 changes: 0 additions & 35 deletions src/modules/vendors/sentry.js

This file was deleted.

31 changes: 31 additions & 0 deletions src/modules/vendors/sentry/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react'
import * as Sentry from '@sentry/react'
import config from '~config'
import pkg from '../../../../package.json'
import { target } from '~target'

Sentry.init({
...config.vendors.sentry,
release: process.env.SENTRY_RELEASE,
ignoreErrors: [
'ResizeObserver loop',
'Non-Error promise rejection captured with keys: message', //happen when extension background page crash
'The string did not match the expected pattern', //weird safari error
'call screen.orientation.lock', //weird android chrome error
'Actions may not have an undefined "type" property. Have you misspelled a constant?', //if redux action have undefined field in it, can be safely ignored
'Refused to evaluate a string as JavaScript because \'unsafe-eval\'',
'Cannot read property \'Sortable', //https://sentry.io/organizations/oblako-corp/issues/2170103500
],
environment: `${target}-${process.env.NODE_ENV}`
})
Sentry.setTag('version', pkg.version)

export default class MySentry extends React.Component {
render() {
return (
<Sentry.ErrorBoundary showDialog>
{this.props.children}
</Sentry.ErrorBoundary>
)
}
}
5 changes: 5 additions & 0 deletions src/modules/vendors/sentry/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let Component = process.env.SENTRY_RELEASE ?
require('./component').default :
function({children}) { return children }

export default Component
26 changes: 14 additions & 12 deletions src/target/extension/background/highlights/highlight.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/target/extension/background/highlights/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ async function send(tab, type, payload) {
async function isInjected(tab) {
if (!await browser.permissions.contains({
permissions: ['scripting'],
origins: [tab.url]
...(tab?.url ? {origins: [tab.url]} : {})
}))
return false

Expand Down

0 comments on commit f7efeb2

Please sign in to comment.