fix(frontend-plugin-api): default api config error

Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2024-01-25 11:04:20 +01:00
parent 01abfa9c2b
commit b1afb710b8
10 changed files with 51 additions and 24 deletions
@@ -35,8 +35,8 @@ describe('AnalyticsContext', () => {
it('returns default values', () => {
const { result } = renderHook(() => useAnalyticsContext());
expect(result.current).toEqual({
extensionId: 'App',
pluginId: 'root',
extensionId: 'app',
pluginId: 'app',
});
});
});
@@ -49,8 +49,8 @@ describe('AnalyticsContext', () => {
</AnalyticsContext>,
);
expect(result.getByTestId('extension-id')).toHaveTextContent('App');
expect(result.getByTestId('plugin-id')).toHaveTextContent('root');
expect(result.getByTestId('extension-id')).toHaveTextContent('app');
expect(result.getByTestId('plugin-id')).toHaveTextContent('app');
});
it('uses provided analytics context', () => {
@@ -60,7 +60,7 @@ describe('AnalyticsContext', () => {
</AnalyticsContext>,
);
expect(result.getByTestId('extension-id')).toHaveTextContent('App');
expect(result.getByTestId('extension-id')).toHaveTextContent('app');
expect(result.getByTestId('plugin-id')).toHaveTextContent('custom');
});
@@ -38,7 +38,7 @@ export const useAnalyticsContext = (): AnalyticsContextValue => {
if (theContext === undefined) {
return {
pluginId: 'app',
extensionId: 'App',
extensionId: 'app',
};
}
@@ -53,8 +53,8 @@ describe('useAnalytics', () => {
some: 'value',
},
context: {
extensionId: 'App',
pluginId: 'root',
extensionId: 'app',
pluginId: 'app',
},
});
});
@@ -23,8 +23,11 @@ import { Tracker } from './Tracker';
function useAnalyticsApi(): AnalyticsApi {
try {
return useApi(analyticsApiRef);
} catch {
return { captureEvent: () => {} };
} catch (error) {
if (error.name === 'NotImplementedError') {
return { captureEvent: () => {} };
}
throw error;
}
}