@financial-times/n-myft-ui 30.4.4 → 30.4.5

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.
@@ -10,7 +10,6 @@
10
10
  "hasInstallScript": true,
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@financial-times/o-tracking": "^4.5.0",
14
13
  "date-fns": "2.16.1",
15
14
  "fetchres": "^1.7.2",
16
15
  "form-serialize": "^0.7.2",
@@ -3379,22 +3378,6 @@
3379
3378
  "@financial-times/o-visual-effects": "^4.0.1"
3380
3379
  }
3381
3380
  },
3382
- "node_modules/@financial-times/o-tracking": {
3383
- "version": "4.5.0",
3384
- "resolved": "https://registry.npmjs.org/@financial-times/o-tracking/-/o-tracking-4.5.0.tgz",
3385
- "integrity": "sha512-gPnAmMPqlYWf8xXNJkAYKQMpEWvHpjxajB4YnadbGhOGl2Zy8y5LJJqyzsfpqoBh51P7VDIc7yBF+A7fgaymYw==",
3386
- "dependencies": {
3387
- "ftdomdelegate": "^5"
3388
- },
3389
- "engines": {
3390
- "npm": "^7 || ^8"
3391
- }
3392
- },
3393
- "node_modules/@financial-times/o-tracking/node_modules/ftdomdelegate": {
3394
- "version": "5.0.0",
3395
- "resolved": "https://registry.npmjs.org/ftdomdelegate/-/ftdomdelegate-5.0.0.tgz",
3396
- "integrity": "sha512-P9UmLMIq/ibxxFVBHlE2EIoHcFNDpamn3urRCwVWMnj3o9nAgLtqe64WVuqcGtkN4wujrBYeyxKCuN1/WO+bQw=="
3397
- },
3398
3381
  "node_modules/@financial-times/o-typography": {
3399
3382
  "version": "7.5.0",
3400
3383
  "resolved": "https://registry.npmjs.org/@financial-times/o-typography/-/o-typography-7.5.0.tgz",
@@ -31403,21 +31386,6 @@
31403
31386
  "ftdomdelegate": "^4.0.6"
31404
31387
  }
31405
31388
  },
31406
- "@financial-times/o-tracking": {
31407
- "version": "4.5.0",
31408
- "resolved": "https://registry.npmjs.org/@financial-times/o-tracking/-/o-tracking-4.5.0.tgz",
31409
- "integrity": "sha512-gPnAmMPqlYWf8xXNJkAYKQMpEWvHpjxajB4YnadbGhOGl2Zy8y5LJJqyzsfpqoBh51P7VDIc7yBF+A7fgaymYw==",
31410
- "requires": {
31411
- "ftdomdelegate": "^5"
31412
- },
31413
- "dependencies": {
31414
- "ftdomdelegate": {
31415
- "version": "5.0.0",
31416
- "resolved": "https://registry.npmjs.org/ftdomdelegate/-/ftdomdelegate-5.0.0.tgz",
31417
- "integrity": "sha512-P9UmLMIq/ibxxFVBHlE2EIoHcFNDpamn3urRCwVWMnj3o9nAgLtqe64WVuqcGtkN4wujrBYeyxKCuN1/WO+bQw=="
31418
- }
31419
- }
31420
- },
31421
31389
  "@financial-times/o-typography": {
31422
31390
  "version": "7.5.0",
31423
31391
  "resolved": "https://registry.npmjs.org/@financial-times/o-typography/-/o-typography-7.5.0.tgz",
@@ -1,6 +1,5 @@
1
1
  import myFtClient from 'next-myft-client';
2
2
  import getToken from '../../../myft/ui/lib/get-csrf-token';
3
- import oTracking from '@financial-times/o-tracking';
4
3
 
5
4
  const csrfToken = getToken();
6
5
 
@@ -46,25 +45,34 @@ const positionModal = ({ event, preferencesModal } = {}) => {
46
45
  }
47
46
  };
48
47
 
49
- const preferenceModalShowAndHide = ({ event, preferencesModal }) => {
48
+ const tracking = (conceptId) => {
49
+ const trackingData = {
50
+ category: 'component',
51
+ action: 'view',
52
+ concept_id: conceptId,
53
+ component: {
54
+ type: 'component',
55
+ name: 'pop-up-box',
56
+ id: '72de123e-5082-11ee-be56-0242ac120002',
57
+ }
58
+ }
59
+
60
+ const trackingEvent = new CustomEvent('oTracking.event', {
61
+ detail: trackingData,
62
+ bubbles: true
63
+ });
64
+
65
+ document.body.dispatchEvent(trackingEvent);
66
+ };
67
+
68
+ const preferenceModalShowAndHide = ({ event, preferencesModal, conceptId }) => {
50
69
  preferencesModal.classList.toggle('n-myft-ui__preferences-modal--show');
51
70
 
52
71
  if (preferencesModal.classList.contains('n-myft-ui__preferences-modal--show')) {
53
72
  positionModal({ event, preferencesModal });
54
- const opts = {
55
- category: 'component',
56
- selector: '[data-component-id="myft-preferences-modal"]',
57
- getContextData: () => {
58
- return {
59
- component: {
60
- type: 'component',
61
- name: 'pop-up-box',
62
- id: '72de123e-5082-11ee-be56-0242ac120002',
63
- },
64
- };
65
- },
66
- };
67
- oTracking.view.init(opts);
73
+
74
+ tracking(conceptId);
75
+
68
76
  } else {
69
77
  // Remove existing errors when hiding the modal
70
78
  renderError({
@@ -79,7 +87,6 @@ const removeTopic = async ({ event, conceptId, preferencesModal }) => {
79
87
 
80
88
  try {
81
89
  await myFtClient.remove('user', null, 'followed', 'concept', conceptId, { token: csrfToken });
82
-
83
90
  preferenceModalShowAndHide({ preferencesModal });
84
91
 
85
92
  } catch (error) {
@@ -91,8 +98,7 @@ const removeTopic = async ({ event, conceptId, preferencesModal }) => {
91
98
 
92
99
  const getAlertsPreferenceText = (addedTextBuffer) => {
93
100
  const alertsEnabledText = `Your delivery channels: ${addedTextBuffer.join(', ')}.`;
94
- const alertsDisabledText = 'You have previously disabled all delivery channels';
95
- return Array.isArray(addedTextBuffer) && addedTextBuffer.length > 0 ? alertsEnabledText : alertsDisabledText;
101
+ return Array.isArray(addedTextBuffer) && addedTextBuffer.length > 0 ? alertsEnabledText : '';
96
102
  };
97
103
 
98
104
  const getAlertsPreferences = async ({ event, preferencesModal }) => {
@@ -213,7 +219,7 @@ export default () => {
213
219
 
214
220
  instantAlertsCheckbox.addEventListener('change', event => toggleInstantAlertsPreference({ event, conceptId, preferencesModal }));
215
221
 
216
- document.addEventListener('myft.preference-modal.show-hide.toggle', event => preferenceModalShowAndHide({ event, preferencesModal }));
222
+ document.addEventListener('myft.preference-modal.show-hide.toggle', event => preferenceModalShowAndHide({ event, preferencesModal, conceptId }));
217
223
 
218
224
  document.addEventListener('myft.user.preferred.preference.load', (event) => getAlertsPreferences({ event, preferencesModal }));
219
225
 
@@ -26,7 +26,6 @@ export default function InstantAlertsPreferencesModal({ flags, conceptId, visibl
26
26
  className={`n-myft-ui__preferences-modal ${visible ? 'n-myft-ui__preferences-modal--show' : ''}`}
27
27
  data-component-id="myft-preferences-modal"
28
28
  data-concept-id={conceptId}
29
- data-o-tracking-view="true"
30
29
  >
31
30
  <div className="n-myft-ui__preferences-modal__content">
32
31
  <span className="o-forms-input o-forms-input--checkbox">
@@ -37,6 +36,7 @@ export default function InstantAlertsPreferencesModal({ flags, conceptId, visibl
37
36
  name="receive-instant-alerts"
38
37
  value="receive-instant-alerts"
39
38
  data-component-id="myft-preferences-modal-checkbox"
39
+ data-trackable-context-concept_id={conceptId}
40
40
  />
41
41
  <span className="o-forms-input__label n-myft-ui__preferences-modal__checkbox__message">
42
42
  Get instant alerts for this topic
@@ -45,9 +45,9 @@ export default function InstantAlertsPreferencesModal({ flags, conceptId, visibl
45
45
  </span>
46
46
 
47
47
  <p data-component-id="myft-preferences-modal-list" className="n-myft-ui__preferences-modal__text"></p>
48
- <a className="n-myft-ui__preferences-modal__text" href="/myft/alerts" data-trackable="pop-up-box|contact-preference">Manage your preferences here</a>
48
+ <a className="n-myft-ui__preferences-modal__text" href="/myft/alerts" data-trackable="pop-up-box|contact-preference" data-trackable-context-concept_id={conceptId}>Manage your delivery channels here</a>
49
49
  <span className="n-myft-ui__preferences-modal-error" data-component-id="myft-preference-modal-error"></span>
50
- <button className="n-myft-ui__preferences-modal__remove-button" data-component-id="myft-preference-modal-remove" data-trackable="pop-up-box|remove-from-myFT">Remove from myFT</button>
50
+ <button className="n-myft-ui__preferences-modal__remove-button" data-component-id="myft-preference-modal-remove" data-trackable="pop-up-box|remove-from-myFT" data-trackable-context-concept_id={conceptId}>Remove from myFT</button>
51
51
  </div>
52
52
  </div>
53
53
  );
@@ -41,8 +41,7 @@ function InstantAlertsPreferencesModal(_ref) {
41
41
  {
42
42
  className: 'n-myft-ui__preferences-modal ' + (visible ? 'n-myft-ui__preferences-modal--show' : ''),
43
43
  'data-component-id': 'myft-preferences-modal',
44
- 'data-concept-id': conceptId,
45
- 'data-o-tracking-view': 'true'
44
+ 'data-concept-id': conceptId
46
45
  },
47
46
  _react2.default.createElement(
48
47
  'div',
@@ -58,7 +57,8 @@ function InstantAlertsPreferencesModal(_ref) {
58
57
  type: 'checkbox',
59
58
  name: 'receive-instant-alerts',
60
59
  value: 'receive-instant-alerts',
61
- 'data-component-id': 'myft-preferences-modal-checkbox'
60
+ 'data-component-id': 'myft-preferences-modal-checkbox',
61
+ 'data-trackable-context-concept_id': conceptId
62
62
  }),
63
63
  _react2.default.createElement(
64
64
  'span',
@@ -70,13 +70,13 @@ function InstantAlertsPreferencesModal(_ref) {
70
70
  _react2.default.createElement('p', { 'data-component-id': 'myft-preferences-modal-list', className: 'n-myft-ui__preferences-modal__text' }),
71
71
  _react2.default.createElement(
72
72
  'a',
73
- { className: 'n-myft-ui__preferences-modal__text', href: '/myft/alerts', 'data-trackable': 'pop-up-box|contact-preference' },
74
- 'Manage your preferences here'
73
+ { className: 'n-myft-ui__preferences-modal__text', href: '/myft/alerts', 'data-trackable': 'pop-up-box|contact-preference', 'data-trackable-context-concept_id': conceptId },
74
+ 'Manage your delivery channels here'
75
75
  ),
76
76
  _react2.default.createElement('span', { className: 'n-myft-ui__preferences-modal-error', 'data-component-id': 'myft-preference-modal-error' }),
77
77
  _react2.default.createElement(
78
78
  'button',
79
- { className: 'n-myft-ui__preferences-modal__remove-button', 'data-component-id': 'myft-preference-modal-remove', 'data-trackable': 'pop-up-box|remove-from-myFT' },
79
+ { className: 'n-myft-ui__preferences-modal__remove-button', 'data-component-id': 'myft-preference-modal-remove', 'data-trackable': 'pop-up-box|remove-from-myFT', 'data-trackable-context-concept_id': conceptId },
80
80
  'Remove from myFT'
81
81
  )
82
82
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/n-myft-ui",
3
- "version": "30.4.4",
3
+ "version": "30.4.5",
4
4
  "description": "Client side component for interaction with myft",
5
5
  "main": "server.js",
6
6
  "scripts": {
@@ -104,7 +104,6 @@
104
104
  "react": "^16.14.0"
105
105
  },
106
106
  "dependencies": {
107
- "@financial-times/o-tracking": "^4.5.0",
108
107
  "date-fns": "2.16.1",
109
108
  "fetchres": "^1.7.2",
110
109
  "form-serialize": "^0.7.2",