@backstage/core-app-api 1.7.1-next.0 → 1.8.0

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,33 @@
1
1
  # @backstage/core-app-api
2
2
 
3
+ ## 1.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c89437db899: The analytics' `navigate` event will now include the route parameters as attributes of the navigate event
8
+
9
+ ### Patch Changes
10
+
11
+ - b645d70034a: Fixed a bug in the Azure auth provider which prevented getting access tokens with multiple scopes for one resource
12
+ - 42d817e76ab: Added `FrontendHostDiscovery` for config driven discovery implementation
13
+ - Updated dependencies
14
+ - @backstage/config@1.0.7
15
+ - @backstage/core-plugin-api@1.5.1
16
+ - @backstage/types@1.0.2
17
+ - @backstage/version-bridge@1.0.4
18
+
19
+ ## 1.8.0-next.1
20
+
21
+ ### Minor Changes
22
+
23
+ - c89437db899: The analytics' `navigate` event will now include the route parameters as attributes of the navigate event
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies
28
+ - @backstage/core-plugin-api@1.5.1
29
+ - @backstage/config@1.0.7
30
+
3
31
  ## 1.7.1-next.0
4
32
 
5
33
  ### Patch Changes
package/dist/index.esm.js CHANGED
@@ -1156,7 +1156,11 @@ const _MicrosoftAuth = class {
1156
1156
  }
1157
1157
  static resourceForScopes(scope) {
1158
1158
  var _a;
1159
- const audiences = scope.split(" ").map(_MicrosoftAuth.resourceForScope).filter((aud) => aud !== "openid");
1159
+ const audiences = [
1160
+ ...new Set(
1161
+ scope.split(" ").map(_MicrosoftAuth.resourceForScope).filter((aud) => aud !== "openid")
1162
+ )
1163
+ ];
1160
1164
  if (audiences.length > 1) {
1161
1165
  return Promise.reject(
1162
1166
  new Error(
@@ -2005,45 +2009,70 @@ function isReactRouterBeta() {
2005
2009
  }
2006
2010
 
2007
2011
  const getExtensionContext = (pathname, routes) => {
2008
- var _a, _b;
2012
+ var _a;
2009
2013
  try {
2010
2014
  const matches = matchRoutes(routes, { pathname });
2011
- const routeObject = (_a = matches == null ? void 0 : matches.filter((match) => {
2015
+ const routeMatch = matches == null ? void 0 : matches.filter((match) => {
2012
2016
  var _a2;
2013
2017
  return ((_a2 = match == null ? void 0 : match.route.routeRefs) == null ? void 0 : _a2.size) > 0;
2014
- }).pop()) == null ? void 0 : _a.route;
2018
+ }).pop();
2019
+ const routeObject = routeMatch == null ? void 0 : routeMatch.route;
2015
2020
  if (!routeObject) {
2016
- return {};
2021
+ return void 0;
2017
2022
  }
2018
2023
  let routeRef;
2019
2024
  if (routeObject.routeRefs.size === 1) {
2020
2025
  routeRef = routeObject.routeRefs.values().next().value;
2021
2026
  }
2027
+ const params = Object.entries(
2028
+ (routeMatch == null ? void 0 : routeMatch.params) || {}
2029
+ ).reduce((acc, [key, value]) => {
2030
+ if (value !== void 0) {
2031
+ acc[key] = value;
2032
+ }
2033
+ return acc;
2034
+ }, {});
2022
2035
  return {
2023
2036
  extension: "App",
2024
- pluginId: ((_b = routeObject.plugin) == null ? void 0 : _b.getId()) || "root",
2025
- ...routeRef ? { routeRef: routeRef.id } : {}
2037
+ pluginId: ((_a = routeObject.plugin) == null ? void 0 : _a.getId()) || "root",
2038
+ ...routeRef ? { routeRef: routeRef.id } : {},
2039
+ params
2026
2040
  };
2027
2041
  } catch {
2028
- return {};
2042
+ return void 0;
2029
2043
  }
2030
2044
  };
2031
2045
  const TrackNavigation = ({
2032
2046
  pathname,
2033
2047
  search,
2034
- hash
2048
+ hash,
2049
+ attributes
2035
2050
  }) => {
2036
2051
  const analytics = useAnalytics();
2037
2052
  useEffect(() => {
2038
- analytics.captureEvent("navigate", `${pathname}${search}${hash}`);
2039
- }, [analytics, pathname, search, hash]);
2053
+ analytics.captureEvent("navigate", `${pathname}${search}${hash}`, {
2054
+ attributes
2055
+ });
2056
+ }, [analytics, pathname, search, hash, attributes]);
2040
2057
  return null;
2041
2058
  };
2042
2059
  const RouteTracker = ({
2043
2060
  routeObjects
2044
2061
  }) => {
2045
2062
  const { pathname, search, hash } = useLocation();
2046
- return /* @__PURE__ */ React.createElement(AnalyticsContext, { attributes: getExtensionContext(pathname, routeObjects) }, /* @__PURE__ */ React.createElement(TrackNavigation, { pathname, search, hash }));
2063
+ const { params, ...attributes } = getExtensionContext(
2064
+ pathname,
2065
+ routeObjects
2066
+ ) || { params: {} };
2067
+ return /* @__PURE__ */ React.createElement(AnalyticsContext, { attributes }, /* @__PURE__ */ React.createElement(
2068
+ TrackNavigation,
2069
+ {
2070
+ pathname,
2071
+ search,
2072
+ hash,
2073
+ attributes: params
2074
+ }
2075
+ ));
2047
2076
  };
2048
2077
 
2049
2078
  function getBasePath(configApi) {