Skip to content
Merged
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
13 changes: 13 additions & 0 deletions src/flashbar/__tests__/analytics-metadata.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { getGeneratedAnalyticsMetadata } from '@cloudscape-design/component-tool

import Button from '../../../lib/components/button';
import Flashbar, { FlashbarProps } from '../../../lib/components/flashbar';
import { DATA_ATTR_ANALYTICS_FLASHBAR } from '../../../lib/components/internal/analytics/selectors';
import createWrapper from '../../../lib/components/test-utils/dom';
import { validateComponentNameAndLabels } from '../../internal/__tests__/analytics-metadata-test-utils';

Expand Down Expand Up @@ -204,4 +205,16 @@ describe('Flashbar renders correct analytics metadata', () => {
...getMetadata(undefined, true, true),
});
});

describe('analytics attributes', () => {
test(`adds ${DATA_ATTR_ANALYTICS_FLASHBAR} attribute with the flashbar type`, () => {
const wrapper = renderFlashbar({ items: [{ id: '0', type: 'success' }] });
expect(wrapper.find(`[${DATA_ATTR_ANALYTICS_FLASHBAR}="success"]`)!.getElement()).toBeInTheDocument();
});

test(`adds ${DATA_ATTR_ANALYTICS_FLASHBAR} attribute with the effective flashbar type when loading`, () => {
const wrapper = renderFlashbar({ items: [{ id: '0', type: 'success', loading: true }] });
expect(wrapper.find(`[${DATA_ATTR_ANALYTICS_FLASHBAR}="info"]`)!.getElement()).toBeInTheDocument();
});
});
});
185 changes: 0 additions & 185 deletions src/flashbar/__tests__/analytics.test.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions src/flashbar/collapsible-flashbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { getComponentsAnalyticsMetadata, getItemAnalyticsMetadata } from './anal
import { useFlashbar } from './common';
import { Flash, focusFlashById } from './flash';
import { FlashbarProps } from './interfaces';
import { sendToggleMetric } from './internal/analytics';
import { counterTypes, getFlashTypeCount, getItemColor, getVisibleCollapsedItems, StackableItem } from './utils';

import styles from './styles.css.js';
Expand Down Expand Up @@ -84,7 +83,6 @@ export default function CollapsibleFlashbar({ items, ...restProps }: FlashbarPro
const animateFlash = !isReducedMotion;

function toggleCollapseExpand() {
sendToggleMetric(items.length, !isFlashbarStackExpanded);
if (!isReducedMotion) {
prepareAnimations();
}
Expand Down
9 changes: 1 addition & 8 deletions src/flashbar/flash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { useComponentMetadata, warnOnce } from '@cloudscape-design/component-too
import { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';

import { ActionsWrapper } from '../alert/actions-wrapper';
import { ButtonProps } from '../button/interfaces';
import { InternalButton } from '../button/internal';
import InternalIcon from '../icon/internal';
import { DATA_ATTR_ANALYTICS_FLASHBAR } from '../internal/analytics/selectors';
Expand All @@ -23,7 +22,6 @@ import InternalLiveRegion from '../live-region/internal';
import InternalSpinner from '../spinner/internal';
import { GeneratedAnalyticsMetadataFlashbarDismiss } from './analytics-metadata/interfaces';
import { FlashbarProps } from './interfaces';
import { sendDismissMetric } from './internal/analytics';
import { FOCUS_THROTTLE_DELAY } from './utils';

import analyticsSelectors from './analytics-metadata/styles.css.js';
Expand Down Expand Up @@ -142,11 +140,6 @@ export const Flash = React.forwardRef(

const effectiveType = loading ? 'info' : type;

const handleDismiss: ButtonProps['onClick'] = event => {
sendDismissMetric(effectiveType);
onDismiss && onDismiss(event);
};

const analyticsAttributes = {
[DATA_ATTR_ANALYTICS_FLASHBAR]: effectiveType,
};
Expand Down Expand Up @@ -230,7 +223,7 @@ export const Flash = React.forwardRef(
onButtonClick={onButtonClick}
/>
</div>
{dismissible && dismissButton(dismissLabel, handleDismiss)}
{dismissible && dismissButton(dismissLabel, onDismiss)}
{ariaRole === 'status' && (
<InternalLiveRegion sources={[statusIconAriaLabel, headerRefObject, contentRefObject]} />
)}
Expand Down
9 changes: 1 addition & 8 deletions src/flashbar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React, { useEffect } from 'react';
import React from 'react';

import { applyDisplayName } from '../internal/utils/apply-display-name';
import CollapsibleFlashbar from './collapsible-flashbar';
import { FlashbarProps } from './interfaces';
import { sendRenderMetric } from './internal/analytics';
import NonCollapsibleFlashbar from './non-collapsible-flashbar';

export { FlashbarProps };

export default function Flashbar(props: FlashbarProps) {
useEffect(() => {
if (props.items.length > 0) {
sendRenderMetric(props.items);
}
}, [props.items]);

if (props.stackItems) {
return <CollapsibleFlashbar {...props} />;
} else {
Expand Down
35 changes: 0 additions & 35 deletions src/flashbar/internal/analytics.ts

This file was deleted.

Loading