@applicaster/zapp-react-native-utils 16.0.0-rc.125 → 16.0.0-rc.127
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/actionsExecutor/ActionExecutor.ts +2 -2
- package/actionsExecutor/ActionExecutorContext.tsx +2 -2
- package/actionsExecutor/__tests__/StorageActions.test.ts +98 -0
- package/actionsExecutor/__tests__/feedDecorator.test.ts +30 -0
- package/actionsExecutor/__tests__/screenToggleFlag.test.ts +90 -0
- package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +47 -0
- package/actionsExecutor/actions/appRestart.ts +2 -2
- package/actionsExecutor/actions/confirmDialog.ts +2 -2
- package/actionsExecutor/actions/dismissBottomSheet.ts +2 -2
- package/actionsExecutor/actions/goBack.ts +2 -2
- package/actionsExecutor/actions/goHome.ts +2 -2
- package/actionsExecutor/actions/navigateToScreen.ts +8 -2
- package/actionsExecutor/actions/openBottomSheet.ts +2 -2
- package/actionsExecutor/actions/presentScreen.ts +2 -2
- package/actionsExecutor/actions/refreshComponent.ts +2 -2
- package/actionsExecutor/actions/screenToggleFlag.ts +1 -3
- package/actionsExecutor/actions/sendCloudEvent.ts +2 -2
- package/actionsExecutor/actions/showAlert.ts +2 -2
- package/actionsExecutor/actions/switchLayout.ts +2 -2
- package/actionsExecutor/feedDecorator.ts +8 -2
- package/actionsExecutor/types.ts +7 -0
- package/analyticsUtils/__tests__/playerAnalyticsSafeguard.test.ts +62 -0
- package/analyticsUtils/logger.ts +9 -4
- package/analyticsUtils/playerAnalyticsTracker.ts +1 -0
- package/appUtils/HooksManager/logger.ts +5 -2
- package/appUtils/accessibilityManager/logger.ts +2 -4
- package/appUtils/accessibilityManager/utils.ts +1 -1
- package/appUtils/contextKeysManager/index.ts +2 -2
- package/appUtils/focusManager/index.ts +2 -2
- package/appUtils/focusManager/logger.ts +2 -2
- package/appUtils/focusManagerAux/index.ts +2 -2
- package/appUtils/orientationHelper.ts +2 -2
- package/appUtils/platform/platformUtils.ts +2 -2
- package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +1 -1
- package/appUtils/playerManager/index.ts +2 -2
- package/appUtils/playerManager/player.ts +1 -1
- package/appUtils/playerManager/playerNative.ts +1 -1
- package/appUtils/playerManager/usePlayNextOverlay.tsx +2 -2
- package/appUtils/playerManager/userCellPlayerMutedPreference.ts +1 -1
- package/appUtils/playerManager/userLanguagePreference.ts +1 -1
- package/cellUtils/logger.ts +2 -2
- package/domUtils/logger.ts +2 -2
- package/entryActions/buildEntryActions.ts +1 -1
- package/focusManager/logger.ts +1 -4
- package/headersUtils/index.ts +2 -2
- package/logger/__tests__/subsystems.test.ts +84 -0
- package/logger/index.ts +41 -7
- package/logger/subsystems.ts +83 -0
- package/modalState/EditableCollectionRegistry.ts +1 -1
- package/modalState/RemoteEditableCollection.ts +1 -1
- package/navigationUtils/index.ts +5 -2
- package/numberUtils/index.ts +2 -2
- package/package.json +2 -2
- package/playerUtils/PlayerTTS/PlayerTTS.ts +1 -1
- package/playerUtils/imaScriptDom.ts +1 -1
- package/playerUtils/useValidatePlayerConfig.tsx +1 -1
- package/pluginUtils/logger.ts +2 -2
- package/reactHooks/cell-click/__tests__/index.test.js +67 -1
- package/reactHooks/cell-click/index.ts +10 -2
- package/reactHooks/feed/__tests__/feedInvalidation.test.tsx +338 -0
- package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +8 -2
- package/reactHooks/feed/useBuildPipesUrl.ts +5 -2
- package/reactHooks/feed/useFeedLoader.tsx +30 -3
- package/reactHooks/feed/useLoadPipesDataDispatch.ts +12 -11
- package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +5 -2
- package/reactHooks/logger.ts +5 -2
- package/reactHooks/navigation/usePresentScreen.ts +2 -2
- package/reactHooks/player/TVSeekControlller/TVSeekController.ts +2 -2
- package/reactHooks/screen/useScreenData.ts +2 -2
- package/reactHooks/videoModal/hooks/useChangeOrientation.ts +1 -4
- package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +1 -1
- package/reactUtils/createContext/helpers.ts +2 -2
- package/reactUtils/logger.ts +2 -2
- package/riverComponetsMeasurementProvider/index.tsx +1 -1
- package/storage/ScreenSingleValueProvider.ts +1 -1
- package/storage/ScreenStateMultiSelectProvider.ts +1 -1
- package/storage/StorageMultiSelectProvider.ts +1 -1
- package/storage/StorageSingleSelectProvider.ts +1 -1
- package/stylesUtils/logger.ts +2 -2
- package/uiActionsRegistrator/registry.ts +1 -1
- package/uiActionsRegistrator/resolveActionIdentifiers.ts +1 -1
- package/uiActionsRegistrator/usableActionItems.ts +1 -1
- package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +2 -1
- package/zappFrameworkUtils/loginPluginUtils.ts +2 -1
- package/zappFrameworkUtils/presentPluginOneTime.ts +2 -1
|
@@ -42,8 +42,8 @@ import {
|
|
|
42
42
|
import { ACTION_TYPES } from "./consts";
|
|
43
43
|
|
|
44
44
|
export const { log_error, log_info, log_debug } = createLogger({
|
|
45
|
-
subsystem: "
|
|
46
|
-
category: "
|
|
45
|
+
subsystem: "core/actions",
|
|
46
|
+
category: "ActionExecutorContext",
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
export type ActionExecutorContextType = {
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ActionResult } from "../ActionExecutor";
|
|
2
|
+
import { localStorageToggleFlag } from "../StorageActions";
|
|
3
|
+
import { TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT } from "../consts";
|
|
4
|
+
import { postEvent } from "../../reactHooks/useSubscriberFor";
|
|
5
|
+
|
|
6
|
+
jest.mock("../ActionExecutorContext", () => ({
|
|
7
|
+
log_error: jest.fn(),
|
|
8
|
+
log_info: jest.fn(),
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
jest.mock("../../reactHooks/useSubscriberFor", () => ({
|
|
12
|
+
postEvent: jest.fn(),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
// In-memory stand-in for the storage-backed provider; the limit check under
|
|
16
|
+
// test lives in storageToggleFlag, not in the provider.
|
|
17
|
+
const mockStore: Record<string, string[]> = {};
|
|
18
|
+
|
|
19
|
+
jest.mock("../../storage/StorageMultiSelectProvider", () => ({
|
|
20
|
+
StorageMultiSelectProvider: {
|
|
21
|
+
getProvider: (keyNamespace: string) => ({
|
|
22
|
+
getSelectedAsync: async () => [...(mockStore[keyNamespace] ?? [])],
|
|
23
|
+
addItem: async (item: string) => {
|
|
24
|
+
mockStore[keyNamespace] = [...(mockStore[keyNamespace] ?? []), item];
|
|
25
|
+
},
|
|
26
|
+
removeItem: async (item: string) => {
|
|
27
|
+
mockStore[keyNamespace] = (mockStore[keyNamespace] ?? []).filter(
|
|
28
|
+
(it) => it !== item
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
const KEY = "user_preferences.teams";
|
|
36
|
+
|
|
37
|
+
// Entries of a team selection feed with explicit tap actions
|
|
38
|
+
// (localStorageToggleFlag with key and selector).
|
|
39
|
+
const teamEntry = (n: number) =>
|
|
40
|
+
({
|
|
41
|
+
id: `team-${n}`,
|
|
42
|
+
title: `Team ${n}`,
|
|
43
|
+
type: { value: "action" },
|
|
44
|
+
extensions: { tag: `TEAM ${n}` },
|
|
45
|
+
}) as unknown as ZappEntry;
|
|
46
|
+
|
|
47
|
+
const tapAction = (extraOptions = {}) =>
|
|
48
|
+
({
|
|
49
|
+
type: "localStorageToggleFlag",
|
|
50
|
+
options: { key: KEY, selector: "extensions.tag", ...extraOptions },
|
|
51
|
+
}) as unknown as ActionType;
|
|
52
|
+
|
|
53
|
+
const tapTeams = async (count: number, extraOptions = {}) => {
|
|
54
|
+
const results: ActionResult[] = [];
|
|
55
|
+
|
|
56
|
+
for (let n = 1; n <= count; n++) {
|
|
57
|
+
results.push(
|
|
58
|
+
await localStorageToggleFlag(
|
|
59
|
+
{ entry: teamEntry(n) },
|
|
60
|
+
tapAction(extraOptions)
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return results;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
describe("localStorageToggleFlag max_items", () => {
|
|
69
|
+
beforeEach(() => {
|
|
70
|
+
delete mockStore[KEY];
|
|
71
|
+
jest.clearAllMocks();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("blocks the 11th team when max_items is in the action options", async () => {
|
|
75
|
+
const results = await tapTeams(11, { max_items: "10" });
|
|
76
|
+
|
|
77
|
+
expect(results.slice(0, 10)).toEqual(Array(10).fill(ActionResult.Success));
|
|
78
|
+
expect(results[10]).toBe(ActionResult.Cancel);
|
|
79
|
+
expect(mockStore[KEY]).toHaveLength(10);
|
|
80
|
+
|
|
81
|
+
expect(postEvent).toHaveBeenCalledWith(
|
|
82
|
+
TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT,
|
|
83
|
+
[expect.objectContaining({ maxItems: "10", tag: "TEAM 11" })]
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("still lets a selected team be removed at the limit", async () => {
|
|
88
|
+
await tapTeams(10, { max_items: "10" });
|
|
89
|
+
|
|
90
|
+
const result = await localStorageToggleFlag(
|
|
91
|
+
{ entry: teamEntry(1) },
|
|
92
|
+
tapAction({ max_items: "10" })
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
expect(result).toBe(ActionResult.Success);
|
|
96
|
+
expect(mockStore[KEY]).toHaveLength(9);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -59,3 +59,33 @@ describe("decorateFeed", () => {
|
|
|
59
59
|
expect(decorated.entry[0].extensions.tap_actions).toBeUndefined();
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
|
+
|
|
63
|
+
describe("decorateFeed max_items", () => {
|
|
64
|
+
const toggleAction = (feed: ZappFeed) =>
|
|
65
|
+
decorateFeed(feed).entry[0].extensions.tap_actions.actions[0];
|
|
66
|
+
|
|
67
|
+
it.each([
|
|
68
|
+
["screen", "screenToggleFlag"],
|
|
69
|
+
["session", "sessionStorageToggleFlag"],
|
|
70
|
+
["ctx", "localStorageToggleFlag"],
|
|
71
|
+
])("passes max_items to the %s toggle action", (scope, type) => {
|
|
72
|
+
const feed = preferenceFeed("multi");
|
|
73
|
+
feed.extensions.preference_editor_options.scope = scope;
|
|
74
|
+
feed.extensions.preference_editor_options.max_items = "10";
|
|
75
|
+
|
|
76
|
+
const toggle = toggleAction(feed);
|
|
77
|
+
|
|
78
|
+
expect(toggle.type).toBe(type);
|
|
79
|
+
expect(toggle.options).toEqual({ key: "agree", max_items: 10 });
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it.each([undefined, 0, "0", "ten", -1])(
|
|
83
|
+
"does not set a limit for max_items %p",
|
|
84
|
+
(maxItems) => {
|
|
85
|
+
const feed = preferenceFeed("multi");
|
|
86
|
+
feed.extensions.preference_editor_options.max_items = maxItems;
|
|
87
|
+
|
|
88
|
+
expect(toggleAction(feed).options).toEqual({ key: "agree" });
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ActionExecutor, ActionResult } from "../ActionExecutor";
|
|
2
|
+
import { screenToggleFlagAction } from "../actions/screenToggleFlag";
|
|
3
|
+
|
|
4
|
+
jest.mock("../ActionExecutorContext", () => ({
|
|
5
|
+
log_error: jest.fn(),
|
|
6
|
+
log_info: jest.fn(),
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
jest.mock("../StorageActions", () => ({
|
|
10
|
+
onMaxTagsReached: jest.fn(),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
// not used here, but it pulls the native bridge logger in at import time
|
|
14
|
+
jest.mock("../../storage/ScreenSingleValueProvider", () => ({}));
|
|
15
|
+
|
|
16
|
+
jest.mock("../../logger", () => ({
|
|
17
|
+
createLogger: () => ({
|
|
18
|
+
log_error: jest.fn(),
|
|
19
|
+
log_debug: jest.fn(),
|
|
20
|
+
log_info: jest.fn(),
|
|
21
|
+
}),
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
const mockSelected: string[] = [];
|
|
25
|
+
|
|
26
|
+
jest.mock("../../storage/ScreenStateMultiSelectProvider", () => ({
|
|
27
|
+
ScreenMultiSelectProvider: {
|
|
28
|
+
getProvider: () => ({
|
|
29
|
+
getSelectedAsync: async () => [...mockSelected],
|
|
30
|
+
addItem: async (item: string) => {
|
|
31
|
+
mockSelected.push(item);
|
|
32
|
+
},
|
|
33
|
+
removeItem: async (item: string) => {
|
|
34
|
+
mockSelected.splice(mockSelected.indexOf(item), 1);
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
const toggleAction = (options = {}) =>
|
|
41
|
+
({
|
|
42
|
+
type: "screenToggleFlag",
|
|
43
|
+
options: { key: "teams", selector: "extensions.tag", ...options },
|
|
44
|
+
}) as unknown as ActionType;
|
|
45
|
+
|
|
46
|
+
const context = (tag: string) => ({
|
|
47
|
+
screenRoute: "/screen",
|
|
48
|
+
screenStateStore: {},
|
|
49
|
+
entry: { id: tag, extensions: { tag } },
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe("screenToggleFlagAction at the max_items limit", () => {
|
|
53
|
+
beforeEach(() => {
|
|
54
|
+
mockSelected.length = 0;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("returns the cancellation so the chained actions do not run", async () => {
|
|
58
|
+
const afterToggle = jest.fn();
|
|
59
|
+
const executor = new ActionExecutor();
|
|
60
|
+
|
|
61
|
+
executor.registerAction("screenToggleFlag", screenToggleFlagAction);
|
|
62
|
+
|
|
63
|
+
executor.registerAction("sendCloudEvent", async () => {
|
|
64
|
+
afterToggle();
|
|
65
|
+
|
|
66
|
+
return ActionResult.Success;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
mockSelected.push("A", "B");
|
|
70
|
+
|
|
71
|
+
const result = await executor.handleActions(
|
|
72
|
+
[toggleAction({ max_items: 2 }), { type: "sendCloudEvent" }],
|
|
73
|
+
context("C") as never
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
expect(result).toBe(ActionResult.Cancel);
|
|
77
|
+
expect(afterToggle).not.toHaveBeenCalled();
|
|
78
|
+
expect(mockSelected).toEqual(["A", "B"]);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("lets the chain continue below the limit", async () => {
|
|
82
|
+
const result = await screenToggleFlagAction(
|
|
83
|
+
toggleAction({ max_items: 2 }),
|
|
84
|
+
context("A") as never
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
expect(result).toBe(ActionResult.Success);
|
|
88
|
+
expect(mockSelected).toEqual(["A"]);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -265,3 +265,50 @@ describe("navigateToScreen target resolution", () => {
|
|
|
265
265
|
expect(navigator.replace).toHaveBeenCalledWith(river, undefined);
|
|
266
266
|
});
|
|
267
267
|
});
|
|
268
|
+
|
|
269
|
+
describe("navigateToScreen entry context", () => {
|
|
270
|
+
it("sets the entry context for the destination before navigating", async () => {
|
|
271
|
+
const navigator = createNavigator();
|
|
272
|
+
const setEntryContext = jest.fn();
|
|
273
|
+
const entry = { id: "entry-id" } as unknown as ZappEntry;
|
|
274
|
+
|
|
275
|
+
const action = {
|
|
276
|
+
type: "navigateToScreen",
|
|
277
|
+
options: {
|
|
278
|
+
typeMapping: "parentLock",
|
|
279
|
+
navigationAction: "push",
|
|
280
|
+
entry: "@{entry/}",
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
await createNavigateToScreenAction(
|
|
285
|
+
navigator,
|
|
286
|
+
rivers,
|
|
287
|
+
contentTypes
|
|
288
|
+
)(action, { entry, setEntryContext });
|
|
289
|
+
|
|
290
|
+
expect(setEntryContext).toHaveBeenCalledWith(entry);
|
|
291
|
+
|
|
292
|
+
expect(
|
|
293
|
+
(setEntryContext as jest.Mock).mock.invocationCallOrder[0]
|
|
294
|
+
).toBeLessThan((navigator.push as jest.Mock).mock.invocationCallOrder[0]);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
it("does not set the entry context when it navigates without an entry", async () => {
|
|
298
|
+
const navigator = createNavigator();
|
|
299
|
+
const setEntryContext = jest.fn();
|
|
300
|
+
|
|
301
|
+
const action = {
|
|
302
|
+
type: "navigateToScreen",
|
|
303
|
+
options: { typeMapping: "parentLock", navigationAction: "push" },
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
await createNavigateToScreenAction(
|
|
307
|
+
navigator,
|
|
308
|
+
rivers,
|
|
309
|
+
contentTypes
|
|
310
|
+
)(action, { setEntryContext });
|
|
311
|
+
|
|
312
|
+
expect(setEntryContext).not.toHaveBeenCalled();
|
|
313
|
+
});
|
|
314
|
+
});
|
|
@@ -6,8 +6,8 @@ import { ActionHandler } from "../types";
|
|
|
6
6
|
import { createLogger } from "../../logger";
|
|
7
7
|
|
|
8
8
|
const { log_info } = createLogger({
|
|
9
|
-
subsystem: "
|
|
10
|
-
category: "
|
|
9
|
+
subsystem: "core/actions",
|
|
10
|
+
category: "ActionExecutor",
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -5,8 +5,8 @@ import { ActionHandler } from "../types";
|
|
|
5
5
|
import { createLogger } from "../../logger";
|
|
6
6
|
|
|
7
7
|
const { log_info } = createLogger({
|
|
8
|
-
subsystem: "
|
|
9
|
-
category: "
|
|
8
|
+
subsystem: "core/actions",
|
|
9
|
+
category: "ActionExecutor",
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -5,8 +5,8 @@ import { ActionHandler } from "../types";
|
|
|
5
5
|
import { createLogger } from "../../logger";
|
|
6
6
|
|
|
7
7
|
const { log_info } = createLogger({
|
|
8
|
-
subsystem: "
|
|
9
|
-
category: "
|
|
8
|
+
subsystem: "core/actions",
|
|
9
|
+
category: "ActionExecutor",
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -4,8 +4,8 @@ import { ActionHandler } from "../types";
|
|
|
4
4
|
import { createLogger } from "../../logger";
|
|
5
5
|
|
|
6
6
|
const { log_info } = createLogger({
|
|
7
|
-
subsystem: "
|
|
8
|
-
category: "
|
|
7
|
+
subsystem: "core/actions",
|
|
8
|
+
category: "ActionExecutor",
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -4,8 +4,8 @@ import { ActionHandler } from "../types";
|
|
|
4
4
|
import { createLogger } from "../../logger";
|
|
5
5
|
|
|
6
6
|
const { log_info } = createLogger({
|
|
7
|
-
subsystem: "
|
|
8
|
-
category: "
|
|
7
|
+
subsystem: "core/actions",
|
|
8
|
+
category: "ActionExecutor",
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -4,8 +4,8 @@ import { ActionHandler, ActionExecutionContext } from "../types";
|
|
|
4
4
|
import { createLogger } from "../../logger";
|
|
5
5
|
|
|
6
6
|
const { log_info, log_error } = createLogger({
|
|
7
|
-
subsystem: "
|
|
8
|
-
category: "
|
|
7
|
+
subsystem: "core/actions",
|
|
8
|
+
category: "ActionExecutor",
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -114,6 +114,12 @@ export function createNavigateToScreenAction(
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
context?.callback?.({ success: false, error: null, abort: true });
|
|
117
|
+
|
|
118
|
+
// The destination screen resolves `@{entry/...}` from the entry context
|
|
119
|
+
if (entry) {
|
|
120
|
+
context?.setEntryContext?.(entry);
|
|
121
|
+
}
|
|
122
|
+
|
|
117
123
|
navigate(navigatingEntry, navigationOptions);
|
|
118
124
|
|
|
119
125
|
return ActionResult.Success;
|
|
@@ -19,8 +19,8 @@ import { actionExecutor, ActionResult } from "../ActionExecutor";
|
|
|
19
19
|
import { createLogger } from "../../logger";
|
|
20
20
|
|
|
21
21
|
const { log_info, log_error } = createLogger({
|
|
22
|
-
subsystem: "
|
|
23
|
-
category: "
|
|
22
|
+
subsystem: "core/actions",
|
|
23
|
+
category: "ActionExecutor",
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
export type LoadedSheetContent = {
|
|
@@ -5,8 +5,8 @@ import type { PresentScreenFn } from "../../reactHooks/navigation/usePresentScre
|
|
|
5
5
|
import { createLogger } from "../../logger";
|
|
6
6
|
|
|
7
7
|
const { log_error } = createLogger({
|
|
8
|
-
subsystem: "
|
|
9
|
-
category: "
|
|
8
|
+
subsystem: "core/actions",
|
|
9
|
+
category: "ActionExecutor",
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -10,8 +10,8 @@ import { ActionHandler, ActionExecutionContext } from "../types";
|
|
|
10
10
|
import { createLogger } from "../../logger";
|
|
11
11
|
|
|
12
12
|
const { log_info } = createLogger({
|
|
13
|
-
subsystem: "
|
|
14
|
-
category: "
|
|
13
|
+
subsystem: "core/actions",
|
|
14
|
+
category: "ActionExecutor",
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
/** Prefer component data.source, otherwise direct UIComponentContext parent. */
|
|
@@ -27,12 +27,10 @@ export const screenToggleFlagAction: ActionHandler<
|
|
|
27
27
|
const screenRoute = context?.screenRoute;
|
|
28
28
|
const screenStateStore = context?.screenStateStore;
|
|
29
29
|
|
|
30
|
-
await screenToggleFlag(
|
|
30
|
+
return await screenToggleFlag(
|
|
31
31
|
screenRoute,
|
|
32
32
|
screenStateStore,
|
|
33
33
|
{ entry: context?.entry, options: action.options },
|
|
34
34
|
action
|
|
35
35
|
);
|
|
36
|
-
|
|
37
|
-
return ActionResult.Success;
|
|
38
36
|
};
|
|
@@ -9,8 +9,8 @@ import { ActionHandler, ActionExecutionContext } from "../types";
|
|
|
9
9
|
import { createLogger } from "../../logger";
|
|
10
10
|
|
|
11
11
|
const { log_info, log_error } = createLogger({
|
|
12
|
-
subsystem: "
|
|
13
|
-
category: "
|
|
12
|
+
subsystem: "core/actions",
|
|
13
|
+
category: "ActionExecutor",
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -5,8 +5,8 @@ import { ActionHandler } from "../types";
|
|
|
5
5
|
import { createLogger } from "../../logger";
|
|
6
6
|
|
|
7
7
|
const { log_info } = createLogger({
|
|
8
|
-
subsystem: "
|
|
9
|
-
category: "
|
|
8
|
+
subsystem: "core/actions",
|
|
9
|
+
category: "ActionExecutor",
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -8,8 +8,8 @@ import { ActionHandler } from "../types";
|
|
|
8
8
|
import { createLogger } from "../../logger";
|
|
9
9
|
|
|
10
10
|
const { log_info } = createLogger({
|
|
11
|
-
subsystem: "
|
|
12
|
-
category: "
|
|
11
|
+
subsystem: "core/actions",
|
|
12
|
+
category: "ActionExecutor",
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -3,8 +3,8 @@ import { getNamespaceAndKey } from "../appUtils/contextKeysManager/utils";
|
|
|
3
3
|
import { createLogger } from "../logger";
|
|
4
4
|
|
|
5
5
|
const { log_error, log_verbose } = createLogger({
|
|
6
|
-
subsystem: "
|
|
7
|
-
category: "
|
|
6
|
+
subsystem: "network/feed",
|
|
7
|
+
category: "FeedDecorator",
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
function getScope(scope) {
|
|
@@ -47,6 +47,11 @@ function makeMultiSelect(feed: ZappFeed, key, decoratedFeed) {
|
|
|
47
47
|
? "sessionStorageToggleFlag"
|
|
48
48
|
: "localStorageToggleFlag";
|
|
49
49
|
|
|
50
|
+
// the toggle actions read their limit from their own options
|
|
51
|
+
const maxItems = Number(
|
|
52
|
+
decoratedFeed.extensions?.preference_editor_options?.max_items
|
|
53
|
+
);
|
|
54
|
+
|
|
50
55
|
decoratedFeed.entry?.forEach((entry: ZappEntry) => {
|
|
51
56
|
entry.type.value = "action";
|
|
52
57
|
entry.id = entry.extensions?.tag || entry.id;
|
|
@@ -59,6 +64,7 @@ function makeMultiSelect(feed: ZappFeed, key, decoratedFeed) {
|
|
|
59
64
|
type: actionType,
|
|
60
65
|
options: {
|
|
61
66
|
key,
|
|
67
|
+
...(maxItems > 0 && { max_items: maxItems }),
|
|
62
68
|
},
|
|
63
69
|
},
|
|
64
70
|
],
|
package/actionsExecutor/types.ts
CHANGED
|
@@ -30,6 +30,13 @@ export interface ActionExecutionContext {
|
|
|
30
30
|
/** Context entry for additional data */
|
|
31
31
|
entryContext?: ZappEntry;
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Sets the entry that the screen opened by this tap reads as `@{entry/...}`.
|
|
35
|
+
* Actions that open a screen call it themselves, so a tap that does not open
|
|
36
|
+
* one (a selection toggle) does not update the shared entry context.
|
|
37
|
+
*/
|
|
38
|
+
setEntryContext?: (entry: ZappEntry) => void;
|
|
39
|
+
|
|
33
40
|
/** Callback function for action completion */
|
|
34
41
|
callback?: (result: { success: boolean; error: any; abort: boolean }) => void;
|
|
35
42
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { PlayerAnalyticsTracker } from "../playerAnalyticsTracker";
|
|
2
|
+
import { PLAYBACK_EVENT } from "../events";
|
|
3
|
+
|
|
4
|
+
const mockPostAnalyticEvent = jest.fn();
|
|
5
|
+
|
|
6
|
+
jest.mock("../manager", () => ({
|
|
7
|
+
postAnalyticEvent: (...args) => mockPostAnalyticEvent(...args),
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
describe("Player Analytics Safeguards against nativeEvent leakage", () => {
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
jest.clearAllMocks();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const mockEntry = {
|
|
16
|
+
id: "vod_123",
|
|
17
|
+
title: "Test Video",
|
|
18
|
+
type: { value: "video" },
|
|
19
|
+
content: { type: "video/mp4" },
|
|
20
|
+
extensions: { duration: 120 },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const mockPlayer = {
|
|
24
|
+
playerPluginId: "quick_brick_player",
|
|
25
|
+
getEntry: () => mockEntry,
|
|
26
|
+
getState: () => ({ isPaused: false, contentPosition: 0.63 }),
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
it("omits nativeEvent from analytics payload if present in eventData", () => {
|
|
30
|
+
const tracker = new PlayerAnalyticsTracker();
|
|
31
|
+
tracker.setPlayer(mockPlayer as any);
|
|
32
|
+
|
|
33
|
+
const payload = tracker.prepareAnalyticPayload(PLAYBACK_EVENT.play, {
|
|
34
|
+
nativeEvent: { currentTime: 0.63, reason: "video_ready" },
|
|
35
|
+
player_type: "quick_brick_player",
|
|
36
|
+
} as any);
|
|
37
|
+
|
|
38
|
+
expect(payload.nativeEvent).toBeUndefined();
|
|
39
|
+
expect(payload.media_id).toBe("vod_123");
|
|
40
|
+
expect(payload.name).toBe("Test Video");
|
|
41
|
+
expect(payload.player_type).toBe("quick_brick_player");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("properly prepares payload when eventData is unwrapped", () => {
|
|
45
|
+
const tracker = new PlayerAnalyticsTracker();
|
|
46
|
+
tracker.setPlayer(mockPlayer as any);
|
|
47
|
+
|
|
48
|
+
const payload = tracker.prepareAnalyticPayload(PLAYBACK_EVENT.play, {
|
|
49
|
+
currentTime: 0.63,
|
|
50
|
+
reason: "video_ready",
|
|
51
|
+
player_type: "quick_brick_player",
|
|
52
|
+
} as any);
|
|
53
|
+
|
|
54
|
+
expect(payload.nativeEvent).toBeUndefined();
|
|
55
|
+
expect(payload.currentTime).toBeUndefined();
|
|
56
|
+
expect(payload.current_position).toBe(0.63);
|
|
57
|
+
expect(payload.reason).toBe("video_ready");
|
|
58
|
+
expect(payload.media_id).toBe("vod_123");
|
|
59
|
+
expect(payload.name).toBe("Test Video");
|
|
60
|
+
expect(payload.player_type).toBe("quick_brick_player");
|
|
61
|
+
});
|
|
62
|
+
});
|
package/analyticsUtils/logger.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { subsystemLogger } from "../logger";
|
|
2
2
|
|
|
3
|
-
export const analyticsUtilsLogger =
|
|
3
|
+
export const analyticsUtilsLogger = subsystemLogger(
|
|
4
|
+
"analytics/utils",
|
|
5
|
+
"AnalyticsUtils"
|
|
6
|
+
);
|
|
4
7
|
|
|
5
8
|
export const log_verbose = (message, data: any = null) => {
|
|
6
9
|
analyticsUtilsLogger.log({
|
|
@@ -37,5 +40,7 @@ export const log_error = (message, data: any = null) => {
|
|
|
37
40
|
});
|
|
38
41
|
};
|
|
39
42
|
|
|
40
|
-
export const playerAnalyticsLogger =
|
|
41
|
-
|
|
43
|
+
export const playerAnalyticsLogger = subsystemLogger(
|
|
44
|
+
"analytics/player",
|
|
45
|
+
"PlayerAnalytics"
|
|
46
|
+
);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { subsystemLogger } from "../../logger";
|
|
2
2
|
|
|
3
|
-
export const hooksManagerLogger =
|
|
3
|
+
export const hooksManagerLogger = subsystemLogger(
|
|
4
|
+
"core/plugins/hooks",
|
|
5
|
+
"HooksManager"
|
|
6
|
+
);
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { subsystemLogger } from "../../logger";
|
|
2
2
|
|
|
3
|
-
export const accessibilityManagerLogger =
|
|
4
|
-
"accessibilityManager"
|
|
5
|
-
);
|
|
3
|
+
export const accessibilityManagerLogger = subsystemLogger("ui/accessibility");
|
|
@@ -7,13 +7,13 @@ import {
|
|
|
7
7
|
buildNamespaceKey,
|
|
8
8
|
savingResultIsSuccess,
|
|
9
9
|
} from "./utils";
|
|
10
|
-
import { utilsLogger } from "../../logger";
|
|
11
10
|
import {
|
|
12
11
|
sessionStorage as SessionStorage,
|
|
13
12
|
localStorage as LocalStorage,
|
|
14
13
|
secureStorage as SecureStorage,
|
|
15
14
|
} from "./storage";
|
|
16
15
|
import { NativeModules } from "react-native";
|
|
16
|
+
import { subsystemLogger } from "../../logger";
|
|
17
17
|
|
|
18
18
|
export { StorageLevel };
|
|
19
19
|
|
|
@@ -42,7 +42,7 @@ type KeyProp = {
|
|
|
42
42
|
storageLevel?: StorageLevel;
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
const UtilsLogger =
|
|
45
|
+
const UtilsLogger = subsystemLogger("core/context", "ContextKeysManager");
|
|
46
46
|
|
|
47
47
|
type Logger = {
|
|
48
48
|
warn: Function;
|