@jolibox/implement 1.1.18-beta.1 → 1.1.18-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.
@@ -14,6 +14,7 @@ export declare class NativeTaskTracker extends TaskTracker {
14
14
  private gameId;
15
15
  private sessionId;
16
16
  private track;
17
+ private taskUrl;
17
18
  constructor(track: Track, eventEmitter: EventEmitter<{
18
19
  visible: [boolean];
19
20
  }>, interval?: number);
@@ -1,9 +1,9 @@
1
1
  Invoking: npm run clean && npm run build:esm && tsc
2
2
 
3
- > @jolibox/implement@1.1.18-beta.1 clean
3
+ > @jolibox/implement@1.1.18-beta.3 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/implement@1.1.18-beta.1 build:esm
7
+ > @jolibox/implement@1.1.18-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,14 +1,14 @@
1
1
  {
2
2
  "name": "@jolibox/implement",
3
3
  "description": "This project is Jolibox JS-SDk implement for Native && H5",
4
- "version": "1.1.18-beta.1",
4
+ "version": "1.1.18-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.1.18-beta.1",
10
- "@jolibox/types": "1.1.18-beta.1",
11
- "@jolibox/native-bridge": "1.1.18-beta.1",
9
+ "@jolibox/common": "1.1.18-beta.3",
10
+ "@jolibox/types": "1.1.18-beta.3",
11
+ "@jolibox/native-bridge": "1.1.18-beta.3",
12
12
  "localforage": "1.10.0",
13
13
  "@jolibox/ui": "1.0.0",
14
14
  "web-vitals": "4.2.4"
@@ -76,7 +76,7 @@ const wrapContext = () => {
76
76
  return headerJson?.__mpType ?? payloadJson?.__mpType ?? 'game';
77
77
  },
78
78
  get platform(): Env['platform'] {
79
- return env.platform ?? env.deviceInfo.platform;
79
+ return (env.platform ?? env.deviceInfo.platform).toLowerCase() as 'h5' | 'android' | 'ios';
80
80
  },
81
81
  get deviceInfo(): DeviceInfo {
82
82
  return env.deviceInfo;
@@ -29,30 +29,39 @@ export class NativeTaskTracker extends TaskTracker {
29
29
  private gameId: string;
30
30
  private sessionId: string;
31
31
  private track: Track;
32
+ private taskUrl: string;
32
33
 
33
34
  constructor(track: Track, eventEmitter: EventEmitter<{ visible: [boolean] }>, interval?: number) {
34
35
  super(eventEmitter, interval);
35
36
  this.gameId = context.mpId;
36
37
  this.sessionId = context.sessionId;
37
38
  this.track = track;
39
+ this.taskUrl = context.testMode
40
+ ? 'https://stg-api.jolibox.com/api/base/app-event'
41
+ : 'https://api.jolibox.com/api/base/app-event';
38
42
  }
39
43
  async reporter(point: TaskPoint): Promise<void> {
40
44
  const { event, params } = point;
41
- const reportTasks = [];
42
- reportTasks.push(
43
- fetch(`/api/base/app-event`, {
44
- method: 'POST',
45
- data: {
46
- eventType: event,
47
- gameInfo: {
48
- gameId: this.gameId,
49
- sessionId: this.sessionId,
50
- ...params
51
- }
52
- }
53
- })
54
- );
55
- await Promise.all(reportTasks);
45
+
46
+ const reportBody = {
47
+ eventType: event,
48
+ gameInfo: {
49
+ gameId: this.gameId,
50
+ sessionId: this.sessionId,
51
+ ...params
52
+ }
53
+ };
54
+ const reportTask =
55
+ context.platform === 'android'
56
+ ? fetch(`/api/base/app-event`, {
57
+ method: 'POST',
58
+ data: reportBody
59
+ })
60
+ : applyNative('trackAppEventAsync', {
61
+ url: this.taskUrl,
62
+ body: JSON.stringify(reportBody)
63
+ });
64
+ await reportTask;
56
65
  }
57
66
 
58
67
  async reportToNative(point: NativeTaskPoint) {