@momo-kits/foundation 0.157.1-test.2 → 0.157.3-beta.20

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.
@@ -29,6 +29,7 @@ import Animated, {
29
29
  withTiming,
30
30
  } from 'react-native-reanimated';
31
31
  import layoutStyles from '../Layout/styles';
32
+ import { version } from '../package.json';
32
33
 
33
34
  const BottomSheet: React.FC<BottomSheetParams> = props => {
34
35
  const { theme, navigator } = useContext(ApplicationContext);
@@ -54,10 +55,40 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
54
55
  useDivider = true,
55
56
  footerComponent,
56
57
  leftOptions,
57
- }: BottomSheetParams = props.route.params;
58
+ screen_name,
59
+ componentName,
60
+ componentLabel,
61
+ description,
62
+ title,
63
+ } = props as BottomSheetParams;
58
64
 
59
65
  const translateY = useSharedValue(heightDevice);
60
66
 
67
+ /**
68
+ * Fire auto_popup_displayed tracking event on mount
69
+ */
70
+ useEffect(() => {
71
+ if (typeof context?.autoTracking !== 'function') {
72
+ return;
73
+ }
74
+
75
+ context.autoTracking({
76
+ ...context,
77
+ eventName: 'auto_popup_displayed',
78
+ screen_name: screen_name ?? context.screenName,
79
+ miniapp_version: context.miniapp_version,
80
+ tracking_source: 1,
81
+ app_id: context.appId,
82
+ feature_code: context.feature_code,
83
+ kits_version: version,
84
+ component_name: componentName,
85
+ component_label: componentLabel,
86
+ description,
87
+ title,
88
+ });
89
+ // eslint-disable-next-line react-hooks/exhaustive-deps
90
+ }, []);
91
+
61
92
  const openAnimation = useCallback(() => {
62
93
  translateY.value = withTiming(0, {
63
94
  duration: 350,
@@ -1,14 +1,14 @@
1
1
  import React, { useCallback, useContext, useEffect, useRef } from 'react';
2
2
  import {
3
3
  Animated,
4
+ BackHandler,
4
5
  Easing,
5
6
  KeyboardAvoidingView,
7
+ Modal as ModalRN,
6
8
  Platform,
7
9
  Pressable,
8
10
  StyleSheet,
9
11
  View,
10
- Modal as ModalRN,
11
- BackHandler,
12
12
  } from 'react-native';
13
13
 
14
14
  import { ApplicationContext, MiniAppContext } from '../Context';
@@ -17,6 +17,7 @@ import Navigation from './Navigation';
17
17
  import { ModalParams } from './types';
18
18
  import BottomSheet from './BottomSheet';
19
19
  import { runOnJS } from 'react-native-reanimated';
20
+ import { version } from '../package.json';
20
21
 
21
22
  const ModalScreen: React.FC<any> = props => {
22
23
  if (props.route?.params?.isBottomSheet) {
@@ -28,14 +29,44 @@ const ModalScreen: React.FC<any> = props => {
28
29
  const Modal: React.FC<ModalParams> = props => {
29
30
  const { navigator } = useContext(ApplicationContext);
30
31
  const context = useContext<any>(MiniAppContext);
31
- const modalParams = useRef<any>(undefined);
32
32
  const {
33
33
  screen,
34
34
  barrierDismissible,
35
35
  modalStyle,
36
36
  useNativeModal = false,
37
+ screen_name,
38
+ componentName,
39
+ componentLabel,
40
+ description,
41
+ title,
37
42
  } = props.route.params;
38
43
  const Component = useRef(screen).current;
44
+
45
+ /**
46
+ * Fire auto_popup_displayed tracking event on mount
47
+ */
48
+ useEffect(() => {
49
+ if (typeof context?.autoTracking !== 'function') {
50
+ return;
51
+ }
52
+
53
+ context.autoTracking({
54
+ ...context,
55
+ eventName: 'auto_popup_displayed',
56
+ screen_name: screen_name ?? context.screenName,
57
+ miniapp_version: context.miniapp_version,
58
+ tracking_source: 1,
59
+ app_id: context.appId,
60
+ feature_code: context.feature_code,
61
+ kits_version: version,
62
+ component_name: componentName,
63
+ component_label: componentLabel,
64
+ description,
65
+ title,
66
+ });
67
+ // eslint-disable-next-line react-hooks/exhaustive-deps
68
+ }, []);
69
+
39
70
  const opacity = useRef(new Animated.Value(0)).current;
40
71
  const scale = useRef(new Animated.Value(0.8)).current;
41
72
 
@@ -50,26 +81,6 @@ const Modal: React.FC<ModalParams> = props => {
50
81
  Container = ModalRN;
51
82
  }
52
83
 
53
- if (screen != null) {
54
- const screenProps = screen?.()?.props || {};
55
- modalParams.current = {
56
- title: screenProps?.title || '',
57
- description: screenProps?.description || '',
58
- };
59
- }
60
-
61
- useEffect(() => {
62
- const item: any = {
63
- screenName: params.screen,
64
- componentName: 'Modal',
65
- ...modalParams.current,
66
- };
67
- context?.autoTracking?.({
68
- ...context,
69
- ...item,
70
- });
71
- }, [context, params.screen]);
72
-
73
84
  useEffect(() => {
74
85
  Animated.parallel([
75
86
  Animated.timing(opacity, {
@@ -185,7 +185,35 @@ export type ScreenTrackingParams = {
185
185
  value2?: any;
186
186
  };
187
187
 
188
- export type ModalParams = {
188
+ export type ModalTrackingProps = {
189
+ /**
190
+ * Optional. Screen name for auto_popup_displayed tracking event.
191
+ * Falls back to the current screen's name from context if not provided.
192
+ */
193
+ screen_name?: string;
194
+
195
+ /**
196
+ * Optional. Component name for auto_popup_displayed tracking event.
197
+ */
198
+ componentName?: string;
199
+
200
+ /**
201
+ * Optional. Component label for auto_popup_displayed tracking event.
202
+ */
203
+ componentLabel?: string;
204
+
205
+ /**
206
+ * Optional. Description for auto_popup_displayed tracking event.
207
+ */
208
+ description?: string;
209
+
210
+ /**
211
+ * Optional. Title for auto_popup_displayed tracking event.
212
+ */
213
+ title?: string;
214
+ };
215
+
216
+ export type ModalParams = ModalTrackingProps & {
189
217
  [key: string]: any;
190
218
  screen: React.ComponentType;
191
219
  onDismiss?: () => void;
@@ -194,7 +222,7 @@ export type ModalParams = {
194
222
  useNativeModal?: boolean;
195
223
  };
196
224
 
197
- export type BottomSheetParams = {
225
+ export type BottomSheetParams = ModalTrackingProps & {
198
226
  [key: string]: any;
199
227
  screen: React.ComponentType;
200
228
  options: {
package/Popup/index.tsx CHANGED
@@ -1,4 +1,4 @@
1
1
  import PopupNotify from './PopupNotify';
2
2
  import PopupPromotion from './PopupPromotion';
3
3
 
4
- export {PopupNotify, PopupPromotion};
4
+ export { PopupNotify, PopupPromotion };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.157.1-test.2",
3
+ "version": "0.157.3-beta.20",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},