@momo-kits/foundation 0.151.1-test.5 → 0.151.1-tracking.2

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.
@@ -1,5 +1,5 @@
1
1
  import React, { useContext, useEffect, useLayoutEffect, useRef } from 'react';
2
- import { Alert, InteractionManager } from 'react-native';
2
+ import { Alert, AppState, InteractionManager } from 'react-native';
3
3
  import { useHeaderHeight } from '@react-navigation/elements';
4
4
  import { ScreenTrackingParams } from './types';
5
5
  import Navigation from './Navigation';
@@ -48,6 +48,24 @@ const StackScreen: React.FC<any> = props => {
48
48
  } = props.route.params;
49
49
  const navigation = useRef(new Navigation(props.navigation, context)).current;
50
50
  const heightHeader = useHeaderHeight();
51
+ const appState = useRef(AppState.currentState);
52
+ let isBackgroundToForeground = useRef(false).current;
53
+
54
+ useEffect(() => {
55
+ const subscription = AppState.addEventListener('change', nextAppState => {
56
+ if (
57
+ appState.current.match(/inactive|background/) &&
58
+ nextAppState === 'active'
59
+ ) {
60
+ isBackgroundToForeground = true;
61
+ }
62
+ appState.current = nextAppState;
63
+ });
64
+
65
+ return () => {
66
+ subscription.remove();
67
+ };
68
+ }, []);
51
69
 
52
70
  const data = {
53
71
  ...initialParams,
@@ -148,10 +166,12 @@ const StackScreen: React.FC<any> = props => {
148
166
  action: tracking.current?.mounted ? 'back' : 'push',
149
167
  };
150
168
 
151
- context?.autoTracking?.({
152
- ...context,
153
- ...item,
154
- });
169
+ if (!isBackgroundToForeground) {
170
+ context?.autoTracking?.({
171
+ ...context,
172
+ ...item,
173
+ });
174
+ }
155
175
 
156
176
  tracking.current.mounted = true;
157
177
 
@@ -163,6 +183,8 @@ const StackScreen: React.FC<any> = props => {
163
183
  message: `${screenName} screen_navigated`,
164
184
  type: 'ERROR',
165
185
  });
186
+
187
+ if (isBackgroundToForeground) isBackgroundToForeground = false;
166
188
  };
167
189
 
168
190
  /**
package/package.json CHANGED
@@ -1,35 +1,35 @@
1
1
  {
2
- "name": "@momo-kits/foundation",
3
- "version": "0.151.1-test.5",
4
- "description": "React Native Component Kits",
5
- "main": "index.ts",
6
- "scripts": {},
7
- "keywords": [
8
- "@momo-kits/foundation"
9
- ],
10
- "dependencies": {
11
- "react-native-fast-image": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-fast-image.git#v8.11.0",
12
- "@react-navigation/bottom-tabs": "7.4.2",
13
- "@react-navigation/core": "7.12.1",
14
- "@react-navigation/elements": "2.5.2",
15
- "@react-navigation/native": "7.1.14",
16
- "@react-navigation/routers": "7.4.1",
17
- "@react-navigation/stack": "7.4.2",
18
- "react-native-gesture-handler": "2.27.1",
19
- "react-native-linear-gradient": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-linear-gradient#v3.0.0",
20
- "react-native-reanimated": "4.1.0",
21
- "react-native-safe-area-context": "5.5.2",
22
- "@shopify/flash-list": "2.1.0"
23
- },
24
- "peerDependencies": {
25
- "react-native": "*"
26
- },
27
- "devDependencies": {
28
- "@momo-platform/versions": "4.1.11",
29
- "@types/color": "3.0.6"
30
- },
31
- "publishConfig": {
32
- "registry": "https://registry.npmjs.org/"
33
- },
34
- "license": "MoMo"
35
- }
2
+ "name": "@momo-kits/foundation",
3
+ "version": "0.151.1-tracking.2",
4
+ "description": "React Native Component Kits",
5
+ "main": "index.ts",
6
+ "scripts": {},
7
+ "keywords": [
8
+ "@momo-kits/foundation"
9
+ ],
10
+ "dependencies": {
11
+ "react-native-fast-image": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-fast-image.git#v8.11.0",
12
+ "@react-navigation/bottom-tabs": "7.4.2",
13
+ "@react-navigation/core": "7.12.1",
14
+ "@react-navigation/elements": "2.5.2",
15
+ "@react-navigation/native": "7.1.14",
16
+ "@react-navigation/routers": "7.4.1",
17
+ "@react-navigation/stack": "7.4.2",
18
+ "react-native-gesture-handler": "2.27.1",
19
+ "react-native-linear-gradient": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-linear-gradient#v3.0.0",
20
+ "react-native-reanimated": "4.1.0",
21
+ "react-native-safe-area-context": "5.5.2",
22
+ "@shopify/flash-list": "2.1.0"
23
+ },
24
+ "peerDependencies": {
25
+ "react-native": "*"
26
+ },
27
+ "devDependencies": {
28
+ "@momo-platform/versions": "4.1.11",
29
+ "@types/color": "3.0.6"
30
+ },
31
+ "publishConfig": {
32
+ "registry": "https://registry.npmjs.org/"
33
+ },
34
+ "license": "MoMo"
35
+ }