@momo-kits/foundation 0.81.43-tracking.1 → 0.81.43-tracking.10

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.
@@ -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 && navigator?.trackingInfo) {
126
+ if (!canGoBack) {
126
127
  const currentRoute = navigator?.ref?.current.getCurrentRoute();
127
128
  navigator?.maxApi?.trackEvent?.('service_icon_clicked', {
128
- feature_code: navigator.trackingInfo.code,
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?.requestApi('getToolsConfig', [undefined], (config: any) => {
314
- navigator.toolkitConfig = config;
315
- setToolConfig(navigator?.toolkitConfig);
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?.requestApi(
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?.requestApi('dismiss', undefined, undefined);
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?.requestApi('dismiss', undefined, undefined);
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?.requestApi('onToolAction', [pinTool?.key], () => {
368
- getToolkitConfig();
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
  />
@@ -178,7 +178,6 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
178
178
  />
179
179
  </View>
180
180
  <NavigationContainer
181
- trackingInfo={navigator?.trackingInfo}
182
181
  maxApi={navigator?.maxApi}
183
182
  theme={{
184
183
  ...theme,
@@ -6,7 +6,7 @@ import {
6
6
  NavigationContainerRef,
7
7
  } from '@react-navigation/native';
8
8
  import {createStackNavigator} from '@react-navigation/stack';
9
- import {Alert, DeviceEventEmitter, NativeModules} from 'react-native';
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
@@ -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,44 +37,41 @@ const StackScreen: React.FC<ScreenParams> = props => {
35
37
  * tracking for screen
36
38
  */
37
39
  useEffect(() => {
38
- if (navigator?.trackingInfo) {
39
- const tracking = {
40
- feature_code: navigator.trackingInfo.code,
41
- app_id: navigator.trackingInfo.appId,
42
- miniapp_version: navigator.trackingInfo.buildNumber,
43
- flow_partner_id: navigator.trackingInfo.flowPartnerId,
44
- screen_name: Component.name,
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
- const routes = props.navigation.getState()?.routes || [];
48
- const routesLength = routes.length;
49
- let pre_screen_name = '';
50
- if (routesLength > 1) {
51
- pre_screen_name = routes[routesLength - 2]?.params?.screen?.name;
52
- }
52
+ navigator?.maxApi?.trackEvent?.('service_frame_displayed', {
53
+ ...tracking,
54
+ pre_screen_name,
55
+ trigger_id: '111378000000000000',
56
+ });
53
57
 
54
- navigator?.maxApi?.trackEvent?.('service_frame_displayed', {
58
+ return props.navigation.addListener('beforeRemove', () => {
59
+ navigator?.maxApi?.trackEvent?.('service_icon_clicked', {
55
60
  ...tracking,
56
- pre_screen_name,
57
- trigger_id: '111378000000000000',
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
- ...navigator?.trackingInfo,
70
+ ...context,
74
71
  screenName: Component.name,
75
- autoTracking: navigator?.maxApi?.autoTracking,
72
+ autoTracking: (data: any) => {
73
+ navigator?.maxApi?.dispatchFunction?.('autoTracking', data);
74
+ },
76
75
  }}>
77
76
  <Component heightHeader={heightHeader} {...params} />
78
77
  {showGrid && <GridSystem />}
@@ -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,
@@ -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,21 +90,12 @@ export type LocalizationObject = {
80
90
  };
81
91
  };
82
92
 
83
- export type TrackingInfo = {
84
- [key: string]: any;
85
- app_id: string;
86
- feature_code: string;
87
- screen_name: string;
88
- flow_partner_id?: string;
89
- };
90
-
91
93
  export type NavigationContainerProps = {
92
94
  screen: Screen;
93
95
  options?: NavigationOptions;
94
96
  theme: Theme;
95
97
  maxApi: any;
96
98
  localization?: LocalizationObject;
97
- trackingInfo?: TrackingInfo;
98
99
  };
99
100
 
100
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,
@@ -75,7 +74,9 @@ export interface ButtonProps extends TouchableOpacityProps {
75
74
  */
76
75
  onPress: () => void;
77
76
 
78
- trackingParams?: any;
77
+ params?: any;
78
+
79
+ componentId?: string;
79
80
  }
80
81
 
81
82
  const Button: FC<ButtonProps> = ({
@@ -88,7 +89,8 @@ const Button: FC<ButtonProps> = ({
88
89
  loading = false,
89
90
  title = 'Button',
90
91
  onPress,
91
- trackingParams,
92
+ params,
93
+ componentId,
92
94
  ...rest
93
95
  }) => {
94
96
  const {theme, config} = useContext(ApplicationContext);
@@ -102,7 +104,7 @@ const Button: FC<ButtonProps> = ({
102
104
  };
103
105
  }
104
106
 
105
- const screenInfo = useContext<TrackingInfo>(ScreenContext);
107
+ const screenInfo = useContext<any>(ScreenContext);
106
108
  const getSizeStyle = () => {
107
109
  const styleSheet: {[key: string]: any} = styles;
108
110
  return styleSheet[size ?? 'small'];
@@ -304,8 +306,10 @@ const Button: FC<ButtonProps> = ({
304
306
  value={{
305
307
  ...screenInfo,
306
308
  componentName: 'Button',
307
- params: trackingParams,
309
+ params,
308
310
  state: type === 'disabled' ? 'disabled' : 'enabled',
311
+ componentId,
312
+ action: 'click',
309
313
  }}>
310
314
  <TouchableOpacity
311
315
  {...rest}
@@ -5,11 +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
-
10
- const {
11
- ScreenContext,
12
- } = require('react-native/Libraries/Components/ScreenContext');
13
8
 
14
9
  const CheckBox: FC<CheckBoxProps> = ({
15
10
  value,
@@ -24,7 +19,6 @@ const CheckBox: FC<CheckBoxProps> = ({
24
19
  const iconSource = indeterminate ? 'ic_minus' : 'ic_checked';
25
20
  let borderColor = theme.colors.text.default;
26
21
  let backgroundColor = theme.colors.background.surface;
27
- const screenInfo = useContext<TrackingInfo>(ScreenContext);
28
22
 
29
23
  if (haveValue) {
30
24
  borderColor = theme.colors.primary;
@@ -41,35 +35,27 @@ const CheckBox: FC<CheckBoxProps> = ({
41
35
  }
42
36
 
43
37
  return (
44
- <ScreenContext.Provider
45
- value={{
46
- ...screenInfo,
47
- componentName: 'CheckBox',
48
- params: {
49
- value,
50
- },
51
- }}>
52
- <TouchableOpacity
53
- activeOpacity={0.8}
54
- onPress={() => onChange?.(!value)}
55
- disabled={disabled}
56
- style={[style, styles.container]}>
57
- <View
58
- style={[
59
- {borderColor, backgroundColor, borderWidth: 1},
60
- styles.checkbox,
61
- ]}>
62
- {haveValue && (
63
- <Icon
64
- color={theme.colors.background.surface}
65
- size={20}
66
- source={iconSource}
67
- />
68
- )}
69
- </View>
70
- {!!label && <Text typography={'body_default_regular'}>{label}</Text>}
71
- </TouchableOpacity>
72
- </ScreenContext.Provider>
38
+ <TouchableOpacity
39
+ accessibilityLabel={`CheckBox/${label}/${value}`}
40
+ activeOpacity={0.8}
41
+ onPress={() => onChange?.(!value)}
42
+ disabled={disabled}
43
+ style={[style, styles.container]}>
44
+ <View
45
+ style={[
46
+ {borderColor, backgroundColor, borderWidth: 1},
47
+ styles.checkbox,
48
+ ]}>
49
+ {haveValue && (
50
+ <Icon
51
+ color={theme.colors.background.surface}
52
+ size={20}
53
+ source={iconSource}
54
+ />
55
+ )}
56
+ </View>
57
+ {!!label && <Text typography={'body_default_regular'}>{label}</Text>}
58
+ </TouchableOpacity>
73
59
  );
74
60
  };
75
61
 
@@ -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,
@@ -31,6 +30,10 @@ export interface IconButtonProps extends TouchableOpacityProps {
31
30
  * Optional. Defines the size of the IconButton.
32
31
  */
33
32
  size?: 'large' | 'small';
33
+
34
+ params?: any;
35
+
36
+ componentId?: string;
34
37
  }
35
38
 
36
39
  const IconButton: React.FC<IconButtonProps> = ({
@@ -38,10 +41,12 @@ const IconButton: React.FC<IconButtonProps> = ({
38
41
  icon,
39
42
  size,
40
43
  onPress,
44
+ params,
45
+ componentId,
41
46
  ...rest
42
47
  }) => {
43
48
  const {theme} = useContext(ApplicationContext);
44
- const screenInfo = useContext<TrackingInfo>(ScreenContext);
49
+ const screenInfo = useContext<any>(ScreenContext);
45
50
 
46
51
  /**
47
52
  * get size icon button
@@ -131,9 +136,10 @@ const IconButton: React.FC<IconButtonProps> = ({
131
136
  value={{
132
137
  ...screenInfo,
133
138
  componentName: 'IconButton',
134
- params: {
135
- icon,
136
- },
139
+ params,
140
+ state: type === 'disabled' ? 'disabled' : 'enabled',
141
+ componentId,
142
+ action: 'click',
137
143
  }}>
138
144
  <TouchableOpacity
139
145
  {...rest}
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
- import {TrackingInfo} from '../Application/types';
16
+
17
17
  const {
18
18
  ScreenContext,
19
19
  } = require('react-native/Libraries/Components/ScreenContext');
@@ -42,7 +42,8 @@ const Input = forwardRef(
42
42
  fontWeight = 'Regular',
43
43
  onPressIcon,
44
44
  style,
45
- trackingParams,
45
+ params,
46
+ componentId,
46
47
  ...props
47
48
  }: InputProps,
48
49
  ref,
@@ -52,7 +53,7 @@ const Input = forwardRef(
52
53
  const [haveValue, setHaveValue] = useState(!!value || !!props.defaultValue);
53
54
  const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
54
55
  const accessibilityLabel = `Input/${floatingValue ?? placeholder}`;
55
- const screenInfo = useContext<TrackingInfo>(ScreenContext);
56
+ const screenInfo = useContext<any>(ScreenContext);
56
57
 
57
58
  const onClearText = () => {
58
59
  inputRef?.current?.clear();
@@ -170,8 +171,10 @@ const Input = forwardRef(
170
171
  value={{
171
172
  ...screenInfo,
172
173
  componentName: 'Input',
173
- params: trackingParams,
174
+ params,
174
175
  state: disabled ? 'disabled' : 'enabled',
176
+ componentId,
177
+ action: 'focus',
175
178
  }}>
176
179
  <View
177
180
  style={[style, styles.wrapper]}
@@ -1,4 +1,10 @@
1
- import React, {forwardRef, useContext, useRef, useState} from 'react';
1
+ import React, {
2
+ forwardRef,
3
+ useContext,
4
+ useImperativeHandle,
5
+ useRef,
6
+ useState,
7
+ } from 'react';
2
8
  import {
3
9
  NativeSyntheticEvent,
4
10
  TextInput,
@@ -12,7 +18,7 @@ import {ErrorView, FloatingView, getBorderColor, getSizeStyle} from './common';
12
18
  import {InputMoneyProps} from './index';
13
19
  import {Icon} from '../Icon';
14
20
  import {formatMoneyToNumber, formatNumberToMoney} from './utils';
15
- import {TrackingInfo} from '../Application/types';
21
+
16
22
  const {
17
23
  ScreenContext,
18
24
  } = require('react-native/Libraries/Components/ScreenContext');
@@ -34,8 +40,9 @@ const InputMoney = forwardRef(
34
40
  required = false,
35
41
  errorSpacing,
36
42
  style,
37
- trackingParams,
43
+ params,
38
44
  defaultValue = '',
45
+ componentId,
39
46
  ...props
40
47
  }: InputMoneyProps,
41
48
  ref,
@@ -44,7 +51,7 @@ const InputMoney = forwardRef(
44
51
  const [focused, setFocused] = useState(false);
45
52
  const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
46
53
  const accessibilityLabel = `InputMoney/${floatingValue}`;
47
- const screenInfo = useContext<TrackingInfo>(ScreenContext);
54
+ const screenInfo = useContext<any>(ScreenContext);
48
55
 
49
56
  const validateText = (text: string) => {
50
57
  const valueFormat = formatMoneyToNumber(text, 'đ');
@@ -69,6 +76,12 @@ const InputMoney = forwardRef(
69
76
  onChangeText?.(formatMoneyToNumber(text, 'đ').toString());
70
77
  };
71
78
 
79
+ useImperativeHandle(ref, () => {
80
+ return {
81
+ setText: _onChangeText,
82
+ };
83
+ });
84
+
72
85
  const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
73
86
  setFocused(true);
74
87
  onFocus?.(e);
@@ -152,8 +165,10 @@ const InputMoney = forwardRef(
152
165
  value={{
153
166
  ...screenInfo,
154
167
  componentName: 'InputMoney',
155
- params: trackingParams,
168
+ params,
156
169
  state: 'enable',
170
+ componentId,
171
+ action: 'focus',
157
172
  }}>
158
173
  <View
159
174
  style={[style, styles.wrapper]}
@@ -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
- import {TrackingInfo} from '../Application/types';
24
+
25
25
  const {
26
26
  ScreenContext,
27
27
  } = require('react-native/Libraries/Components/ScreenContext');
@@ -82,8 +82,9 @@ const InputOTP = forwardRef(
82
82
  onFocus,
83
83
  onBlur,
84
84
  dataType = 'number',
85
- trackingParams,
85
+ params,
86
86
  style,
87
+ componentId,
87
88
  ...props
88
89
  }: InputOTPProps,
89
90
  ref,
@@ -94,7 +95,7 @@ const InputOTP = forwardRef(
94
95
  const inputRef = useRef<TextInput>(null);
95
96
  const {theme} = useContext(ApplicationContext);
96
97
  const accessibilityLabel = `InputOTP/${floatingValue ?? placeholder}`;
97
- const screenInfo = useContext<TrackingInfo>(ScreenContext);
98
+ const screenInfo = useContext<any>(ScreenContext);
98
99
 
99
100
  useImperativeHandle(ref, () => ({
100
101
  onChangeText: (text: string) => {
@@ -233,8 +234,10 @@ const InputOTP = forwardRef(
233
234
  value={{
234
235
  ...screenInfo,
235
236
  componentName: 'InputOTP',
236
- params: trackingParams,
237
+ params,
237
238
  state: 'enable',
239
+ componentId,
240
+ action: 'focus',
238
241
  }}>
239
242
  <TouchableOpacity
240
243
  activeOpacity={1}
@@ -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
- import {TrackingInfo} from '../Application/types';
15
+
16
16
  const {
17
17
  ScreenContext,
18
18
  } = require('react-native/Libraries/Components/ScreenContext');
@@ -33,7 +33,8 @@ const InputSearch = forwardRef(
33
33
  style,
34
34
  defaultValue,
35
35
  onPressButtonText,
36
- trackingParams,
36
+ params,
37
+ componentId,
37
38
  ...props
38
39
  }: InputSearchProps,
39
40
  ref,
@@ -43,7 +44,7 @@ const InputSearch = forwardRef(
43
44
  const [haveValue, setHaveValue] = useState(!!value || !!defaultValue);
44
45
  const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
45
46
  const accessibilityLabel = `InputMoney/${placeholder}`;
46
- const screenInfo = useContext<TrackingInfo>(ScreenContext);
47
+ const screenInfo = useContext<any>(ScreenContext);
47
48
 
48
49
  const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
49
50
  setFocused(true);
@@ -129,8 +130,10 @@ const InputSearch = forwardRef(
129
130
  value={{
130
131
  ...screenInfo,
131
132
  componentName: 'InputSearch',
132
- params: trackingParams,
133
+ params,
133
134
  state: 'enabled',
135
+ componentId,
136
+ action: 'focus',
134
137
  }}>
135
138
  <View
136
139
  style={[style, styles.searchInputContainer]}
package/Input/index.tsx CHANGED
@@ -81,7 +81,8 @@ export interface InputProps extends TextInputProps {
81
81
 
82
82
  onPressIcon?: () => void;
83
83
 
84
- trackingParams?: any;
84
+ params?: any;
85
+ componentId?: string;
85
86
  }
86
87
 
87
88
  type InputPropsWithoutSizeAndIcon = Omit<
@@ -129,7 +130,9 @@ export interface InputSearchProps extends TextInputProps {
129
130
  */
130
131
  icon?: string;
131
132
 
132
- trackingParams?: any;
133
+ params?: any;
134
+
135
+ componentId?: string;
133
136
  }
134
137
 
135
138
  export interface InputMoneyProps extends InputPropsWithoutPlaceholder {}
@@ -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
- if (navigator?.trackingInfo) {
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
- feature_code: navigator?.trackingInfo?.code,
46
- app_id: navigator?.trackingInfo?.appId,
47
- miniapp_version: navigator?.trackingInfo?.buildNumber,
48
- flow_partner_id: navigator?.trackingInfo?.flowPartnerId,
49
- screen_name,
50
- component_type: 'popup',
51
- component_name: id,
52
- error_code: error ? error : undefined,
53
- };
54
- navigator?.maxApi?.trackEvent?.('service_component_displayed', {
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: '111012100000000000',
59
+ trigger_id: '111154100000000001',
60
+ action_type: closeAction.current,
57
61
  });
58
- return () => {
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
  /**
@@ -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
- if (navigator?.trackingInfo) {
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
- feature_code: navigator?.trackingInfo?.code,
30
- app_id: navigator?.trackingInfo?.appId,
31
- miniapp_version: navigator?.trackingInfo?.buildNumber,
32
- flow_partner_id: navigator?.trackingInfo?.flowPartnerId,
33
- screen_name,
34
- component_type: 'popup',
35
- component_name: id,
36
- };
37
- navigator?.maxApi?.trackEvent?.('service_component_displayed', {
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: '111012100000000000',
41
+ trigger_id: '111154100000000001',
42
+ action_type: closeAction.current,
40
43
  });
41
- return () => {
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,11 +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
-
11
- const {
12
- ScreenContext,
13
- } = require('react-native/Libraries/Components/ScreenContext');
14
9
 
15
10
  const Radio: FC<RadioProps> = ({
16
11
  value,
@@ -42,38 +37,28 @@ const Radio: FC<RadioProps> = ({
42
37
  };
43
38
  }
44
39
 
45
- const screenInfo = useContext<TrackingInfo>(ScreenContext);
46
-
47
40
  return (
48
- <ScreenContext.Provider
49
- value={{
50
- ...screenInfo,
51
- componentName: 'Radio',
52
- params: {
53
- value,
41
+ <TouchableOpacity
42
+ accessibilityLabel={`Radio/${label}/${value}`}
43
+ onPress={onChange}
44
+ disabled={disabled}
45
+ style={[
46
+ style,
47
+ {
48
+ flexDirection: 'row',
49
+ alignItems: 'center',
54
50
  },
55
- }}>
56
- <TouchableOpacity
57
- onPress={onChange}
58
- disabled={disabled}
51
+ ]}>
52
+ <View
59
53
  style={[
60
- style,
61
- {
62
- flexDirection: 'row',
63
- alignItems: 'center',
64
- },
65
- ]}>
66
- <View
67
- style={[
68
- styles.radio,
69
- checkBoxStyle,
70
- disabledStyle,
71
- {marginRight: label ? Spacing.XS : 0},
72
- ]}
73
- />
74
- {!!label && <Text typography={'body_default_regular'}>{label}</Text>}
75
- </TouchableOpacity>
76
- </ScreenContext.Provider>
54
+ styles.radio,
55
+ checkBoxStyle,
56
+ disabledStyle,
57
+ {marginRight: label ? Spacing.XS : 0},
58
+ ]}
59
+ />
60
+ {!!label && <Text typography={'body_default_regular'}>{label}</Text>}
61
+ </TouchableOpacity>
77
62
  );
78
63
  };
79
64
 
package/Switch/index.tsx CHANGED
@@ -1,19 +1,13 @@
1
- import React, {FC, useContext} from 'react';
1
+ import React, {FC} from 'react';
2
2
  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
-
8
- const {
9
- ScreenContext,
10
- } = require('react-native/Libraries/Components/ScreenContext');
11
6
 
12
7
  const Switch: FC<SwitchProps> = props => {
13
8
  const {value, onChange, disabled, style} = props;
14
9
  const circleBackgroundColor = value ? Colors.black_01 : Colors.black_03;
15
10
  const circleAlign = value ? 'flex-end' : 'flex-start';
16
- const screenInfo = useContext<TrackingInfo>(ScreenContext);
17
11
 
18
12
  let backgroundColor = value ? Colors.green_03 : Colors.black_07;
19
13
  if (disabled) {
@@ -21,27 +15,19 @@ const Switch: FC<SwitchProps> = props => {
21
15
  }
22
16
 
23
17
  return (
24
- <ScreenContext.Provider
25
- value={{
26
- ...screenInfo,
27
- componentName: 'Switch',
28
- params: {
29
- value,
30
- },
31
- }}>
32
- <TouchableOpacity
33
- disabled={disabled}
34
- onPress={() => onChange?.(!value)}
35
- style={[
36
- style,
37
- styles.container,
38
- {backgroundColor, alignItems: circleAlign},
39
- ]}>
40
- <View style={[styles.circle, {backgroundColor: circleBackgroundColor}]}>
41
- <View style={[styles.circleSmall, {backgroundColor}]} />
42
- </View>
43
- </TouchableOpacity>
44
- </ScreenContext.Provider>
18
+ <TouchableOpacity
19
+ accessibilityLabel={'Switch'}
20
+ disabled={disabled}
21
+ onPress={() => onChange?.(!value)}
22
+ style={[
23
+ style,
24
+ styles.container,
25
+ {backgroundColor, alignItems: circleAlign},
26
+ ]}>
27
+ <View style={[styles.circle, {backgroundColor: circleBackgroundColor}]}>
28
+ <View style={[styles.circleSmall, {backgroundColor}]} />
29
+ </View>
30
+ </TouchableOpacity>
45
31
  );
46
32
  };
47
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.81.43-tracking.1",
3
+ "version": "0.81.43-tracking.10",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {