@applicaster/zapp-react-native-utils 16.0.0-rc.8 → 16.0.0-rc.81

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.
Files changed (190) hide show
  1. package/actionsExecutor/ActionExecutor.ts +47 -11
  2. package/actionsExecutor/ActionExecutorContext.tsx +102 -315
  3. package/actionsExecutor/__tests__/feedDecorator.test.ts +61 -0
  4. package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +25 -0
  5. package/actionsExecutor/actions/__tests__/goBack.test.ts +62 -0
  6. package/actionsExecutor/actions/__tests__/goHome.test.ts +19 -0
  7. package/actionsExecutor/actions/__tests__/loadItemsFromSource.test.ts +88 -0
  8. package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +133 -0
  9. package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +76 -0
  10. package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +212 -0
  11. package/actionsExecutor/actions/__tests__/showToast.test.ts +88 -0
  12. package/actionsExecutor/actions/appRestart.ts +24 -0
  13. package/actionsExecutor/actions/confirmDialog.ts +53 -0
  14. package/actionsExecutor/actions/dismissBottomSheet.ts +23 -0
  15. package/actionsExecutor/actions/goBack.ts +60 -0
  16. package/actionsExecutor/actions/goHome.ts +31 -0
  17. package/actionsExecutor/actions/index.ts +38 -0
  18. package/actionsExecutor/actions/localStorageRemove.ts +27 -0
  19. package/actionsExecutor/actions/localStorageSet.ts +28 -0
  20. package/actionsExecutor/actions/localStorageToggleFlag.ts +28 -0
  21. package/actionsExecutor/actions/navigateToScreen.ts +137 -0
  22. package/actionsExecutor/actions/openBottomSheet.ts +325 -0
  23. package/actionsExecutor/actions/refreshComponent.ts +85 -0
  24. package/actionsExecutor/actions/screenSetVariable.ts +35 -0
  25. package/actionsExecutor/actions/screenToggleFlag.ts +38 -0
  26. package/actionsExecutor/actions/sendCloudEvent.ts +93 -0
  27. package/actionsExecutor/actions/sessionStorageRemove.ts +19 -0
  28. package/actionsExecutor/actions/sessionStorageSet.ts +20 -0
  29. package/actionsExecutor/actions/sessionStorageToggleFlag.ts +15 -0
  30. package/actionsExecutor/actions/showToast.ts +87 -0
  31. package/actionsExecutor/actions/switchLayout.ts +40 -0
  32. package/actionsExecutor/consts.ts +25 -0
  33. package/actionsExecutor/feedDecorator.ts +6 -6
  34. package/actionsExecutor/types.ts +59 -0
  35. package/analyticsUtils/AnalyticsEvents/sendMenuClickEvent.ts +2 -2
  36. package/analyticsUtils/PlayerAnalyticsManager.ts +12 -2
  37. package/analyticsUtils/__tests__/analyticsMapper.test.ts +35 -0
  38. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testACP_events.json +1 -1
  39. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testBlockUnlistedParams_rules.json +1 -1
  40. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEmptyRenameKeepsName_events.json +4 -0
  41. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEmptyRenameKeepsName_rules.json +6 -0
  42. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEventRegex_events.json +3 -9
  43. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testIgnoreOrdering_events.json +18 -0
  44. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testIgnoreOrdering_rules.json +16 -0
  45. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexEventNoFallback_events.json +4 -0
  46. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexEventNoFallback_rules.json +6 -0
  47. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexMultiGroupRename_events.json +4 -0
  48. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexMultiGroupRename_rules.json +6 -0
  49. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexNonNamedFullMatch_events.json +4 -0
  50. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexNonNamedFullMatch_rules.json +6 -0
  51. package/analyticsUtils/__tests__/fixtures/index.js +20 -0
  52. package/analyticsUtils/analyticsMapper.ts +4 -1
  53. package/analyticsUtils/playerAnalyticsTracker.ts +26 -3
  54. package/appUtils/HooksManager/index.ts +12 -8
  55. package/appUtils/contextKeysManager/__tests__/getKey/failure.test.ts +1 -1
  56. package/appUtils/contextKeysManager/__tests__/removeKey/failure.test.ts +1 -1
  57. package/appUtils/contextKeysManager/__tests__/setKey/failure/invalidKey.test.ts +4 -4
  58. package/appUtils/contextKeysManager/index.ts +1 -1
  59. package/appUtils/contextKeysManager/utils/index.ts +38 -25
  60. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +143 -53
  61. package/appUtils/playerManager/OverlayObserver/__tests__/liveContent.test.ts +205 -0
  62. package/appUtils/playerManager/OverlayObserver/__tests__/utils.test.ts +49 -0
  63. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.android.tv.ts +4 -0
  64. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ios.tv.ts +4 -0
  65. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ts +11 -0
  66. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.web.ts +4 -0
  67. package/appUtils/playerManager/OverlayObserver/utils.ts +54 -20
  68. package/appUtils/playerManager/__tests__/playerContent.test.ts +403 -0
  69. package/appUtils/playerManager/__tests__/playerFactory.test.ts +1 -1
  70. package/appUtils/playerManager/__tests__/playerNative.test.ts +38 -0
  71. package/appUtils/playerManager/__tests__/usePlayerContent.test.tsx +64 -0
  72. package/appUtils/playerManager/{conts.ts → const.ts} +20 -0
  73. package/appUtils/playerManager/index.ts +1 -1
  74. package/appUtils/playerManager/player.ts +115 -3
  75. package/appUtils/playerManager/playerFactory.ts +1 -1
  76. package/appUtils/playerManager/playerNative.ts +6 -4
  77. package/appUtils/playerManager/usePlayerContent.tsx +43 -0
  78. package/appUtils/playerManager/usePlayerControllerSetup.tsx +1 -1
  79. package/appUtils/playerManager/userLanguagePreference.ts +1 -1
  80. package/arrayUtils/__tests__/{anyThruthy.test.ts → anyTruthy.test.ts} +8 -0
  81. package/arrayUtils/__tests__/arrayUtils.test.ts +165 -108
  82. package/arrayUtils/__tests__/isEmptyArray.test.ts +11 -0
  83. package/arrayUtils/__tests__/isFilledArray.test.ts +12 -0
  84. package/arrayUtils/__tests__/isFirst.test.ts +17 -0
  85. package/arrayUtils/__tests__/isIndexInRange.test.ts +14 -0
  86. package/arrayUtils/__tests__/isLast.test.ts +31 -0
  87. package/arrayUtils/__tests__/makeListOf.test.ts +31 -0
  88. package/arrayUtils/__tests__/makeListOfIndexes.test.ts +20 -0
  89. package/arrayUtils/__tests__/reorderByIds.test.ts +50 -0
  90. package/arrayUtils/__tests__/sample.test.ts +61 -0
  91. package/arrayUtils/index.ts +136 -20
  92. package/bottomSheet/__tests__/scrollContext.test.tsx +35 -0
  93. package/bottomSheet/index.ts +17 -0
  94. package/cellUtils/index.ts +33 -8
  95. package/colorUtils/__tests__/isTransparentColor.test.ts +76 -0
  96. package/colorUtils/__tests__/isValidColor.test.ts +70 -0
  97. package/colorUtils/index.ts +50 -0
  98. package/configurationUtils/__tests__/manifestKeyParser.test.ts +21 -0
  99. package/configurationUtils/__tests__/modalBlocksParser.test.ts +260 -0
  100. package/configurationUtils/manifestKeyParser.ts +50 -10
  101. package/configurationUtils/modalBlocksParser.ts +296 -0
  102. package/entryActions/__tests__/buildEntryActions.test.ts +156 -0
  103. package/entryActions/aliasPresentation.ts +124 -0
  104. package/entryActions/buildEntryActions.ts +166 -0
  105. package/entryActions/index.ts +17 -0
  106. package/entryActions/types.ts +39 -0
  107. package/manifestUtils/__tests__/player.audioControls.test.js +158 -0
  108. package/manifestUtils/_internals/index.js +14 -3
  109. package/manifestUtils/defaultManifestConfigurations/generalContent.js +35 -0
  110. package/manifestUtils/defaultManifestConfigurations/player.js +349 -20
  111. package/manifestUtils/fieldUtils/__tests__/fieldUtils.test.js +84 -0
  112. package/manifestUtils/fieldUtils/index.js +125 -0
  113. package/manifestUtils/index.js +3 -0
  114. package/manifestUtils/keys.js +9 -0
  115. package/manifestUtils/mobileAction/button/index.js +16 -0
  116. package/manifestUtils/mobileAction/container/index.js +3 -1
  117. package/manifestUtils/mobileAction/groups/defaults.js +3 -1
  118. package/manifestUtils/modalBlocks.js +304 -0
  119. package/manifestUtils/platformIsTV.js +1 -0
  120. package/modalState/ContentViewModel.ts +113 -0
  121. package/modalState/EditableCollection.ts +17 -0
  122. package/modalState/EditableCollectionRegistry.ts +51 -0
  123. package/modalState/ModalOrchestrator.ts +211 -0
  124. package/modalState/RemoteEditableCollection.ts +227 -0
  125. package/modalState/__tests__/ContentViewModel.editable.test.ts +69 -0
  126. package/modalState/__tests__/ContentViewModel.test.ts +165 -0
  127. package/modalState/__tests__/EditableCollectionRegistry.test.ts +112 -0
  128. package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +47 -0
  129. package/modalState/__tests__/RemoteEditableCollection.test.ts +326 -0
  130. package/modalState/__tests__/index.test.ts +30 -1
  131. package/modalState/__tests__/useBottomSheetContent.test.ts +349 -0
  132. package/modalState/index.ts +35 -83
  133. package/modalState/store.ts +102 -0
  134. package/modalState/types.ts +159 -0
  135. package/modalState/useBottomSheetContent.ts +104 -0
  136. package/numberUtils/__tests__/isMinusZero.test.ts +20 -0
  137. package/numberUtils/__tests__/isZero.test.ts +27 -0
  138. package/numberUtils/__tests__/requireNumber.test.ts +50 -0
  139. package/numberUtils/__tests__/toNumber.test.ts +27 -0
  140. package/numberUtils/__tests__/toNumberWithDefault.test.ts +64 -0
  141. package/numberUtils/__tests__/toNumberWithDefaultZero.test.ts +48 -0
  142. package/numberUtils/index.ts +27 -8
  143. package/package.json +2 -2
  144. package/pipesUtils/__tests__/buildUrlWithQuery.test.ts +33 -0
  145. package/pipesUtils/__tests__/withPipesEndpoint.test.tsx +56 -0
  146. package/pipesUtils/index.ts +1 -0
  147. package/pipesUtils/withPipesEndpoint.tsx +54 -0
  148. package/playerUtils/__tests__/contentDataKeys.test.ts +297 -0
  149. package/playerUtils/__tests__/resolvePlayerActions.test.ts +138 -0
  150. package/playerUtils/__tests__/resolvePlayerTitleSubtitle.test.ts +180 -0
  151. package/playerUtils/contentDataKeys.ts +134 -0
  152. package/playerUtils/index.ts +58 -15
  153. package/playerUtils/isAudioItem.ts +26 -0
  154. package/playerUtils/resolvePlayerActions.ts +71 -0
  155. package/playerUtils/resolvePlayerTitleSubtitle.ts +76 -0
  156. package/reactHooks/actions/index.ts +117 -2
  157. package/reactHooks/cell-click/index.ts +18 -10
  158. package/reactHooks/feed/__mocks__/useMarkPipesDataStale.ts +4 -0
  159. package/reactHooks/feed/__tests__/useInflatedUrl.test.tsx +25 -0
  160. package/reactHooks/feed/index.ts +5 -1
  161. package/reactHooks/feed/useBatchLoading.ts +9 -1
  162. package/reactHooks/feed/{usePipesCacheReset.ts → useMarkPipesDataStale.ts} +12 -4
  163. package/reactHooks/index.ts +2 -0
  164. package/reactHooks/layout/index.ts +1 -1
  165. package/reactHooks/navigation/__mocks__/index.ts +4 -0
  166. package/reactHooks/navigation/__tests__/useIsScreenActive.test.ts +42 -0
  167. package/reactHooks/navigation/index.ts +1 -1
  168. package/reactHooks/navigation/useIsScreenActive.ts +29 -8
  169. package/reactHooks/state/useComponentScreenState.ts +1 -1
  170. package/reactHooks/usePluginConfiguration.ts +4 -1
  171. package/reactHooks/utils/__tests__/index.test.js +22 -2
  172. package/reactHooks/utils/index.ts +13 -2
  173. package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +22 -4
  174. package/riverComponetsMeasurementProvider/index.tsx +12 -8
  175. package/stringUtils/__tests__/stringUtils.test.js +42 -0
  176. package/stringUtils/index.ts +2 -2
  177. package/uiActionsRegistrator/__tests__/resolveActionIdentifiers.test.ts +93 -0
  178. package/uiActionsRegistrator/__tests__/subscribe.test.ts +107 -0
  179. package/uiActionsRegistrator/__tests__/usableActionItems.test.ts +52 -0
  180. package/uiActionsRegistrator/index.ts +25 -0
  181. package/uiActionsRegistrator/registry.ts +335 -0
  182. package/uiActionsRegistrator/resolveActionIdentifiers.ts +100 -0
  183. package/uiActionsRegistrator/usableActionItems.ts +66 -0
  184. package/zappFrameworkUtils/__tests__/localStorageHelper.test.ts +146 -0
  185. package/zappFrameworkUtils/localStorageHelper.ts +19 -15
  186. package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +0 -56
  187. package/playerUtils/__tests__/getPlayerActionButtons.test.ts +0 -54
  188. package/playerUtils/getPlayerActionButtons.ts +0 -17
  189. package/reactHooks/feed/__mocks__/usePipesCacheReset.ts +0 -1
  190. /package/reactHooks/actions/__tests__/{index.test.js → index.test.tsx} +0 -0
@@ -0,0 +1,87 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { ActionResult } from "../ActionExecutor";
3
+ import { ActionHandler } from "../types";
4
+ import { postEvent } from "../../reactHooks/useSubscriberFor";
5
+
6
+ export const CONFIRMATION_TOAST_SOURCE = "confirmation";
7
+
8
+ export const CONFIRMATION_TOAST_DEFAULT_TIMEOUT = 1000;
9
+
10
+ /**
11
+ * Shows a mobile confirmation toast with Theme defaults from
12
+ * `Confirmation Toast / Message` in the base theme plugin.
13
+ *
14
+ * This action is confirmation-only by design: it always stamps
15
+ * `source: "confirmation"` (so Theme confirmation styles apply) and defaults
16
+ * `timeout` to 1000 ms. Non-confirmation toasts (e.g. Offline Experience)
17
+ * must post on the shared `"showToast"` event bus directly and omit `source`.
18
+ * Callers may override individual style fields; Theme supplies the rest.
19
+ *
20
+ * @example From React via ActionExecutorContext
21
+ * ```tsx
22
+ * import React, { useContext } from "react";
23
+ * import { ActionExecutorContext } from "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutorContext";
24
+ *
25
+ * function QueueButton() {
26
+ * const { handleAction } = useContext(ActionExecutorContext);
27
+ *
28
+ * const onPress = () => {
29
+ * void handleAction({
30
+ * type: "showToast",
31
+ * options: { message: "Added to queue" },
32
+ * });
33
+ * };
34
+ *
35
+ * return <Button onPress={onPress} title="Add to queue" />;
36
+ * }
37
+ * ```
38
+ *
39
+ * @example From code via the actionExecutor singleton
40
+ * ```ts
41
+ * import { actionExecutor } from "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutor";
42
+ *
43
+ * await actionExecutor.handleAction({
44
+ * type: "showToast",
45
+ * options: {
46
+ * message: "Playlist created",
47
+ * style: { backgroundColor: "#00AA55" }, // optional partial override
48
+ * },
49
+ * });
50
+ * ```
51
+ *
52
+ * @example From entry / pipes actions JSON
53
+ * ```json
54
+ * {
55
+ * "type": "showToast",
56
+ * "options": {
57
+ * "message": "Item removed from playlist"
58
+ * }
59
+ * }
60
+ * ```
61
+ */
62
+ export interface ShowToastActionOptions {
63
+ id?: string;
64
+ message?: string;
65
+ extraMessage?: string;
66
+ style?: any;
67
+ timeout?: number;
68
+ }
69
+
70
+ export const showToastAction: ActionHandler<ShowToastActionOptions> = async (
71
+ action
72
+ ): Promise<ActionResult> => {
73
+ const options = action?.options;
74
+
75
+ postEvent("showToast", [
76
+ {
77
+ id: options?.id,
78
+ message: options?.message,
79
+ extraMessage: options?.extraMessage,
80
+ style: options?.style,
81
+ timeout: options?.timeout ?? CONFIRMATION_TOAST_DEFAULT_TIMEOUT,
82
+ source: CONFIRMATION_TOAST_SOURCE,
83
+ },
84
+ ]);
85
+
86
+ return ActionResult.Success;
87
+ };
@@ -0,0 +1,40 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
3
+ import * as QuickBrickManager from "@applicaster/zapp-react-native-bridge/QuickBrick";
4
+ import { QUICK_BRICK_EVENTS } from "@applicaster/zapp-react-native-bridge/QuickBrick";
5
+ import { ACTIVE_LAYOUT_ID_STORAGE_KEY } from "@applicaster/quick-brick-core/App/remoteContextReloader/consts";
6
+ import { ActionResult } from "../ActionExecutor";
7
+ import { ActionHandler } from "../types";
8
+ import { createLogger } from "../../logger";
9
+
10
+ const { log_info } = createLogger({
11
+ subsystem: "ActionExecutorContext",
12
+ category: "General",
13
+ });
14
+
15
+ /**
16
+ * Options for the switchLayout action.
17
+ */
18
+ export interface SwitchLayoutOptions {
19
+ /** The ID of the layout to switch to */
20
+ layoutId: string;
21
+ }
22
+
23
+ /**
24
+ * Switches the active layout and triggers an app reload.
25
+ * Saves the new layout ID to local storage before reloading.
26
+ */
27
+ export const switchLayoutAction: ActionHandler<SwitchLayoutOptions> = async (
28
+ action
29
+ ): Promise<ActionResult> => {
30
+ log_info("handleAction: switchLayout event");
31
+
32
+ await localStorage.setItem(
33
+ ACTIVE_LAYOUT_ID_STORAGE_KEY,
34
+ action.options.layoutId
35
+ );
36
+
37
+ QuickBrickManager.sendQuickBrickEvent(QUICK_BRICK_EVENTS.FORCE_APP_RELOAD);
38
+
39
+ return ActionResult.Success;
40
+ };
@@ -2,3 +2,28 @@ export const TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT =
2
2
  "action.localStorageToggleFlag.maxItemsReached";
3
3
 
4
4
  export const ACTION_EXECUTOR_EVENT_SOURCE = "ActionExecutor";
5
+
6
+ export const ACTION_TYPES = {
7
+ OPEN_BOTTOM_SHEET: "openBottomSheet",
8
+ DISMISS_BOTTOM_SHEET: "dismissBottomSheet",
9
+ PRESENT_SUB_MENU: "presentSubMenu",
10
+ SEND_CLOUD_EVENT: "sendCloudEvent",
11
+ NAVIGATE_TO_SCREEN: "navigateToScreen",
12
+ GO_BACK: "goBack",
13
+ GO_HOME: "goHome",
14
+ SHOW_TOAST: "showToast",
15
+ LOCAL_STORAGE_SET: "localStorageSet",
16
+ LOCAL_STORAGE_REMOVE: "localStorageRemove",
17
+ LOCAL_STORAGE_TOGGLE_FLAG: "localStorageToggleFlag",
18
+ SESSION_STORAGE_SET: "sessionStorageSet",
19
+ SESSION_STORAGE_REMOVE: "sessionStorageRemove",
20
+ SESSION_STORAGE_TOGGLE_FLAG: "sessionStorageToggleFlag",
21
+ REFRESH_COMPONENT: "refreshComponent",
22
+ SWITCH_LAYOUT: "switchLayout",
23
+ APP_RESTART: "appRestart",
24
+ CONFIRM_DIALOG: "confirmDialog",
25
+ SCREEN_SET_VARIABLE: "screenSetVariable",
26
+ SCREEN_TOGGLE_FLAG: "screenToggleFlag",
27
+ } as const;
28
+
29
+ export type KnownActionType = (typeof ACTION_TYPES)[keyof typeof ACTION_TYPES];
@@ -159,13 +159,13 @@ export const decorateFeed = (feed: ZappFeed) => {
159
159
 
160
160
  const decoratedFeed = R.clone(feed);
161
161
 
162
- const isSingleSelect =
163
- (feed.extensions?.preference_editor_options?.select_mode ||
164
- feed.extensions?.behavior?.select_mode) === "single";
162
+ const selectMode =
163
+ feed.extensions?.preference_editor_options?.select_mode ||
164
+ feed.extensions?.behavior?.select_mode;
165
165
 
166
- if (isSingleSelect) {
166
+ if (selectMode === "single") {
167
167
  return makeSingleSelect(feed, key, decoratedFeed);
168
- } else {
169
- return makeMultiSelect(feed, key, decoratedFeed);
170
168
  }
169
+
170
+ return makeMultiSelect(feed, key, decoratedFeed);
171
171
  };
@@ -0,0 +1,59 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { ActionResult } from "./ActionExecutor";
3
+ import { useScreenStateStore } from "../reactHooks/navigation/useScreenStateStore";
4
+
5
+ /**
6
+ * Base context object passed to action handlers during execution.
7
+ * Contains references to the current entry, screen, and other execution state.
8
+ */
9
+ export interface ActionExecutionContext {
10
+ /** The entry associated with this action (e.g., the item that was tapped) */
11
+ entry?: ZappEntry;
12
+
13
+ /** The current screen/river data */
14
+ screenData?: ZappRiver;
15
+
16
+ /** The entry that defines the screen (if screen was opened from an entry) */
17
+ screenEntry?: ZappEntry;
18
+
19
+ /** The UI component that triggered the action.
20
+ * From UIComponentContext as `{ ...component, parent }`.
21
+ */
22
+ component?: ZappUIComponent & { parent?: ZappUIComponent };
23
+
24
+ /** The route identifier for the current screen */
25
+ screenRoute?: string;
26
+
27
+ /** The screen state store for managing screen-level state (Zustand store) */
28
+ screenStateStore?: ReturnType<typeof useScreenStateStore>;
29
+
30
+ /** Context entry for additional data */
31
+ entryContext?: ZappEntry;
32
+
33
+ /** Callback function for action completion */
34
+ callback?: (result: { success: boolean; error: any; abort: boolean }) => void;
35
+
36
+ screenState?: Record<any, any>;
37
+ }
38
+
39
+ /**
40
+ * Type for action handler functions.
41
+ * Handlers receive the action (which may have typed options) and execution context.
42
+ *
43
+ * @template _TOptions - Optional type hint for the action's options object (for documentation/intellisense)
44
+ * @param action - The action to execute
45
+ * @param context - The execution context
46
+ * @returns A promise that resolves to the action result
47
+ */
48
+ export type ActionHandler<_TOptions = any> = (
49
+ action: ActionType,
50
+ context?: ActionExecutionContext
51
+ ) => Promise<ActionResult>;
52
+
53
+ /**
54
+ * Factory function that creates an action handler.
55
+ * Used for actions that need to capture dependencies at registration time.
56
+ */
57
+ export type ActionHandlerFactory<_TOptions = any> = (
58
+ ...dependencies: any[]
59
+ ) => ActionHandler<_TOptions>;
@@ -6,9 +6,9 @@ import { postAnalyticEvent } from "../manager";
6
6
  import { ANALYTICS_CORE_EVENTS } from "../events";
7
7
 
8
8
  type AnalyticsDefaultHelperProperties = {
9
- analyticsScreenData: AnalyticsScreenProperties;
9
+ analyticsScreenData?: AnalyticsScreenProperties;
10
10
  extraProps: any;
11
- props;
11
+ props?: any;
12
12
  };
13
13
 
14
14
  export const sendMenuClickEvent = ({
@@ -8,7 +8,7 @@ import {
8
8
  } from "../appUtils/playerManager";
9
9
  import { Player } from "../appUtils/playerManager/player";
10
10
  import { AnalyticPlayerListener } from "./AnalyticPlayerListener";
11
- import { PlayerRole } from "../appUtils/playerManager/conts";
11
+ import { PlayerRole } from "../appUtils/playerManager/const";
12
12
 
13
13
  enum PlayerAnalyticsTrackerType {
14
14
  PlayerAnalyticsTracker = "PlayerAnalyticsTracker",
@@ -23,6 +23,15 @@ class PlayerAnalyticsTrackerFactory {
23
23
  return new PlayerAnalyticsTracker();
24
24
  }
25
25
  }
26
+
27
+ onPlayerRegistered(tracker: PlayerAnalyticsTrackerI, player: Player) {
28
+ tracker.setPlayer(player);
29
+ tracker.onPlayerPresented();
30
+ }
31
+
32
+ onPlayerUnRegistered(tracker?: PlayerAnalyticsTrackerI) {
33
+ tracker?.onPlayerClosed();
34
+ }
26
35
  }
27
36
 
28
37
  export class PlayerAnalyticsManager implements PlayerLifecycleListener {
@@ -70,7 +79,7 @@ export class PlayerAnalyticsManager implements PlayerLifecycleListener {
70
79
  }
71
80
 
72
81
  const tracker = this.getTracker(player.playerId);
73
- tracker.setPlayer(player);
82
+ this.trackerFactory.onPlayerRegistered(tracker, player);
74
83
 
75
84
  const analyticsListener = new AnalyticPlayerListener({
76
85
  analyticsTracker: tracker,
@@ -84,6 +93,7 @@ export class PlayerAnalyticsManager implements PlayerLifecycleListener {
84
93
  };
85
94
 
86
95
  onUnRegistered = (player: Player) => {
96
+ this.trackerFactory.onPlayerUnRegistered(this.trackers[player.playerId]);
87
97
  player.removeListener(AnalyticPlayerListener.analyticsListenerID);
88
98
  delete this.trackers[player.playerId];
89
99
  };
@@ -74,4 +74,39 @@ describe("Analytics Mapper", () => {
74
74
  const rules = fixtures.ACPEventRules;
75
75
  await setConfigRunMapTest(rules, fixtures.ACPEventEvents);
76
76
  });
77
+
78
+ it("Does not let an ignore rule short-circuit later events", async () => {
79
+ await setConfigRunMapTest(
80
+ fixtures.ignoreOrderingRules,
81
+ fixtures.ignoreOrderingEvents
82
+ );
83
+ });
84
+
85
+ it("Keeps the original name when rename is empty", async () => {
86
+ await setConfigRunMapTest(
87
+ fixtures.emptyRenameRules,
88
+ fixtures.emptyRenameEvents
89
+ );
90
+ });
91
+
92
+ it("Renames via a regex with no named groups", async () => {
93
+ await setConfigRunMapTest(
94
+ fixtures.regexNonNamedFullMatchRules,
95
+ fixtures.regexNonNamedFullMatchEvents
96
+ );
97
+ });
98
+
99
+ it("Substitutes every named group in a regex rename", async () => {
100
+ await setConfigRunMapTest(
101
+ fixtures.regexMultiGroupRenameRules,
102
+ fixtures.regexMultiGroupRenameEvents
103
+ );
104
+ });
105
+
106
+ it("Does not fall back to event match when a regex rule does not match", async () => {
107
+ await setConfigRunMapTest(
108
+ fixtures.regexEventNoFallbackRules,
109
+ fixtures.regexEventNoFallbackEvents
110
+ );
111
+ });
77
112
  });
@@ -23,7 +23,7 @@
23
23
  "second": {
24
24
  "name": "EventName",
25
25
  "params": {
26
- "acp": 1
26
+ "acp": "1"
27
27
  }
28
28
  }
29
29
  }
@@ -12,4 +12,4 @@
12
12
  }
13
13
  ],
14
14
  "strategy": "allowUnlisted"
15
- }
15
+ }
@@ -0,0 +1,4 @@
1
+ [
2
+ { "first": { "name": "keep_me", "params": {} },
3
+ "second": { "name": "keep_me", "params": {} } }
4
+ ]
@@ -0,0 +1,6 @@
1
+ {
2
+ "rules": [
3
+ { "event": "keep_me", "ignore": false, "rename": "", "strategy": "allowUnlisted" }
4
+ ],
5
+ "strategy": "allowUnlisted"
6
+ }
@@ -2,17 +2,11 @@
2
2
  {
3
3
  "first": {
4
4
  "name": "Screen viewed: Ads & redirects",
5
- "params": {
6
- "ignored_param": "removed_value",
7
- "kept_param": "kept_value"
8
- }
5
+ "params": {}
9
6
  },
10
7
  "second": {
11
8
  "name": "Screen Ads & redirects",
12
- "params": {
13
- "ignored_param": "removed_value",
14
- "kept_param": "kept_value"
15
- }
9
+ "params": {}
16
10
  }
17
11
  }
18
- ]
12
+ ]
@@ -0,0 +1,18 @@
1
+ [
2
+ {
3
+ "first": {
4
+ "name": "screen_view",
5
+ "params": {}
6
+ },
7
+ "second": {
8
+ "name": "page_view",
9
+ "params": {}
10
+ }
11
+ },
12
+ {
13
+ "first": {
14
+ "name": "player_presented",
15
+ "params": {}
16
+ }
17
+ }
18
+ ]
@@ -0,0 +1,16 @@
1
+ {
2
+ "rules": [
3
+ {
4
+ "event": "player_presented",
5
+ "ignore": true,
6
+ "strategy": "allowUnlisted"
7
+ },
8
+ {
9
+ "event": "screen_view",
10
+ "ignore": false,
11
+ "rename": "page_view",
12
+ "strategy": "allowUnlisted"
13
+ }
14
+ ],
15
+ "strategy": "allowUnlisted"
16
+ }
@@ -0,0 +1,4 @@
1
+ [
2
+ { "first": { "name": "my_event", "params": {} },
3
+ "second": { "name": "my_event", "params": {} } }
4
+ ]
@@ -0,0 +1,6 @@
1
+ {
2
+ "rules": [
3
+ { "event": "my_event", "ignore": false, "rename": "should_not_apply", "regex": "wont_match_.*", "strategy": "allowUnlisted" }
4
+ ],
5
+ "strategy": "allowUnlisted"
6
+ }
@@ -0,0 +1,4 @@
1
+ [
2
+ { "first": { "name": "play-video", "params": {} },
3
+ "second": { "name": "play_video", "params": {} } }
4
+ ]
@@ -0,0 +1,6 @@
1
+ {
2
+ "rules": [
3
+ { "ignore": false, "rename": "$<first>_$<second>", "regex": "(?<first>[a-z]+)-(?<second>[a-z]+)", "strategy": "allowUnlisted" }
4
+ ],
5
+ "strategy": "allowUnlisted"
6
+ }
@@ -0,0 +1,4 @@
1
+ [
2
+ { "first": { "name": "screen_view", "params": {} },
3
+ "second": { "name": "renamed", "params": {} } }
4
+ ]
@@ -0,0 +1,6 @@
1
+ {
2
+ "rules": [
3
+ { "ignore": false, "rename": "renamed", "regex": "screen_view", "strategy": "allowUnlisted" }
4
+ ],
5
+ "strategy": "allowUnlisted"
6
+ }
@@ -14,6 +14,16 @@ import blockUnlistedEventEvents from "./analytics_mapper_testBlockUnlistedEvents
14
14
  import blockUnlistedEventRules from "./analytics_mapper_testBlockUnlistedEvents_rules.json";
15
15
  import ACPEventEvents from "./analytics_mapper_testACP_events.json";
16
16
  import ACPEventRules from "./analytics_mapper_testACP_rules.json";
17
+ import emptyRenameRules from "./analytics_mapper_testEmptyRenameKeepsName_rules.json";
18
+ import emptyRenameEvents from "./analytics_mapper_testEmptyRenameKeepsName_events.json";
19
+ import ignoreOrderingRules from "./analytics_mapper_testIgnoreOrdering_rules.json";
20
+ import ignoreOrderingEvents from "./analytics_mapper_testIgnoreOrdering_events.json";
21
+ import regexEventNoFallbackRules from "./analytics_mapper_testRegexEventNoFallback_rules.json";
22
+ import regexEventNoFallbackEvents from "./analytics_mapper_testRegexEventNoFallback_events.json";
23
+ import regexMultiGroupRenameRules from "./analytics_mapper_testRegexMultiGroupRename_rules.json";
24
+ import regexMultiGroupRenameEvents from "./analytics_mapper_testRegexMultiGroupRename_events.json";
25
+ import regexNonNamedFullMatchRules from "./analytics_mapper_testRegexNonNamedFullMatch_rules.json";
26
+ import regexNonNamedFullMatchEvents from "./analytics_mapper_testRegexNonNamedFullMatch_events.json";
17
27
 
18
28
  export const fixtures = {
19
29
  renameRules,
@@ -32,4 +42,14 @@ export const fixtures = {
32
42
  blockUnlistedEventRules,
33
43
  ACPEventEvents,
34
44
  ACPEventRules,
45
+ emptyRenameRules,
46
+ emptyRenameEvents,
47
+ ignoreOrderingRules,
48
+ ignoreOrderingEvents,
49
+ regexEventNoFallbackRules,
50
+ regexEventNoFallbackEvents,
51
+ regexMultiGroupRenameRules,
52
+ regexMultiGroupRenameEvents,
53
+ regexNonNamedFullMatchRules,
54
+ regexNonNamedFullMatchEvents,
35
55
  };
@@ -76,7 +76,10 @@ class StateHolder {
76
76
  delete this.pluckedParams[prefix];
77
77
  }
78
78
 
79
- return this._cap?.[suffix];
79
+ // Stringify so values match the native iOS/Android mappers (which coerce
80
+ // analyticsCustomProperties values to strings) — keeps GA4 data consistent
81
+ // across web/LG/Samsung and native platforms.
82
+ return this._cap?.[suffix]?.toString() ?? null;
80
83
  }
81
84
 
82
85
  private async getFromLocalAndSession(
@@ -4,8 +4,14 @@ import { isTrue } from "@applicaster/zapp-react-native-utils/booleanUtils";
4
4
  import { postAnalyticEvent } from "./manager";
5
5
  import { isLive } from "../playerUtils";
6
6
  import { extensionsEvents } from "./AnalyticsEvents/helper";
7
- import { AD_EVENT, EVENT_TYPES, PLAYER_DISPLAY_STATES } from "./events";
7
+ import {
8
+ AD_EVENT,
9
+ EVENT_TYPES,
10
+ GENERAL_EVENT,
11
+ PLAYER_DISPLAY_STATES,
12
+ } from "./events";
8
13
  import { Player } from "../appUtils/playerManager/player";
14
+ import { isNil } from "@applicaster/zapp-react-native-utils/utils";
9
15
 
10
16
  export interface PlayerAnalyticsTrackerI {
11
17
  handleAnalyticEvent(
@@ -13,6 +19,8 @@ export interface PlayerAnalyticsTrackerI {
13
19
  eventData?: QuickBrickPlayer.EventData
14
20
  ): void;
15
21
  setPlayer(player: Player): void;
22
+ onPlayerPresented(): void;
23
+ onPlayerClosed(): void;
16
24
  }
17
25
 
18
26
  export class PlayerAnalyticsTracker implements PlayerAnalyticsTrackerI {
@@ -26,6 +34,15 @@ export class PlayerAnalyticsTracker implements PlayerAnalyticsTrackerI {
26
34
  this.player = player;
27
35
  }
28
36
 
37
+ onPlayerPresented() {
38
+ this.handleAnalyticEvent(GENERAL_EVENT.player_presented);
39
+ }
40
+
41
+ onPlayerClosed() {
42
+ this.handleAnalyticEvent(GENERAL_EVENT.session_end);
43
+ this.handleAnalyticEvent(GENERAL_EVENT.player_closed);
44
+ }
45
+
29
46
  isAdBreak(event: string): boolean {
30
47
  const adBreakEvents = [
31
48
  AD_EVENT.ad_break_start,
@@ -180,7 +197,8 @@ export class PlayerAnalyticsTracker implements PlayerAnalyticsTrackerI {
180
197
  this.entry?.extensions?.free || this.entry?.extensions?.isFree;
181
198
 
182
199
  const title = this.entry?.title;
183
- const streamType = isLive(this.entry) ? "live" : "vod"; // Todo: determine other types, channel, podcast, aod
200
+ const isStreamLive = isLive(this.entry);
201
+ const streamType = isStreamLive ? "live" : "vod"; // Todo: determine other types, channel, podcast, aod
184
202
 
185
203
  const currentPosition = this.getCurrentPosition(
186
204
  event,
@@ -201,6 +219,7 @@ export class PlayerAnalyticsTracker implements PlayerAnalyticsTrackerI {
201
219
  );
202
220
 
203
221
  const playerState = this.getPlayerState();
222
+ const playerType = this.player?.playerPluginId;
204
223
 
205
224
  const analyticsCustomProperties = extensionsEvents(this.entry?.extensions);
206
225
 
@@ -210,7 +229,11 @@ export class PlayerAnalyticsTracker implements PlayerAnalyticsTrackerI {
210
229
  name: title,
211
230
  media_type: mediaType,
212
231
  stream_type: streamType,
213
- duration: mediaDuration,
232
+ player_type: playerType,
233
+ // We do not pass duration for live streams anymore (it's now seekableDuration),
234
+ // but we can't mark it as optional in Analytics Mapper yet,
235
+ // so we set it to -1 for live streams
236
+ duration: isStreamLive && isNil(mediaDuration) ? -1 : mediaDuration,
214
237
  current_position: currentPosition,
215
238
  player_state: playerState,
216
239
  stream_format: contentType,
@@ -87,7 +87,7 @@ export function HooksManager({
87
87
  }: HookManagerArgs): HookManager {
88
88
  hooksManagerLogger.addContext({ targetScreenId: targetScreen.id });
89
89
 
90
- function logHookEvent(func, message, data) {
90
+ function logHookEvent(func, message, data = {}) {
91
91
  func({
92
92
  message,
93
93
  data: __DEV__ ? data : null,
@@ -344,7 +344,6 @@ export function HooksManager({
344
344
  `hookCallback: send app to background, cancelled flow blocker hook ${hookPlugin.identifier} on home screen`,
345
345
  {
346
346
  payload,
347
- hook: hookPlugin,
348
347
  }
349
348
  );
350
349
 
@@ -356,17 +355,13 @@ export function HooksManager({
356
355
  `hookCallback: hook successfully finished: ${hookPlugin.identifier}`,
357
356
  {
358
357
  payload,
359
- hook: hookPlugin,
360
358
  }
361
359
  );
362
360
 
363
361
  if (!callback) {
364
362
  logHookEvent(
365
- hooksManagerLogger.warn,
366
- `hookCallback: ${hookPlugin.identifier} is missing \`callback\`, using hookCallback(default one)`,
367
- {
368
- hookPlugin,
369
- }
363
+ hooksManagerLogger.debug,
364
+ `hookCallback: ${hookPlugin.identifier} is missing \`callback\`, using hookCallback(default one)`
370
365
  );
371
366
 
372
367
  callback = hookCallback;
@@ -503,6 +498,15 @@ export function HooksManager({
503
498
  presentUI
504
499
  );
505
500
  } catch (e) {
501
+ // Without this the failure is invisible: the hook stops right after the
502
+ // "Executing hook" line, with nothing in the log explaining why and no
503
+ // remaining hook ever running.
504
+ logHookEvent(
505
+ hooksManagerLogger.error,
506
+ `runInBackground: hook ${hookPlugin.identifier} threw: ${e?.message}`,
507
+ { hook: hookPlugin, payload, error: e, stack: e?.stack }
508
+ );
509
+
506
510
  hookPlugin.setStateAndNotify(HOOKS_EVENTS.ERROR, {
507
511
  error: e,
508
512
  hookPlugin,
@@ -46,7 +46,7 @@ describe("Context Keys Manager - getKey", () => {
46
46
 
47
47
  expect(mockedLogger.warn).toHaveBeenCalledWith({
48
48
  message:
49
- "Provided key is not valid - expecing an object with namespace and key properties",
49
+ "Provided key is not valid - expecting an object with namespace and key properties",
50
50
  data: { key: invalidKey },
51
51
  });
52
52
 
@@ -47,7 +47,7 @@ describe("Context Keys Manager - removeKey", () => {
47
47
 
48
48
  expect(mockedLogger.warn).toHaveBeenCalledWith({
49
49
  message:
50
- "Provided key is not valid - expecing an object with namespace and key properties",
50
+ "Provided key is not valid - expecting an object with namespace and key properties",
51
51
  data: { key },
52
52
  });
53
53