@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.
- package/android/src/main/java/com/scalebun/core/performance/AppStartCollector.kt +61 -13
- package/android/src/main/java/com/scalebun/rn/performance/PerformanceModule.kt +11 -0
- package/dist/scalebun.full.js +78 -9
- package/dist/scalebun.full.js.map +1 -1
- package/dist/scalebun.slim.js +78 -9
- package/dist/scalebun.slim.js.map +1 -1
- package/lib/commonjs/features/performance/PerformanceFeature.js +22 -2
- package/lib/commonjs/features/performance/PerformanceFeature.js.map +1 -1
- package/lib/commonjs/features/performance/collectors/AppLaunchCollector.js +21 -3
- package/lib/commonjs/features/performance/collectors/AppLaunchCollector.js.map +1 -1
- package/lib/commonjs/features/session/BackendSessionAdapter.js +41 -4
- package/lib/commonjs/features/session/BackendSessionAdapter.js.map +1 -1
- package/lib/module/features/performance/PerformanceFeature.js +22 -2
- package/lib/module/features/performance/PerformanceFeature.js.map +1 -1
- package/lib/module/features/performance/collectors/AppLaunchCollector.js +21 -3
- package/lib/module/features/performance/collectors/AppLaunchCollector.js.map +1 -1
- package/lib/module/features/session/BackendSessionAdapter.js +41 -4
- package/lib/module/features/session/BackendSessionAdapter.js.map +1 -1
- package/lib/typescript/features/performance/PerformanceFeature.d.ts.map +1 -1
- package/lib/typescript/features/performance/collectors/AppLaunchCollector.d.ts.map +1 -1
- package/lib/typescript/features/session/BackendSessionAdapter.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/features/performance/PerformanceFeature.ts +19 -2
- package/src/features/performance/collectors/AppLaunchCollector.ts +17 -3
- package/src/features/session/BackendSessionAdapter.ts +32 -5
package/dist/scalebun.slim.js
CHANGED
|
@@ -10609,6 +10609,7 @@ function getNativePerformanceModule() {
|
|
|
10609
10609
|
}
|
|
10610
10610
|
|
|
10611
10611
|
// lib/module/features/performance/collectors/AppLaunchCollector.js
|
|
10612
|
+
init_internalLogger();
|
|
10612
10613
|
var JS_IMPORT_TIME = Date.now();
|
|
10613
10614
|
var AppLaunchCollector = class {
|
|
10614
10615
|
collected = false;
|
|
@@ -10626,10 +10627,19 @@ var AppLaunchCollector = class {
|
|
|
10626
10627
|
if (this.collected || !this.config.appLaunch) return;
|
|
10627
10628
|
try {
|
|
10628
10629
|
const perfModule = getNativePerformanceModule();
|
|
10629
|
-
if (!perfModule?.getAppStartInfo)
|
|
10630
|
+
if (!perfModule?.getAppStartInfo) {
|
|
10631
|
+
logger.warn("[perf.trace] AppLaunchCollector: native perf module unavailable \u2014 no app_launch");
|
|
10632
|
+
return;
|
|
10633
|
+
}
|
|
10630
10634
|
const jsReadyTimestamp = Date.now();
|
|
10631
10635
|
const info = await perfModule.getAppStartInfo();
|
|
10632
|
-
if (!info || typeof info.durationMs !== "number")
|
|
10636
|
+
if (!info || typeof info.durationMs !== "number") {
|
|
10637
|
+
logger.warn("[perf.trace] AppLaunchCollector: getAppStartInfo returned no usable duration \u2014 no app_launch", {
|
|
10638
|
+
hasInfo: !!info,
|
|
10639
|
+
durationType: typeof info?.durationMs
|
|
10640
|
+
});
|
|
10641
|
+
return;
|
|
10642
|
+
}
|
|
10633
10643
|
this.collected = true;
|
|
10634
10644
|
const breakdown = {};
|
|
10635
10645
|
const phaseLabels = {};
|
|
@@ -10674,8 +10684,15 @@ var AppLaunchCollector = class {
|
|
|
10674
10684
|
breakdown: hasBreakdown ? breakdown : void 0,
|
|
10675
10685
|
phaseLabels: hasBreakdown ? phaseLabels : void 0
|
|
10676
10686
|
};
|
|
10687
|
+
logger.warn("[perf.trace] AppLaunchCollector: app_launch built, invoking handler", {
|
|
10688
|
+
durationMs: event.durationMs,
|
|
10689
|
+
launchType: event.launchType
|
|
10690
|
+
});
|
|
10677
10691
|
this.onLaunch(event);
|
|
10678
|
-
} catch {
|
|
10692
|
+
} catch (e) {
|
|
10693
|
+
logger.warn("[perf.trace] AppLaunchCollector: collect() threw", {
|
|
10694
|
+
message: e?.message
|
|
10695
|
+
});
|
|
10679
10696
|
}
|
|
10680
10697
|
}
|
|
10681
10698
|
};
|
|
@@ -11395,6 +11412,7 @@ var PerformanceTransport = class {
|
|
|
11395
11412
|
|
|
11396
11413
|
// lib/module/features/performance/PerformanceFeature.js
|
|
11397
11414
|
init_SessionManager();
|
|
11415
|
+
init_internalLogger();
|
|
11398
11416
|
var PerformanceFeature = class _PerformanceFeature {
|
|
11399
11417
|
name = "performance";
|
|
11400
11418
|
active = false;
|
|
@@ -11795,7 +11813,14 @@ var PerformanceFeature = class _PerformanceFeature {
|
|
|
11795
11813
|
* flushes the backlog in the order the metrics were produced.
|
|
11796
11814
|
*/
|
|
11797
11815
|
_forwardMetricToBackend(metric) {
|
|
11798
|
-
const
|
|
11816
|
+
const sm = SessionManager.getExistingInstance();
|
|
11817
|
+
const backendTransport = sm?.getBackendTransport();
|
|
11818
|
+
logger.warn("[perf.trace] forwardMetricToBackend", {
|
|
11819
|
+
type: metric.type,
|
|
11820
|
+
hasSessionManager: !!sm,
|
|
11821
|
+
hasBackendTransport: !!backendTransport,
|
|
11822
|
+
buffered: this._pendingBackendMetrics.length
|
|
11823
|
+
});
|
|
11799
11824
|
if (backendTransport) {
|
|
11800
11825
|
this._drainPendingBackendMetrics(backendTransport);
|
|
11801
11826
|
backendTransport.queuePerformanceMetric(metric);
|
|
@@ -11815,6 +11840,9 @@ var PerformanceFeature = class _PerformanceFeature {
|
|
|
11815
11840
|
for (const metric of buffered) {
|
|
11816
11841
|
backendTransport.queuePerformanceMetric(metric);
|
|
11817
11842
|
}
|
|
11843
|
+
logger.warn("[perf.trace] drained buffered metrics to backend", {
|
|
11844
|
+
count: buffered.length
|
|
11845
|
+
});
|
|
11818
11846
|
this._clearBackendDrainTimer();
|
|
11819
11847
|
this._backendDrainAttempts = 0;
|
|
11820
11848
|
}
|
|
@@ -11827,7 +11855,13 @@ var PerformanceFeature = class _PerformanceFeature {
|
|
|
11827
11855
|
*/
|
|
11828
11856
|
_scheduleBackendDrain() {
|
|
11829
11857
|
if (this._backendDrainTimer) return;
|
|
11830
|
-
if (this._backendDrainAttempts >= _PerformanceFeature.BACKEND_DRAIN_MAX_ATTEMPTS)
|
|
11858
|
+
if (this._backendDrainAttempts >= _PerformanceFeature.BACKEND_DRAIN_MAX_ATTEMPTS) {
|
|
11859
|
+
logger.warn("[perf.trace] drain gave up \u2014 buffered metrics never reached the backend", {
|
|
11860
|
+
attempts: this._backendDrainAttempts,
|
|
11861
|
+
dropped: this._pendingBackendMetrics.length
|
|
11862
|
+
});
|
|
11863
|
+
return;
|
|
11864
|
+
}
|
|
11831
11865
|
const delays = _PerformanceFeature.BACKEND_DRAIN_DELAYS;
|
|
11832
11866
|
const delay = delays[Math.min(this._backendDrainAttempts, delays.length - 1)];
|
|
11833
11867
|
this._backendDrainAttempts++;
|
|
@@ -12548,12 +12582,23 @@ var BackendSessionAdapter = class _BackendSessionAdapter {
|
|
|
12548
12582
|
this._triggerNativeFlush();
|
|
12549
12583
|
}
|
|
12550
12584
|
queuePerformanceMetric(data) {
|
|
12551
|
-
if (this.destroyed || !this.config.clientKey)
|
|
12585
|
+
if (this.destroyed || !this.config.clientKey) {
|
|
12586
|
+
logger.warn("[perf.queue] dropped \u2014 no clientKey or adapter destroyed", {
|
|
12587
|
+
type: data.type,
|
|
12588
|
+
destroyed: this.destroyed,
|
|
12589
|
+
hasClientKey: !!this.config.clientKey
|
|
12590
|
+
});
|
|
12591
|
+
return;
|
|
12592
|
+
}
|
|
12552
12593
|
this.pendingPerformanceMetrics.push({
|
|
12553
12594
|
...data,
|
|
12554
12595
|
clientId: this._clientId(),
|
|
12555
12596
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
12556
12597
|
});
|
|
12598
|
+
logger.warn("[perf.trace] queue enqueued performance metric", {
|
|
12599
|
+
type: data.type,
|
|
12600
|
+
pending: this.pendingPerformanceMetrics.length
|
|
12601
|
+
});
|
|
12557
12602
|
if (this.pendingPerformanceMetrics.length >= 20) {
|
|
12558
12603
|
this._flushPerformance().catch(() => {
|
|
12559
12604
|
});
|
|
@@ -13120,19 +13165,43 @@ var BackendSessionAdapter = class _BackendSessionAdapter {
|
|
|
13120
13165
|
}
|
|
13121
13166
|
}
|
|
13122
13167
|
async _flushPerformance() {
|
|
13123
|
-
if (this.pendingPerformanceMetrics.length === 0
|
|
13168
|
+
if (this.pendingPerformanceMetrics.length === 0) return;
|
|
13169
|
+
if (!this.currentSessionId || !this.config.clientKey) {
|
|
13170
|
+
logger.warn("[perf.trace] flush waiting \u2014 not deliverable yet", {
|
|
13171
|
+
pending: this.pendingPerformanceMetrics.length,
|
|
13172
|
+
hasSession: !!this.currentSessionId,
|
|
13173
|
+
hasClientKey: !!this.config.clientKey
|
|
13174
|
+
});
|
|
13175
|
+
return;
|
|
13176
|
+
}
|
|
13124
13177
|
const batch = this.pendingPerformanceMetrics.splice(0, 50);
|
|
13125
13178
|
try {
|
|
13126
|
-
if (await this._enqueueNative("performance", batch))
|
|
13179
|
+
if (await this._enqueueNative("performance", batch)) {
|
|
13180
|
+
logger.warn("[perf.trace] flush handed to native outbox", {
|
|
13181
|
+
count: batch.length
|
|
13182
|
+
});
|
|
13183
|
+
return;
|
|
13184
|
+
}
|
|
13127
13185
|
if (!this._sessionRowReady()) {
|
|
13186
|
+
logger.warn("[perf.trace] flush session row not ready \u2014 re-buffering", {
|
|
13187
|
+
count: batch.length
|
|
13188
|
+
});
|
|
13128
13189
|
this.pendingPerformanceMetrics.unshift(...batch);
|
|
13129
13190
|
return;
|
|
13130
13191
|
}
|
|
13131
13192
|
await this._post(ENDPOINTS.INGESTION_PERFORMANCE(this.currentSessionId), {
|
|
13132
13193
|
metrics: batch
|
|
13133
13194
|
});
|
|
13195
|
+
logger.warn("[perf.trace] flush POST performance metrics ok", {
|
|
13196
|
+
count: batch.length
|
|
13197
|
+
});
|
|
13134
13198
|
} catch (err) {
|
|
13135
|
-
|
|
13199
|
+
const permanent = _BackendSessionAdapter._isPermanentHttpError(err);
|
|
13200
|
+
logger.warn("[perf.flush] POST performance metrics failed", {
|
|
13201
|
+
count: batch.length,
|
|
13202
|
+
permanent
|
|
13203
|
+
});
|
|
13204
|
+
if (!permanent) this.pendingPerformanceMetrics.unshift(...batch);
|
|
13136
13205
|
}
|
|
13137
13206
|
}
|
|
13138
13207
|
async _flushLogs() {
|