From ec59f3e388efbbe71687eb4fa396f7be519f74d2 Mon Sep 17 00:00:00 2001 From: Jasper Boeijenga Date: Thu, 12 Oct 2023 15:01:28 +0200 Subject: [PATCH] Updated GA plugin playgrounds Signed-off-by: Jasper Boeijenga --- plugins/analytics-module-ga/dev/index.tsx | 16 ++++++++++++++-- plugins/analytics-module-ga4/dev/index.tsx | 21 +++++++++++++++++---- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/plugins/analytics-module-ga/dev/index.tsx b/plugins/analytics-module-ga/dev/index.tsx index 74b3439cff..8c0d7f9607 100644 --- a/plugins/analytics-module-ga/dev/index.tsx +++ b/plugins/analytics-module-ga/dev/index.tsx @@ -15,11 +15,23 @@ */ import React from 'react'; import { createDevApp } from '@backstage/dev-utils'; -import { analyticsModuleGA } from '../src/plugin'; import { Playground } from './Playground'; +import { + analyticsApiRef, + configApiRef, + identityApiRef, +} from '@backstage/core-plugin-api'; +import { GoogleAnalytics } from '../src'; createDevApp() - .registerPlugin(analyticsModuleGA) + .registerApi({ + api: analyticsApiRef, + deps: { configApi: configApiRef, identityApi: identityApiRef }, + factory: ({ configApi, identityApi }) => + GoogleAnalytics.fromConfig(configApi, { + identityApi, + }), + }) .addPage({ path: '/ga', title: 'GA Playground', diff --git a/plugins/analytics-module-ga4/dev/index.tsx b/plugins/analytics-module-ga4/dev/index.tsx index eb694498f5..4fe8496b35 100644 --- a/plugins/analytics-module-ga4/dev/index.tsx +++ b/plugins/analytics-module-ga4/dev/index.tsx @@ -13,11 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import React from 'react'; +import { + analyticsApiRef, + configApiRef, + createPlugin, + identityApiRef, +} from '@backstage/core-plugin-api'; import { createDevApp } from '@backstage/dev-utils'; -import { Playground } from './Playground'; +import React from 'react'; -import { createPlugin } from '@backstage/core-plugin-api'; +import { GoogleAnalytics4 } from '../src'; +import { Playground } from './Playground'; /** * @deprecated Importing and including this plugin in an app has no effect. @@ -29,7 +35,14 @@ export const analyticsModuleGA4 = createPlugin({ id: 'analytics-provider-ga4', }); createDevApp() - .registerPlugin(analyticsModuleGA4) + .registerApi({ + api: analyticsApiRef, + deps: { configApi: configApiRef, identityApi: identityApiRef }, + factory: ({ configApi, identityApi }) => + GoogleAnalytics4.fromConfig(configApi, { + identityApi, + }), + }) .addPage({ path: '/ga4', title: 'GA4 Playground',