Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/platforms/javascript/guides/react/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ Sentry.init({
// Enable logs to be sent to Sentry
enableLogs: true,
// ___PRODUCT_OPTION_END___ logs

// ___PRODUCT_OPTION_START___ performance

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for tracing.
// Learn more at
Expand Down
20 changes: 8 additions & 12 deletions src/components/codeBlock/code-blocks.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
border-radius: 0 0 6px 6px;
margin-top: 0;
margin-bottom: 0;
/* Wrap overly long lines so blocks never expand layout */
white-space: pre-wrap;
word-break: break-word;
overflow-wrap: anywhere;
/* Use horizontal scroll instead of wrapping */
white-space: pre;
overflow-x: auto;
max-width: 100%;
tab-size: 2;
}
Expand All @@ -26,10 +25,9 @@
border: 1px solid var(--accent-11);
border-radius: 6px;
margin: 0;
/* Ensure syntax-highlighted pre behaves like above */
white-space: pre-wrap;
word-break: break-word;
overflow-wrap: anywhere;
/* Use horizontal scroll instead of wrapping */
white-space: pre;
overflow-x: auto;
}

/**
Expand Down Expand Up @@ -76,10 +74,8 @@
float: left;
min-width: 100%;
box-sizing: border-box;
/* Allow wrapping inside each highlighted line */
white-space: pre-wrap;
word-break: break-word;
overflow-wrap: anywhere;
/* Use horizontal scroll instead of wrapping */
white-space: pre;
// Set placeholder for highlight accent border color to transparent
border-left: 4px solid rgba(0, 0, 0, 0);

Expand Down
14 changes: 11 additions & 3 deletions src/components/codeBlock/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,17 @@ function getCopiableText(element: HTMLDivElement) {
let text = '';
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT, {
acceptNode: function (node) {
// Skip if parent has .no-copy class
if (node.parentElement?.classList.contains('no-copy')) {
return NodeFilter.FILTER_REJECT;
let parent = node.parentElement;
// Walk up the tree to check if any parent has .no-copy, .hidden, or data-onboarding-option-hidden
while (parent && parent !== element) {
if (
parent.classList.contains('no-copy') ||
parent.classList.contains('hidden') ||
parent.hasAttribute('data-onboarding-option-hidden')
) {
return NodeFilter.FILTER_REJECT;
}
parent = parent.parentElement;
}
return NodeFilter.FILTER_ACCEPT;
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/codeKeywords/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const KeywordSpan = styled(motion.span, {
grid-row: 1;
grid-column: 1;
display: inline-block;
margin-top: ${p => (p.hasPreview ? '24px' : '0')};
margin-top: 0;
`;

export const KeywordSearchInput = styled('input')<{dark: boolean}>`
Expand Down
3 changes: 2 additions & 1 deletion src/components/docPage/type.scss
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@
margin-top: 0;
}

[data-onboarding-option].hidden {
[data-onboarding-option].hidden,
[data-integrations-wrapper].hidden {
display: none;
}
// force hide markers (___PRODUCT_OPTION_START___ and ___PRODUCT_OPTION_END___)
Expand Down
80 changes: 80 additions & 0 deletions src/components/onboarding/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,86 @@ export function updateElementsVisibilityForOptions(
});
}
});

// Handle integrations wrapper: hide opening/closing brackets if no integrations are visible
const openWrappers = document.querySelectorAll<HTMLElement>(
'[data-integrations-wrapper="open"]'
);

openWrappers.forEach(openLine => {
const codeBlock = openLine.closest('code.code-highlight');
if (!codeBlock) return;

const allLines = Array.from(codeBlock.children) as HTMLElement[];
const openIndex = allLines.indexOf(openLine);

// Find the matching close line in the same code block
let closeIndex = -1;
for (let i = openIndex + 1; i < allLines.length; i++) {
if (allLines[i].dataset.integrationsWrapper === 'close') {
closeIndex = i;
break;
}
}

if (closeIndex === -1) return;

// Check if any lines between open and close are visible (non-marker lines)
let hasVisibleIntegrations = false;
for (let i = openIndex + 1; i < closeIndex; i++) {
const line = allLines[i];
const isHidden = line.classList.contains('hidden');
const isMarker = line.dataset.onboardingOptionHidden;

// Count any visible non-marker line
if (!isMarker && !isHidden) {
hasVisibleIntegrations = true;
break;
}
}

// Toggle visibility of both open and close lines
openLine.classList.toggle('hidden', !hasVisibleIntegrations);
allLines[closeIndex].classList.toggle('hidden', !hasVisibleIntegrations);

// Hide empty lines adjacent to the wrapper when no integrations are visible
if (!hasVisibleIntegrations) {
// Check line before open wrapper
if (openIndex > 0) {
const prevLine = allLines[openIndex - 1];
const prevText = prevLine.textContent?.trim();
if (!prevText || prevText === '') {
prevLine.style.display = 'none';
}
}

// Check line after close wrapper
if (closeIndex < allLines.length - 1) {
const nextLine = allLines[closeIndex + 1];
const nextText = nextLine.textContent?.trim();
if (!nextText || nextText === '') {
nextLine.style.display = 'none';
}
}
} else {
// Show empty lines when integrations are visible
if (openIndex > 0) {
const prevLine = allLines[openIndex - 1];
const prevText = prevLine.textContent?.trim();
if (!prevText || prevText === '') {
prevLine.style.display = '';
}
}

if (closeIndex < allLines.length - 1) {
const nextLine = allLines[closeIndex + 1];
const nextText = nextLine.textContent?.trim();
if (!nextText || nextText === '') {
nextLine.style.display = '';
}
}
}
});
}

export function OnboardingOptionButtons({
Expand Down
31 changes: 31 additions & 0 deletions src/rehype-onboarding-lines.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ function handle_inline_options(node) {
// ___PRODUCT_OPTION_END___ session-replay
const PRODUCT_OPTION_START = '___PRODUCT_OPTION_START___';
const PRODUCT_OPTION_END = '___PRODUCT_OPTION_END___';

// First pass: mark lines with options
node.children?.forEach(line => {
const lineStr = toString(line);
if (lineStr.includes(PRODUCT_OPTION_START)) {
Expand All @@ -55,4 +57,33 @@ function handle_inline_options(node) {
line.properties['data-onboarding-option'] = currentOption;
}
});

// Second pass: Mark integrations array opening/closing lines
// These should be hidden if all content inside is from options that are disabled
for (let i = 0; i < (node.children?.length ?? 0); i++) {
const line = node.children[i];
const lineStr = toString(line).trim();

// Found "integrations: ["
if (lineStr.match(/integrations:\s*\[/)) {
// Mark the opening line and hide it by default
line.properties['data-integrations-wrapper'] = 'open';
line.properties.className = [...(line.properties.className || []), 'hidden'];

// Find the closing "],"
for (let j = i + 1; j < node.children.length; j++) {
const closeStr = toString(node.children[j]).trim();
if (closeStr.includes('],')) {
// Mark the closing line and hide it by default
node.children[j].properties['data-integrations-wrapper'] = 'close';
node.children[j].properties.className = [
...(node.children[j].properties.className || []),
'hidden',
];
break;
}
}
break; // Only handle first integrations array
}
}
}
Loading