@backstage/plugin-app 0.1.9-next.3 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @backstage/plugin-app
|
|
2
2
|
|
|
3
|
+
## 0.1.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fb58f20: Internal update to use the new `pluginId` option of `createFrontendPlugin`.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/frontend-plugin-api@0.10.2
|
|
10
|
+
- @backstage/theme@0.6.6
|
|
11
|
+
- @backstage/core-components@0.17.2
|
|
12
|
+
- @backstage/core-plugin-api@1.10.7
|
|
13
|
+
- @backstage/integration-react@1.2.7
|
|
14
|
+
- @backstage/plugin-permission-react@0.4.34
|
|
15
|
+
- @backstage/types@1.2.1
|
|
16
|
+
|
|
3
17
|
## 0.1.9-next.3
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -22,7 +22,7 @@ const getExtensionContext = (pathname, routes) => {
|
|
|
22
22
|
}
|
|
23
23
|
return acc;
|
|
24
24
|
}, {});
|
|
25
|
-
const plugin = routeObject.appNode?.spec.
|
|
25
|
+
const plugin = routeObject.appNode?.spec.plugin;
|
|
26
26
|
const extension = routeObject.appNode?.spec.extension;
|
|
27
27
|
return {
|
|
28
28
|
params,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouteTracker.esm.js","sources":["../../../../../../../packages/frontend-app-api/src/routing/RouteTracker.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect } from 'react';\nimport { matchRoutes, useLocation } from 'react-router-dom';\nimport {\n useAnalytics,\n AnalyticsContext,\n AnalyticsEventAttributes,\n} from '@backstage/frontend-plugin-api';\nimport { BackstageRouteObject } from './types';\n\n/**\n * Returns an extension context given the current pathname and a list of\n * Backstage route objects.\n */\nconst getExtensionContext = (\n pathname: string,\n routes: BackstageRouteObject[],\n) => {\n try {\n // Find matching routes for the given path name.\n const matches = matchRoutes(routes, { pathname });\n\n // Of the matching routes, get the last (e.g. most specific) instance of\n // the BackstageRouteObject that contains a routeRef. Filtering by routeRef\n // ensures subRouteRefs are aligned to their parent routes' context.\n const routeMatch = matches\n ?.filter(match => match?.route.routeRefs?.size > 0)\n .pop();\n const routeObject = routeMatch?.route;\n\n // If there is no route object, then allow inheritance of default context.\n if (!routeObject) {\n return undefined;\n }\n\n // If the matched route is the root route (no path), and the pathname is\n // not the path of the homepage, then inherit from the default context.\n if (routeObject.path === '' && pathname !== '/') {\n return undefined;\n }\n\n const params = Object.entries(\n routeMatch?.params || {},\n ).reduce<AnalyticsEventAttributes>((acc, [key, value]) => {\n if (value !== undefined && key !== '*') {\n acc[key] = value;\n }\n return acc;\n }, {});\n\n const plugin = routeObject.appNode?.spec.
|
|
1
|
+
{"version":3,"file":"RouteTracker.esm.js","sources":["../../../../../../../packages/frontend-app-api/src/routing/RouteTracker.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect } from 'react';\nimport { matchRoutes, useLocation } from 'react-router-dom';\nimport {\n useAnalytics,\n AnalyticsContext,\n AnalyticsEventAttributes,\n} from '@backstage/frontend-plugin-api';\nimport { BackstageRouteObject } from './types';\n\n/**\n * Returns an extension context given the current pathname and a list of\n * Backstage route objects.\n */\nconst getExtensionContext = (\n pathname: string,\n routes: BackstageRouteObject[],\n) => {\n try {\n // Find matching routes for the given path name.\n const matches = matchRoutes(routes, { pathname });\n\n // Of the matching routes, get the last (e.g. most specific) instance of\n // the BackstageRouteObject that contains a routeRef. Filtering by routeRef\n // ensures subRouteRefs are aligned to their parent routes' context.\n const routeMatch = matches\n ?.filter(match => match?.route.routeRefs?.size > 0)\n .pop();\n const routeObject = routeMatch?.route;\n\n // If there is no route object, then allow inheritance of default context.\n if (!routeObject) {\n return undefined;\n }\n\n // If the matched route is the root route (no path), and the pathname is\n // not the path of the homepage, then inherit from the default context.\n if (routeObject.path === '' && pathname !== '/') {\n return undefined;\n }\n\n const params = Object.entries(\n routeMatch?.params || {},\n ).reduce<AnalyticsEventAttributes>((acc, [key, value]) => {\n if (value !== undefined && key !== '*') {\n acc[key] = value;\n }\n return acc;\n }, {});\n\n const plugin = routeObject.appNode?.spec.plugin;\n const extension = routeObject.appNode?.spec.extension;\n\n return {\n params,\n pluginId: plugin?.id || 'root',\n extensionId: extension?.id || 'App',\n };\n } catch {\n return undefined;\n }\n};\n\n/**\n * Performs the actual event capture on render.\n */\nconst TrackNavigation = ({\n pathname,\n search,\n hash,\n attributes,\n}: {\n pathname: string;\n search: string;\n hash: string;\n attributes?: AnalyticsEventAttributes;\n}) => {\n const analytics = useAnalytics();\n useEffect(() => {\n analytics.captureEvent('navigate', `${pathname}${search}${hash}`, {\n attributes,\n });\n }, [analytics, pathname, search, hash, attributes]);\n\n return null;\n};\n\n/**\n * Logs a \"navigate\" event with appropriate plugin-level analytics context\n * attributes each time the user navigates to a page.\n */\nexport const RouteTracker = ({\n routeObjects,\n}: {\n routeObjects: BackstageRouteObject[];\n}) => {\n const { pathname, search, hash } = useLocation();\n\n const { params, ...attributes } = getExtensionContext(\n pathname,\n routeObjects,\n ) || { params: {} };\n\n return (\n <AnalyticsContext attributes={attributes}>\n <TrackNavigation\n pathname={pathname}\n search={search}\n hash={hash}\n attributes={params}\n />\n </AnalyticsContext>\n );\n};\n"],"names":[],"mappings":";;;;;AA6BA,MAAM,mBAAA,GAAsB,CAC1B,QAAA,EACA,MACG,KAAA;AACH,EAAI,IAAA;AAEF,IAAA,MAAM,OAAU,GAAA,WAAA,CAAY,MAAQ,EAAA,EAAE,UAAU,CAAA;AAKhD,IAAM,MAAA,UAAA,GAAa,OACf,EAAA,MAAA,CAAO,CAAS,KAAA,KAAA,KAAA,EAAO,MAAM,SAAW,EAAA,IAAA,GAAO,CAAC,CAAA,CACjD,GAAI,EAAA;AACP,IAAA,MAAM,cAAc,UAAY,EAAA,KAAA;AAGhC,IAAA,IAAI,CAAC,WAAa,EAAA;AAChB,MAAO,OAAA,KAAA,CAAA;AAAA;AAKT,IAAA,IAAI,WAAY,CAAA,IAAA,KAAS,EAAM,IAAA,QAAA,KAAa,GAAK,EAAA;AAC/C,MAAO,OAAA,KAAA,CAAA;AAAA;AAGT,IAAA,MAAM,SAAS,MAAO,CAAA,OAAA;AAAA,MACpB,UAAA,EAAY,UAAU;AAAC,MACvB,MAAiC,CAAA,CAAC,KAAK,CAAC,GAAA,EAAK,KAAK,CAAM,KAAA;AACxD,MAAI,IAAA,KAAA,KAAU,KAAa,CAAA,IAAA,GAAA,KAAQ,GAAK,EAAA;AACtC,QAAA,GAAA,CAAI,GAAG,CAAI,GAAA,KAAA;AAAA;AAEb,MAAO,OAAA,GAAA;AAAA,KACT,EAAG,EAAE,CAAA;AAEL,IAAM,MAAA,MAAA,GAAS,WAAY,CAAA,OAAA,EAAS,IAAK,CAAA,MAAA;AACzC,IAAM,MAAA,SAAA,GAAY,WAAY,CAAA,OAAA,EAAS,IAAK,CAAA,SAAA;AAE5C,IAAO,OAAA;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"0.1.9",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "frontend-plugin",
|
|
6
6
|
"pluginId": "app",
|
|
@@ -40,22 +40,22 @@
|
|
|
40
40
|
"test": "backstage-cli package test"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@backstage/core-components": "0.17.2
|
|
44
|
-
"@backstage/core-plugin-api": "1.10.7
|
|
45
|
-
"@backstage/frontend-plugin-api": "0.10.2
|
|
46
|
-
"@backstage/integration-react": "1.2.7
|
|
47
|
-
"@backstage/plugin-permission-react": "0.4.34
|
|
48
|
-
"@backstage/theme": "0.6.6
|
|
49
|
-
"@backstage/types": "1.2.1",
|
|
43
|
+
"@backstage/core-components": "^0.17.2",
|
|
44
|
+
"@backstage/core-plugin-api": "^1.10.7",
|
|
45
|
+
"@backstage/frontend-plugin-api": "^0.10.2",
|
|
46
|
+
"@backstage/integration-react": "^1.2.7",
|
|
47
|
+
"@backstage/plugin-permission-react": "^0.4.34",
|
|
48
|
+
"@backstage/theme": "^0.6.6",
|
|
49
|
+
"@backstage/types": "^1.2.1",
|
|
50
50
|
"@material-ui/core": "^4.9.13",
|
|
51
51
|
"@material-ui/icons": "^4.9.1",
|
|
52
52
|
"@material-ui/lab": "^4.0.0-alpha.61",
|
|
53
53
|
"react-use": "^17.2.4"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@backstage/cli": "0.32.1
|
|
57
|
-
"@backstage/dev-utils": "1.1.10
|
|
58
|
-
"@backstage/frontend-test-utils": "0.3.2
|
|
56
|
+
"@backstage/cli": "^0.32.1",
|
|
57
|
+
"@backstage/dev-utils": "^1.1.10",
|
|
58
|
+
"@backstage/frontend-test-utils": "^0.3.2",
|
|
59
59
|
"@testing-library/jest-dom": "^6.0.0",
|
|
60
60
|
"@testing-library/react": "^16.0.0",
|
|
61
61
|
"@testing-library/user-event": "^14.0.0",
|