@jolibox/implement 1.3.4 → 1.3.5-beta.3

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,9 +1,9 @@
1
1
  Invoking: npm run clean && npm run build:esm && tsc
2
2
 
3
- > @jolibox/implement@1.3.4 clean
3
+ > @jolibox/implement@1.3.5-beta.3 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/implement@1.3.4 build:esm
7
+ > @jolibox/implement@1.3.5-beta.3 build:esm
8
8
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
9
9
 
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@jolibox/implement",
3
3
  "description": "This project is Jolibox JS-SDk implement for Native && H5",
4
- "version": "1.3.4",
4
+ "version": "1.3.5-beta.3",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "@jolibox/common": "1.3.4",
10
- "@jolibox/types": "1.3.4",
11
- "@jolibox/native-bridge": "1.3.4",
12
- "@jolibox/ads": "1.3.4",
9
+ "@jolibox/common": "1.3.5-beta.3",
10
+ "@jolibox/types": "1.3.5-beta.3",
11
+ "@jolibox/native-bridge": "1.3.5-beta.3",
12
+ "@jolibox/ads": "1.3.5-beta.3",
13
13
  "localforage": "1.10.0",
14
- "@jolibox/ui": "1.3.4",
14
+ "@jolibox/ui": "1.3.5-beta.3",
15
15
  "web-vitals": "4.2.4"
16
16
  },
17
17
  "devDependencies": {
@@ -13,6 +13,9 @@ const JOLIBOX_JOLI_UNLOGIN_MODAL_EVENT = 'JOLIBOX_JOLI_UNLOGIN_MODAL_EVENT'; //
13
13
  const JOLIBOX_GET_USER_SUB_STATUS = 'JOLIBOX_GET_USER_SUB_STATUS';
14
14
  const JOLIBOX_SUB_EVENT = 'JOLIBOX_SUB_EVENT';
15
15
 
16
+ const CP_LOAD_FINISH = 'CP_LOAD_FINISH';
17
+ const CP_LOAD_PROGRESS = 'CP_LOAD_PROGRESS';
18
+
16
19
  interface JoliboxCustomEvent {
17
20
  [JOLIBOX_CUSTOM_ADS_EVENT_TYPE]: {
18
21
  isAdShowing: boolean;
@@ -52,6 +55,12 @@ interface JoliboxCustomEvent {
52
55
  [JOLIBOX_SUB_EVENT]: {
53
56
  sequenceId: string;
54
57
  };
58
+ [CP_LOAD_FINISH]: {
59
+ // no data
60
+ };
61
+ [CP_LOAD_PROGRESS]: {
62
+ progress: number;
63
+ };
55
64
  }
56
65
 
57
66
  const notifyCustomEvent = <T extends keyof JoliboxCustomEvent>(eventName: T, data: JoliboxCustomEvent[T]) => {
package/src/h5/api/ads.ts CHANGED
@@ -125,7 +125,11 @@ const adsContext: IAdsContext<'GAME'> = {
125
125
  osType: platform.isAndroid ? 'ANDROID' : platform.isiOS ? 'IOS' : 'PC',
126
126
  runtimeType: 'WEB',
127
127
  platform: 1000, // WebSDK
128
- joliSource: context.joliSource ?? ''
128
+ joliSource: context.joliSource ?? '',
129
+ deviceInfo: {
130
+ platform: 'h5',
131
+ nativeSDKVersionCode: 0 // not support in h5
132
+ }
129
133
  };
130
134
  }
131
135
  };
@@ -1,16 +1,19 @@
1
1
  import { createCommands } from '@jolibox/common';
2
2
  import { track } from '../report';
3
3
  import { context } from '@/common/context';
4
+ import { notifyCustomEvent } from '@/common/utils';
4
5
 
5
6
  const commands = createCommands();
6
7
 
7
8
  commands.registerCommand('RuntimeSDK.loadFinishedEvent', () => {
8
9
  const duration = performance.now();
10
+ notifyCustomEvent('CP_LOAD_FINISH', {});
9
11
  track('loadFinished', {
10
12
  duration
11
13
  });
12
14
  });
13
15
 
14
16
  commands.registerCommand('RuntimeSDK.loadProgressEvent', (progress) => {
17
+ notifyCustomEvent('CP_LOAD_PROGRESS', { progress });
15
18
  console.log('RuntimeSDK.loadProgressEvent', progress);
16
19
  });
@@ -85,7 +85,11 @@ const adsContext: IAdsContext<'GAME'> = {
85
85
  osType: context.platform === 'android' ? 'ANDROID' : context.platform === 'ios' ? 'IOS' : 'PC',
86
86
  runtimeType: 'APP',
87
87
  platform: 1000, // WebSDK
88
- joliSource: context.joliSource ?? ''
88
+ joliSource: context.joliSource ?? '',
89
+ deviceInfo: {
90
+ platform: context.platform,
91
+ nativeSDKVersionCode: context.sdkInfo.nativeSDKVersionCode ?? 0
92
+ }
89
93
  };
90
94
  }
91
95
  };
@@ -9,6 +9,7 @@ import { innerFetch } from '../network';
9
9
  import { Env } from '@jolibox/types';
10
10
  import { registerLanguageHandler } from '@jolibox/ui';
11
11
  import { createIframeModal, registerIframeModalToGlobal } from '../ui/modal-iframe';
12
+ import { onFCP, onLCP, onTTFB } from 'web-vitals';
12
13
  interface IBasicMetaConfig {
13
14
  canShowRecommended: boolean;
14
15
  }
@@ -217,6 +218,32 @@ function addDoExitLoader() {
217
218
  });
218
219
  }
219
220
 
221
+ function trackPerformance() {
222
+ onFCP((metric) => {
223
+ track('GameFCP', {
224
+ value: metric.value,
225
+ rating: metric.rating,
226
+ navigationType: metric.navigationType
227
+ });
228
+ });
229
+
230
+ onLCP((metric) => {
231
+ track('GameLCP', {
232
+ value: metric.value,
233
+ rating: metric.rating,
234
+ navigationType: metric.navigationType
235
+ });
236
+ });
237
+
238
+ onTTFB((metric) => {
239
+ track('GameTTFB', {
240
+ value: metric.value,
241
+ rating: metric.rating,
242
+ navigationType: metric.navigationType
243
+ });
244
+ });
245
+ }
246
+
220
247
  async function fetchMetaConfig() {
221
248
  try {
222
249
  const url = `/api/fe-configs/js-sdk/basic-meta`;
@@ -242,6 +269,7 @@ export function config(): void {
242
269
  addWebviewReadyListener();
243
270
  addI18nChangedListener();
244
271
  fetchMetaConfig();
272
+ trackPerformance();
245
273
  unregisterIframeModal = registerIframeModalToGlobal();
246
274
 
247
275
  cleanStyles = initializeNativeEnv();