@24i/bigscreen-sdk 1.0.54-alpha.2836 → 2.1.1-alpha.2133
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/README.md +3 -2
- package/package.json +34 -53
- package/packages/adobe-heartbeat/src/AdobeHeartbeat.ts +9 -9
- package/packages/async-image/src/AsyncImage.tsx +10 -15
- package/packages/developer-tools/PlayerDebugWindow/README.md +1 -1
- package/packages/developer-tools/src/DeveloperToolsService/DeveloperToolsList.tsx +0 -11
- package/packages/developer-tools/src/PlayerDebugWindow/PlayerDebugWindow.tsx +5 -5
- package/packages/developer-tools/src/PlayerDebugWindow/constants.ts +0 -15
- package/packages/developer-tools/src/TechnicalInfo/TechnicalInfoDetail.tsx +1 -2
- package/packages/developer-tools/src/TechnicalInfo/TechnicalInfoProvider.ts +5 -57
- package/packages/developer-tools/src/TechnicalInfo/__mocks__/Device.ts +0 -12
- package/packages/developer-tools/src/TechnicalInfo/translations.ts +0 -8
- package/packages/device/src/getKeyDigit.ts +2 -2
- package/packages/device/src/resolver/resolver.ts +5 -18
- package/packages/digital-clock/src/DigitalClock.tsx +4 -15
- package/packages/driver-androidtv/src/DeviceAndroidTV.ts +9 -92
- package/packages/driver-androidtv/src/__mocks__/javaScriptBridge.ts +5 -38
- package/packages/driver-androidtv/src/index.ts +0 -1
- package/packages/driver-androidtv/src/keymap.ts +0 -18
- package/packages/driver-androidtv/src/types.ts +16 -144
- package/packages/driver-base/src/DeviceBase.ts +2 -80
- package/packages/driver-base/src/KeyMap/Key.ts +1 -8
- package/packages/driver-base/src/KeyMap/KeyMap.ts +0 -4
- package/packages/driver-base/src/KeyMap/interface.ts +0 -1
- package/packages/driver-base/src/KeyMap/overrideValues.ts +1 -2
- package/packages/driver-base/src/__mocks__/DeviceBase.ts +0 -24
- package/packages/driver-base/src/__mocks__/keyMap.ts +0 -1
- package/packages/driver-base/src/index.ts +0 -3
- package/packages/driver-base/src/types/DeviceEvent.ts +0 -2
- package/packages/driver-base/src/types/KeycodeKeyMap.ts +0 -1
- package/packages/driver-browser/src/DeviceBrowser.ts +0 -26
- package/packages/driver-browser/src/keymap.ts +0 -8
- package/packages/driver-entone/src/DeviceEntone.ts +1 -31
- package/packages/driver-entone/src/keymap.ts +0 -1
- package/packages/driver-hbbtv/src/DeviceHbbTV.ts +0 -26
- package/packages/driver-kreatv/src/DeviceKreaTV.ts +0 -26
- package/packages/driver-saphi/src/DeviceSaphi.ts +0 -26
- package/packages/driver-tizen/src/DeviceTizen.ts +7 -126
- package/packages/driver-tizen/src/ITizen.ts +202 -15116
- package/packages/driver-tizen/src/IWebapis.ts +87 -8643
- package/packages/driver-tizen/src/TizenKeys.ts +2 -4
- package/packages/driver-tizen/src/__mocks__/tizen.ts +8 -7
- package/packages/driver-tizen/src/constants.ts +195 -1
- package/packages/driver-tizen/src/types.ts +14 -0
- package/packages/driver-vidaa/src/DeviceVidaa.ts +2 -29
- package/packages/driver-vidaa/src/__mocks__/vidaa.ts +1 -1
- package/packages/driver-vidaa/src/keymap.ts +0 -2
- package/packages/driver-webos/src/DeviceWebos.ts +0 -55
- package/packages/driver-webos/src/__mocks__/webos.ts +0 -33
- package/packages/driver-webos/src/constants.ts +0 -1
- package/packages/driver-webos/src/keymap.ts +1 -2
- package/packages/driver-webos/src/types.ts +0 -30
- package/packages/driver-xbox/src/DeviceXbox.ts +1 -30
- package/packages/driver-xbox/src/keymap.ts +1 -1
- package/packages/epg/README.md +1 -3
- package/packages/epg/src/v2/Cell.tsx +2 -16
- package/packages/epg/src/v2/DataManager.ts +41 -112
- package/packages/epg/src/v2/DatePicker.tsx +3 -9
- package/packages/epg/src/v2/DateToast/DateToast.tsx +9 -12
- package/packages/epg/src/v2/Day.tsx +3 -6
- package/packages/epg/src/v2/Epg.tsx +5 -5
- package/packages/epg/src/v2/MockGenerator/generator.ts +2 -3
- package/packages/epg/src/v2/ProgramInfo/utils.ts +3 -4
- package/packages/epg/src/v2/Row.tsx +1 -3
- package/packages/epg/src/v2/TimelineSection.tsx +1 -4
- package/packages/epg/src/v2/basic/CellsManager.tsx +2 -7
- package/packages/epg/src/v2/basic/RowsManager.tsx +1 -3
- package/packages/epg/src/v2/interface.ts +0 -13
- package/packages/events-manager/src/EventsManager.ts +56 -1
- package/packages/focus/README.md +0 -33
- package/packages/focus/src/IFocusable.ts +0 -1
- package/packages/focus/src/Layout/Base.tsx +6 -41
- package/packages/focus/src/Layout/Matrix.tsx +19 -51
- package/packages/focus/src/Layout/__test__/Base.spec.ts +180 -0
- package/packages/focus/src/Layout/__test__/Horizontal.spec.ts +94 -0
- package/packages/focus/src/Layout/__test__/Matrix.spec.ts +261 -0
- package/packages/focus/src/Layout/__test__/Vertical.spec.ts +46 -0
- package/packages/focus/src/Layout/__test__/isRtl.spec.ts +23 -0
- package/packages/focus/src/Layout/__test__/shared.ts +19 -0
- package/packages/focus/src/focusFirstExisting.ts +1 -7
- package/packages/focus/src/index.ts +1 -2
- package/packages/gallup/src/Gallup.ts +3 -3
- package/packages/grid/src/Base/Base.tsx +10 -15
- package/packages/grid/src/FirstOnlyGrid/FirstOnlyGrid.tsx +2 -4
- package/packages/grid/src/UnifiedGridController/UnifiedGridController.ts +6 -6
- package/packages/icon/src/Icon.tsx +5 -27
- package/packages/input/README.md +1 -1
- package/packages/input/src/Input.tsx +10 -16
- package/packages/interactable/README.md +1 -2
- package/packages/interactable/src/Interactable.tsx +3 -9
- package/packages/interactable/src/interface.ts +0 -1
- package/packages/jsx/src/index.ts +1 -1
- package/packages/jsx/src/test-utils/index.ts +0 -1
- package/packages/keyboard/src/Backdrop/Backdrop.scss +0 -2
- package/packages/keyboard/src/KeyboardBase.tsx +4 -16
- package/packages/keyboard/src/WhitelabelKeyboard/Keyboard.scss +0 -4
- package/packages/keyboard/src/WhitelabelKeyboard/Keyboard.tsx +20 -28
- package/packages/keyboard/src/WhitelabelKeyboard/_sizes.1080.scss +0 -1
- package/packages/keyboard/src/WhitelabelKeyboard/_sizes.scss +0 -1
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/index.ts +0 -12
- package/packages/keyboard/src/WhitelabelKeyboard/types.ts +0 -1
- package/packages/keyboard/src/utils/caret.ts +8 -5
- package/packages/keyboard/src/utils/input.ts +6 -5
- package/packages/l10n/README.md +0 -18
- package/packages/l10n/src/date/common.ts +6 -18
- package/packages/l10n/src/date/cs.ts +8 -2
- package/packages/l10n/src/date/en-001.ts +3 -3
- package/packages/l10n/src/date/en-common.ts +4 -5
- package/packages/l10n/src/date/en-us.ts +3 -3
- package/packages/l10n/src/date/iso.ts +13 -12
- package/packages/l10n/src/date/types.ts +0 -9
- package/packages/l10n/src/l10n.ts +3 -61
- package/packages/list/src/Base/Base.tsx +9 -19
- package/packages/list/src/Base/interface.ts +2 -2
- package/packages/list/src/BasicList/BasicList.tsx +7 -7
- package/packages/list/src/CenteredList/CenteredList.tsx +2 -2
- package/packages/list/src/CenteredList/controller.ts +1 -0
- package/packages/list/src/EdgeOffsetList/EdgeOffsetList.tsx +10 -10
- package/packages/list/src/FirstOnlyList/FirstOnlyList.tsx +2 -2
- package/packages/list/src/FirstOnlyVariedList/FirstOnlyVariedList.tsx +2 -2
- package/packages/list/src/FixedToEndList/FixedToEndList.tsx +2 -2
- package/packages/list/src/UnifiedListController/UnifiedListController.ts +2 -6
- package/packages/list/src/interface.ts +2 -2
- package/packages/logger/src/loggers/ConsoleLogger/ConsoleLogger.ts +1 -7
- package/packages/logger/src/loggers/SentryLogger/Sentry.ts +0 -1
- package/packages/logger/src/loggers/SentryLogger/SentryLogger.ts +3 -5
- package/packages/menu/src/MenuAndContentContainer/MenuAndContentContainer.tsx +3 -31
- package/packages/menu/src/MenuAndContentContainer/interface.ts +0 -8
- package/packages/modal-service/README.md +1 -4
- package/packages/modal-service/src/ModalService.tsx +5 -29
- package/packages/perf-utils/README.md +120 -1
- package/packages/perf-utils/src/array/filter.ts +54 -1
- package/packages/perf-utils/src/array/find.ts +43 -1
- package/packages/perf-utils/src/array/findIndex.ts +43 -1
- package/packages/perf-utils/src/array/forEach.ts +48 -1
- package/packages/perf-utils/src/array/includes.ts +41 -1
- package/packages/perf-utils/src/array/includesNaN.ts +32 -1
- package/packages/perf-utils/src/array/index.ts +7 -1
- package/packages/perf-utils/src/array/map.ts +52 -1
- package/packages/player-ui/README.md +1 -1
- package/packages/player-ui/src/CurrentTime.tsx +2 -2
- package/packages/player-ui/src/Duration.tsx +2 -2
- package/packages/player-ui/src/PauseButton.tsx +0 -8
- package/packages/player-ui/src/PlayerInteractable.tsx +0 -1
- package/packages/player-ui/src/PlayerTime.tsx +1 -3
- package/packages/player-ui/src/PlayerUI.tsx +35 -68
- package/packages/player-ui/src/RemainingTime.tsx +2 -2
- package/packages/player-ui/src/Seekbar.tsx +18 -110
- package/packages/player-ui/src/Seeking.ts +16 -57
- package/packages/player-ui/src/Subtitles.tsx +2 -2
- package/packages/player-ui/src/index.ts +0 -1
- package/packages/player-ui/src/mocks.ts +8 -32
- package/packages/player-ui/src/timeUtils.ts +3 -3
- package/packages/player-ui/src/types.ts +3 -9
- package/packages/router/README.md +0 -1
- package/packages/router/src/Route.tsx +27 -61
- package/packages/router/src/Router.tsx +14 -63
- package/packages/router/src/history.ts +1 -8
- package/packages/router/src/index.ts +1 -1
- package/packages/router/src/utils.ts +4 -9
- package/packages/sass-utils/src/linear-gradient.scss +4 -9
- package/packages/sass-utils/src/scale.1080.scss +1 -3
- package/packages/sass-utils/src/scale.720.scss +1 -1
- package/packages/time/README.md +1 -4
- package/packages/time/src/Time.ts +13 -35
- package/packages/time/src/constants.ts +0 -1
- package/packages/toast/src/ToastService.tsx +5 -16
- package/packages/types-bigscreen-jsx/README.md +4 -5
- package/packages/types-bigscreen-jsx/index.d.ts +67 -72
- package/packages/utils/README.md +0 -27
- package/packages/utils/src/elementUtils.ts +0 -25
- package/packages/utils/src/index.ts +0 -8
- package/packages/utils/src/scaledImage.ts +3 -6
- package/packages/utils/src/textUtils.ts +14 -46
- package/packages/utils/src/wait.ts +1 -3
- package/packages/utils/src/xhr/xhrSend.ts +1 -3
- package/packages/utils/src/xhr/xhrSendRetry.ts +1 -3
- package/packages/zapping/src/ChannelZapping.ts +0 -9
- package/packages/zapping/src/Zapping.tsx +0 -10
- package/ci/is_ci_job_skippable.sh +0 -153
- package/packages/analytics/README.md +0 -8
- package/packages/analytics/src/A.ts +0 -1
- package/packages/analytics/src/Analytics.ts +0 -1
- package/packages/analytics/src/analyticsOnScroll.ts +0 -1
- package/packages/analytics/src/clients/ConsoleAnalytics/ConsoleAnalytics.ts +0 -1
- package/packages/analytics/src/clients/ConsoleAnalytics/index.ts +0 -1
- package/packages/analytics/src/clients/GoogleAnalytics/GoogleAnalytics.ts +0 -196
- package/packages/analytics/src/clients/GoogleAnalytics/constants.ts +0 -126
- package/packages/analytics/src/clients/GoogleAnalytics/getUrl.ts +0 -17
- package/packages/analytics/src/clients/GoogleAnalytics/index.ts +0 -2
- package/packages/analytics/src/clients/GoogleAnalytics/interface.ts +0 -82
- package/packages/analytics/src/clients/GoogleAnalytics/mapPayload.ts +0 -51
- package/packages/analytics/src/clients/GoogleAnalytics/prepareBody.ts +0 -14
- package/packages/analytics/src/clients/TealiumAnalytics/TealiumAnalytics.ts +0 -181
- package/packages/analytics/src/clients/TealiumAnalytics/constants.ts +0 -106
- package/packages/analytics/src/clients/TealiumAnalytics/findForLanguage.ts +0 -9
- package/packages/analytics/src/clients/TealiumAnalytics/index.ts +0 -4
- package/packages/analytics/src/clients/TealiumAnalytics/interface.ts +0 -35
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/__mocks__/mediaPayload.ts +0 -72
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/helper.ts +0 -36
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapAppError.ts +0 -13
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapAppOpen.ts +0 -13
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapFavoriteAdd.ts +0 -11
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapFavoriteRemove.ts +0 -11
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapPlayerClose.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapPlayerOpen.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSceneView.ts +0 -18
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearch.ts +0 -18
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearchFailed.ts +0 -8
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearchSuccess.ts +0 -8
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoPause.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoProgress.ts +0 -18
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoResume.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoStart.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoStop.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/types.ts +0 -161
- package/packages/analytics/src/clients/TwentyFourIQ/TwentyFourIQClient.ts +0 -107
- package/packages/analytics/src/clients/TwentyFourIQ/constants.ts +0 -111
- package/packages/analytics/src/clients/TwentyFourIQ/helper.ts +0 -34
- package/packages/analytics/src/clients/TwentyFourIQ/index.ts +0 -2
- package/packages/analytics/src/clients/TwentyFourIQ/interface.ts +0 -34
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapAdEvent.ts +0 -20
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapBase.ts +0 -24
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapBuffering.ts +0 -15
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapPlayerClose.ts +0 -25
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapPlayerOpen.ts +0 -17
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapSceneView.ts +0 -15
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapScroll.ts +0 -17
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoComplete.ts +0 -22
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoPause.ts +0 -25
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoProgress.ts +0 -25
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoStart.ts +0 -34
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoStop.ts +0 -32
- package/packages/analytics/src/clients/TwentyFourIQ/types.ts +0 -132
- package/packages/analytics/src/constants.ts +0 -1
- package/packages/analytics/src/index.ts +0 -3
- package/packages/analytics/src/interface.ts +0 -1
- package/packages/analytics/src/utils/generateSessionId.ts +0 -8
- package/packages/device/src/driver/index.firetv.ts +0 -1
- package/packages/device/src/driver/index.smartcast.tv.ts +0 -1
- package/packages/driver-base/src/types/AdInfo.ts +0 -5
- package/packages/driver-base/src/types/InAppPurchase.ts +0 -25
- package/packages/driver-firetv/src/DeviceFireTV.ts +0 -91
- package/packages/driver-firetv/src/__mocks__/javaScriptBridge.ts +0 -45
- package/packages/driver-firetv/src/index.ts +0 -1
- package/packages/driver-firetv/src/types.ts +0 -1
- package/packages/driver-smartcast/src/DeviceSmartCast.ts +0 -394
- package/packages/driver-smartcast/src/__mocks__/api.ts +0 -79
- package/packages/driver-smartcast/src/index.ts +0 -1
- package/packages/driver-smartcast/src/keymap.ts +0 -9
- package/packages/driver-smartcast/src/types.ts +0 -111
- package/packages/focus/src/hasFocus.ts +0 -36
- package/packages/jsx/src/test-utils/keyup.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/arabic.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/burmese.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/dari.ts +0 -28
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/korean.ts +0 -26
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/pashto.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/persian.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/russian.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/spanish.ts +0 -26
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/tibetan.ts +0 -26
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/turkish.ts +0 -26
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/ukrainian.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/urdu.ts +0 -26
- package/packages/keyboard/src/utils/setInputSelectionRange.ts +0 -10
- package/packages/l10n/src/date/de.ts +0 -97
- package/packages/l10n/src/date/es.ts +0 -71
- package/packages/l10n/src/date/fr.ts +0 -94
- package/packages/l10n/src/date/he.ts +0 -101
- package/packages/time/src/adapters/24iMediaTimeApi.ts +0 -47
- package/packages/time/src/services/24iMediaTimeApi/24iMediaTimeApi.ts +0 -43
- package/packages/time/src/services/24iMediaTimeApi/index.ts +0 -6
- package/packages/utils/src/forceReflow.ts +0 -14
- package/packages/utils/src/keyPress/index.ts +0 -6
- package/packages/utils/src/keyPress/keyPressSimulator.ts +0 -74
- package/packages/utils/src/keyPress/simulateKeyPress.ts +0 -25
- package/utils/release/release.ts +0 -156
|
@@ -4,12 +4,6 @@ import { SCREEN_WIDTH } from './sizes';
|
|
|
4
4
|
|
|
5
5
|
const SAFE_TIMEOUT = 100;
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Test if the element (or element in the reference) is wrapped visible. This means that the
|
|
9
|
-
* element does not have `display: none` or `visibility: hidden`.
|
|
10
|
-
* @param elementOrReference DOM element or reference to element on which we test wrapping
|
|
11
|
-
* @returns true if element is visible
|
|
12
|
-
*/
|
|
13
7
|
export const isElementVisible = (
|
|
14
8
|
elementOrReference: HTMLElement | Reference<HTMLElement>,
|
|
15
9
|
) => {
|
|
@@ -19,18 +13,10 @@ export const isElementVisible = (
|
|
|
19
13
|
return style.display !== 'none' && style.visibility !== 'hidden';
|
|
20
14
|
};
|
|
21
15
|
|
|
22
|
-
/**
|
|
23
|
-
* Test if the element (or element in the reference) is wrapped fully visible. This means that the
|
|
24
|
-
* element does not have `display: none` or `visibility: hidden` and exists
|
|
25
|
-
* inside visible DOM tree, which exists in the document.body.
|
|
26
|
-
* @param elementOrReference DOM element or reference to element on which we test wrapping
|
|
27
|
-
* @returns true if element is visible
|
|
28
|
-
*/
|
|
29
16
|
export const isElementFullyVisible = (
|
|
30
17
|
elementOrReference: HTMLElement | Reference<HTMLElement>,
|
|
31
18
|
) => {
|
|
32
19
|
const element = unwrapReference(elementOrReference);
|
|
33
|
-
if (!element) return false;
|
|
34
20
|
if (isElementVisible(element)) {
|
|
35
21
|
let parent = element.parentElement;
|
|
36
22
|
while (parent) {
|
|
@@ -47,16 +33,6 @@ export const isElementFullyVisible = (
|
|
|
47
33
|
return false;
|
|
48
34
|
};
|
|
49
35
|
|
|
50
|
-
/**
|
|
51
|
-
* Test if the element (or element in the reference) is wrapped by another element.
|
|
52
|
-
* @param elementOrReference DOM element or reference to element on which we test wrapping
|
|
53
|
-
* @param wrapperElementOrReferenceOrCondition wrapper element or certain condition (utils is
|
|
54
|
-
* running upwards in the DOM tree from first element till some element has some specific condition)
|
|
55
|
-
* @param includesElementItself if true, test will check also provided element itself.
|
|
56
|
-
* This is useful in some cases when we need to include also provided element as wrapper
|
|
57
|
-
* in one run of the util.
|
|
58
|
-
* @returns true if the element is wrapped by provided wrapper
|
|
59
|
-
*/
|
|
60
36
|
export const isElementWrappedBy = (
|
|
61
37
|
elementOrReference: HTMLElement | Reference<HTMLElement>,
|
|
62
38
|
wrapperElementOrReferenceOrCondition:
|
|
@@ -64,7 +40,6 @@ export const isElementWrappedBy = (
|
|
|
64
40
|
includesElementItself = false,
|
|
65
41
|
) => {
|
|
66
42
|
const element = unwrapReference(elementOrReference);
|
|
67
|
-
if (!element) return false;
|
|
68
43
|
let currentParent = includesElementItself ? element : element.parentElement;
|
|
69
44
|
let wrapperElement: HTMLElement | null = null;
|
|
70
45
|
let condition: ((currentWrapper: HTMLElement) => boolean) | null = null;
|
|
@@ -6,7 +6,6 @@ export { addClass } from './addClass';
|
|
|
6
6
|
export { removeClass } from './removeClass';
|
|
7
7
|
export { debounce } from './debounce';
|
|
8
8
|
export { wait } from './wait';
|
|
9
|
-
export { forceReflow } from './forceReflow';
|
|
10
9
|
export { scaledImage } from './scaledImage';
|
|
11
10
|
export { nTimes } from './nTimes';
|
|
12
11
|
export { getDisplayToggler, DISPLAY_NONE } from './displayToggler';
|
|
@@ -16,7 +15,6 @@ export {
|
|
|
16
15
|
isElementVisible,
|
|
17
16
|
isElementFullyVisible,
|
|
18
17
|
isElementWrappedBy,
|
|
19
|
-
preventDefaultScroll,
|
|
20
18
|
} from './elementUtils';
|
|
21
19
|
export { createInterval, createTimeout, runAsync } from './timers';
|
|
22
20
|
export type { TimedFunction } from './timers';
|
|
@@ -35,9 +33,3 @@ export {
|
|
|
35
33
|
} from './timeConstants';
|
|
36
34
|
export { xhrSend, xhrSendRetry, defaultRetryConfig, mockXhr } from './xhr';
|
|
37
35
|
export type { XhrOptions, XhrResponse, RetryConfig, RSOptions, ShouldRetryParam } from './xhr';
|
|
38
|
-
export {
|
|
39
|
-
registerKeyPressSimulator,
|
|
40
|
-
unregisterKeyPressSimulator,
|
|
41
|
-
dispatchKeyboardEvent,
|
|
42
|
-
simulateKeyPress,
|
|
43
|
-
} from './keyPress';
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
+
export const DEFAULT_SCALING_ENDPOINT = 'http://imageresize.24i.com';
|
|
2
|
+
|
|
1
3
|
type Dimensions = {
|
|
2
4
|
height: number,
|
|
3
5
|
width: number,
|
|
4
6
|
fit?: 'cover' | 'contain' | 'inside',
|
|
5
7
|
};
|
|
6
8
|
|
|
7
|
-
const getEndpointProtocol = (protocol: string) => (protocol === 'https:' ? 'https:' : 'http:');
|
|
8
|
-
|
|
9
9
|
const attention = (fit: Dimensions['fit']) => (
|
|
10
10
|
fit === 'cover' ? '&a=attention' : ''
|
|
11
11
|
);
|
|
12
12
|
|
|
13
|
-
// eslint-disable-next-line max-len
|
|
14
|
-
export const DEFAULT_SCALING_ENDPOINT = `${getEndpointProtocol(window.location.protocol)}//imageresize.24i.com`;
|
|
15
|
-
|
|
16
13
|
const scaledImage = (
|
|
17
14
|
url: string,
|
|
18
15
|
{ height, width, fit = 'cover' }: Dimensions,
|
|
@@ -21,4 +18,4 @@ const scaledImage = (
|
|
|
21
18
|
`${scalingEndpoint}?url=${url}&h=${height}&w=${width}&fit=${fit}${attention(fit)}`
|
|
22
19
|
);
|
|
23
20
|
|
|
24
|
-
export { scaledImage, Dimensions
|
|
21
|
+
export { scaledImage, Dimensions };
|
|
@@ -1,57 +1,25 @@
|
|
|
1
1
|
const ELLIPSIS = '...';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
row
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
row.style.visibility = 'hidden';
|
|
14
|
-
const lineHeightString = window.getComputedStyle(row, null).getPropertyValue('line-height');
|
|
15
|
-
const lineHeight = parseInt(lineHeightString, 10);
|
|
16
|
-
let numberOfLines = row.offsetHeight / lineHeight;
|
|
17
|
-
if (numberOfLines > requestedNumberOfLines) {
|
|
18
|
-
const originalTextContent = row.textContent!;
|
|
19
|
-
row.textContent = ellipsis;
|
|
20
|
-
let stringBuffer = '';
|
|
21
|
-
if (ending) {
|
|
22
|
-
let currentPosition = 0;
|
|
23
|
-
do {
|
|
24
|
-
stringBuffer += originalTextContent.charAt(currentPosition);
|
|
25
|
-
row.textContent = stringBuffer + ellipsis;
|
|
26
|
-
currentPosition += 1;
|
|
27
|
-
numberOfLines = row.offsetHeight / lineHeight;
|
|
28
|
-
} while (numberOfLines <= requestedNumberOfLines
|
|
29
|
-
&& currentPosition < originalTextContent.length);
|
|
30
|
-
row.textContent = stringBuffer.substring(0, stringBuffer.length - 1) + ellipsis;
|
|
31
|
-
|
|
32
|
-
} else {
|
|
3
|
+
export const trimWithLeadingEllipsis = (row: HTMLSpanElement, requestedNumberOfLines: number) => {
|
|
4
|
+
if (row && row.textContent != null) {
|
|
5
|
+
row.style.visibility = 'hidden';
|
|
6
|
+
const lineHeightString = window.getComputedStyle(row, null).getPropertyValue('line-height');
|
|
7
|
+
const lineHeight = parseInt(lineHeightString, 10);
|
|
8
|
+
let numberOfLines = row.offsetHeight / lineHeight;
|
|
9
|
+
if (numberOfLines > requestedNumberOfLines) {
|
|
10
|
+
const originalTextContent = row.textContent;
|
|
11
|
+
row.textContent = ELLIPSIS;
|
|
12
|
+
let stringBuffer = '';
|
|
33
13
|
let currentPosition = originalTextContent.length - 1;
|
|
34
14
|
do {
|
|
35
|
-
const charToAdd = originalTextContent.
|
|
15
|
+
const charToAdd = originalTextContent.at(currentPosition);
|
|
36
16
|
stringBuffer = `${charToAdd}${stringBuffer}`;
|
|
37
|
-
row.textContent = `${
|
|
17
|
+
row.textContent = `${ELLIPSIS}${stringBuffer}`;
|
|
38
18
|
currentPosition -= 1;
|
|
39
19
|
numberOfLines = Math.floor(row.offsetHeight / lineHeight);
|
|
40
20
|
} while (numberOfLines <= requestedNumberOfLines && currentPosition >= 0);
|
|
41
|
-
row.textContent = `${
|
|
21
|
+
row.textContent = `${ELLIPSIS}${stringBuffer.substring(1)}`;
|
|
42
22
|
}
|
|
23
|
+
row.style.visibility = '';
|
|
43
24
|
}
|
|
44
|
-
row.style.visibility = visibility;
|
|
45
25
|
};
|
|
46
|
-
|
|
47
|
-
export const trimWithLeadingEllipsis = (
|
|
48
|
-
row: HTMLSpanElement | HTMLDivElement,
|
|
49
|
-
requestedNumberOfLines: number,
|
|
50
|
-
ellipsis = ELLIPSIS,
|
|
51
|
-
) => trimWithEllipsis(row, requestedNumberOfLines, ellipsis, false);
|
|
52
|
-
|
|
53
|
-
export const trimWithEndingEllipsis = (
|
|
54
|
-
row: HTMLSpanElement | HTMLDivElement,
|
|
55
|
-
requestedNumberOfLines: number,
|
|
56
|
-
ellipsis = ELLIPSIS,
|
|
57
|
-
) => trimWithEllipsis(row, requestedNumberOfLines, ellipsis, true);
|
|
@@ -84,9 +84,7 @@ function xhrSend(url: string, options: Partial<XhrOptions> = {}): Promise<XhrRes
|
|
|
84
84
|
const xhr = new XMLHttpRequest();
|
|
85
85
|
|
|
86
86
|
function onLoad() {
|
|
87
|
-
const dataText = 'response' in
|
|
88
|
-
? xhr.response
|
|
89
|
-
: xhr.responseText;
|
|
87
|
+
const dataText = 'response' in xhr ? xhr.response : xhr.responseText;
|
|
90
88
|
const dataJson = parseJson(dataText);
|
|
91
89
|
const status = xhr.status === undefined ? HttpStatusCode.OK : xhr.status;
|
|
92
90
|
const statusText = xhr.statusText === undefined ? 'OK' : xhr.statusText;
|
|
@@ -68,9 +68,7 @@ Promise<XhrResponse | TypeError> {
|
|
|
68
68
|
const shouldRetryFn = config.shouldRetry || defaultRetryConfig.shouldRetry;
|
|
69
69
|
const shouldRetry = shouldRetryFn({ options, response, error });
|
|
70
70
|
if (shouldRetry) {
|
|
71
|
-
await new Promise((res) =>
|
|
72
|
-
window.setTimeout(res, config.retryDelay);
|
|
73
|
-
});
|
|
71
|
+
await new Promise((res) => window.setTimeout(res, config.retryDelay));
|
|
74
72
|
config.currentRetryAttempt += 1;
|
|
75
73
|
return xhrSendRetry(url, options);
|
|
76
74
|
}
|
|
@@ -99,15 +99,6 @@ export class ChannelZapping<T extends Asset = Asset> {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
/**
|
|
103
|
-
* Updates the current index of channel zapping.
|
|
104
|
-
* @param channels the array of all channels
|
|
105
|
-
* @param currentChannel currently active channel
|
|
106
|
-
*/
|
|
107
|
-
onUpdate(channels: T[], currentChannel: T) {
|
|
108
|
-
this.currentIndex = getCurrentChannelIndex(channels, currentChannel);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
102
|
/**
|
|
112
103
|
* Changes to the next/previous channel.
|
|
113
104
|
* @param direction direction of the change
|
|
@@ -96,20 +96,10 @@ export class Zapping<T extends Asset = Asset> extends Component<Props<T>> {
|
|
|
96
96
|
this.channelZapping!.onKeyDown(event);
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
/**
|
|
100
|
-
* Updates channel zapping with new data.
|
|
101
|
-
* @param channels the array of all channels
|
|
102
|
-
* @param currentChannel currently active channel
|
|
103
|
-
*/
|
|
104
|
-
onUpdate(channels: T[], currentChannel: T) {
|
|
105
|
-
this.channelZapping!.onUpdate(channels, currentChannel);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
99
|
render() {
|
|
109
100
|
const { numericZapper } = this.props;
|
|
110
101
|
return numericZapper
|
|
111
102
|
? <NumericZapper {...numericZapper} ref={zapperServiceRef} />
|
|
112
|
-
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
113
103
|
: <></>;
|
|
114
104
|
}
|
|
115
105
|
}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
: '
|
|
4
|
-
Resolves whether CI job can be skipped or not.
|
|
5
|
-
|
|
6
|
-
It requires to be executed with "source", as the script exports result as a variable
|
|
7
|
-
which needs to be processed outside the script.
|
|
8
|
-
|
|
9
|
-
- EXPORTS:
|
|
10
|
-
Exports numeric variable IS_CI_JOB_SKIPPABLE,
|
|
11
|
-
where 0 represents not skippable build and 1 represent skippable build.
|
|
12
|
-
|
|
13
|
-
- PARAMETERS:
|
|
14
|
-
File paths or glob patterns with paths to files which are not relevant for the CI job.
|
|
15
|
-
Each glob pattern has to be wrapped into double quotes.
|
|
16
|
-
|
|
17
|
-
- USAGE:
|
|
18
|
-
source <path/to/script.sh> "filePathOrGlob1" "filePathOrGlob2" ... "filePathOrGlobN"
|
|
19
|
-
|
|
20
|
-
- EXAMPLE:
|
|
21
|
-
source path/to/script.sh "docs/**/*" ".eslintrc.json"
|
|
22
|
-
if [[ "$IS_CI_JOB_SKIPPABLE" -eq 1 ]]; then
|
|
23
|
-
# job is skippable, do something here
|
|
24
|
-
fi
|
|
25
|
-
'
|
|
26
|
-
|
|
27
|
-
# Includes filenames beginning with a ‘.’ in the results of filename expansion.
|
|
28
|
-
# The filenames ‘.’ and ‘..’ must always be matched explicitly, even if dotglob is set.
|
|
29
|
-
shopt -s dotglob
|
|
30
|
-
|
|
31
|
-
# Patterns which fail to match filenames during filename expansion will not result in an expansion error.
|
|
32
|
-
shopt -u failglob
|
|
33
|
-
|
|
34
|
-
# The pattern ‘**’ used in a filename expansion context will match all files and zero or more directories and subdirectories.
|
|
35
|
-
shopt -s globstar
|
|
36
|
-
|
|
37
|
-
# Bash allows filename patterns which match no files to expand to a null string, rather than themselves.
|
|
38
|
-
shopt -s nullglob
|
|
39
|
-
|
|
40
|
-
function printFormattedArrayItems () {
|
|
41
|
-
FUNCTION_INPUT_ARRAY=("$@")
|
|
42
|
-
for i in "${FUNCTION_INPUT_ARRAY[@]}"; do
|
|
43
|
-
echo " - $i"
|
|
44
|
-
done
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
# Exported numeric variable with the result.
|
|
48
|
-
# 0 represents not skippable build, 1 represent skippable build.
|
|
49
|
-
IS_CI_JOB_SKIPPABLE=0
|
|
50
|
-
|
|
51
|
-
# Printed when build is skippable.
|
|
52
|
-
RESULT_TRUE_STRING="It's possible to skip the CI job!"
|
|
53
|
-
|
|
54
|
-
# Printed when build is not skippable.
|
|
55
|
-
RESULT_FALSE_STRING="It's NOT possible to skip the CI job!"
|
|
56
|
-
|
|
57
|
-
# Variable for providing details about the result.
|
|
58
|
-
RESULT_REASON_STRING="N/A"
|
|
59
|
-
|
|
60
|
-
# The range of commits that were included in the push or pull request.
|
|
61
|
-
# Example "SHA1...SHA2".
|
|
62
|
-
COMMIT_RANGE=""
|
|
63
|
-
|
|
64
|
-
echo ""
|
|
65
|
-
echo "==========================================================================================="
|
|
66
|
-
echo "RESOLVING THE POSSIBILITY TO SKIP THE CI JOB..."
|
|
67
|
-
|
|
68
|
-
# GitHub Actions CI
|
|
69
|
-
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
|
|
70
|
-
# This is a Pull Request event
|
|
71
|
-
if [[ -z "$GITHUB_BASE_REF" ]]; then
|
|
72
|
-
RESULT_REASON_STRING="GITHUB_BASE_REF is empty for this CI build."
|
|
73
|
-
elif [[ -z "$GITHUB_HEAD_REF" ]]; then
|
|
74
|
-
RESULT_REASON_STRING="GITHUB_HEAD_REF is empty for this CI build."
|
|
75
|
-
else
|
|
76
|
-
COMMIT_RANGE="origin/${GITHUB_BASE_REF}...origin/${GITHUB_HEAD_REF}"
|
|
77
|
-
echo "set COMMIT_RANGE for PR (GA) to \"${COMMIT_RANGE}\""
|
|
78
|
-
fi
|
|
79
|
-
else
|
|
80
|
-
# This is not Pull Request event (it is for example push)
|
|
81
|
-
if [[ "$GA_EVENT_BEFORE" == "0000000000000000000000000000000000000000" ]]; then
|
|
82
|
-
# variable it is set to zeros for the initial commit of a new branch
|
|
83
|
-
RESULT_REASON_STRING="GA_EVENT_BEFORE is zeros for this CI build."
|
|
84
|
-
elif [[ -z "$GA_EVENT_BEFORE" ]]; then
|
|
85
|
-
RESULT_REASON_STRING="GA_EVENT_BEFORE is empty for this CI build."
|
|
86
|
-
elif [[ -z "$GA_EVENT_AFTER" ]]; then
|
|
87
|
-
RESULT_REASON_STRING="GA_EVENT_AFTER is empty for this CI build."
|
|
88
|
-
else
|
|
89
|
-
COMMIT_RANGE="${GA_EVENT_BEFORE}...${GA_EVENT_AFTER}"
|
|
90
|
-
echo "set COMMIT_RANGE for \"${GITHUB_EVENT_NAME}\" (GA) to \"${COMMIT_RANGE}\""
|
|
91
|
-
fi
|
|
92
|
-
fi
|
|
93
|
-
|
|
94
|
-
if [[ ! -z "$COMMIT_RANGE" ]]; then
|
|
95
|
-
CHANGED_FILES_ARRAY=()
|
|
96
|
-
while IFS= read -r line; do
|
|
97
|
-
CHANGED_FILES_ARRAY+=("${line}")
|
|
98
|
-
done < <(git diff --name-only "$COMMIT_RANGE")
|
|
99
|
-
|
|
100
|
-
IRRELEVANT_FILES_INPUT_ARRAY=($@) # array with all params
|
|
101
|
-
|
|
102
|
-
RESOLVED_RELEVANT_FILES=()
|
|
103
|
-
RESOLVED_IRRELEVANT_FILES=()
|
|
104
|
-
for i in "${CHANGED_FILES_ARRAY[@]}"; do
|
|
105
|
-
if [[ "${IRRELEVANT_FILES_INPUT_ARRAY[*]}" =~ $i ]]; then
|
|
106
|
-
RESOLVED_IRRELEVANT_FILES+=("$i")
|
|
107
|
-
else
|
|
108
|
-
RESOLVED_RELEVANT_FILES+=("$i")
|
|
109
|
-
fi
|
|
110
|
-
done
|
|
111
|
-
|
|
112
|
-
echo ""
|
|
113
|
-
echo "Provided filter for irrelevant files ($#):"
|
|
114
|
-
printFormattedArrayItems "$@"
|
|
115
|
-
|
|
116
|
-
echo ""
|
|
117
|
-
echo "Resolved provided filter for irrelevant files (${#IRRELEVANT_FILES_INPUT_ARRAY[@]}):"
|
|
118
|
-
printFormattedArrayItems "${IRRELEVANT_FILES_INPUT_ARRAY[@]}"
|
|
119
|
-
|
|
120
|
-
echo ""
|
|
121
|
-
echo "Detected changed files from GIT (${#CHANGED_FILES_ARRAY[@]}):"
|
|
122
|
-
printFormattedArrayItems "${CHANGED_FILES_ARRAY[@]}"
|
|
123
|
-
|
|
124
|
-
echo ""
|
|
125
|
-
echo "Changed files resolved as relevant for the CI job (${#RESOLVED_RELEVANT_FILES[@]}):"
|
|
126
|
-
printFormattedArrayItems "${RESOLVED_RELEVANT_FILES[@]}"
|
|
127
|
-
|
|
128
|
-
echo ""
|
|
129
|
-
echo "Changed files resolved as irrelevant for the CI job: (${#RESOLVED_IRRELEVANT_FILES[@]}):"
|
|
130
|
-
printFormattedArrayItems "${RESOLVED_IRRELEVANT_FILES[@]}"
|
|
131
|
-
|
|
132
|
-
if [[ ${#RESOLVED_RELEVANT_FILES[@]} -eq 0 ]]; then
|
|
133
|
-
IS_CI_JOB_SKIPPABLE=1
|
|
134
|
-
RESULT_REASON_STRING="With given filter, all changed files are irrelevant for this CI job."
|
|
135
|
-
else
|
|
136
|
-
RESULT_REASON_STRING="With given filter, there are changes which have to be processed in this CI job."
|
|
137
|
-
fi
|
|
138
|
-
fi
|
|
139
|
-
|
|
140
|
-
echo ""
|
|
141
|
-
echo "The result:"
|
|
142
|
-
if [[ "$IS_CI_JOB_SKIPPABLE" -eq 1 ]]; then
|
|
143
|
-
echo " $RESULT_TRUE_STRING"
|
|
144
|
-
else
|
|
145
|
-
echo " $RESULT_FALSE_STRING"
|
|
146
|
-
fi
|
|
147
|
-
echo ""
|
|
148
|
-
echo "The reason of the result:"
|
|
149
|
-
echo " $RESULT_REASON_STRING"
|
|
150
|
-
echo "==========================================================================================="
|
|
151
|
-
echo ""
|
|
152
|
-
|
|
153
|
-
export IS_CI_JOB_SKIPPABLE
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { A } from '@24i/appstage-shared-analytics';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { analytics } from '@24i/appstage-shared-analytics';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { analyticsOnScroll } from '@24i/appstage-shared-analytics';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ConsoleAnalytics } from '@24i/appstage-shared-analytics/dist/clients/ConsoleAnalytics';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ConsoleAnalytics } from './ConsoleAnalytics';
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { Storage } from '@24i/bigscreen-sdk/storage';
|
|
2
|
-
import { device } from '@24i/bigscreen-sdk/device';
|
|
3
|
-
import { debounce } from '@24i/bigscreen-sdk/utils/debounce';
|
|
4
|
-
import { createTimeout } from '@24i/bigscreen-sdk/utils/timers';
|
|
5
|
-
import { MINUTE_IN_MS } from '@24i/bigscreen-sdk/utils/timeConstants';
|
|
6
|
-
import { generateUuid } from '@24i/bigscreen-sdk/utils/generateUuid';
|
|
7
|
-
import { i18n } from '@24i/bigscreen-sdk/i18n';
|
|
8
|
-
import type { AnalyticsClient, AnalyticsEventsMap, AnyPayload } from '../../interface';
|
|
9
|
-
import { mapEventParamsToUrlParams, mapPayload } from './mapPayload';
|
|
10
|
-
import { prepareBody } from './prepareBody';
|
|
11
|
-
import { getUrl } from './getUrl';
|
|
12
|
-
import { generateSessionId } from '../../utils/generateSessionId';
|
|
13
|
-
import { GOOGLE_ANALYTICS_TRIGGERS, TRIGGER_NAME_TO_GA_EVENTS } from './constants';
|
|
14
|
-
import {
|
|
15
|
-
GAEventsNames,
|
|
16
|
-
QueuedEvent,
|
|
17
|
-
ConstantUrlParams,
|
|
18
|
-
SessionInfo,
|
|
19
|
-
EventUrlParams,
|
|
20
|
-
} from './interface';
|
|
21
|
-
|
|
22
|
-
const SEND_DEBOUNCE_MS = 5000;
|
|
23
|
-
const MAX_QUEUE_LENGTH = 10;
|
|
24
|
-
// eslint-disable-next-line no-magic-numbers
|
|
25
|
-
const SESSION_TIMEOUT = 30 * MINUTE_IN_MS;
|
|
26
|
-
|
|
27
|
-
const GA_CLIENT_ID = 'GA_client_id';
|
|
28
|
-
const GA_SESSION_COUNTER = 'GA_session_counter';
|
|
29
|
-
const GA_FIRST_VISIT = 'GA_first_visit';
|
|
30
|
-
|
|
31
|
-
export class GoogleAnalytics implements AnalyticsClient {
|
|
32
|
-
name = 'GoogleAnalytics';
|
|
33
|
-
|
|
34
|
-
constantUrlParams: ConstantUrlParams = {
|
|
35
|
-
cid: '',
|
|
36
|
-
sid: 0,
|
|
37
|
-
seg: 0,
|
|
38
|
-
sct: 0,
|
|
39
|
-
_p: generateUuid(),
|
|
40
|
-
'up.device_manufacturer': '',
|
|
41
|
-
'up.device_platform': '',
|
|
42
|
-
'up.device_platform_version': '',
|
|
43
|
-
'up.app_version': '',
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
manufacturer = '';
|
|
47
|
-
|
|
48
|
-
platform = '';
|
|
49
|
-
|
|
50
|
-
platformVersion = '';
|
|
51
|
-
|
|
52
|
-
lastOnEvent: number | undefined = undefined;
|
|
53
|
-
|
|
54
|
-
eventsQueue: QueuedEvent[] = [];
|
|
55
|
-
|
|
56
|
-
sessionTimeout = createTimeout();
|
|
57
|
-
|
|
58
|
-
isSessionActive = false;
|
|
59
|
-
|
|
60
|
-
sessionStartSent = false;
|
|
61
|
-
|
|
62
|
-
firstEvent = true;
|
|
63
|
-
|
|
64
|
-
firstVisit: boolean | undefined = undefined;
|
|
65
|
-
|
|
66
|
-
constructor(private id: string, private appVersion: string = '') {
|
|
67
|
-
this.init();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async init() {
|
|
71
|
-
const params = this.constantUrlParams;
|
|
72
|
-
params.cid = await Storage.getItem(GA_CLIENT_ID) ?? '';
|
|
73
|
-
if (!params.cid) {
|
|
74
|
-
params.cid = generateUuid();
|
|
75
|
-
await Storage.setItem(GA_CLIENT_ID, params.cid);
|
|
76
|
-
}
|
|
77
|
-
this.firstVisit = !(await Storage.getItem(GA_FIRST_VISIT));
|
|
78
|
-
if (this.firstVisit) {
|
|
79
|
-
await Storage.setItem(GA_FIRST_VISIT, '0');
|
|
80
|
-
}
|
|
81
|
-
this.manufacturer = await device.getManufacturerName();
|
|
82
|
-
this.platform = await device.getPlatformName();
|
|
83
|
-
this.platformVersion = await device.getPlatformVersion();
|
|
84
|
-
await this.startSession();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async startSession() {
|
|
88
|
-
const sessionNumber = parseInt(await Storage.getItem(GA_SESSION_COUNTER) ?? '0', 10) + 1;
|
|
89
|
-
this.constantUrlParams.sct = sessionNumber;
|
|
90
|
-
this.constantUrlParams.sid = generateSessionId();
|
|
91
|
-
this.constantUrlParams['up.device_manufacturer'] = this.manufacturer;
|
|
92
|
-
this.constantUrlParams['up.device_platform'] = this.platform;
|
|
93
|
-
this.constantUrlParams['up.device_platform_version'] = this.platformVersion;
|
|
94
|
-
this.constantUrlParams['up.app_version'] = this.appVersion;
|
|
95
|
-
await Storage.setItem(GA_SESSION_COUNTER, sessionNumber.toString());
|
|
96
|
-
this.isSessionActive = true;
|
|
97
|
-
this.setSessionTimeout();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
setSessionTimeout() {
|
|
101
|
-
this.sessionTimeout.set(() => {
|
|
102
|
-
this.isSessionActive = false;
|
|
103
|
-
this.sessionStartSent = false;
|
|
104
|
-
this.constantUrlParams.seg = 0;
|
|
105
|
-
}, SESSION_TIMEOUT);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// @ts-ignore - cross event typing
|
|
109
|
-
async onEvent<Event extends keyof AnalyticsEventsMap>(
|
|
110
|
-
triggerName: Event,
|
|
111
|
-
payload: Parameters<AnalyticsEventsMap[Event]>[0],
|
|
112
|
-
) {
|
|
113
|
-
if (this.isSessionActive) {
|
|
114
|
-
this.setSessionTimeout();
|
|
115
|
-
} else {
|
|
116
|
-
await this.startSession();
|
|
117
|
-
}
|
|
118
|
-
const events = TRIGGER_NAME_TO_GA_EVENTS[
|
|
119
|
-
triggerName as typeof GOOGLE_ANALYTICS_TRIGGERS[number]
|
|
120
|
-
];
|
|
121
|
-
const now = Date.now();
|
|
122
|
-
const engagementTime = this.lastOnEvent ? now - this.lastOnEvent : undefined;
|
|
123
|
-
this.lastOnEvent = now;
|
|
124
|
-
await Promise.all(events.map(async (event, index) => {
|
|
125
|
-
const sessionInfo = await this.getSessionInfo(
|
|
126
|
-
payload!, index === 0 ? engagementTime : undefined,
|
|
127
|
-
);
|
|
128
|
-
const gtagPayload = mapPayload(event, triggerName, { ...payload, ...sessionInfo });
|
|
129
|
-
const urlParams = mapEventParamsToUrlParams({ ...sessionInfo, ...payload });
|
|
130
|
-
this.send(event, gtagPayload, urlParams);
|
|
131
|
-
}));
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
private send(name: GAEventsNames, params: Record<string, any>, urlParams: EventUrlParams) {
|
|
135
|
-
const lastUrlParams = JSON.stringify(
|
|
136
|
-
this.eventsQueue[this.eventsQueue.length - 1]?.urlParams ?? {},
|
|
137
|
-
);
|
|
138
|
-
if (lastUrlParams !== '{}' && lastUrlParams !== JSON.stringify(urlParams)) {
|
|
139
|
-
this.sendQueue();
|
|
140
|
-
}
|
|
141
|
-
if (this.constantUrlParams.seg === 0) {
|
|
142
|
-
this.eventsQueue.push({ name, params, urlParams });
|
|
143
|
-
this.sendQueue();
|
|
144
|
-
this.constantUrlParams.seg = 1;
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
this.eventsQueue.push({ name, params, urlParams });
|
|
148
|
-
if (this.eventsQueue.length >= MAX_QUEUE_LENGTH) {
|
|
149
|
-
this.sendQueue();
|
|
150
|
-
} else {
|
|
151
|
-
this.sendQueueWithDelay();
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
private sendQueue = () => {
|
|
156
|
-
if (this.eventsQueue.length === 0) return;
|
|
157
|
-
const body = prepareBody(this.eventsQueue);
|
|
158
|
-
const { urlParams } = this.eventsQueue[0];
|
|
159
|
-
this.eventsQueue.length = 0;
|
|
160
|
-
try {
|
|
161
|
-
fetch(getUrl(this.id, {
|
|
162
|
-
...this.constantUrlParams,
|
|
163
|
-
...urlParams,
|
|
164
|
-
}), { method: 'POST', body });
|
|
165
|
-
} catch (e) {
|
|
166
|
-
// Effort to send was made.
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
private sendQueueWithDelay = debounce(this.sendQueue, SEND_DEBOUNCE_MS);
|
|
171
|
-
|
|
172
|
-
private async getSessionInfo(
|
|
173
|
-
payload: AnyPayload,
|
|
174
|
-
engagementTime: number | undefined,
|
|
175
|
-
): Promise<SessionInfo> {
|
|
176
|
-
const sessionStarted = !this.sessionStartSent;
|
|
177
|
-
this.sessionStartSent = true;
|
|
178
|
-
const { firstEvent } = this;
|
|
179
|
-
this.firstEvent = false;
|
|
180
|
-
const { firstVisit } = this;
|
|
181
|
-
this.firstVisit = false;
|
|
182
|
-
return {
|
|
183
|
-
appVersion: this.appVersion,
|
|
184
|
-
manufacturer: this.manufacturer,
|
|
185
|
-
language: i18n.getLanguage(),
|
|
186
|
-
resolution: `${window.screen.width}x${window.screen.height}`,
|
|
187
|
-
referrer: document.referrer,
|
|
188
|
-
platform: this.platform,
|
|
189
|
-
sessionStarted,
|
|
190
|
-
engagementTime,
|
|
191
|
-
firstEvent,
|
|
192
|
-
isAuthenticated: payload?.userId ? '1' : '0',
|
|
193
|
-
firstVisit: firstVisit as boolean,
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
}
|