@momo-kits/foundation 0.92.31 → 0.92.33

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,6 +1,6 @@
1
1
  import React, {useContext, useEffect, useLayoutEffect, useRef} from 'react';
2
2
  import {useHeaderHeight} from '@react-navigation/stack';
3
- import {InteractionManager, Linking, View} from 'react-native';
3
+ import {Alert, InteractionManager, Linking, View} from 'react-native';
4
4
  import {ScreenParams} from './types';
5
5
  import Navigation from './Navigation';
6
6
  import {ApplicationContext, MiniAppContext, ScreenContext} from './index';
@@ -95,6 +95,8 @@ const StackScreen: React.FC<ScreenParams> = props => {
95
95
  const timeInteraction = useRef(0);
96
96
  const timeoutLoad = useRef<any>();
97
97
  const tracked = useRef<any>({
98
+ traceIdLoad: undefined,
99
+ traceIdInteraction: undefined,
98
100
  releaseLoad: undefined,
99
101
  releaseInteraction: undefined,
100
102
  timeoutLoad: undefined,
@@ -125,6 +127,15 @@ const StackScreen: React.FC<ScreenParams> = props => {
125
127
  if (options) {
126
128
  navigation.setOptions(options);
127
129
  }
130
+ navigator?.maxApi?.startTraceScreenLoad?.(screenName, (data: any) => {
131
+ tracked.current.traceIdLoad = data?.traceId;
132
+ });
133
+ navigator?.maxApi?.startTraceScreenInteraction?.(
134
+ screenName,
135
+ (data: any) => {
136
+ tracked.current.traceIdInteraction = data?.traceId;
137
+ }
138
+ );
128
139
  }, [options]);
129
140
 
130
141
  /**
@@ -146,6 +157,8 @@ const StackScreen: React.FC<ScreenParams> = props => {
146
157
  }, 5000);
147
158
 
148
159
  return () => {
160
+ clearTimeout(tracked.current.timeoutLoad);
161
+ clearTimeout(tracked.current.timeoutInteraction);
149
162
  onScreenLoad();
150
163
  onScreenInteraction();
151
164
  };
@@ -155,8 +168,10 @@ const StackScreen: React.FC<ScreenParams> = props => {
155
168
  * tracking for screen load
156
169
  */
157
170
  const onScreenLoad = () => {
158
- clearTimeout(tracked.current.timeoutLoad);
159
171
  if (!tracked.current?.releaseLoad) {
172
+ if (timeLoad.current === 0) {
173
+ timeLoad.current = endTime.current - startTime.current;
174
+ }
160
175
  context.autoTracking?.({
161
176
  appId: context.appId,
162
177
  code: context.code,
@@ -166,10 +181,18 @@ const StackScreen: React.FC<ScreenParams> = props => {
166
181
  state: 'load',
167
182
  duration: timeLoad.current,
168
183
  });
184
+ navigator?.maxApi?.stopTrace?.(
185
+ tracked.current.traceIdLoad,
186
+ {value: timeLoad.current},
187
+ null
188
+ );
169
189
  navigator?.maxApi?.showToastDebug?.({
170
190
  appId: `auto - ${context.appId}`,
171
191
  message: `${screenName} screen_load_time ${timeLoad.current}`,
172
192
  });
193
+ if (timeLoad.current === 0 && context.enableAutoId) {
194
+ Alert.alert(screenName, "Can't get screen load time");
195
+ }
173
196
  tracked.current.releaseLoad = true;
174
197
  }
175
198
  };
@@ -178,8 +201,17 @@ const StackScreen: React.FC<ScreenParams> = props => {
178
201
  * tracking for screen load
179
202
  */
180
203
  const onScreenInteraction = () => {
181
- clearTimeout(tracked.current.timeoutInteraction);
182
204
  if (!tracked.current?.releaseInteraction) {
205
+ if (timeLoad.current === 0) {
206
+ timeLoad.current = endTime.current - startTime.current;
207
+ }
208
+ if (timeInteraction.current === 0 && context.enableAutoId) {
209
+ if (context.enableAutoId) {
210
+ Alert.alert(screenName, "Can't get screen interaction time");
211
+ }
212
+ timeInteraction.current = timeLoad.current;
213
+ }
214
+
183
215
  context.autoTracking?.({
184
216
  appId: context.appId,
185
217
  code: context.code,
@@ -189,7 +221,11 @@ const StackScreen: React.FC<ScreenParams> = props => {
189
221
  state: 'interaction',
190
222
  duration: timeInteraction.current - timeLoad.current,
191
223
  });
192
-
224
+ navigator?.maxApi?.stopTrace?.(
225
+ tracked.current.traceIdInteraction,
226
+ {value: timeInteraction.current},
227
+ null
228
+ );
193
229
  navigator?.maxApi?.showToastDebug?.({
194
230
  appId: `auto - ${context.appId}`,
195
231
  message: `${screenName} screen_interaction_time ${timeInteraction.current}`,
@@ -203,12 +239,12 @@ const StackScreen: React.FC<ScreenParams> = props => {
203
239
  value={{
204
240
  screenName,
205
241
  onElementLoad: () => {
242
+ clearTimeout(timeoutLoad.current);
206
243
  endTime.current = Date.now();
207
244
  interaction.current?.cancel?.();
208
245
  interaction.current = InteractionManager.runAfterInteractions(() => {
209
246
  timeInteraction.current = Date.now() - startTime.current;
210
247
  });
211
- clearTimeout(timeoutLoad.current);
212
248
  timeoutLoad.current = setTimeout(() => {
213
249
  if (timeLoad.current === 0) {
214
250
  timeLoad.current = endTime.current - startTime.current;
package/Tag/styles.ts CHANGED
@@ -1,19 +1,20 @@
1
1
  import {StyleSheet} from 'react-native';
2
2
  import {Radius, Spacing} from '../Consts';
3
+ import {scaleSize} from '../Text';
3
4
 
4
5
  export default StyleSheet.create({
5
6
  container: {
6
7
  paddingHorizontal: Spacing.S,
7
8
  borderRadius: Radius.S,
8
9
  flexDirection: 'row',
9
- height: 24,
10
+ height: scaleSize(24),
10
11
  alignItems: 'center',
11
12
  justifyContent: 'center',
12
13
  },
13
14
  mediumContainer: {
14
15
  paddingHorizontal: Spacing.S,
15
16
  borderRadius: Radius.S,
16
- height: 18,
17
+ height: scaleSize(18),
17
18
  alignItems: 'center',
18
19
  flexDirection: 'row',
19
20
  justifyContent: 'center',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.92.31",
3
+ "version": "0.92.33",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},
package/publish.sh CHANGED
@@ -1,28 +1,18 @@
1
1
  #!/bin/bash
2
2
 
3
- # Prepare dist files
4
- rm -rf dist
5
- mkdir dist
6
- rsync -r --exclude=/dist ./* dist
7
- cd dist
8
-
9
3
  if [ "$1" == "stable" ]; then
10
- #npm version $(npm view @momo-kits/foundation@stable version)
11
- #npm version patch
4
+ npm version $(npm view @momo-kits/foundation@stable version)
5
+ npm version patch
12
6
  npm publish --tag stable --access=public
13
7
  elif [ "$1" == "latest" ]; then
14
- #npm version $(npm view @momo-kits/foundation@latest version)
15
- #npm version prerelease --preid=rc
8
+ npm version $(npm view @momo-kits/foundation@latest version)
9
+ npm version prerelease --preid=rc
16
10
  npm publish --tag latest --access=public
17
11
  else
18
- #npm version $(npm view @momo-kits/foundation@beta version)
19
- #npm version prerelease --preid=beta
12
+ npm version $(npm view @momo-kits/foundation@beta version)
13
+ npm version prerelease --preid=beta
20
14
  npm publish --tag beta --access=public
21
15
  fi
22
16
 
23
17
  PACKAGE_NAME=$(npm pkg get name)
24
18
  NEW_PACKAGE_VERSION=$(npm pkg get version)
25
-
26
- # Clean up
27
- cd ..
28
- rm -rf dist