|
10 | 10 | import io.sentry.SentryFeedbackOptions; |
11 | 11 | import io.sentry.SentryIntegrationPackageStorage; |
12 | 12 | import io.sentry.SentryLevel; |
| 13 | +import io.sentry.SentryReplayOptions; |
13 | 14 | import io.sentry.protocol.SdkVersion; |
14 | 15 | import io.sentry.util.Objects; |
| 16 | +import java.util.ArrayList; |
15 | 17 | import java.util.Arrays; |
16 | 18 | import java.util.Collections; |
17 | 19 | import java.util.List; |
@@ -114,6 +116,21 @@ final class ManifestMetadataReader { |
114 | 116 | static final String REPLAYS_DEBUG = "io.sentry.session-replay.debug"; |
115 | 117 | static final String REPLAYS_SCREENSHOT_STRATEGY = "io.sentry.session-replay.screenshot-strategy"; |
116 | 118 |
|
| 119 | + static final String REPLAYS_NETWORK_DETAIL_ALLOW_URLS = |
| 120 | + "io.sentry.session-replay.network-detail-allow-urls"; |
| 121 | + |
| 122 | + static final String REPLAYS_NETWORK_DETAIL_DENY_URLS = |
| 123 | + "io.sentry.session-replay.network-detail-deny-urls"; |
| 124 | + |
| 125 | + static final String REPLAYS_NETWORK_CAPTURE_BODIES = |
| 126 | + "io.sentry.session-replay.network-capture-bodies"; |
| 127 | + |
| 128 | + static final String REPLAYS_NETWORK_REQUEST_HEADERS = |
| 129 | + "io.sentry.session-replay.network-request-headers"; |
| 130 | + |
| 131 | + static final String REPLAYS_NETWORK_RESPONSE_HEADERS = |
| 132 | + "io.sentry.session-replay.network-response-headers"; |
| 133 | + |
117 | 134 | static final String FORCE_INIT = "io.sentry.force-init"; |
118 | 135 |
|
119 | 136 | static final String MAX_BREADCRUMBS = "io.sentry.max-breadcrumbs"; |
@@ -488,6 +505,91 @@ static void applyMetadata( |
488 | 505 | options.getSessionReplay().setScreenshotStrategy(ScreenshotStrategyType.PIXEL_COPY); |
489 | 506 | } |
490 | 507 | } |
| 508 | + |
| 509 | + // Network Details Configuration |
| 510 | + if (options.getSessionReplay().getNetworkDetailAllowUrls().length == 0) { |
| 511 | + final @Nullable List<String> allowUrls = |
| 512 | + readList(metadata, logger, REPLAYS_NETWORK_DETAIL_ALLOW_URLS); |
| 513 | + if (allowUrls != null && !allowUrls.isEmpty()) { |
| 514 | + final List<String> filteredUrls = new ArrayList<>(); |
| 515 | + for (String url : allowUrls) { |
| 516 | + final String trimmedUrl = url.trim(); |
| 517 | + if (!trimmedUrl.isEmpty()) { |
| 518 | + filteredUrls.add(trimmedUrl); |
| 519 | + } |
| 520 | + } |
| 521 | + if (!filteredUrls.isEmpty()) { |
| 522 | + options |
| 523 | + .getSessionReplay() |
| 524 | + .setNetworkDetailAllowUrls(filteredUrls.toArray(new String[0])); |
| 525 | + } |
| 526 | + } |
| 527 | + } |
| 528 | + |
| 529 | + if (options.getSessionReplay().getNetworkDetailDenyUrls().length == 0) { |
| 530 | + final @Nullable List<String> denyUrls = |
| 531 | + readList(metadata, logger, REPLAYS_NETWORK_DETAIL_DENY_URLS); |
| 532 | + if (denyUrls != null && !denyUrls.isEmpty()) { |
| 533 | + final List<String> filteredUrls = new ArrayList<>(); |
| 534 | + for (String url : denyUrls) { |
| 535 | + final String trimmedUrl = url.trim(); |
| 536 | + if (!trimmedUrl.isEmpty()) { |
| 537 | + filteredUrls.add(trimmedUrl); |
| 538 | + } |
| 539 | + } |
| 540 | + if (!filteredUrls.isEmpty()) { |
| 541 | + options |
| 542 | + .getSessionReplay() |
| 543 | + .setNetworkDetailDenyUrls(filteredUrls.toArray(new String[0])); |
| 544 | + } |
| 545 | + } |
| 546 | + } |
| 547 | + |
| 548 | + options |
| 549 | + .getSessionReplay() |
| 550 | + .setNetworkCaptureBodies( |
| 551 | + readBool( |
| 552 | + metadata, |
| 553 | + logger, |
| 554 | + REPLAYS_NETWORK_CAPTURE_BODIES, |
| 555 | + options.getSessionReplay().isNetworkCaptureBodies() /* defaultValue */)); |
| 556 | + |
| 557 | + if (options.getSessionReplay().getNetworkRequestHeaders().length |
| 558 | + == SentryReplayOptions.getNetworkDetailsDefaultHeaders().size()) { // Only has defaults |
| 559 | + final @Nullable List<String> requestHeaders = |
| 560 | + readList(metadata, logger, REPLAYS_NETWORK_REQUEST_HEADERS); |
| 561 | + if (requestHeaders != null) { |
| 562 | + final List<String> filteredHeaders = new ArrayList<>(); |
| 563 | + for (String header : requestHeaders) { |
| 564 | + final String trimmedHeader = header.trim(); |
| 565 | + if (!trimmedHeader.isEmpty()) { |
| 566 | + filteredHeaders.add(trimmedHeader); |
| 567 | + } |
| 568 | + } |
| 569 | + if (!filteredHeaders.isEmpty()) { |
| 570 | + options.getSessionReplay().setNetworkRequestHeaders(filteredHeaders); |
| 571 | + } |
| 572 | + } |
| 573 | + } |
| 574 | + |
| 575 | + if (options.getSessionReplay().getNetworkResponseHeaders().length |
| 576 | + == SentryReplayOptions.getNetworkDetailsDefaultHeaders().size()) { // Only has defaults |
| 577 | + final @Nullable List<String> responseHeaders = |
| 578 | + readList(metadata, logger, REPLAYS_NETWORK_RESPONSE_HEADERS); |
| 579 | + if (responseHeaders != null && !responseHeaders.isEmpty()) { |
| 580 | + final List<String> filteredHeaders = new ArrayList<>(); |
| 581 | + for (String header : responseHeaders) { |
| 582 | + final String trimmedHeader = header.trim(); |
| 583 | + if (!trimmedHeader.isEmpty()) { |
| 584 | + filteredHeaders.add(trimmedHeader); |
| 585 | + } |
| 586 | + } |
| 587 | + if (!filteredHeaders.isEmpty()) { |
| 588 | + options.getSessionReplay().setNetworkResponseHeaders(filteredHeaders); |
| 589 | + } |
| 590 | + } |
| 591 | + } |
| 592 | + |
491 | 593 | options.setIgnoredErrors(readList(metadata, logger, IGNORED_ERRORS)); |
492 | 594 |
|
493 | 595 | final @Nullable List<String> includes = readList(metadata, logger, IN_APP_INCLUDES); |
|
0 commit comments