@scalebun/react-native 1.2.1 → 1.2.2-beta.1

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.
Files changed (25) hide show
  1. package/android/src/main/java/com/scalebun/core/performance/AppStartCollector.kt +61 -13
  2. package/android/src/main/java/com/scalebun/rn/performance/PerformanceModule.kt +11 -0
  3. package/dist/scalebun.full.js +78 -9
  4. package/dist/scalebun.full.js.map +1 -1
  5. package/dist/scalebun.slim.js +78 -9
  6. package/dist/scalebun.slim.js.map +1 -1
  7. package/lib/commonjs/features/performance/PerformanceFeature.js +22 -2
  8. package/lib/commonjs/features/performance/PerformanceFeature.js.map +1 -1
  9. package/lib/commonjs/features/performance/collectors/AppLaunchCollector.js +21 -3
  10. package/lib/commonjs/features/performance/collectors/AppLaunchCollector.js.map +1 -1
  11. package/lib/commonjs/features/session/BackendSessionAdapter.js +41 -4
  12. package/lib/commonjs/features/session/BackendSessionAdapter.js.map +1 -1
  13. package/lib/module/features/performance/PerformanceFeature.js +22 -2
  14. package/lib/module/features/performance/PerformanceFeature.js.map +1 -1
  15. package/lib/module/features/performance/collectors/AppLaunchCollector.js +21 -3
  16. package/lib/module/features/performance/collectors/AppLaunchCollector.js.map +1 -1
  17. package/lib/module/features/session/BackendSessionAdapter.js +41 -4
  18. package/lib/module/features/session/BackendSessionAdapter.js.map +1 -1
  19. package/lib/typescript/features/performance/PerformanceFeature.d.ts.map +1 -1
  20. package/lib/typescript/features/performance/collectors/AppLaunchCollector.d.ts.map +1 -1
  21. package/lib/typescript/features/session/BackendSessionAdapter.d.ts.map +1 -1
  22. package/package.json +1 -1
  23. package/src/features/performance/PerformanceFeature.ts +19 -2
  24. package/src/features/performance/collectors/AppLaunchCollector.ts +17 -3
  25. package/src/features/session/BackendSessionAdapter.ts +32 -5
@@ -13,6 +13,7 @@ import { getNativePerformanceModule } from '../getNativePerformanceModule';
13
13
  import type { AppLaunchEvent, PerfContext, LaunchType } from '../models';
14
14
  import { PERF_SCHEMA_VERSION } from '../models';
15
15
  import type { PerformanceConfig } from '../config';
16
+ import { logger } from '../../../core/logger/internalLogger';
16
17
 
17
18
  export type LaunchEventCallback = (event: AppLaunchEvent) => void;
18
19
 
@@ -46,12 +47,21 @@ export class AppLaunchCollector {
46
47
 
47
48
  try {
48
49
  const perfModule = getNativePerformanceModule();
49
- if (!perfModule?.getAppStartInfo) return;
50
+ if (!perfModule?.getAppStartInfo) {
51
+ // [perf.trace] diagnostic (warn so it survives the default release log level)
52
+ logger.warn('[perf.trace] AppLaunchCollector: native perf module unavailable — no app_launch');
53
+ return;
54
+ }
50
55
 
51
56
  // The moment we call the native bridge = JS is ready
52
57
  const jsReadyTimestamp = Date.now();
53
58
  const info = await perfModule.getAppStartInfo();
54
- if (!info || typeof info.durationMs !== 'number') return;
59
+ if (!info || typeof info.durationMs !== 'number') {
60
+ logger.warn('[perf.trace] AppLaunchCollector: getAppStartInfo returned no usable duration — no app_launch', {
61
+ hasInfo: !!info, durationType: typeof info?.durationMs,
62
+ });
63
+ return;
64
+ }
55
65
 
56
66
  this.collected = true;
57
67
 
@@ -108,9 +118,13 @@ export class AppLaunchCollector {
108
118
  phaseLabels: hasBreakdown ? phaseLabels : undefined,
109
119
  };
110
120
 
121
+ logger.warn('[perf.trace] AppLaunchCollector: app_launch built, invoking handler', {
122
+ durationMs: event.durationMs, launchType: event.launchType,
123
+ });
111
124
  this.onLaunch(event);
112
- } catch {
125
+ } catch (e) {
113
126
  // No-throw — native module may not be available
127
+ logger.warn('[perf.trace] AppLaunchCollector: collect() threw', { message: (e as Error)?.message });
114
128
  }
115
129
  }
116
130
  }
@@ -717,8 +717,17 @@ export class BackendSessionAdapter implements SessionTransport {
717
717
  type: string; screenName?: string; duration?: number; value?: number;
718
718
  metadata?: Record<string, unknown>;
719
719
  }): void {
720
- if (this.destroyed || !this.config.clientKey) return;
720
+ if (this.destroyed || !this.config.clientKey) {
721
+ logger.warn('[perf.queue] dropped — no clientKey or adapter destroyed', {
722
+ type: data.type, destroyed: this.destroyed, hasClientKey: !!this.config.clientKey,
723
+ });
724
+ return;
725
+ }
721
726
  this.pendingPerformanceMetrics.push({ ...data, clientId: this._clientId(), timestamp: new Date().toISOString() });
727
+ // [perf.trace] diagnostic at warn so it survives the default release log level.
728
+ logger.warn('[perf.trace] queue enqueued performance metric', {
729
+ type: data.type, pending: this.pendingPerformanceMetrics.length,
730
+ });
722
731
  if (this.pendingPerformanceMetrics.length >= 20) {
723
732
  this._flushPerformance().catch(() => {});
724
733
  }
@@ -1405,14 +1414,32 @@ export class BackendSessionAdapter implements SessionTransport {
1405
1414
  }
1406
1415
 
1407
1416
  private async _flushPerformance(): Promise<void> {
1408
- if (this.pendingPerformanceMetrics.length === 0 || !this.currentSessionId || !this.config.clientKey) return;
1417
+ if (this.pendingPerformanceMetrics.length === 0) return;
1418
+ if (!this.currentSessionId || !this.config.clientKey) {
1419
+ // [perf.trace] diagnostics below are warn-level so they survive the default release log level.
1420
+ logger.warn('[perf.trace] flush waiting — not deliverable yet', {
1421
+ pending: this.pendingPerformanceMetrics.length,
1422
+ hasSession: !!this.currentSessionId, hasClientKey: !!this.config.clientKey,
1423
+ });
1424
+ return;
1425
+ }
1409
1426
  const batch = this.pendingPerformanceMetrics.splice(0, 50);
1410
1427
  try {
1411
- if (await this._enqueueNative('performance', batch)) return;
1412
- if (!this._sessionRowReady()) { this.pendingPerformanceMetrics.unshift(...batch); return; }
1428
+ if (await this._enqueueNative('performance', batch)) {
1429
+ logger.warn('[perf.trace] flush handed to native outbox', { count: batch.length });
1430
+ return;
1431
+ }
1432
+ if (!this._sessionRowReady()) {
1433
+ logger.warn('[perf.trace] flush session row not ready — re-buffering', { count: batch.length });
1434
+ this.pendingPerformanceMetrics.unshift(...batch);
1435
+ return;
1436
+ }
1413
1437
  await this._post(ENDPOINTS.INGESTION_PERFORMANCE(this.currentSessionId), { metrics: batch });
1438
+ logger.warn('[perf.trace] flush POST performance metrics ok', { count: batch.length });
1414
1439
  } catch (err) {
1415
- if (!BackendSessionAdapter._isPermanentHttpError(err)) this.pendingPerformanceMetrics.unshift(...batch);
1440
+ const permanent = BackendSessionAdapter._isPermanentHttpError(err);
1441
+ logger.warn('[perf.flush] POST performance metrics failed', { count: batch.length, permanent });
1442
+ if (!permanent) this.pendingPerformanceMetrics.unshift(...batch);
1416
1443
  }
1417
1444
  }
1418
1445