@momo-kits/foundation 0.102.6-beta.8 → 0.102.6-beta.9
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/StackScreen.tsx +52 -43
- package/package.json +1 -1
|
@@ -15,18 +15,19 @@ import {Colors, Radius, Spacing} from '../Consts';
|
|
|
15
15
|
*/
|
|
16
16
|
const StackScreen: React.FC<ScreenParams> = props => {
|
|
17
17
|
const {showGrid, navigator} = useContext(ApplicationContext);
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const tracked = useRef<any>({
|
|
18
|
+
const tracking = useRef<any>({
|
|
19
|
+
timeoutLoad: undefined,
|
|
20
|
+
interaction: undefined,
|
|
21
|
+
startTime: Date.now(),
|
|
22
|
+
endTime: Date.now(),
|
|
24
23
|
traceIdLoad: undefined,
|
|
25
24
|
traceIdInteraction: undefined,
|
|
26
25
|
releaseLoad: undefined,
|
|
27
26
|
releaseInteraction: undefined,
|
|
27
|
+
timeLoad: 0,
|
|
28
|
+
timeInteraction: 0,
|
|
28
29
|
});
|
|
29
|
-
|
|
30
|
+
|
|
30
31
|
const context = useContext<any>(MiniAppContext);
|
|
31
32
|
const {screen: Component, options, initialParams} = props.route.params;
|
|
32
33
|
const navigation = new Navigation(props.navigation);
|
|
@@ -71,19 +72,22 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
71
72
|
}, 300);
|
|
72
73
|
}
|
|
73
74
|
navigator?.maxApi?.of?.({screenName});
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
props.navigation?.addListener?.('focus', () => {
|
|
76
|
+
navigator?.maxApi?.getDataObserver('CURRENT_SCREEN', (data: any) => {
|
|
77
|
+
if (data) {
|
|
78
|
+
Alert.alert('getDataObserver', JSON.stringify(data));
|
|
79
|
+
}
|
|
80
|
+
navigator?.maxApi?.setObserver('CURRENT_SCREEN', {screenName});
|
|
81
|
+
});
|
|
79
82
|
});
|
|
83
|
+
|
|
80
84
|
navigator?.maxApi?.startTraceScreenLoad?.(screenName, (data: any) => {
|
|
81
|
-
|
|
85
|
+
tracking.current.traceIdLoad = data?.traceId;
|
|
82
86
|
});
|
|
83
87
|
navigator?.maxApi?.startTraceScreenInteraction?.(
|
|
84
88
|
screenName,
|
|
85
89
|
(data: any) => {
|
|
86
|
-
|
|
90
|
+
tracking.current.traceIdInteraction = data?.traceId;
|
|
87
91
|
}
|
|
88
92
|
);
|
|
89
93
|
return () => {
|
|
@@ -96,9 +100,10 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
96
100
|
* tracking for screen load
|
|
97
101
|
*/
|
|
98
102
|
const onScreenLoad = () => {
|
|
99
|
-
if (!
|
|
100
|
-
if (
|
|
101
|
-
|
|
103
|
+
if (!tracking.current?.releaseLoad) {
|
|
104
|
+
if (tracking.current.timeLoad === 0) {
|
|
105
|
+
tracking.current.timeLoad =
|
|
106
|
+
tracking.current.endTime - tracking.current.startTime;
|
|
102
107
|
}
|
|
103
108
|
|
|
104
109
|
context.autoTracking?.({
|
|
@@ -109,24 +114,24 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
109
114
|
action: 'push',
|
|
110
115
|
componentName: 'Screen',
|
|
111
116
|
state: 'load',
|
|
112
|
-
duration:
|
|
117
|
+
duration: tracking.current.timeLoad,
|
|
113
118
|
});
|
|
114
119
|
navigator?.maxApi?.stopTrace?.(
|
|
115
|
-
|
|
116
|
-
{value:
|
|
120
|
+
tracking.current.traceIdLoad,
|
|
121
|
+
{value: tracking.current.timeLoad / 1000},
|
|
117
122
|
null
|
|
118
123
|
);
|
|
119
|
-
|
|
124
|
+
tracking.current.releaseLoad = true;
|
|
120
125
|
|
|
121
126
|
/**
|
|
122
127
|
* debug
|
|
123
128
|
*/
|
|
124
129
|
navigator?.maxApi?.showToastDebug?.({
|
|
125
130
|
appId: context.appId,
|
|
126
|
-
message: `${screenName} screen_load_time ${
|
|
131
|
+
message: `${screenName} screen_load_time ${tracking.current.timeLoad}`,
|
|
127
132
|
type: 'ERROR',
|
|
128
133
|
});
|
|
129
|
-
if (
|
|
134
|
+
if (tracking.current.timeLoad <= 0 && context.enableAutoId) {
|
|
130
135
|
Alert.alert(screenName, "Can't get screen load time");
|
|
131
136
|
}
|
|
132
137
|
}
|
|
@@ -136,12 +141,13 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
136
141
|
* tracking for screen load
|
|
137
142
|
*/
|
|
138
143
|
const onScreenInteraction = () => {
|
|
139
|
-
if (!
|
|
140
|
-
if (
|
|
141
|
-
|
|
144
|
+
if (!tracking.current?.releaseInteraction) {
|
|
145
|
+
if (tracking.current.timeLoad === 0) {
|
|
146
|
+
tracking.current.timeLoad =
|
|
147
|
+
tracking.current.endTime - tracking.current.startTime;
|
|
142
148
|
}
|
|
143
|
-
if (
|
|
144
|
-
|
|
149
|
+
if (tracking.current.timeInteraction === 0) {
|
|
150
|
+
tracking.current.timeInteraction = tracking.current.timeLoad;
|
|
145
151
|
}
|
|
146
152
|
|
|
147
153
|
context.autoTracking?.({
|
|
@@ -151,24 +157,24 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
151
157
|
screenName,
|
|
152
158
|
componentName: 'Screen',
|
|
153
159
|
state: 'interaction',
|
|
154
|
-
duration:
|
|
160
|
+
duration: tracking.current.timeInteraction - tracking.current.timeLoad,
|
|
155
161
|
});
|
|
156
162
|
navigator?.maxApi?.stopTrace?.(
|
|
157
|
-
|
|
158
|
-
{value:
|
|
163
|
+
tracking.current.traceIdInteraction,
|
|
164
|
+
{value: tracking.current.timeInteraction / 1000},
|
|
159
165
|
null
|
|
160
166
|
);
|
|
161
|
-
|
|
167
|
+
tracking.current.releaseInteraction = true;
|
|
162
168
|
|
|
163
169
|
/**
|
|
164
170
|
* debug toast
|
|
165
171
|
*/
|
|
166
172
|
navigator?.maxApi?.showToastDebug?.({
|
|
167
173
|
appId: context.appId,
|
|
168
|
-
message: `${screenName} screen_interaction_time ${
|
|
174
|
+
message: `${screenName} screen_interaction_time ${tracking.current.timeInteraction}`,
|
|
169
175
|
type: 'ERROR',
|
|
170
176
|
});
|
|
171
|
-
if (
|
|
177
|
+
if (tracking.current.timeInteraction <= 0 && context.enableAutoId) {
|
|
172
178
|
Alert.alert(screenName, "Can't get screen interaction time");
|
|
173
179
|
}
|
|
174
180
|
}
|
|
@@ -179,15 +185,18 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
179
185
|
value={{
|
|
180
186
|
screenName,
|
|
181
187
|
onElementLoad: () => {
|
|
182
|
-
clearTimeout(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
clearTimeout(tracking.current.timeoutLoad);
|
|
189
|
+
tracking.current.endTime = Date.now();
|
|
190
|
+
tracking.current.interaction?.cancel?.();
|
|
191
|
+
tracking.current.interaction =
|
|
192
|
+
InteractionManager.runAfterInteractions(() => {
|
|
193
|
+
tracking.current.timeInteraction =
|
|
194
|
+
Date.now() - tracking.current.startTime;
|
|
195
|
+
});
|
|
196
|
+
tracking.current.timeoutLoad = setTimeout(() => {
|
|
197
|
+
if (tracking.current.timeLoad === 0) {
|
|
198
|
+
tracking.current.timeLoad =
|
|
199
|
+
tracking.current.endTime - tracking.current.startTime;
|
|
191
200
|
}
|
|
192
201
|
onScreenLoad();
|
|
193
202
|
onScreenInteraction();
|