@momo-kits/foundation 0.89.4-tracking.14 → 0.89.4-tracking.16

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.
@@ -6,7 +6,6 @@ import React, {
6
6
  useState,
7
7
  } from 'react';
8
8
  import {
9
- Alert,
10
9
  Animated,
11
10
  BackHandler,
12
11
  DeviceEventEmitter,
@@ -121,23 +120,18 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
121
120
  const goBack = () => {
122
121
  const canGoBack = navigator?.ref.current?.canGoBack();
123
122
  if (!canGoBack) {
124
- const currentRoute = navigator?.ref?.current.getCurrentRoute();
125
- Alert.alert(
126
- 'service_icon_clicked',
127
- JSON.stringify({
128
- ...context,
129
- screen_name:
130
- currentRoute?.params?.screen?.name ?? currentRoute?.name,
131
- trigger_id: '111154000000000000',
132
- icon_name: 'back',
133
- }),
134
- );
135
- navigator?.maxApi?.trackEvent?.('service_icon_clicked', {
123
+ const currentRoute = navigator?.ref?.current?.getCurrentRoute?.();
124
+ const params = {
136
125
  ...context,
137
126
  screen_name: currentRoute?.params?.screen?.name ?? currentRoute?.name,
138
127
  trigger_id: '111154000000000000',
139
128
  icon_name: 'back',
129
+ };
130
+ navigator?.maxApi?.showToastDebug?.({
131
+ title: 'service_icon_clicked',
132
+ params,
140
133
  });
134
+ navigator?.maxApi?.trackEvent?.('service_icon_clicked', params);
141
135
  }
142
136
  if (canGoBack) {
143
137
  navigator?.ref.current?.goBack();
@@ -4,7 +4,7 @@ import Navigation from './Navigation';
4
4
  import {ApplicationContext, MiniAppContext} from './index';
5
5
  import {GridSystem} from '../Layout';
6
6
  import {useHeaderHeight} from '@react-navigation/stack';
7
- import {Alert} from 'react-native';
7
+ import {Alert, InteractionManager} from 'react-native';
8
8
 
9
9
  const {
10
10
  ScreenContext,
@@ -37,12 +37,24 @@ const StackScreen: React.FC<ScreenParams> = props => {
37
37
  if (options) {
38
38
  navigation.setOptions(options);
39
39
  }
40
+ InteractionManager.runAfterInteractions(() => {
41
+ navigator?.maxApi?.showToastDebug?.({
42
+ title: 'screen_interaction_time',
43
+ message: Date.now() - startTime.current,
44
+ });
45
+ });
40
46
  }, [options]);
41
47
 
42
48
  /**
43
49
  * tracking for screen
44
50
  */
45
51
  useEffect(() => {
52
+ if (__DEV__) {
53
+ if (!Component.name || Component.name === 'screen') {
54
+ Alert.alert('Design system', `Unvalidated screen name "${Component.name}" !`)
55
+ }
56
+ }
57
+
46
58
  const tracking = {
47
59
  ...context,
48
60
  screen_name: Component.name,
@@ -55,34 +67,28 @@ const StackScreen: React.FC<ScreenParams> = props => {
55
67
  pre_screen_name = routes[routesLength - 2]?.params?.screen?.name;
56
68
  }
57
69
 
58
- navigator?.maxApi?.trackEvent?.('service_frame_displayed', {
70
+ const params = {
59
71
  ...tracking,
60
72
  pre_screen_name,
61
73
  trigger_id: '111378000000000000',
74
+ };
75
+ navigator?.maxApi?.trackEvent?.('service_frame_displayed', params);
76
+ navigator?.maxApi?.showToastDebug?.({
77
+ title: 'service_frame_displayed',
78
+ params,
62
79
  });
63
80
 
64
- Alert.alert(
65
- 'service_frame_displayed',
66
- JSON.stringify({
67
- ...tracking,
68
- pre_screen_name,
69
- trigger_id: '111378000000000000',
70
- }),
71
- );
72
81
  return props.navigation.addListener('beforeRemove', () => {
73
- navigator?.maxApi?.trackEvent?.('service_icon_clicked', {
82
+ const params = {
74
83
  ...tracking,
75
84
  trigger_id: '111154000000000000',
76
85
  icon_name: 'back',
86
+ };
87
+ navigator?.maxApi?.trackEvent?.('service_icon_clicked', params);
88
+ navigator?.maxApi?.showToastDebug?.({
89
+ title: 'service_icon_clicked',
90
+ params,
77
91
  });
78
- Alert.alert(
79
- 'service_icon_clicked',
80
- JSON.stringify({
81
- ...tracking,
82
- trigger_id: '111154000000000000',
83
- icon_name: 'back',
84
- }),
85
- );
86
92
  });
87
93
  }, []);
88
94
 
@@ -100,6 +106,10 @@ const StackScreen: React.FC<ScreenParams> = props => {
100
106
  clearTimeout(timeout.current);
101
107
  timeout.current = setTimeout(() => {
102
108
  timeLoad.current = endTime.current - startTime.current;
109
+ navigator?.maxApi?.showToastDebug?.({
110
+ title: 'screen_load_time',
111
+ message: timeLoad.current,
112
+ });
103
113
  }, 1000);
104
114
  },
105
115
  }}>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.89.4-tracking.14",
3
+ "version": "0.89.4-tracking.16",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {