Make componetName == extension (name)

Signed-off-by: Eric Peterson <ericpeterson@spotify.com>
This commit is contained in:
Eric Peterson
2021-09-16 20:15:28 +02:00
parent 11582dacc2
commit ae4680b88d
19 changed files with 41 additions and 77 deletions
@@ -15,15 +15,12 @@
*/
import React from 'react';
import { withAnalyticsContext } from '@backstage/core-plugin-api';
import { Link } from '@backstage/core-components';
const ContextlessPlayground = () => {
export const Playground = () => {
return (
<>
<Link to="#clicked">Click Here</Link>
</>
);
};
export const Playground = withAnalyticsContext(ContextlessPlayground, {});
@@ -51,7 +51,7 @@ describe('GoogleAnalytics', () => {
describe('integration', () => {
const context = {
componentName: 'App',
extension: 'App',
pluginId: 'some-plugin',
releaseNum: 1337,
};
@@ -125,7 +125,7 @@ describe('GoogleAnalytics', () => {
expect(command).toBe('send');
expect(data).toMatchObject({
hitType: 'event',
eventCategory: context.componentName,
eventCategory: context.extension,
eventAction: expectedAction,
eventLabel: expectedLabel,
eventValue: expectedValue,
@@ -178,7 +178,7 @@ describe('GoogleAnalytics', () => {
expect(command).toBe('send');
expect(data).toMatchObject({
hitType: 'event',
eventCategory: context.componentName,
eventCategory: context.extension,
eventAction: expectedAction,
eventLabel: expectedLabel,
eventValue: expectedValue,
@@ -106,7 +106,7 @@ export class GoogleAnalytics implements AnalyticsApi {
}: AnalyticsEvent) {
const customMetadata = this.getCustomDimensionMetrics(context, attributes);
if (action === 'navigate' && context?.componentName === 'App') {
if (action === 'navigate' && context?.extension === 'App') {
// Set any/all custom dimensions.
if (Object.keys(customMetadata).length) {
ReactGA.set(customMetadata);
@@ -117,7 +117,7 @@ export class GoogleAnalytics implements AnalyticsApi {
}
ReactGA.event({
category: context.componentName || 'App',
category: context.extension || 'App',
action,
label: subject,
value,