@applicaster/zapp-react-native-utils 14.0.0-alpha.5222319560 → 14.0.0-alpha.5234792518
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/analyticsUtils/playerAnalyticsTracker.ts +2 -1
- package/appUtils/HooksManager/index.ts +10 -10
- package/navigationUtils/index.ts +1 -1
- package/package.json +2 -2
- package/reactHooks/feed/useLoadPipesDataDispatch.ts +7 -1
- package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +72 -0
- package/zappFrameworkUtils/HookCallback/hookCallbackManifestExtensions.config.ts +59 -0
|
@@ -105,7 +105,8 @@ export class PlayerAnalyticsTracker implements PlayerAnalyticsTrackerI {
|
|
|
105
105
|
return this.getDateTimestamp();
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
this.mediaTime =
|
|
108
|
+
this.mediaTime =
|
|
109
|
+
this.playerState?.contentPosition || eventData?.currentTime;
|
|
109
110
|
|
|
110
111
|
return this.mediaTime;
|
|
111
112
|
}
|
|
@@ -230,7 +230,7 @@ export function HooksManager({
|
|
|
230
230
|
function completeHook(hookPlugin, payload, callback) {
|
|
231
231
|
logHookEvent(
|
|
232
232
|
hooksManagerLogger.info,
|
|
233
|
-
`completeHook: hook sequence completed successfully: ${hookPlugin
|
|
233
|
+
`completeHook: hook sequence completed successfully: ${hookPlugin.identifier}`,
|
|
234
234
|
{
|
|
235
235
|
payload,
|
|
236
236
|
hook: hookPlugin,
|
|
@@ -276,7 +276,7 @@ export function HooksManager({
|
|
|
276
276
|
if (hookPlugin.isCancelled()) {
|
|
277
277
|
logHookEvent(
|
|
278
278
|
hooksManagerLogger.info,
|
|
279
|
-
`hookCallback: hook was cancelled: ${hookPlugin
|
|
279
|
+
`hookCallback: hook was cancelled: ${hookPlugin.identifier}`,
|
|
280
280
|
{}
|
|
281
281
|
);
|
|
282
282
|
|
|
@@ -305,7 +305,7 @@ export function HooksManager({
|
|
|
305
305
|
if (!success) {
|
|
306
306
|
logHookEvent(
|
|
307
307
|
hooksManagerLogger.info,
|
|
308
|
-
`hookCallback: hook was cancelled: ${hookPlugin
|
|
308
|
+
`hookCallback: hook was cancelled: ${hookPlugin.identifier}`,
|
|
309
309
|
{
|
|
310
310
|
payload,
|
|
311
311
|
hook: hookPlugin,
|
|
@@ -334,7 +334,7 @@ export function HooksManager({
|
|
|
334
334
|
if (isHookInHomescreen && isHookFlowBlocker && cancelled) {
|
|
335
335
|
logHookEvent(
|
|
336
336
|
hooksManagerLogger.info,
|
|
337
|
-
`hookCallback: send app to background, cancelled flow blocker hook ${hookPlugin
|
|
337
|
+
`hookCallback: send app to background, cancelled flow blocker hook ${hookPlugin.identifier} on home screen`,
|
|
338
338
|
{
|
|
339
339
|
payload,
|
|
340
340
|
hook: hookPlugin,
|
|
@@ -349,7 +349,7 @@ export function HooksManager({
|
|
|
349
349
|
} else {
|
|
350
350
|
logHookEvent(
|
|
351
351
|
hooksManagerLogger.info,
|
|
352
|
-
`hookCallback: hook successfully finished: ${hookPlugin
|
|
352
|
+
`hookCallback: hook successfully finished: ${hookPlugin.identifier}`,
|
|
353
353
|
{
|
|
354
354
|
payload,
|
|
355
355
|
hook: hookPlugin,
|
|
@@ -359,7 +359,7 @@ export function HooksManager({
|
|
|
359
359
|
if (!callback) {
|
|
360
360
|
logHookEvent(
|
|
361
361
|
hooksManagerLogger.warn,
|
|
362
|
-
`hookCallback: ${hookPlugin
|
|
362
|
+
`hookCallback: ${hookPlugin.identifier} is missing \`callback\`, using hookCallback(default one)`,
|
|
363
363
|
{
|
|
364
364
|
hookPlugin,
|
|
365
365
|
}
|
|
@@ -401,7 +401,7 @@ export function HooksManager({
|
|
|
401
401
|
|
|
402
402
|
logHookEvent(
|
|
403
403
|
hooksManagerLogger.info,
|
|
404
|
-
`presentScreenHook: Presenting screen hook: ${hookPlugin
|
|
404
|
+
`presentScreenHook: Presenting screen hook: ${hookPlugin.identifier}`,
|
|
405
405
|
{
|
|
406
406
|
hook: hookPlugin,
|
|
407
407
|
payload,
|
|
@@ -421,7 +421,7 @@ export function HooksManager({
|
|
|
421
421
|
hooksManager.executeHook = function (hookPlugin, payload, callback) {
|
|
422
422
|
logHookEvent(
|
|
423
423
|
hooksManagerLogger.info,
|
|
424
|
-
`executeHook: ${hookPlugin
|
|
424
|
+
`executeHook: ${hookPlugin.identifier}`,
|
|
425
425
|
{
|
|
426
426
|
hook: hookPlugin,
|
|
427
427
|
payload,
|
|
@@ -433,7 +433,7 @@ export function HooksManager({
|
|
|
433
433
|
} catch (error) {
|
|
434
434
|
logHookEvent(
|
|
435
435
|
hooksManagerLogger.error,
|
|
436
|
-
`executeHook: error executing hook: ${hookPlugin
|
|
436
|
+
`executeHook: error executing hook: ${hookPlugin.identifier} error: ${error.message}`,
|
|
437
437
|
{
|
|
438
438
|
hook: hookPlugin,
|
|
439
439
|
payload,
|
|
@@ -460,7 +460,7 @@ export function HooksManager({
|
|
|
460
460
|
try {
|
|
461
461
|
logHookEvent(
|
|
462
462
|
hooksManagerLogger.info,
|
|
463
|
-
`runInBackground: Executing hook: ${hookPlugin
|
|
463
|
+
`runInBackground: Executing hook: ${hookPlugin.identifier}`,
|
|
464
464
|
{
|
|
465
465
|
hook: hookPlugin,
|
|
466
466
|
payload,
|
package/navigationUtils/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "14.0.0-alpha.
|
|
3
|
+
"version": "14.0.0-alpha.5234792518",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@applicaster/applicaster-types": "14.0.0-alpha.
|
|
30
|
+
"@applicaster/applicaster-types": "14.0.0-alpha.5234792518",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
|
@@ -30,7 +30,13 @@ export const useLoadPipesDataDispatch = () => {
|
|
|
30
30
|
return React.useCallback(
|
|
31
31
|
(
|
|
32
32
|
url: string,
|
|
33
|
-
options
|
|
33
|
+
options: {
|
|
34
|
+
callback?: (data: unknown, error?: Error | null | undefined) => void;
|
|
35
|
+
riverId?: string;
|
|
36
|
+
clearCache?: boolean;
|
|
37
|
+
silentRefresh?: boolean;
|
|
38
|
+
parentFeed?: string;
|
|
39
|
+
} = {},
|
|
34
40
|
{
|
|
35
41
|
withResolvers = false,
|
|
36
42
|
withScreenRouteMapping = false,
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useNavigation } from "../../reactHooks";
|
|
3
|
+
import {
|
|
4
|
+
CALLBACK_NAVIGATION_KEY,
|
|
5
|
+
NavigationCallbackOptions,
|
|
6
|
+
} from "./hookCallbackManifestExtensions.config";
|
|
7
|
+
import { createLogger } from "../../logger";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
type CallbackParams = {
|
|
11
|
+
navigationAction: NavigationCallbackOptions;
|
|
12
|
+
screen?: ZappRiver;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const LogPrefix = "useCallBackNavigationAction:";
|
|
16
|
+
const { log_info } = createLogger({ subsystem: "hook-navigation-callback" });
|
|
17
|
+
|
|
18
|
+
export const useCallBackNavigationAction = (item: ZappUIComponent) => {
|
|
19
|
+
const navigation = useNavigation();
|
|
20
|
+
|
|
21
|
+
return useCallback(
|
|
22
|
+
(data: CallbackParams) => {
|
|
23
|
+
if (item.general?.[CALLBACK_NAVIGATION_KEY]) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const action =
|
|
28
|
+
data?.navigationAction ?? NavigationCallbackOptions.DEFAULT;
|
|
29
|
+
|
|
30
|
+
switch (action) {
|
|
31
|
+
case NavigationCallbackOptions.GO_BACK: {
|
|
32
|
+
if (navigation.canGoBack()) {
|
|
33
|
+
navigation.goBack();
|
|
34
|
+
log_info(`${LogPrefix} performing 'GO BACK' action`);
|
|
35
|
+
} else {
|
|
36
|
+
log_info(`${LogPrefix} can not perform 'GO BACK' action, Ignoring`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
case NavigationCallbackOptions.GO_HOME: {
|
|
43
|
+
navigation.goHome();
|
|
44
|
+
log_info(`${LogPrefix} performing 'GO HOME' action`);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
case NavigationCallbackOptions.GO_TO_SCREEN: {
|
|
49
|
+
const screen = data.screen;
|
|
50
|
+
|
|
51
|
+
if (screen) {
|
|
52
|
+
navigation.replace(screen);
|
|
53
|
+
|
|
54
|
+
log_info(
|
|
55
|
+
`${LogPrefix} performing 'GO TO SCREEN' action to screen: ${screen.id}`
|
|
56
|
+
);
|
|
57
|
+
} else {
|
|
58
|
+
log_info(
|
|
59
|
+
`${LogPrefix} can not perform 'GO TO SCREEN' action, Ignoring`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
default:
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
[item.general, navigation]
|
|
71
|
+
);
|
|
72
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
|
|
2
|
+
export enum NavigationCallbackOptions {
|
|
3
|
+
DEFAULT = "default",
|
|
4
|
+
GO_HOME = "go_home",
|
|
5
|
+
GO_BACK = "go_back",
|
|
6
|
+
GO_TO_SCREEN = "go_to_screen",
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const CALLBACK_NAVIGATION_KEY = "hook_callback_navigation";
|
|
10
|
+
|
|
11
|
+
export const CALLBACK_NAVIGATION_GO_TO_SCREEN_KEY = "hook_callback_navigation";
|
|
12
|
+
|
|
13
|
+
export const extendManifestWithHookCallback = () => (
|
|
14
|
+
{
|
|
15
|
+
group: true,
|
|
16
|
+
label: "CallBack Navigation",
|
|
17
|
+
folded: true,
|
|
18
|
+
fields: [
|
|
19
|
+
{
|
|
20
|
+
type: "select",
|
|
21
|
+
key: CALLBACK_NAVIGATION_KEY,
|
|
22
|
+
label: "Callback Navigation",
|
|
23
|
+
label_tooltip:
|
|
24
|
+
"Defines what navigation action should be performed after the callback is called.",
|
|
25
|
+
options: [
|
|
26
|
+
{
|
|
27
|
+
text: "Use default flow",
|
|
28
|
+
value: NavigationCallbackOptions.DEFAULT,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
text: "Go Back to home screen",
|
|
32
|
+
value: NavigationCallbackOptions.GO_HOME,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
text: "Go Back to previous screen",
|
|
36
|
+
value: NavigationCallbackOptions.GO_BACK,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
text: "Move to specific screen",
|
|
40
|
+
value: NavigationCallbackOptions.GO_TO_SCREEN,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
initial_value: "default",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: "screen_selector",
|
|
47
|
+
key: CALLBACK_NAVIGATION_GO_TO_SCREEN_KEY,
|
|
48
|
+
label: "Navigate to screen",
|
|
49
|
+
label_tooltip: "Screen you wish to navigate to after success purchase",
|
|
50
|
+
rules: "conditional",
|
|
51
|
+
conditional_fields: [
|
|
52
|
+
{
|
|
53
|
+
key: `general/${CALLBACK_NAVIGATION_KEY}`,
|
|
54
|
+
condition_value: NavigationCallbackOptions.GO_TO_SCREEN,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
}]
|
|
58
|
+
}
|
|
59
|
+
);
|