MCPcopy Index your code
hub / github.com/callstack/agent-device / readSessionNetworkCapture

Function readSessionNetworkCapture

src/daemon/app-log.ts:201–300  ·  view source on GitHub ↗
(
  params: SessionNetworkCaptureParams,
)

Source from the content-addressed store, hash-verified

199}
200
201export async function readSessionNetworkCapture(
202 params: SessionNetworkCaptureParams,
203): Promise<SessionNetworkCapture> {
204 const {
205 device,
206 appBundleId,
207 appLogState,
208 appLogStartedAt,
209 appLogPath,
210 maxEntries,
211 include,
212 maxPayloadChars,
213 maxScanLines,
214 } = params;
215 const backend = resolveLogBackend(device);
216 let dump = readRecentNetworkTraffic(appLogPath, {
217 backend,
218 maxEntries,
219 include,
220 maxPayloadChars,
221 maxScanLines,
222 });
223 const notes: string[] = [];
224
225 const androidRecovery = await resolveAndroidNetworkRecoveryContext({
226 device,
227 appBundleId,
228 appLogPath,
229 appLogState,
230 });
231 if (androidRecovery) {
232 const recovered = await readRecentAndroidLogcatForPackage(device.id, appBundleId as string);
233 if (recovered) {
234 const recoveredDump = readRecentNetworkTrafficFromText(recovered.text, {
235 path: `${appLogPath} (adb logcat recovery)`,
236 backend: 'android',
237 maxEntries,
238 include,
239 maxPayloadChars,
240 maxScanLines,
241 });
242 if (recoveredDump.entries.length > 0) {
243 dump = mergeNetworkDumps(recoveredDump, dump, maxEntries);
244 notes.push(buildAndroidRecoveryNote(androidRecovery, recovered.recoveredPids));
245 }
246 }
247 }
248
249 const canRecoverIosSimulatorLogShow =
250 isIosFamily(device) && device.kind === 'simulator' && Boolean(appBundleId);
251 if (canRecoverIosSimulatorLogShow && dump.entries.length === 0) {
252 const recovered = await readRecentIosSimulatorNetworkCapture({
253 deviceId: device.id,
254 appBundleId: appBundleId as string,
255 startedAt: appLogStartedAt,
256 simulatorSetPath: device.simulatorSetPath,
257 appLogPath,
258 maxEntries,

Callers 1

handleNetworkCommandFunction · 0.90

Calls 11

readRecentNetworkTrafficFunction · 0.90
mergeNetworkDumpsFunction · 0.90
isIosFamilyFunction · 0.90
resolveLogBackendFunction · 0.85
buildAndroidRecoveryNoteFunction · 0.85
buildNoHttpEntriesNoteFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected