hr-design-system-handlebars 1.95.1 → 1.96.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # v1.96.0 (Mon Aug 26 2024)
2
+
3
+ #### 🚀 Enhancement
4
+
5
+ - Feature/dpe 3322 [#1053](https://github.com/mumprod/hr-design-system-handlebars/pull/1053) ([@szuelch](https://github.com/szuelch))
6
+
7
+ #### Authors: 1
8
+
9
+ - [@szuelch](https://github.com/szuelch)
10
+
11
+ ---
12
+
1
13
  # v1.95.1 (Fri Aug 23 2024)
2
14
 
3
15
  #### 🐛 Bug Fix
@@ -3332,7 +3332,7 @@ article.indexTextDS .indexTextHighlighted .link {
3332
3332
  border-bottom-color: var(--color-secondary-ds);
3333
3333
  }
3334
3334
  .counter-reset {
3335
- counter-reset: cnt1724406325510;
3335
+ counter-reset: cnt1724672641168;
3336
3336
  }
3337
3337
  .hyphens-auto {
3338
3338
  -webkit-hyphens: auto;
@@ -3740,7 +3740,7 @@ article.indexTextDS .indexTextHighlighted .link {
3740
3740
  --tw-ring-color: rgba(255, 255, 255, 0.5);
3741
3741
  }
3742
3742
  .-ordered {
3743
- counter-increment: cnt1724406325510 1;
3743
+ counter-increment: cnt1724672641168 1;
3744
3744
  }
3745
3745
  .-ordered::before {
3746
3746
  position: absolute;
@@ -3756,7 +3756,7 @@ article.indexTextDS .indexTextHighlighted .link {
3756
3756
  letter-spacing: .0125em;
3757
3757
  --tw-text-opacity: 1;
3758
3758
  color: rgba(0, 0, 0, var(--tw-text-opacity));
3759
- content: counter(cnt1724406325510);
3759
+ content: counter(cnt1724672641168);
3760
3760
  }
3761
3761
  /*! ****************************/
3762
3762
  /*! DataPolicy stuff */
@@ -1,51 +1,37 @@
1
- import { download, pi, uxAction, uxNavigation } from 'base/tracking/pianoHelper.subfeature'
1
+ import { download, pi, uxAction, uxNavigation } from 'base/tracking/pianoHelper.subfeature';
2
2
 
3
- const ClickTracking = function (context) {
4
- const { options } = context,
5
- { element: elementToTrack } = context,
6
- settings = options.settings || []
3
+ const ClickTracking = (context) => {
4
+ const { options, element: elementToTrack } = context;
5
+ const settings = options.settings || [];
7
6
 
8
- const init = function () {
9
- configureEventHandlers()
10
- }
11
-
12
- const configureEventHandlers = function () {
13
- if (window.attachEvent) {
14
- elementToTrack.attachEvent('click', clickHandler)
15
- } else {
16
- elementToTrack.addEventListener('click', clickHandler)
17
- }
18
- }
19
-
20
- const clickHandler = function (event) {
21
- settings.forEach(function (trackingSetting) {
7
+ const clickHandler = (event) => {
8
+ settings.forEach(({ type, clickLabel, secondLevelId }) => {
22
9
  /* use String.prototype.replace function with a regex and the global flag
23
10
  instead of String.prototype.replaceAll function to prevent errors in older
24
11
  browsers that don't know the replaceAll function
25
12
  see: https://www.designcise.com/web/tutorial/how-to-fix-replaceall-is-not-a-function-javascript-error
26
13
  */
27
- trackingSetting.clickLabel = trackingSetting.clickLabel.replace(/&/g, '-')
28
- switch (trackingSetting.type) {
14
+ const sanitizedLabel = clickLabel.replace(/&/g, '-');
15
+ switch (type) {
29
16
  case 'download':
30
- download(trackingSetting.clickLabel, trackingSetting.secondLevelId)
31
- break
17
+ download(sanitizedLabel, secondLevelId);
18
+ break;
32
19
  case 'pi':
33
- pi()
34
- break
20
+ pi();
21
+ break;
35
22
  case 'uxAction':
36
- uxAction(trackingSetting.clickLabel, trackingSetting.secondLevelId)
37
- break
23
+ uxAction(sanitizedLabel, secondLevelId);
24
+ break;
38
25
  case 'uxNavigation':
39
- uxNavigation(trackingSetting.clickLabel, trackingSetting.secondLevelId)
40
- break
26
+ uxNavigation(sanitizedLabel, secondLevelId);
27
+ break;
41
28
  default:
42
- console.log('Fehler, es wurde kein Tracking Typ angegeben.')
43
- break
29
+ console.error('Fehler, es wurde kein Tracking Typ angegeben.');
44
30
  }
45
- })
46
- }
31
+ });
32
+ };
47
33
 
48
- init()
49
- }
34
+ elementToTrack.addEventListener('click', clickHandler);
35
+ };
50
36
 
51
- export default ClickTracking
37
+ export default ClickTracking;
@@ -1,44 +1,36 @@
1
- import SettingsCookie from 'components/externalService/globalSettingsCookie.subfeature'
1
+ import SettingsCookie from 'components/externalService/globalSettingsCookie.subfeature';
2
2
 
3
3
  const isTrackingAllowed = () => {
4
- const settingsCookie = new SettingsCookie()
5
- return settingsCookie.isSettingsCookieAccepted('ati')
6
- }
7
-
8
- const uxAction = (label, secondLevelId) => {
9
- secondLevelId = undefined !== secondLevelId ? secondLevelId : typeof pageDisplayConfig !== "undefined" && pageDisplayConfig !== undefined ? pageDisplayConfig.site_level2_id:99
10
- if (typeof pa !== "undefined" && pa !== undefined && isTrackingAllowed()) {
11
- pa.sendEvent('click.action', {
12
- click: label,
13
- site_level2_id: secondLevelId,
14
- })
15
- }
16
- }
17
-
18
- const uxNavigation = (label, secondLevelId) => {
19
- secondLevelId = undefined !== secondLevelId ? secondLevelId : typeof pageDisplayConfig !== "undefined" && pageDisplayConfig !== undefined ? pageDisplayConfig.site_level2_id:99
20
- if (typeof pa !== "undefined" && pa !== undefined && isTrackingAllowed()) {
21
- pa.sendEvent('click.navigation', {
22
- click: label,
23
- site_level2_id: secondLevelId,
24
- })
25
- }
26
- }
4
+ const settingsCookie = new SettingsCookie();
5
+ return settingsCookie.isSettingsCookieAccepted('ati');
6
+ };
27
7
 
28
- const pi = () => {
29
- if (typeof pa !== "undefined" && pa !== undefined && isTrackingAllowed()) {
30
- pa.sendEvent('page.display', pageDisplayConfig)
8
+ const sendEvent = (eventType, event) => {
9
+ if (typeof pa !== 'undefined' && pa !== undefined && isTrackingAllowed()) {
10
+ pa.sendEvent(eventType, event);
31
11
  }
32
- }
33
-
34
- const download = (label, secondLevelId) => {
35
- secondLevelId = undefined !== secondLevelId ? secondLevelId : typeof pageDisplayConfig !== "undefined" && pageDisplayConfig !== undefined ? pageDisplayConfig.site_level2_id:99
36
- if (typeof pa !== "undefined" && pa !== undefined && isTrackingAllowed()) {
37
- pa.sendEvent('click.download', {
38
- click: label,
39
- site_level2_id: secondLevelId,
40
- })
12
+ };
13
+
14
+ const getDefaultEvent = (label, secondLevelId) => {
15
+ return {
16
+ click: label,
17
+ site_level2_id: determineSecondLevelId(secondLevelId)
41
18
  }
42
- }
19
+ };
20
+
21
+ const determineSecondLevelId = (secondLevelId) => {
22
+ return secondLevelId !== undefined
23
+ ? secondLevelId
24
+ : pageDisplayConfig.site_level2_id;
25
+ };
26
+
27
+ const uxAction = (label, secondLevelId) => sendEvent('click.action', getDefaultEvent(label, secondLevelId));
28
+
29
+ const uxNavigation = (label, secondLevelId) => sendEvent('click.navigation', getDefaultEvent(label, secondLevelId));
30
+
31
+ const pi = () => sendEvent('page.display', pageDisplayConfig);
32
+
33
+ const download = (label, secondLevelId) => sendEvent('click.download', getDefaultEvent(label, secondLevelId));
34
+
43
35
 
44
- export { isTrackingAllowed, uxAction, uxNavigation, pi, download }
36
+ export { isTrackingAllowed, uxAction, uxNavigation, pi, download };
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "license": "MIT",
7
7
  "main": "dist/index.js",
8
8
  "repository": "https://github.com/szuelch/hr-design-system-handlebars",
9
- "version": "1.95.1",
9
+ "version": "1.96.0",
10
10
  "scripts": {
11
11
  "test": "echo \"Error: no test specified\" && exit 1",
12
12
  "storybook": "storybook dev -p 6006 public",
@@ -1,51 +1,37 @@
1
- import { download, pi, uxAction, uxNavigation } from 'base/tracking/pianoHelper.subfeature'
1
+ import { download, pi, uxAction, uxNavigation } from 'base/tracking/pianoHelper.subfeature';
2
2
 
3
- const ClickTracking = function (context) {
4
- const { options } = context,
5
- { element: elementToTrack } = context,
6
- settings = options.settings || []
3
+ const ClickTracking = (context) => {
4
+ const { options, element: elementToTrack } = context;
5
+ const settings = options.settings || [];
7
6
 
8
- const init = function () {
9
- configureEventHandlers()
10
- }
11
-
12
- const configureEventHandlers = function () {
13
- if (window.attachEvent) {
14
- elementToTrack.attachEvent('click', clickHandler)
15
- } else {
16
- elementToTrack.addEventListener('click', clickHandler)
17
- }
18
- }
19
-
20
- const clickHandler = function (event) {
21
- settings.forEach(function (trackingSetting) {
7
+ const clickHandler = (event) => {
8
+ settings.forEach(({ type, clickLabel, secondLevelId }) => {
22
9
  /* use String.prototype.replace function with a regex and the global flag
23
10
  instead of String.prototype.replaceAll function to prevent errors in older
24
11
  browsers that don't know the replaceAll function
25
12
  see: https://www.designcise.com/web/tutorial/how-to-fix-replaceall-is-not-a-function-javascript-error
26
13
  */
27
- trackingSetting.clickLabel = trackingSetting.clickLabel.replace(/&/g, '-')
28
- switch (trackingSetting.type) {
14
+ const sanitizedLabel = clickLabel.replace(/&/g, '-');
15
+ switch (type) {
29
16
  case 'download':
30
- download(trackingSetting.clickLabel, trackingSetting.secondLevelId)
31
- break
17
+ download(sanitizedLabel, secondLevelId);
18
+ break;
32
19
  case 'pi':
33
- pi()
34
- break
20
+ pi();
21
+ break;
35
22
  case 'uxAction':
36
- uxAction(trackingSetting.clickLabel, trackingSetting.secondLevelId)
37
- break
23
+ uxAction(sanitizedLabel, secondLevelId);
24
+ break;
38
25
  case 'uxNavigation':
39
- uxNavigation(trackingSetting.clickLabel, trackingSetting.secondLevelId)
40
- break
26
+ uxNavigation(sanitizedLabel, secondLevelId);
27
+ break;
41
28
  default:
42
- console.log('Fehler, es wurde kein Tracking Typ angegeben.')
43
- break
29
+ console.error('Fehler, es wurde kein Tracking Typ angegeben.');
44
30
  }
45
- })
46
- }
31
+ });
32
+ };
47
33
 
48
- init()
49
- }
34
+ elementToTrack.addEventListener('click', clickHandler);
35
+ };
50
36
 
51
- export default ClickTracking
37
+ export default ClickTracking;
@@ -1,44 +1,36 @@
1
- import SettingsCookie from 'components/externalService/globalSettingsCookie.subfeature'
1
+ import SettingsCookie from 'components/externalService/globalSettingsCookie.subfeature';
2
2
 
3
3
  const isTrackingAllowed = () => {
4
- const settingsCookie = new SettingsCookie()
5
- return settingsCookie.isSettingsCookieAccepted('ati')
6
- }
7
-
8
- const uxAction = (label, secondLevelId) => {
9
- secondLevelId = undefined !== secondLevelId ? secondLevelId : typeof pageDisplayConfig !== "undefined" && pageDisplayConfig !== undefined ? pageDisplayConfig.site_level2_id:99
10
- if (typeof pa !== "undefined" && pa !== undefined && isTrackingAllowed()) {
11
- pa.sendEvent('click.action', {
12
- click: label,
13
- site_level2_id: secondLevelId,
14
- })
15
- }
16
- }
17
-
18
- const uxNavigation = (label, secondLevelId) => {
19
- secondLevelId = undefined !== secondLevelId ? secondLevelId : typeof pageDisplayConfig !== "undefined" && pageDisplayConfig !== undefined ? pageDisplayConfig.site_level2_id:99
20
- if (typeof pa !== "undefined" && pa !== undefined && isTrackingAllowed()) {
21
- pa.sendEvent('click.navigation', {
22
- click: label,
23
- site_level2_id: secondLevelId,
24
- })
25
- }
26
- }
4
+ const settingsCookie = new SettingsCookie();
5
+ return settingsCookie.isSettingsCookieAccepted('ati');
6
+ };
27
7
 
28
- const pi = () => {
29
- if (typeof pa !== "undefined" && pa !== undefined && isTrackingAllowed()) {
30
- pa.sendEvent('page.display', pageDisplayConfig)
8
+ const sendEvent = (eventType, event) => {
9
+ if (typeof pa !== 'undefined' && pa !== undefined && isTrackingAllowed()) {
10
+ pa.sendEvent(eventType, event);
31
11
  }
32
- }
33
-
34
- const download = (label, secondLevelId) => {
35
- secondLevelId = undefined !== secondLevelId ? secondLevelId : typeof pageDisplayConfig !== "undefined" && pageDisplayConfig !== undefined ? pageDisplayConfig.site_level2_id:99
36
- if (typeof pa !== "undefined" && pa !== undefined && isTrackingAllowed()) {
37
- pa.sendEvent('click.download', {
38
- click: label,
39
- site_level2_id: secondLevelId,
40
- })
12
+ };
13
+
14
+ const getDefaultEvent = (label, secondLevelId) => {
15
+ return {
16
+ click: label,
17
+ site_level2_id: determineSecondLevelId(secondLevelId)
41
18
  }
42
- }
19
+ };
20
+
21
+ const determineSecondLevelId = (secondLevelId) => {
22
+ return secondLevelId !== undefined
23
+ ? secondLevelId
24
+ : pageDisplayConfig.site_level2_id;
25
+ };
26
+
27
+ const uxAction = (label, secondLevelId) => sendEvent('click.action', getDefaultEvent(label, secondLevelId));
28
+
29
+ const uxNavigation = (label, secondLevelId) => sendEvent('click.navigation', getDefaultEvent(label, secondLevelId));
30
+
31
+ const pi = () => sendEvent('page.display', pageDisplayConfig);
32
+
33
+ const download = (label, secondLevelId) => sendEvent('click.download', getDefaultEvent(label, secondLevelId));
34
+
43
35
 
44
- export { isTrackingAllowed, uxAction, uxNavigation, pi, download }
36
+ export { isTrackingAllowed, uxAction, uxNavigation, pi, download };