@jolibox/implement 1.1.32 → 1.1.34

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,10 @@
6
6
  export declare const checkUseModalFrequency: (config: {
7
7
  dailyMaxPopUps: number;
8
8
  minInterval: number;
9
- }) => Promise<boolean>;
9
+ }) => Promise<{
10
+ canShow: boolean;
11
+ isFirst: boolean;
12
+ }>;
10
13
  export declare const updateUseModalFrequency: () => Promise<void>;
11
14
  /**
12
15
  * check can show paymentModal
@@ -14,7 +17,10 @@ export declare const updateUseModalFrequency: () => Promise<void>;
14
17
  export declare const checkPaymentFrequency: (config: {
15
18
  dailyMaxPopUps: number;
16
19
  minInterval: number;
17
- }) => Promise<boolean>;
20
+ }) => Promise<{
21
+ canShow: boolean;
22
+ isFirst: boolean;
23
+ }>;
18
24
  /**
19
25
  * update paymentFrequency
20
26
  */
@@ -1,9 +1,9 @@
1
1
  Invoking: npm run clean && npm run build:esm && tsc
2
2
 
3
- > @jolibox/implement@1.1.32 clean
3
+ > @jolibox/implement@1.1.34 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/implement@1.1.32 build:esm
7
+ > @jolibox/implement@1.1.34 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,15 +1,15 @@
1
1
  {
2
2
  "name": "@jolibox/implement",
3
3
  "description": "This project is Jolibox JS-SDk implement for Native && H5",
4
- "version": "1.1.32",
4
+ "version": "1.1.34",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "@jolibox/common": "1.1.32",
10
- "@jolibox/types": "1.1.32",
11
- "@jolibox/native-bridge": "1.1.32",
12
- "@jolibox/ads": "1.1.32",
9
+ "@jolibox/common": "1.1.34",
10
+ "@jolibox/types": "1.1.34",
11
+ "@jolibox/native-bridge": "1.1.34",
12
+ "@jolibox/ads": "1.1.34",
13
13
  "localforage": "1.10.0",
14
14
  "@jolibox/ui": "1.0.0",
15
15
  "web-vitals": "4.2.4"
@@ -39,7 +39,8 @@ type MPType = 'game' | 'miniApp';
39
39
  export enum SDKEnvironment {
40
40
  jolibox = 'jolibox', // 默认
41
41
  dlightek = 'dlightek', // 传音
42
- funmax = 'funmax' // 小米
42
+ funmax = 'funmax', // 小米
43
+ huaweiQuick = 'huaweiQuick' // 华为快应用
43
44
  }
44
45
 
45
46
  type Viewport = {
@@ -139,6 +140,10 @@ const wrapContext = () => {
139
140
  if (hasDlightekMeta) {
140
141
  return SDKEnvironment.dlightek;
141
142
  }
143
+ const huaweiQuick = urlParams.get('huaweiQuick') === 'true';
144
+ if (huaweiQuick) {
145
+ return SDKEnvironment.huaweiQuick;
146
+ }
142
147
  return SDKEnvironment.jolibox;
143
148
  },
144
149
  get viewport(): Viewport {
@@ -1,4 +1,4 @@
1
- import { debounce } from '@jolibox/common';
1
+ import { debounce, EventType } from '@jolibox/common';
2
2
  import { ReportHandler, Track, TrackPerformance, CommonReportConfig } from './types';
3
3
  import { PerformanceType, TrackEvent } from '@jolibox/types';
4
4
  import { InternalGlobalJSError } from '@jolibox/common';
@@ -7,11 +7,13 @@ import { reportError } from './errors/report';
7
7
  // Track system event, wrap common config
8
8
  export function createTrack(reportHandler: ReportHandler, common: CommonReportConfig): Track {
9
9
  const track = (tag: TrackEvent, info: Record<string, unknown> | null, webviewId?: number): void => {
10
+ const { eventType, ...rest } = info ?? {};
10
11
  const data = {
11
12
  tag,
13
+ eventType: (eventType ?? EventType.Other) as number,
12
14
  ...common,
13
15
  extra: {
14
- ...info
16
+ ...rest
15
17
  }
16
18
  };
17
19
  if (tag == 'globalJsError') {
@@ -1,8 +1,8 @@
1
1
  import { PerformanceType, TrackEvent } from '@jolibox/types';
2
- import { EProject } from '@jolibox/common';
2
+ import { EProject, EventType } from '@jolibox/common';
3
3
 
4
4
  export interface Track {
5
- (tag: TrackEvent, info: Record<string, unknown> | null): void;
5
+ (tag: TrackEvent, info: Record<string, unknown> | null, eventType?: number): void;
6
6
  debounce: (tag: TrackEvent, info: Record<string, unknown>) => void;
7
7
  }
8
8
 
@@ -13,7 +13,7 @@ export interface TrackPerformance {
13
13
 
14
14
  export type ReportHandler = (
15
15
  event: string,
16
- data: { tag: TrackEvent; data?: Record<string, string | number | boolean | null> },
16
+ data: { tag: TrackEvent; eventType?: number; data?: Record<string, string | number | boolean | null> },
17
17
  webviewId?: number
18
18
  ) => void;
19
19
 
@@ -81,9 +81,7 @@ export const createShowUnlockWithJolicoinModal = (
81
81
  };
82
82
 
83
83
  const checkIfCancel = (result: IPaymentResult | IUseModalResult) => {
84
- if (result == 'CANCEL') {
85
- throw new Error('CANCEL');
86
- }
84
+ return result == 'CANCEL';
87
85
  };
88
86
 
89
87
  export const createCommonJolicoinRewardHandler = (
@@ -118,7 +116,6 @@ export const createCommonJolicoinRewardHandler = (
118
116
  userJoliCoin: unlockOptions?.userJoliCoin,
119
117
  joliCoinQuantity
120
118
  });
121
- checkIfCancel(paymentResult);
122
119
 
123
120
  if (paymentResult !== 'SUCCESS') {
124
121
  handleUnlockFailed?.(params);
@@ -137,7 +134,6 @@ export const createCommonJolicoinRewardHandler = (
137
134
  joliCoinQuantity
138
135
  });
139
136
 
140
- checkIfCancel(shouldUnlock);
141
137
  if (shouldUnlock !== 'CONFIRM') {
142
138
  handleUnlockFailed?.(params);
143
139
  return false;
package/src/h5/api/ads.ts CHANGED
@@ -18,47 +18,26 @@ import {
18
18
  } from '@jolibox/ads';
19
19
  import { context, SDKEnvironment } from '@/common/context';
20
20
  import '../rewards';
21
+ import DlightekAdsHandler from './platformAdsHandle/DlightekAdsHandler';
22
+ import HuaweiQuickAdsHandler from './platformAdsHandle/HuaweiQuickAdsHandler';
21
23
 
22
24
  declare global {
23
25
  interface Window {
24
- h5sdk: any;
26
+ // 传音sdk
27
+ h5sdk: JoliboxAdsForGame;
28
+ // 华为快应用
29
+ system: {
30
+ postMessage: (params: string) => void;
31
+ };
25
32
  }
26
33
  }
27
-
28
- // 统一的广告处理器接口
29
- interface IAdsHandler {
34
+ export interface IAdsHandler {
30
35
  init(config?: IAdsInitParams): void;
31
36
  adConfig(params: IAdConfigParams): void;
32
37
  adBreak(params: IAdBreakParams): Promise<void> | void;
33
38
  adUnit(params: IAdUnitParams): void;
34
- getAdsInstance(): JoliboxAdsForGame | any;
35
- }
36
-
37
- // 具体处理器实现
38
- class DlightekAdsHandler implements IAdsHandler {
39
- constructor(private ads: any) {}
40
-
41
- getAdsInstance(): any {
42
- return this.ads;
43
- }
44
-
45
- init(_config?: IAdsInitParams): void {
46
- // Dlightek 不需要初始化
47
- }
48
-
49
- adConfig(params: IAdConfigParams): void {
50
- this.ads.adConfig(params);
51
- }
52
-
53
- adBreak(params: IAdBreakParams): void {
54
- this.ads.adBreak(params);
55
- }
56
-
57
- adUnit(_params: IAdUnitParams): void {
58
- // Dlightek 不需要 adUnit
59
- }
39
+ getAdsInstance(): JoliboxAdsForGame;
60
40
  }
61
-
62
41
  class JoliboxAdsHandler implements IAdsHandler {
63
42
  constructor(private ads: JoliboxAdsForGame) {}
64
43
 
@@ -115,6 +94,10 @@ class H5AdsManager {
115
94
  this.cacheHandler = new DlightekAdsHandler(window.h5sdk);
116
95
  break;
117
96
  }
97
+ case SDKEnvironment.huaweiQuick: {
98
+ this.cacheHandler = HuaweiQuickAdsHandler.getInstance();
99
+ break;
100
+ }
118
101
  default: {
119
102
  const joliboxAds = new JoliboxAdsForGame(this.context);
120
103
  this.cacheHandler = new JoliboxAdsHandler(joliboxAds);
@@ -0,0 +1,26 @@
1
+ import { IAdConfigParams, IAdBreakParams, JoliboxAdsForGame } from '@jolibox/ads';
2
+ import { IAdsHandler } from '../ads';
3
+
4
+ export default class DlightekAdsHandler implements IAdsHandler {
5
+ constructor(private ads: JoliboxAdsForGame) {}
6
+
7
+ getAdsInstance(): JoliboxAdsForGame {
8
+ return this.ads;
9
+ }
10
+
11
+ init(): void {
12
+ // Dlightek 不需要初始化
13
+ }
14
+
15
+ adConfig(params: IAdConfigParams): void {
16
+ this.ads.adConfig(params);
17
+ }
18
+
19
+ adBreak(params: IAdBreakParams): void {
20
+ this.ads.adBreak(params);
21
+ }
22
+
23
+ adUnit(): void {
24
+ // Dlightek 不需要 adUnit
25
+ }
26
+ }
@@ -0,0 +1,268 @@
1
+ import {
2
+ IAdsInitParams,
3
+ IAdConfigParams,
4
+ IAdBreakParams,
5
+ IAdUnitParams,
6
+ JoliboxAdsForGame,
7
+ IPlacementInfo
8
+ } from '@jolibox/ads';
9
+ import { IAdsHandler } from '../ads';
10
+
11
+ enum HuaweiQuickAdsEventEnum {
12
+ INIT = 'huawei_quick_ads_init',
13
+ AD_CONFIG = 'huawei_quick_ads_ad_config',
14
+ AD_BREAK = 'huawei_quick_ads_ad_break',
15
+ AD_UNIT = 'huawei_quick_ads_ad_unit',
16
+
17
+ AD_OPERATION = 'huawei_quick_ads_ad_operation'
18
+ }
19
+
20
+ enum HuaweiQuickAdsOnMessageEventEnum {
21
+ INIT = 'huawei_quick_ads_on_message_init',
22
+ AD_CONFIG = 'huawei_quick_ads_on_message_ad_config',
23
+ AD_BREAK = 'huawei_quick_ads_on_message_ad_break',
24
+ AD_UNIT = 'huawei_quick_ads_on_message_ad_unit'
25
+ }
26
+
27
+ interface HuaweiQuickAdsEventMap {
28
+ [HuaweiQuickAdsEventEnum.INIT]: IAdsInitParams | undefined;
29
+ [HuaweiQuickAdsEventEnum.AD_CONFIG]: IAdConfigParams;
30
+ [HuaweiQuickAdsEventEnum.AD_BREAK]: IAdBreakParams;
31
+ [HuaweiQuickAdsEventEnum.AD_UNIT]: IAdUnitParams;
32
+ [HuaweiQuickAdsEventEnum.AD_OPERATION]: undefined;
33
+ }
34
+
35
+ // 通用事件接口
36
+ interface HuaweiQuickAdsEvent<T extends HuaweiQuickAdsEventEnum> {
37
+ type: T;
38
+ data?: HuaweiQuickAdsEventMap[T];
39
+ }
40
+
41
+ interface HuaweiQuickAdsCallbackMap {
42
+ onReady?: () => void;
43
+
44
+ adBreakDone?: (placementInfo: IPlacementInfo) => void;
45
+ beforeAd?: () => void;
46
+ afterAd?: () => void;
47
+ beforeReward?: (showAdFn: () => void) => void;
48
+ adDismissed?: () => void;
49
+ adViewed?: () => void;
50
+
51
+ breakType?: string;
52
+ breakName?: string;
53
+ breakFormat?: 'interstitial' | 'reward';
54
+ }
55
+
56
+ export default class HuaweiQuickAdsHandler implements IAdsHandler {
57
+ private static instance: HuaweiQuickAdsHandler;
58
+
59
+ private callbacksId: number;
60
+ private callbackMap: Map<number, HuaweiQuickAdsCallbackMap>;
61
+
62
+ private constructor() {
63
+ this.callbacksId = 0;
64
+ this.callbackMap = new Map();
65
+
66
+ this.initOnMessage();
67
+ }
68
+
69
+ public static getInstance(): HuaweiQuickAdsHandler {
70
+ if (!HuaweiQuickAdsHandler.instance) {
71
+ HuaweiQuickAdsHandler.instance = new HuaweiQuickAdsHandler();
72
+ }
73
+ return HuaweiQuickAdsHandler.instance;
74
+ }
75
+
76
+ private initOnMessage() {
77
+ window.addEventListener('message', (event) => {
78
+ // const { data, origin, source } = event;
79
+ console.log(`HuaweiQuickAdsHandler,event => ${event}`);
80
+ if (event.origin != window.location.origin) return;
81
+
82
+ console.log(`data => ${event.data}`);
83
+
84
+ if (event.data && event.data.type == null) {
85
+ const data = JSON.parse(event.data);
86
+
87
+ console.log(`HuaweiQuickAdsHandler type => ${data.type}`);
88
+ switch (data.type) {
89
+ case HuaweiQuickAdsOnMessageEventEnum.INIT:
90
+ console.log('HuaweiQuickAdsHandler window.addEventListener init', data);
91
+ break;
92
+ case HuaweiQuickAdsOnMessageEventEnum.AD_CONFIG:
93
+ {
94
+ const callbackId = data.callbackId;
95
+ if (callbackId) {
96
+ const callbacks = this.callbackMap.get(callbackId);
97
+ callbacks?.onReady?.();
98
+ }
99
+ console.log('HuaweiQuickAdsHandler window.addEventListener adConfig', data);
100
+ }
101
+ break;
102
+ case HuaweiQuickAdsOnMessageEventEnum.AD_BREAK:
103
+ {
104
+ const callbackId = data.callbackId;
105
+ if (callbackId) {
106
+ const callbacks = this.callbackMap.get(callbackId);
107
+ let adsRes:
108
+ | 'notReady'
109
+ | 'timeout'
110
+ | 'error'
111
+ | 'noAdPreloaded'
112
+ | 'frequencyCapped'
113
+ | 'ignored'
114
+ | 'other'
115
+ | 'dismissed'
116
+ | 'viewed' = 'noAdPreloaded';
117
+ let isBreakDone = false;
118
+
119
+ switch (data.adsRes) {
120
+ case 'viewed':
121
+ adsRes = 'viewed';
122
+ callbacks?.adViewed?.();
123
+ isBreakDone = true;
124
+ break;
125
+ case 'dismissed':
126
+ adsRes = 'dismissed';
127
+ callbacks?.adDismissed?.();
128
+ isBreakDone = true;
129
+ break;
130
+ case 'error':
131
+ adsRes = 'error';
132
+ isBreakDone = true;
133
+ break;
134
+ case 'other':
135
+ adsRes = 'other';
136
+ isBreakDone = true;
137
+ break;
138
+
139
+ case 'beforeReward':
140
+ callbacks?.beforeReward?.(() => {
141
+ // this.sendPostMessage(HuaweiQuickAdsEventEnum.AD_OPERATION, undefined, undefined);
142
+ window.system.postMessage(
143
+ JSON.stringify({
144
+ type: HuaweiQuickAdsEventEnum.AD_OPERATION
145
+ })
146
+ );
147
+ console.log('HuaweiQuickAdsHandler beforeReward postMessage AD_OPERATION');
148
+ });
149
+ isBreakDone = false;
150
+ break;
151
+ case 'beforeAd':
152
+ callbacks?.beforeAd?.();
153
+ isBreakDone = false;
154
+ break;
155
+ case 'afterAd':
156
+ callbacks?.afterAd?.();
157
+ isBreakDone = false;
158
+ break;
159
+ }
160
+
161
+ isBreakDone &&
162
+ callbacks?.adBreakDone?.({
163
+ breakType: callbacks.breakType ?? '',
164
+ breakName: callbacks.breakName,
165
+ breakFormat: callbacks.breakFormat ?? 'interstitial',
166
+ breakStatus: adsRes
167
+ });
168
+ }
169
+
170
+ console.log('HuaweiQuickAdsHandler window.addEventListener adBreak', data);
171
+ }
172
+ break;
173
+ case HuaweiQuickAdsOnMessageEventEnum.AD_UNIT:
174
+ console.log('HuaweiQuickAdsHandler window.addEventListener adUnit', data);
175
+ break;
176
+ default:
177
+ break;
178
+ }
179
+ }
180
+ });
181
+ }
182
+
183
+ getAdsInstance(): JoliboxAdsForGame {
184
+ return HuaweiQuickAdsHandler.getInstance() as unknown as JoliboxAdsForGame;
185
+ }
186
+
187
+ init(config?: IAdsInitParams): void {
188
+ try {
189
+ this.sendPostMessage(HuaweiQuickAdsEventEnum.INIT, undefined, config);
190
+ } catch (e) {
191
+ console.error('init failed', e);
192
+ }
193
+ }
194
+
195
+ adConfig(params: IAdConfigParams): void {
196
+ try {
197
+ let callbackId = undefined;
198
+ if (params.onReady) {
199
+ callbackId = ++this.callbacksId;
200
+ this.callbackMap.set(callbackId, { onReady: params.onReady });
201
+ }
202
+
203
+ this.sendPostMessage(HuaweiQuickAdsEventEnum.AD_CONFIG, callbackId, params);
204
+ } catch (e) {
205
+ console.error('adConfig failed', e);
206
+ }
207
+ }
208
+
209
+ adBreak(params: IAdBreakParams): void {
210
+ try {
211
+ const callbackId = ++this.callbacksId;
212
+ const callbacks: HuaweiQuickAdsCallbackMap = {};
213
+
214
+ callbacks.breakType = params.type;
215
+ if (params.type !== 'preroll' && params.name) callbacks.breakName = params.name;
216
+ callbacks.breakFormat = params.type === 'reward' ? 'reward' : 'interstitial';
217
+
218
+ if (params.adBreakDone) callbacks.adBreakDone = params.adBreakDone;
219
+ if (params.type !== 'preroll' && params.beforeAd) callbacks.beforeAd = params.beforeAd;
220
+ if (params.type !== 'preroll' && params.afterAd) callbacks.afterAd = params.afterAd;
221
+ if (params.type === 'reward' && params.beforeReward) callbacks.beforeReward = params.beforeReward;
222
+ if (params.type === 'reward' && params.adDismissed) callbacks.adDismissed = params.adDismissed;
223
+ if (params.type === 'reward' && params.adViewed) callbacks.adViewed = params.adViewed;
224
+
225
+ this.callbackMap.set(callbackId, callbacks);
226
+
227
+ this.sendPostMessage(HuaweiQuickAdsEventEnum.AD_BREAK, callbackId, params);
228
+ } catch (e) {
229
+ params.adBreakDone?.({
230
+ breakType: params.type,
231
+ breakName: params.type === 'preroll' ? undefined : params.name,
232
+ breakFormat: params.type === 'reward' ? 'reward' : 'interstitial',
233
+ breakStatus: 'noAdPreloaded'
234
+ });
235
+ }
236
+ }
237
+
238
+ adUnit(params: IAdUnitParams): void {
239
+ try {
240
+ this.sendPostMessage(HuaweiQuickAdsEventEnum.AD_UNIT, undefined, params);
241
+ } catch (e) {
242
+ console.error('adUnit failed', e);
243
+ }
244
+ }
245
+
246
+ private sendPostMessage<T extends HuaweiQuickAdsEventEnum>(
247
+ type: T,
248
+ callbackId?: number,
249
+ data?: HuaweiQuickAdsEventMap[T]
250
+ ): void {
251
+ try {
252
+ if (!window.system?.postMessage) {
253
+ throw new Error('window.system.postMessage is not available');
254
+ }
255
+
256
+ const message: HuaweiQuickAdsEvent<T> = {
257
+ type,
258
+ ...(callbackId !== undefined && { callbackId }),
259
+ ...(data !== undefined && { data })
260
+ };
261
+
262
+ window.system.postMessage(JSON.stringify(message));
263
+ } catch (e) {
264
+ console.error('sendPostMessage failed', e);
265
+ throw e;
266
+ }
267
+ }
268
+ }
@@ -1,6 +1,7 @@
1
1
  import { createCommands } from '@jolibox/common';
2
2
  import { createSyncAPI, registerCanIUse } from './base';
3
3
  import { invokeNative } from '@jolibox/native-bridge';
4
+ import { context } from '@/common/context';
4
5
 
5
6
  const commands = createCommands();
6
7
 
@@ -19,7 +20,11 @@ const getSystemInfoSync = createSyncAPI(API_GET_SYSTEM_SYNC, {
19
20
  language: data.deviceInfo.lang,
20
21
  brand: data.deviceInfo.brand,
21
22
  appName: data.hostInfo?.appName,
22
- SDKVersion: data.sdkInfo.jssdkVersion
23
+ SDKVersion: data.sdkInfo.jssdkVersion,
24
+ viewport: {
25
+ statusBarHeight: context.viewport.statusBarHeight,
26
+ navigationBarHeight: context.viewport.navigationBarHeight
27
+ }
23
28
  };
24
29
  }
25
30
  });
@@ -40,5 +45,8 @@ registerCanIUse('env', {
40
45
  });
41
46
 
42
47
  registerCanIUse('getSystemInfoSync', {
43
- version: '1.0.0'
48
+ version: '1.0.0',
49
+ properties: {
50
+ viewport: '1.0.33'
51
+ }
44
52
  });
@@ -23,15 +23,38 @@ registerCanIUse('checkSession', {
23
23
  }
24
24
  });
25
25
 
26
+ const loginDeferredMap = new Map<string, Deferred<{ isLogin: boolean; token?: string }>>();
27
+
28
+ onNative('onLoginStateChange', ({ isLogin, token, uuid }) => {
29
+ const deferred = loginDeferredMap.get(uuid);
30
+ if (deferred) {
31
+ deferred.resolve({ isLogin, token });
32
+ loginDeferredMap.delete(uuid);
33
+ }
34
+ });
35
+
26
36
  export const login = createAPI('login', {
27
- async implement() {
37
+ paramsSchema: t.tuple(
38
+ t
39
+ .object({
40
+ skipLogin: t.boolean().optional(),
41
+ triggerFrom: t.string().optional()
42
+ })
43
+ .optional()
44
+ ),
45
+ async implement(params) {
28
46
  const {
29
47
  data: { isLogin }
30
48
  } = await applyNative('checkLoginAsync');
31
49
  if (isLogin) {
32
50
  return { isLogin: true, token: context.hostUserInfo?.token };
33
51
  }
34
- const res = invokeNative('loginSync');
52
+
53
+ const { skipLogin, triggerFrom } = params ?? {};
54
+ const res = invokeNative('loginSync', {
55
+ skipLogin,
56
+ triggerFrom
57
+ });
35
58
 
36
59
  const {
37
60
  data: { uuid: loginUUID }
@@ -42,17 +65,12 @@ export const login = createAPI('login', {
42
65
  msg: 'login failed'
43
66
  });
44
67
  }
45
- onNative('onLoginStateChange', ({ isLogin, token, uuid }) => {
46
- if (uuid == loginUUID) {
47
- resolve({ isLogin, token });
48
- }
49
- });
50
- const { promise, resolve } = new Deferred<{ isLogin: boolean; token?: string }>();
51
68
 
52
- const loginRes = await promise;
69
+ const deferred = new Deferred<{ isLogin: boolean; token?: string }>();
70
+ loginDeferredMap.set(loginUUID, deferred);
71
+ const loginRes = await deferred.promise;
53
72
  context.onEnvConfigChanged({ hostUserInfo: loginRes });
54
73
  hostEmitter.emit('onLoginComplete', loginRes);
55
-
56
74
  return loginRes;
57
75
  }
58
76
  });
@@ -58,11 +58,13 @@ onNative('onPaymentStateChange', (data) => {
58
58
  );
59
59
  }
60
60
  }
61
- const failedStatus = IPaymentIAPFailedStatusMap[status] ?? 'unlockFailed';
62
- createToast(`{slot-error} {slot-i18n-jolicoin.${failedStatus}}`, {
63
- position: 'center',
64
- duration: 3000
65
- });
61
+ const failedStatus = IPaymentIAPFailedStatusMap[status];
62
+ if (failedStatus) {
63
+ createToast(`{slot-error} {slot-i18n-jolicoin.${failedStatus}}`, {
64
+ position: 'center',
65
+ duration: 3000
66
+ });
67
+ }
66
68
  deferred.resolve({
67
69
  code: 'FAILED' as ResponseType,
68
70
  message: 'jolicoin payment failed'
@@ -1,5 +1,5 @@
1
1
  import './errors';
2
- import { createCommands, isObject, isString, EventEmitter, EProject } from '@jolibox/common';
2
+ import { createCommands, isObject, isString, EventEmitter, EProject, EventType } from '@jolibox/common';
3
3
  export * from '../../common/report/types';
4
4
  import { createTracks, ReportHandler } from '@/common/report';
5
5
  import { context } from '@/common/context';
@@ -20,10 +20,13 @@ const reportNative: ReportHandler = (event, data, webviewId) => {
20
20
  session_id: context.sessionId,
21
21
  user_id: context.hostUserInfo?.uid ?? ''
22
22
  };
23
+ const eventType = (_data.eventType ?? EventType.Other) as number;
24
+
23
25
  invokeNative('trackAsync', {
24
26
  event: data.tag ?? event,
25
27
  data: extra,
26
- webviewId
28
+ webviewId,
29
+ eventType
27
30
  });
28
31
  };
29
32