Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion react/src/components/Checkout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ async function checkout(cart, checkout_span) {
return;
}

if(getTag('backendType') === 'flask') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now 2 more backends have a well-tested seer RCA+solution

Suggested change
if(getTag('backendType') === 'flask') {
if(['flask', 'laravel', 'flask-otlp'].includes(getTag('backendType'))) {

Sentry.setTag('seerDemo', true);
}

checkout_span.setAttribute("checkout.click", 1);
checkout_span.setAttribute("items_at_checkout", itemsInCart);

let tags = { 'backendType': getTag('backendType'), 'cexp': getTag('cexp'), 'items_at_checkout': itemsInCart, 'checkout.click': 1 };
let tags = { 'backendType': getTag('backendType'), 'cexp': getTag('cexp'), 'items_at_checkout': itemsInCart, 'checkout.click': 1, };
checkout_span.setAttributes(tags);
const stopMeasurement = measureRequestDuration('/checkout');

Expand Down
70 changes: 70 additions & 0 deletions react/src/tests/Checkout.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ jest.mock('react-loader-spinner', () => () => <div data-testid="loader" />);
jest.mock('@sentry/react', () => ({
...jest.requireActual('@sentry/react'),
captureException: jest.fn(),
setTag: jest.fn(),
getCurrentScope: jest.fn(() => ({
_tags: {}
})),
metrics: {
increment: jest.fn(),
distribution: jest.fn(),
Expand Down Expand Up @@ -44,6 +48,72 @@ describe('Checkout Component', () => {
// expect(screen.getByPlaceholderText(/123 Main Street/i)).toBeInTheDocument();
});

// test('sets seerDemo tag when backendType is flask', async () => {
// const mockGetCurrentScope = jest.fn(() => ({
// _tags: { backendType: 'flask' }
// }));
// Sentry.getCurrentScope.mockImplementation(mockGetCurrentScope);

// render(
// <Provider store={store}>
// <Router>
// <Checkout backend="/api" rageclick={false} />
// </Router>
// </Provider>
// );

// // Trigger checkout by submitting the form
// fireEvent.submit(screen.getByRole('button', { name: /Complete order/i }));

// await waitFor(() => {
// expect(Sentry.setTag).toHaveBeenCalledWith('seerDemo', true);
// });
// });

// test('does not set seerDemo tag when backendType is not flask', async () => {
// const mockGetCurrentScope = jest.fn(() => ({
// _tags: { backendType: 'express' }
// }));
// Sentry.getCurrentScope.mockImplementation(mockGetCurrentScope);

// render(
// <Provider store={store}>
// <Router>
// <Checkout backend="/api" rageclick={false} />
// </Router>
// </Provider>
// );

// // Trigger checkout by submitting the form
// fireEvent.submit(screen.getByRole('button', { name: /Complete order/i }));

// await waitFor(() => {
// expect(Sentry.setTag).not.toHaveBeenCalledWith('seerDemo', true);
// });
// });

// test('does not set seerDemo tag when backendType is undefined', async () => {
// const mockGetCurrentScope = jest.fn(() => ({
// _tags: {}
// }));
// Sentry.getCurrentScope.mockImplementation(mockGetCurrentScope);

// render(
// <Provider store={store}>
// <Router>
// <Checkout backend="/api" rageclick={false} />
// </Router>
// </Provider>
// );

// // Trigger checkout by submitting the form
// fireEvent.submit(screen.getByRole('button', { name: /Complete order/i }));

// await waitFor(() => {
// expect(Sentry.setTag).not.toHaveBeenCalledWith('seerDemo', true);
// });
// });

Comment on lines +51 to +116
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

// test('handles input change', () => {
// render(
// <Provider store={store}>
Expand Down
Loading