Completed
Push — Feature-GoogleAnalyticsOptout ( 39c6dd...b0cf78 )
by
unknown
02:20
created

script.js ➔ optOut   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
c 0
b 0
f 0
nc 6
nop 0
dl 0
loc 17
rs 9.2
1
/* global dataFlyntFeatureGoogleAnalytics, Cookies */
2
3
import 'file-loader?name=vendor/js-cookie.js!js-cookie/src/js.cookie'
4
5
const data = dataFlyntFeatureGoogleAnalytics
6
7
export function optOut () {
8
  let confirmOptout = false
0 ignored issues
show
Unused Code introduced by
The assignment to variable confirmOptout seems to be never used. Consider removing it.
Loading history...
9
10
  if (data.confirm) {
11
    confirmOptout = window.confirm(data.confirm)
12
  } else {
13
    confirmOptout = true
14
  }
15
16
  if (confirmOptout) {
17
    window['ga-disable-' + data.gaId] = true
18
    if (data.success) {
19
      window.alert(data.success)
20
    }
21
    setOptoutCookie()
22
  }
23
}
24
25
export function isOptout () {
26
  return getOptoutCookie()
27
}
28
29
function setOptoutCookie () {
30
  Cookies.set('disableGa', true)
31
}
32
33
function getOptoutCookie () {
34
  return Cookies.get('disableGa')
35
}
36