Skip to content

Commit

Permalink
chore: Leave Albacross active after signup
Browse files Browse the repository at this point in the history
  • Loading branch information
novakzaballa committed Mar 6, 2024
1 parent 0080509 commit c72a7e9
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions frontend/web/components/pages/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import { informationCircleOutline } from 'ionicons/icons'
import { IonIcon } from '@ionic/react'
import Checkbox from 'components/base/forms/Checkbox'

let controller = new AbortController()

const HomePage = class extends React.Component {
static contextTypes = {
router: propTypes.object.isRequired,
Expand All @@ -32,41 +30,16 @@ const HomePage = class extends React.Component {
}

addAlbacross() {
EventTarget.prototype.oldAddEventListener =
EventTarget.prototype.addEventListener
window._nQc = Project.albacross
const script = document.createElement('script')
script.type = 'text/javascript'
script.async = true
script.src = 'https://serve.albacross.com/track.js'
script.id = 'albacross'

EventTarget.prototype.addEventListener = function (
type,
listener,
options = false,
) {
const parsedOptions =
typeof options == 'boolean' ? { capture: options } : options

EventTarget.prototype.oldAddEventListener.call(this, type, listener, {
signal: controller.signal,
...parsedOptions,
})
}

document.body.appendChild(script)
}

removeAlbacross() {
controller.abort()
controller = new AbortController()
EventTarget.prototype.addEventListener =
EventTarget.prototype.oldAddEventListener
document.body.removeChild(document.getElementById('albacross'))
delete window._nQc
}

componentDidUpdate(prevProps) {
if (this.props.location.pathname !== prevProps.location.pathname) {
const emailField =
Expand All @@ -80,18 +53,10 @@ const HomePage = class extends React.Component {
this.props.location.pathname.indexOf('signup') !== -1
) {
this.addAlbacross()
} else if (document.getElementById('albacross')) {
this.removeAlbacross()
}
}
}

componentWillUnmount() {
if (document.getElementById('albacross')) {
this.removeAlbacross()
}
}

componentDidMount() {
if (
Project.albacross &&
Expand Down

0 comments on commit c72a7e9

Please sign in to comment.