Skip to content

Commit 2ea5ab6

Browse files
authored
fix(Docs) integrations without conditionals were hidden by default (#15230)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## Fix: Integrations wrapper incorrectly hidden when no onboarding options present ### Problem Regression from #15160 - `integrations: [...]` wrapper was always hidden by default in code blocks, even when the integrations inside should always be visible (e.g., `integrations: [Sentry.captureConsoleIntegration()]`). The wrapper was only restored to visible by `updateElementsVisibilityForOptions`, which never runs on pages without onboarding option buttons. ### Root Cause In `src/rehype-onboarding-lines.js`, the integrations wrapper was unconditionally hidden at build time, relying on client-side JavaScript to show it when appropriate. Pages without `<OnboardingOptionButtons />` never executed the restore logic. ### Solution Updated the build-time logic to only hide the integrations wrapper when **ALL** content inside is conditional (wrapped in `___PRODUCT_OPTION_START/END___` markers). If any integration is always-visible (no onboarding option), the wrapper remains visible by default. ### Scenarios Now Handled Correctly - ✅ Always-visible integrations only → wrapper always shown - ✅ All conditional integrations → wrapper hidden/shown based on option selection - ✅ Mixed (some always-visible + some conditional) → wrapper always shown, conditional lines toggle independently - ✅ Empty inline arrays `integrations: []` → unaffected (not matched by regex) ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [x] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [ ] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## LEGAL BOILERPLATE <!-- Sentry employees and contractors can delete or ignore this section. --> Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms. ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
1 parent 743010f commit 2ea5ab6

File tree

1 file changed

+33
-18
lines changed

1 file changed

+33
-18
lines changed

src/rehype-onboarding-lines.js

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,38 +58,53 @@ function handle_inline_options(node) {
5858
}
5959
});
6060

61+
// Helper to add a class to a line's className property
62+
const addClass = (line, className) => {
63+
const existing = line.properties.className;
64+
line.properties.className = [
65+
...(Array.isArray(existing) ? existing : existing ? [existing] : []),
66+
className,
67+
];
68+
};
69+
6170
// Second pass: Mark integrations array opening/closing lines
62-
// These should be hidden if all content inside is from options that are disabled
71+
// Hide wrapper only if ALL content inside is conditional (from onboarding options)
6372
for (let i = 0; i < (node.children?.length ?? 0); i++) {
6473
const line = node.children[i];
6574
const lineStr = toString(line).trim();
6675

6776
// Found "integrations: ["
6877
if (lineStr.match(/integrations:\s*\[/)) {
69-
// Mark the opening line and hide it by default
7078
line.properties['data-integrations-wrapper'] = 'open';
71-
const openClasses = Array.isArray(line.properties.className)
72-
? line.properties.className
73-
: line.properties.className
74-
? [line.properties.className]
75-
: [];
76-
line.properties.className = [...openClasses, 'hidden'];
7779

78-
// Find the closing "]," - must be exactly ],
80+
// Find the closing "],"
81+
let closeIndex = -1;
7982
for (let j = i + 1; j < node.children.length; j++) {
80-
const closeStr = toString(node.children[j]).trim();
81-
if (closeStr === '],') {
82-
// Mark the closing line and hide it by default
83+
if (toString(node.children[j]).trim() === '],') {
84+
closeIndex = j;
8385
node.children[j].properties['data-integrations-wrapper'] = 'close';
84-
const closeClasses = Array.isArray(node.children[j].properties.className)
85-
? node.children[j].properties.className
86-
: node.children[j].properties.className
87-
? [node.children[j].properties.className]
88-
: [];
89-
node.children[j].properties.className = [...closeClasses, 'hidden'];
9086
break;
9187
}
9288
}
89+
90+
if (closeIndex === -1) break;
91+
92+
// Check if ALL content is conditional (has onboarding-option attribute or is a marker)
93+
const hasAlwaysVisibleContent = node.children
94+
.slice(i + 1, closeIndex)
95+
.some(contentLine => {
96+
const isMarker = contentLine.properties['data-onboarding-option-hidden'];
97+
const hasOption = contentLine.properties['data-onboarding-option'];
98+
const hasContent = toString(contentLine).trim();
99+
return hasContent && !isMarker && !hasOption;
100+
});
101+
102+
// Only hide wrapper if ALL content is conditional
103+
if (!hasAlwaysVisibleContent) {
104+
addClass(line, 'hidden');
105+
addClass(node.children[closeIndex], 'hidden');
106+
}
107+
93108
break; // Only handle first integrations array
94109
}
95110
}

0 commit comments

Comments
 (0)