• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / gui / 1015445845

25 Sep 2023 09:43AM UTC coverage: 82.537% (-17.4%) from 99.964%
1015445845

Pull #4028

gitlab-ci

mzedel
chore: aligned release retrieval with v2 api models

Signed-off-by: Manuel Zedel <manuel.zedel@northern.tech>
Pull Request #4028: MEN-6455

4355 of 6315 branches covered (0.0%)

184 of 206 new or added lines in 19 files covered. (89.32%)

1724 existing lines in 164 files now uncovered.

8323 of 10084 relevant lines covered (82.54%)

208.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

28.57
/src/js/tracking.js
1
import ReactGA4 from 'react-ga4';
2

3
const cookieConsentCSS = 'https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.css';
186✔
4
const cookieConsentJS = 'https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.js';
186✔
5

6
const ReactGA = ReactGA4.default;
186✔
7

8
class Tracker {
9
  constructor() {
10
    this.initialized = false;
186✔
11
    this.trackingEnabled = true;
186✔
12
    this.currentPageView = null;
186✔
13
    this.currentOrganizationUser = null;
186✔
14
  }
15
  cookieconsent() {
UNCOV
16
    return new Promise(resolve => {
×
UNCOV
17
      const style = document.createElement('link');
×
UNCOV
18
      style.href = cookieConsentCSS;
×
UNCOV
19
      style.rel = 'stylesheet';
×
UNCOV
20
      style.async = true;
×
UNCOV
21
      document.head.appendChild(style);
×
22
      //
UNCOV
23
      const script = document.createElement('script');
×
UNCOV
24
      script.src = cookieConsentJS;
×
UNCOV
25
      script.async = false;
×
UNCOV
26
      script.addEventListener('load', () => {
×
UNCOV
27
        window.cookieconsent.initialise({
×
28
          palette: {
29
            popup: {
30
              background: '#5d0f43',
31
              text: '#ffffff'
32
            },
33
            button: {
34
              background: '#73a4ad',
35
              text: '#ffffff'
36
            }
37
          },
38
          position: 'bottom-left',
39
          type: 'opt-out',
40
          content: {
41
            message: 'We use cookies to analyze our traffic so we can improve our website and give you a better experience.',
42
            link: 'View our cookie policy',
43
            href: 'https://northern.tech/legal/cookies'
44
          },
45
          autoOpen: true,
46
          revokable: false,
47
          law: {
48
            regionalLaw: false
49
          },
50
          onStatusChange: status => {
UNCOV
51
            let hasConsented = status == 'allow';
×
UNCOV
52
            resolve({ trackingConsentGiven: hasConsented });
×
53
          }
54
        });
55
      });
UNCOV
56
      document.body.appendChild(script);
×
57
    });
58
  }
59
  exception(error) {
UNCOV
60
    if (this.initialized && this.trackingEnabled) {
×
UNCOV
61
      ReactGA.event('error', error);
×
62
    }
63
  }
64
  event(data) {
65
    if (this.initialized && this.trackingEnabled) {
45!
UNCOV
66
      ReactGA.event(data);
×
67
    }
68
  }
69
  initialize(trackingCode) {
UNCOV
70
    if (this.initialized && this.trackingEnabled) {
×
UNCOV
71
      return false;
×
72
    }
UNCOV
73
    ReactGA.initialize(trackingCode);
×
UNCOV
74
    this.initialized = true;
×
UNCOV
75
    return true;
×
76
  }
77
  pageview(data) {
78
    if (data) {
1!
79
      this.currentPageView = data;
1✔
80
    }
81
  }
82
  set(value) {
UNCOV
83
    if (this.initialized && this.trackingEnabled) {
×
UNCOV
84
      ReactGA.set(value);
×
85
    }
86
  }
87
  setOrganizationUser(organization, user) {
UNCOV
88
    if (this.initialized && this.trackingEnabled && this.currentOrganizationUser != { organization, user }) {
×
UNCOV
89
      this.currentOrganizationUser = { organization, user };
×
UNCOV
90
      this.set({ dimension1: organization.plan });
×
UNCOV
91
      this.set({ dimension2: organization.id });
×
UNCOV
92
      this.set({ dimension3: user.id });
×
UNCOV
93
      this.set({ userId: user.id });
×
94
    }
95
  }
96
  setTrackingEnabled(trackingEnabled) {
97
    this.trackingEnabled = trackingEnabled;
6✔
98
  }
99
}
100

101
const Tracking = new Tracker();
186✔
102
export default Tracking;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc