Skip to content

Commit 362fbcb

Browse files
authored
Merge branch 'main' into dev-v3-ernstka-shortcuts
2 parents a1c7cb8 + fa886b7 commit 362fbcb

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/app-layout/__tests__/runtime-feature-notifications.test.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { act, fireEvent, render, waitFor } from '@testing-library/react';
55

66
import AppLayout from '../../../lib/components/app-layout';
77
import TestI18nProvider from '../../../lib/components/i18n/testing';
8+
import { metrics } from '../../../lib/components/internal/metrics';
89
import {
910
persistFeatureNotifications,
1011
retrieveFeatureNotifications,
@@ -565,4 +566,24 @@ describeEachAppLayout({ themes: ['refresh-toolbar'] }, ({ size }) => {
565566
expect(wrapper.findDrawerTriggerById(featureNotificationsDefaults.id)).toBeTruthy();
566567
expect(wrapper.findToolsToggle()).toBeTruthy();
567568
});
569+
570+
test('usage metrics', () => {
571+
const sendPanoramaMetricSpy = jest.spyOn(metrics, 'logComponentUsed').mockImplementation(() => {});
572+
573+
featureNotifications.registerFeatureNotifications(featureNotificationsDefaults);
574+
renderComponent(<AppLayout />);
575+
576+
expect(sendPanoramaMetricSpy).toHaveBeenCalledWith('feature-notifications', {
577+
props: {
578+
featuresPageLink: '/features-page',
579+
suppressFeaturePrompt: undefined,
580+
},
581+
metadata: {
582+
featuresLength: 3,
583+
hasMountItem: true,
584+
hasFilterFeatures: false,
585+
hasPersistenceConfig: true,
586+
},
587+
});
588+
});
568589
});

src/app-layout/visual-refresh-toolbar/state/use-feature-notifications.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';
66

77
import { useInternalI18n } from '../../../i18n/context';
88
import FeaturePrompt, { FeaturePromptProps } from '../../../internal/do-not-use/feature-prompt';
9+
import { metrics } from '../../../internal/metrics';
910
import { persistFeatureNotifications, retrieveFeatureNotifications } from '../../../internal/persistence';
1011
import {
1112
Feature,
@@ -117,6 +118,18 @@ export function useFeatureNotifications() {
117118
function featureNotificationsMessageHandler(event: WidgetMessage) {
118119
if (event.type === 'registerFeatureNotifications') {
119120
const { payload } = event;
121+
metrics.logComponentUsed('feature-notifications', {
122+
props: {
123+
featuresPageLink: payload.featuresPageLink,
124+
suppressFeaturePrompt: payload.suppressFeaturePrompt,
125+
},
126+
metadata: {
127+
featuresLength: payload.features.length,
128+
hasMountItem: !!payload.mountItem,
129+
hasFilterFeatures: !!payload.filterFeatures,
130+
hasPersistenceConfig: !!payload.persistenceConfig,
131+
},
132+
});
120133
const features = getFeaturesToDisplay(payload);
121134
if (features.length === 0) {
122135
return;

0 commit comments

Comments
 (0)