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

Features/GoogleAnalytics/script.js   A

Complexity

Total Complexity 7
Complexity/F 1.75

Size

Lines of Code 33
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 0
c 2
b 0
f 0
nc 1
dl 0
loc 33
rs 10
wmc 7
mnd 2
bc 8
fnc 4
bpm 2
cpm 1.75
noi 1

4 Functions

Rating   Name   Duplication   Size   Complexity  
A script.js ➔ getOptoutCookie 0 3 1
A script.js ➔ setOptoutCookie 0 3 1
A script.js ➔ isOptout 0 3 1
A script.js ➔ optOut 0 17 4
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