Source:
<code>void reportInternalBugsnagError(@NonNull Event event) { Map<String, Object> app = appData.getAppDataSummary(); app.put("duration", AppData.getDurationMs()); app.put("durationInForeground", appData.calculateDurationInForeground()); app.put("inForeground", sessionTracker.isInForeground()); event.setApp(app); Map<String, Object> device = deviceData.getDeviceDataSummary(); device.put("freeDisk", deviceData.calculateFreeDisk()); event.setDevice(device); Notifier notifier = Notifier.INSTANCE; event.addMetadata(INTERNAL_DIAGNOSTICS_TAB, "notifierName", notifier.getName()); event.addMetadata(INTERNAL_DIAGNOSTICS_TAB, "notifierVersion", notifier.getVersion()); event.addMetadata(INTERNAL_DIAGNOSTICS_TAB, "apiKey", immutableConfig.getApiKey()); Object packageName = appData.getAppData().get("packageName"); event.addMetadata(INTERNAL_DIAGNOSTICS_TAB, "packageName", packageName); final Report report = new Report(null, event); try { Async.run(new Runnable() { @Override public void run() { try { Delivery delivery = immutableConfig.getDelivery(); DeliveryParams params = immutableConfig.errorApiDeliveryParams(); if (delivery instanceof DefaultDelivery) { Map<String, String> headers = params.getHeaders(); <START> headers.put("Bugsnag-Internal-Error", "true"); <END> headers.remove(HEADER_API_KEY); DefaultDelivery defaultDelivery = (DefaultDelivery) delivery; defaultDelivery.deliver(params.getEndpoint(), report, headers); } } catch (Exception exception) { logger.w("Failed to report internal event to Bugsnag", exception); } } }); } catch (RejectedExecutionException ignored) { } }</code><technical_language>extract this a header in this class for consistency</technical_language>

Target:
void reportInternalBugsnagError(@NonNull Event event) { Map<String, Object> app = appData.getAppDataSummary(); app.put("duration", AppData.getDurationMs()); app.put("durationInForeground", appData.calculateDurationInForeground()); app.put("inForeground", sessionTracker.isInForeground()); event.setApp(app); Map<String, Object> device = deviceData.getDeviceDataSummary(); device.put("freeDisk", deviceData.calculateFreeDisk()); event.setDevice(device); Notifier notifier = Notifier.INSTANCE; event.addMetadata(INTERNAL_DIAGNOSTICS_TAB, "notifierName", notifier.getName()); event.addMetadata(INTERNAL_DIAGNOSTICS_TAB, "notifierVersion", notifier.getVersion()); event.addMetadata(INTERNAL_DIAGNOSTICS_TAB, "apiKey", immutableConfig.getApiKey()); Object packageName = appData.getAppData().get("packageName"); event.addMetadata(INTERNAL_DIAGNOSTICS_TAB, "packageName", packageName); final Report report = new Report(null, event); try { Async.run(new Runnable() { @Override public void run() { try { Delivery delivery = immutableConfig.getDelivery(); DeliveryParams params = immutableConfig.errorApiDeliveryParams(); if (delivery instanceof DefaultDelivery) { Map<String, String> headers = params.getHeaders(); headers.put(HEADER_INTERNAL_ERROR, "true"); headers.remove(HEADER_API_KEY); DefaultDelivery defaultDelivery = (DefaultDelivery) delivery; defaultDelivery.deliver(params.getEndpoint(), report, headers); } } catch (Exception exception) { logger.w("Failed to report internal event to Bugsnag", exception); } } }); } catch (RejectedExecutionException ignored) { } }