@momo-kits/foundation 0.81.43-tracking.3 → 0.81.43-tracking.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Application/Components.tsx +26 -16
- package/Application/ModalScreen.tsx +0 -1
- package/Application/NavigationContainer.tsx +1 -3
- package/Application/Navigator.ts +0 -14
- package/Application/StackScreen.tsx +26 -29
- package/Application/index.ts +10 -1
- package/Application/types.ts +10 -10
- package/Button/index.tsx +1 -2
- package/CheckBox/index.tsx +1 -2
- package/IconButton/index.tsx +1 -2
- package/Input/Input.tsx +2 -2
- package/Input/InputMoney.tsx +2 -2
- package/Input/InputOTP.tsx +2 -2
- package/Input/InputSearch.tsx +2 -2
- package/Popup/PopupNotify.tsx +25 -28
- package/Popup/PopupPromotion.tsx +23 -27
- package/Radio/index.tsx +1 -2
- package/Switch/index.tsx +1 -2
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
View,
|
|
16
16
|
ViewStyle,
|
|
17
17
|
} from 'react-native';
|
|
18
|
-
import {ApplicationContext} from './index';
|
|
18
|
+
import {ApplicationContext, MiniAppContext} from './index';
|
|
19
19
|
import {Colors, Radius, Spacing, Styles} from '../Consts';
|
|
20
20
|
import {Image} from '../Image';
|
|
21
21
|
import {
|
|
@@ -108,6 +108,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
108
108
|
useBorder,
|
|
109
109
|
accessibilityLabel = '',
|
|
110
110
|
}) => {
|
|
111
|
+
const context = useContext(MiniAppContext);
|
|
111
112
|
const {navigator} = useContext(ApplicationContext);
|
|
112
113
|
|
|
113
114
|
useEffect(() => {
|
|
@@ -122,13 +123,10 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
122
123
|
const goBackSafe = () => {
|
|
123
124
|
const goBack = () => {
|
|
124
125
|
const canGoBack = navigator?.ref.current?.canGoBack();
|
|
125
|
-
if (!canGoBack
|
|
126
|
+
if (!canGoBack) {
|
|
126
127
|
const currentRoute = navigator?.ref?.current.getCurrentRoute();
|
|
127
128
|
navigator?.maxApi?.trackEvent?.('service_icon_clicked', {
|
|
128
|
-
|
|
129
|
-
app_id: navigator.trackingInfo.appId,
|
|
130
|
-
miniapp_version: navigator.trackingInfo.buildNumber,
|
|
131
|
-
flow_partner_id: navigator.trackingInfo.flowPartnerId,
|
|
129
|
+
...context,
|
|
132
130
|
screen_name: currentRoute?.params?.screen?.name ?? currentRoute?.name,
|
|
133
131
|
trigger_id: '111154000000000000',
|
|
134
132
|
icon_name: 'back',
|
|
@@ -310,15 +308,19 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
310
308
|
}, []);
|
|
311
309
|
|
|
312
310
|
const getToolkitConfig = () => {
|
|
313
|
-
navigator?.
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
311
|
+
navigator?.maxApi?.dispatchFunction?.(
|
|
312
|
+
'getToolsConfig',
|
|
313
|
+
[undefined],
|
|
314
|
+
(config: any) => {
|
|
315
|
+
navigator.toolkitConfig = config;
|
|
316
|
+
setToolConfig(navigator?.toolkitConfig);
|
|
317
|
+
},
|
|
318
|
+
);
|
|
317
319
|
};
|
|
318
320
|
|
|
319
321
|
const onMore = () => {
|
|
320
322
|
onAction?.('onMore');
|
|
321
|
-
navigator?.
|
|
323
|
+
navigator?.maxApi?.dispatchFunction?.(
|
|
322
324
|
'showTools',
|
|
323
325
|
[undefined],
|
|
324
326
|
(res: {item: {action?: string; key: string}}) => {
|
|
@@ -339,14 +341,18 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
339
341
|
title: preventBack.primary.title,
|
|
340
342
|
onPress: () => {
|
|
341
343
|
preventBack?.primary.onPress();
|
|
342
|
-
navigator?.
|
|
344
|
+
navigator?.maxApi?.dispatchFunction?.(
|
|
345
|
+
'dismiss',
|
|
346
|
+
undefined,
|
|
347
|
+
undefined,
|
|
348
|
+
);
|
|
343
349
|
},
|
|
344
350
|
}}
|
|
345
351
|
/>
|
|
346
352
|
),
|
|
347
353
|
});
|
|
348
354
|
} else {
|
|
349
|
-
navigator?.
|
|
355
|
+
navigator?.maxApi?.dispatchFunction?.('dismiss', undefined, undefined);
|
|
350
356
|
}
|
|
351
357
|
};
|
|
352
358
|
|
|
@@ -364,9 +370,13 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
364
370
|
badgeValue={badgeValue}
|
|
365
371
|
badgeType={badgeType}
|
|
366
372
|
onPress={() => {
|
|
367
|
-
navigator?.
|
|
368
|
-
|
|
369
|
-
|
|
373
|
+
navigator?.maxApi?.dispatchFunction?.(
|
|
374
|
+
'onToolAction',
|
|
375
|
+
[pinTool?.key],
|
|
376
|
+
() => {
|
|
377
|
+
getToolkitConfig();
|
|
378
|
+
},
|
|
379
|
+
);
|
|
370
380
|
navigator?.toolkitCallback?.(pinTool.key);
|
|
371
381
|
}}
|
|
372
382
|
/>
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
NavigationContainerRef,
|
|
7
7
|
} from '@react-navigation/native';
|
|
8
8
|
import {createStackNavigator} from '@react-navigation/stack';
|
|
9
|
-
import {
|
|
9
|
+
import {DeviceEventEmitter, NativeModules} from 'react-native';
|
|
10
10
|
import StackScreen from './StackScreen';
|
|
11
11
|
import ModalScreen from './ModalScreen';
|
|
12
12
|
import Navigator from './Navigator';
|
|
@@ -23,7 +23,6 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
23
23
|
options,
|
|
24
24
|
maxApi,
|
|
25
25
|
localization,
|
|
26
|
-
trackingInfo,
|
|
27
26
|
}) => {
|
|
28
27
|
const navigationRef = React.useRef<NavigationContainerRef>(null);
|
|
29
28
|
const navigator = useRef(new Navigator(navigationRef));
|
|
@@ -68,7 +67,6 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
68
67
|
* inject data for navigator
|
|
69
68
|
*/
|
|
70
69
|
navigator.current.maxApi = maxApi;
|
|
71
|
-
navigator.current.trackingInfo = trackingInfo;
|
|
72
70
|
|
|
73
71
|
/**
|
|
74
72
|
* translate
|
package/Application/Navigator.ts
CHANGED
|
@@ -4,14 +4,12 @@ import {
|
|
|
4
4
|
HeaderToolkitProps,
|
|
5
5
|
ModalParams,
|
|
6
6
|
ScreenParams,
|
|
7
|
-
TrackingInfo,
|
|
8
7
|
} from './types';
|
|
9
8
|
|
|
10
9
|
class Navigator {
|
|
11
10
|
ref?: any;
|
|
12
11
|
toolkitConfig?: HeaderToolkitProps;
|
|
13
12
|
maxApi?: any;
|
|
14
|
-
trackingInfo?: TrackingInfo;
|
|
15
13
|
dismissData?: any;
|
|
16
14
|
toolkitCallback?: (item: any) => void;
|
|
17
15
|
|
|
@@ -111,18 +109,6 @@ class Navigator {
|
|
|
111
109
|
);
|
|
112
110
|
};
|
|
113
111
|
|
|
114
|
-
/**
|
|
115
|
-
* request max api for mini app
|
|
116
|
-
* @param func
|
|
117
|
-
* @param args
|
|
118
|
-
* @param callback
|
|
119
|
-
*/
|
|
120
|
-
requestApi = (func: any, args: any = [], callback: any) => {
|
|
121
|
-
if (this.maxApi) {
|
|
122
|
-
this.maxApi[func]?.(...args, callback);
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
|
|
126
112
|
setToolkitCallback = (
|
|
127
113
|
callback: (item: {key: string; action: string}) => void,
|
|
128
114
|
) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, {useContext, useEffect, useLayoutEffect} from 'react';
|
|
2
2
|
import {ScreenParams} from './types';
|
|
3
3
|
import Navigation from './Navigation';
|
|
4
|
-
import {ApplicationContext} from './index';
|
|
4
|
+
import {ApplicationContext, MiniAppContext} from './index';
|
|
5
5
|
import {GridSystem} from '../Layout';
|
|
6
6
|
import {useHeaderHeight} from '@react-navigation/stack';
|
|
7
7
|
|
|
@@ -10,8 +10,10 @@ const {
|
|
|
10
10
|
} = require('react-native/Libraries/Components/ScreenContext');
|
|
11
11
|
|
|
12
12
|
const StackScreen: React.FC<ScreenParams> = props => {
|
|
13
|
-
const {screen: Component, options}: ScreenParams = props.route.params;
|
|
14
13
|
const {theme, showGrid, navigator} = useContext(ApplicationContext);
|
|
14
|
+
const context = useContext(MiniAppContext);
|
|
15
|
+
|
|
16
|
+
const {screen: Component, options}: ScreenParams = props.route.params;
|
|
15
17
|
const navigation = new Navigation(props.navigation, theme);
|
|
16
18
|
const heightHeader = useHeaderHeight();
|
|
17
19
|
|
|
@@ -35,42 +37,37 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
35
37
|
* tracking for screen
|
|
36
38
|
*/
|
|
37
39
|
useEffect(() => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
const tracking = {
|
|
41
|
+
...context,
|
|
42
|
+
screen_name: Component.name,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const routes = props.navigation.getState()?.routes || [];
|
|
46
|
+
const routesLength = routes.length;
|
|
47
|
+
let pre_screen_name = '';
|
|
48
|
+
if (routesLength > 1) {
|
|
49
|
+
pre_screen_name = routes[routesLength - 2]?.params?.screen?.name;
|
|
50
|
+
}
|
|
46
51
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
52
|
+
navigator?.maxApi?.trackEvent?.('service_frame_displayed', {
|
|
53
|
+
...tracking,
|
|
54
|
+
pre_screen_name,
|
|
55
|
+
trigger_id: '111378000000000000',
|
|
56
|
+
});
|
|
53
57
|
|
|
54
|
-
|
|
58
|
+
return props.navigation.addListener('beforeRemove', () => {
|
|
59
|
+
navigator?.maxApi?.trackEvent?.('service_icon_clicked', {
|
|
55
60
|
...tracking,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
return props.navigation.addListener('beforeRemove', () => {
|
|
61
|
-
navigator?.maxApi?.trackEvent?.('service_icon_clicked', {
|
|
62
|
-
...tracking,
|
|
63
|
-
trigger_id: '111154000000000000',
|
|
64
|
-
icon_name: 'back',
|
|
65
|
-
});
|
|
61
|
+
trigger_id: '111154000000000000',
|
|
62
|
+
icon_name: 'back',
|
|
66
63
|
});
|
|
67
|
-
}
|
|
64
|
+
});
|
|
68
65
|
}, []);
|
|
69
66
|
|
|
70
67
|
return (
|
|
71
68
|
<ScreenContext.Provider
|
|
72
69
|
value={{
|
|
73
|
-
...
|
|
70
|
+
...context,
|
|
74
71
|
screenName: Component.name,
|
|
75
72
|
autoTracking: navigator?.maxApi?.autoTracking,
|
|
76
73
|
}}>
|
package/Application/index.ts
CHANGED
|
@@ -13,12 +13,21 @@ import {
|
|
|
13
13
|
import BottomTab from './BottomTab';
|
|
14
14
|
import {createContext} from 'react';
|
|
15
15
|
import {defaultContext} from '../Consts';
|
|
16
|
+
import {MiniAppInfo} from './types';
|
|
16
17
|
|
|
17
18
|
const ApplicationContext = createContext(defaultContext);
|
|
19
|
+
const MiniAppContext = createContext<MiniAppInfo>({
|
|
20
|
+
appId: '',
|
|
21
|
+
buildNumber: 0,
|
|
22
|
+
code: '',
|
|
23
|
+
toolkitConfig: {},
|
|
24
|
+
fromCode: '',
|
|
25
|
+
});
|
|
18
26
|
|
|
19
27
|
export {
|
|
20
|
-
NavigationContainer,
|
|
21
28
|
ApplicationContext,
|
|
29
|
+
MiniAppContext,
|
|
30
|
+
NavigationContainer,
|
|
22
31
|
Screen,
|
|
23
32
|
BottomTab,
|
|
24
33
|
NavigationButton,
|
package/Application/types.ts
CHANGED
|
@@ -71,6 +71,16 @@ export type Context = {
|
|
|
71
71
|
translate?: (key: string) => string;
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
+
export type MiniAppInfo = {
|
|
75
|
+
[key: string]: any;
|
|
76
|
+
code: string;
|
|
77
|
+
appId: string;
|
|
78
|
+
buildNumber: number;
|
|
79
|
+
flowPartnerId?: string;
|
|
80
|
+
toolkitConfig?: object;
|
|
81
|
+
fromCode?: string;
|
|
82
|
+
};
|
|
83
|
+
|
|
74
84
|
export type LocalizationObject = {
|
|
75
85
|
vi: {
|
|
76
86
|
[key: string]: string;
|
|
@@ -80,22 +90,12 @@ export type LocalizationObject = {
|
|
|
80
90
|
};
|
|
81
91
|
};
|
|
82
92
|
|
|
83
|
-
export type TrackingInfo = {
|
|
84
|
-
[key: string]: any;
|
|
85
|
-
appId: string;
|
|
86
|
-
code: string;
|
|
87
|
-
buildNumber: string;
|
|
88
|
-
screenName?: string;
|
|
89
|
-
flowPartnerId?: string;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
93
|
export type NavigationContainerProps = {
|
|
93
94
|
screen: Screen;
|
|
94
95
|
options?: NavigationOptions;
|
|
95
96
|
theme: Theme;
|
|
96
97
|
maxApi: any;
|
|
97
98
|
localization?: LocalizationObject;
|
|
98
|
-
trackingInfo?: TrackingInfo;
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
export type NavigationScreenProps = {
|
package/Button/index.tsx
CHANGED
|
@@ -14,7 +14,6 @@ import {Colors, Spacing} from '../Consts';
|
|
|
14
14
|
import styles from './styles';
|
|
15
15
|
import {Icon} from '../Icon';
|
|
16
16
|
import {Loader} from '../Loader';
|
|
17
|
-
import {TrackingInfo} from '../Application/types';
|
|
18
17
|
|
|
19
18
|
const {
|
|
20
19
|
ScreenContext,
|
|
@@ -105,7 +104,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
105
104
|
};
|
|
106
105
|
}
|
|
107
106
|
|
|
108
|
-
const screenInfo = useContext<
|
|
107
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
109
108
|
const getSizeStyle = () => {
|
|
110
109
|
const styleSheet: {[key: string]: any} = styles;
|
|
111
110
|
return styleSheet[size ?? 'small'];
|
package/CheckBox/index.tsx
CHANGED
|
@@ -5,7 +5,6 @@ import styles from './styles';
|
|
|
5
5
|
import {ApplicationContext} from '../Application';
|
|
6
6
|
import {Text} from '../Text';
|
|
7
7
|
import {Icon} from '../Icon';
|
|
8
|
-
import {TrackingInfo} from '../Application/types';
|
|
9
8
|
|
|
10
9
|
const {
|
|
11
10
|
ScreenContext,
|
|
@@ -24,7 +23,7 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
24
23
|
const iconSource = indeterminate ? 'ic_minus' : 'ic_checked';
|
|
25
24
|
let borderColor = theme.colors.text.default;
|
|
26
25
|
let backgroundColor = theme.colors.background.surface;
|
|
27
|
-
const screenInfo = useContext<
|
|
26
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
28
27
|
|
|
29
28
|
if (haveValue) {
|
|
30
29
|
borderColor = theme.colors.primary;
|
package/IconButton/index.tsx
CHANGED
|
@@ -9,7 +9,6 @@ import {ApplicationContext} from '../Application';
|
|
|
9
9
|
import {Colors} from '../Consts';
|
|
10
10
|
import {Icon} from '../Icon';
|
|
11
11
|
import styles from './styles';
|
|
12
|
-
import {TrackingInfo} from '../Application/types';
|
|
13
12
|
|
|
14
13
|
const {
|
|
15
14
|
ScreenContext,
|
|
@@ -41,7 +40,7 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
41
40
|
...rest
|
|
42
41
|
}) => {
|
|
43
42
|
const {theme} = useContext(ApplicationContext);
|
|
44
|
-
const screenInfo = useContext<
|
|
43
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
45
44
|
|
|
46
45
|
/**
|
|
47
46
|
* get size icon button
|
package/Input/Input.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import {InputProps} from './index';
|
|
|
13
13
|
import {Icon} from '../Icon';
|
|
14
14
|
import {checkTyping} from './utils';
|
|
15
15
|
import {Loader} from '../Loader';
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
const {
|
|
18
18
|
ScreenContext,
|
|
19
19
|
} = require('react-native/Libraries/Components/ScreenContext');
|
|
@@ -53,7 +53,7 @@ const Input = forwardRef(
|
|
|
53
53
|
const [haveValue, setHaveValue] = useState(!!value || !!props.defaultValue);
|
|
54
54
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
55
55
|
const accessibilityLabel = `Input/${floatingValue ?? placeholder}`;
|
|
56
|
-
const screenInfo = useContext<
|
|
56
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
57
57
|
|
|
58
58
|
const onClearText = () => {
|
|
59
59
|
inputRef?.current?.clear();
|
package/Input/InputMoney.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import {ErrorView, FloatingView, getBorderColor, getSizeStyle} from './common';
|
|
|
12
12
|
import {InputMoneyProps} from './index';
|
|
13
13
|
import {Icon} from '../Icon';
|
|
14
14
|
import {formatMoneyToNumber, formatNumberToMoney} from './utils';
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
const {
|
|
17
17
|
ScreenContext,
|
|
18
18
|
} = require('react-native/Libraries/Components/ScreenContext');
|
|
@@ -45,7 +45,7 @@ const InputMoney = forwardRef(
|
|
|
45
45
|
const [focused, setFocused] = useState(false);
|
|
46
46
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
47
47
|
const accessibilityLabel = `InputMoney/${floatingValue}`;
|
|
48
|
-
const screenInfo = useContext<
|
|
48
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
49
49
|
|
|
50
50
|
const validateText = (text: string) => {
|
|
51
51
|
const valueFormat = formatMoneyToNumber(text, 'đ');
|
package/Input/InputOTP.tsx
CHANGED
|
@@ -21,7 +21,7 @@ import styles from './styles';
|
|
|
21
21
|
import {ErrorView, getBorderColor} from './common';
|
|
22
22
|
import {ApplicationContext} from '../Application';
|
|
23
23
|
import {Spacing} from '../Consts';
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
const {
|
|
26
26
|
ScreenContext,
|
|
27
27
|
} = require('react-native/Libraries/Components/ScreenContext');
|
|
@@ -95,7 +95,7 @@ const InputOTP = forwardRef(
|
|
|
95
95
|
const inputRef = useRef<TextInput>(null);
|
|
96
96
|
const {theme} = useContext(ApplicationContext);
|
|
97
97
|
const accessibilityLabel = `InputOTP/${floatingValue ?? placeholder}`;
|
|
98
|
-
const screenInfo = useContext<
|
|
98
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
99
99
|
|
|
100
100
|
useImperativeHandle(ref, () => ({
|
|
101
101
|
onChangeText: (text: string) => {
|
package/Input/InputSearch.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import styles from './styles';
|
|
|
12
12
|
import {Icon} from '../Icon';
|
|
13
13
|
import {Text} from '../Text';
|
|
14
14
|
import {checkTyping} from './utils';
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
const {
|
|
17
17
|
ScreenContext,
|
|
18
18
|
} = require('react-native/Libraries/Components/ScreenContext');
|
|
@@ -45,7 +45,7 @@ const InputSearch = forwardRef(
|
|
|
45
45
|
const [haveValue, setHaveValue] = useState(!!value || !!defaultValue);
|
|
46
46
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
47
47
|
const accessibilityLabel = `InputMoney/${placeholder}`;
|
|
48
|
-
const screenInfo = useContext<
|
|
48
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
49
49
|
|
|
50
50
|
const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
51
51
|
setFocused(true);
|
package/Popup/PopupNotify.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import {PopupNotifyProps} from './types';
|
|
|
4
4
|
import {Radius, Spacing, Styles} from '../Consts';
|
|
5
5
|
import {Image} from '../Image';
|
|
6
6
|
import {Text} from '../Text';
|
|
7
|
-
import {ApplicationContext} from '../Application';
|
|
7
|
+
import {ApplicationContext, MiniAppContext} from '../Application';
|
|
8
8
|
import {Button} from '../Button';
|
|
9
9
|
import {Icon} from '../Icon';
|
|
10
10
|
|
|
@@ -19,6 +19,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
19
19
|
buttonDirection = 'row',
|
|
20
20
|
onIconClose,
|
|
21
21
|
}) => {
|
|
22
|
+
const context = useContext(MiniAppContext);
|
|
22
23
|
const {theme, navigator, translate} = useContext(ApplicationContext);
|
|
23
24
|
const [scrollContent, setScrollContent] = useState(false);
|
|
24
25
|
const closeAction = useRef('touch_outside');
|
|
@@ -34,35 +35,31 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
34
35
|
* tracking
|
|
35
36
|
*/
|
|
36
37
|
useEffect(() => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
38
|
+
const routes = navigator?.ref.current?.getRootState()?.routes || [];
|
|
39
|
+
const routesLength = routes.length;
|
|
40
|
+
let screen_name = routes?.[0]?.params?.screen?.name;
|
|
41
|
+
if (routesLength > 1) {
|
|
42
|
+
screen_name = routes[routesLength - 2]?.params?.screen?.name;
|
|
43
|
+
}
|
|
44
|
+
const tracking = {
|
|
45
|
+
...context,
|
|
46
|
+
screen_name,
|
|
47
|
+
component_type: 'popup',
|
|
48
|
+
component_name: id,
|
|
49
|
+
error_code: error ? error : undefined,
|
|
50
|
+
};
|
|
51
|
+
navigator?.maxApi?.trackEvent?.('service_component_displayed', {
|
|
52
|
+
...tracking,
|
|
53
|
+
trigger_id: '111012100000000000',
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return () => {
|
|
57
|
+
navigator?.maxApi?.trackEvent?.('service_popup_dismissed', {
|
|
55
58
|
...tracking,
|
|
56
|
-
trigger_id: '
|
|
59
|
+
trigger_id: '111154100000000001',
|
|
60
|
+
action_type: closeAction.current,
|
|
57
61
|
});
|
|
58
|
-
|
|
59
|
-
navigator?.maxApi?.trackEvent?.('service_popup_dismissed', {
|
|
60
|
-
...tracking,
|
|
61
|
-
trigger_id: '111154100000000001',
|
|
62
|
-
action_type: closeAction.current,
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
}
|
|
62
|
+
};
|
|
66
63
|
}, []);
|
|
67
64
|
|
|
68
65
|
/**
|
package/Popup/PopupPromotion.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, {useContext, useEffect, useRef} from 'react';
|
|
2
2
|
import {StyleSheet, TouchableOpacity, View} from 'react-native';
|
|
3
3
|
import {PopupPromotionProps} from './types';
|
|
4
|
-
import {ApplicationContext} from '../Application';
|
|
4
|
+
import {ApplicationContext, MiniAppContext} from '../Application';
|
|
5
5
|
import {Image} from '../Image';
|
|
6
6
|
import {Radius, Spacing} from '../Consts';
|
|
7
7
|
import {Icon} from '../Icon';
|
|
@@ -11,6 +11,7 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
|
11
11
|
image,
|
|
12
12
|
onIconClose,
|
|
13
13
|
}) => {
|
|
14
|
+
const context = useContext(MiniAppContext);
|
|
14
15
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
15
16
|
const closeAction = useRef('touch_outside');
|
|
16
17
|
|
|
@@ -18,34 +19,29 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
|
18
19
|
* tracking
|
|
19
20
|
*/
|
|
20
21
|
useEffect(() => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
22
|
+
const routes = navigator?.ref.current?.getRootState()?.routes || [];
|
|
23
|
+
const routesLength = routes.length;
|
|
24
|
+
let screen_name = routes?.[0]?.params?.screen?.name;
|
|
25
|
+
if (routesLength > 1) {
|
|
26
|
+
screen_name = routes[routesLength - 2]?.params?.screen?.name;
|
|
27
|
+
}
|
|
28
|
+
const tracking = {
|
|
29
|
+
...context,
|
|
30
|
+
screen_name,
|
|
31
|
+
component_type: 'popup',
|
|
32
|
+
component_name: id,
|
|
33
|
+
};
|
|
34
|
+
navigator?.maxApi?.trackEvent?.('service_component_displayed', {
|
|
35
|
+
...tracking,
|
|
36
|
+
trigger_id: '111012100000000000',
|
|
37
|
+
});
|
|
38
|
+
return () => {
|
|
39
|
+
navigator?.maxApi?.trackEvent?.('service_popup_dismissed', {
|
|
38
40
|
...tracking,
|
|
39
|
-
trigger_id: '
|
|
41
|
+
trigger_id: '111154100000000001',
|
|
42
|
+
action_type: closeAction.current,
|
|
40
43
|
});
|
|
41
|
-
|
|
42
|
-
navigator?.maxApi?.trackEvent?.('service_popup_dismissed', {
|
|
43
|
-
...tracking,
|
|
44
|
-
trigger_id: '111154100000000001',
|
|
45
|
-
action_type: closeAction.current,
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
}
|
|
44
|
+
};
|
|
49
45
|
}, []);
|
|
50
46
|
|
|
51
47
|
/**
|
package/Radio/index.tsx
CHANGED
|
@@ -6,7 +6,6 @@ import {Text} from '../Text';
|
|
|
6
6
|
import styles from './styles';
|
|
7
7
|
import {ApplicationContext} from '../Application';
|
|
8
8
|
import {Spacing} from '../Consts';
|
|
9
|
-
import {TrackingInfo} from '../Application/types';
|
|
10
9
|
|
|
11
10
|
const {
|
|
12
11
|
ScreenContext,
|
|
@@ -42,7 +41,7 @@ const Radio: FC<RadioProps> = ({
|
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
const screenInfo = useContext<
|
|
44
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
46
45
|
|
|
47
46
|
return (
|
|
48
47
|
<ScreenContext.Provider
|
package/Switch/index.tsx
CHANGED
|
@@ -3,7 +3,6 @@ import {TouchableOpacity, View} from 'react-native';
|
|
|
3
3
|
import {SwitchProps} from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
5
|
import {Colors} from '../Consts';
|
|
6
|
-
import {TrackingInfo} from '../Application/types';
|
|
7
6
|
|
|
8
7
|
const {
|
|
9
8
|
ScreenContext,
|
|
@@ -13,7 +12,7 @@ const Switch: FC<SwitchProps> = props => {
|
|
|
13
12
|
const {value, onChange, disabled, style} = props;
|
|
14
13
|
const circleBackgroundColor = value ? Colors.black_01 : Colors.black_03;
|
|
15
14
|
const circleAlign = value ? 'flex-end' : 'flex-start';
|
|
16
|
-
const screenInfo = useContext<
|
|
15
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
17
16
|
|
|
18
17
|
let backgroundColor = value ? Colors.green_03 : Colors.black_07;
|
|
19
18
|
if (disabled) {
|