@scayle/storefront-nuxt 8.1.5 → 8.2.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,24 @@
1
1
  # @scayle/storefront-nuxt
2
2
 
3
+ ## 8.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - `storefront-nuxt` now includes experimental support for OpenTelemetry spans covering the bootstrapping and redirects middlewares. This aims to provide better insights into their performance impact. Please note that this is an experimental feature and its implementation and API might change in future releases.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependency `@scayle/h3-session@^0.5.0` to `@scayle/h3-session@0.5.0`
12
+
13
+ ## 8.1.6
14
+
15
+ ### Patch Changes
16
+
17
+ **Dependencies**
18
+
19
+ - Updated dependency to @scayle/h3-session@0.5.0
20
+ - Updated dependency to @scayle/unstorage-compression-driver@0.2.2
21
+
3
22
  ## 8.1.5
4
23
 
5
24
  ### Patch Changes
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
- "version": "8.1.5",
3
+ "version": "8.2.0",
4
4
  "configKey": "storefront",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.9.0"
package/dist/module.mjs CHANGED
@@ -45,7 +45,7 @@ export default {
45
45
  }`;
46
46
  }
47
47
  const PACKAGE_NAME = "@scayle/storefront-nuxt";
48
- const PACKAGE_VERSION = "8.1.5";
48
+ const PACKAGE_VERSION = "8.2.0";
49
49
  const logger = createConsola({
50
50
  fancy: true,
51
51
  formatOptions: {
@@ -5,6 +5,7 @@ import {
5
5
  useSession,
6
6
  unsignCookie
7
7
  } from "@scayle/h3-session";
8
+ import { trace, SpanStatusCode } from "@opentelemetry/api";
8
9
  import { buildContext } from "../../context.js";
9
10
  import { useCacheStorage, useSessionStorage } from "../utils/cacheStorage.js";
10
11
  import {
@@ -24,6 +25,10 @@ const generateSessionId = (event) => {
24
25
  }
25
26
  return userId ? `${userId}:${randomUUID()}` : randomUUID();
26
27
  };
28
+ const tracer = trace.getTracer(
29
+ "storefront-nuxt",
30
+ "__sfc_version"
31
+ );
27
32
  async function getOldSessionData(event, cookieName, store, secret) {
28
33
  const rawCookie = getCookie(event, cookieName);
29
34
  const normalizedSecrets = Array.isArray(secret) ? secret : [secret];
@@ -134,50 +139,73 @@ async function bootstrap(event, $shopConfig, $storefrontConfig, apiBasePath, con
134
139
  });
135
140
  }
136
141
  export default defineEventHandler(async (event) => {
137
- try {
138
- const { path, originalPath } = getBootstrapPath(event);
139
- if (path.startsWith("/__nuxt")) {
140
- return;
141
- }
142
- if (path === "/favicon.ico") {
143
- return;
144
- }
145
- const config = useRuntimeConfig(event);
146
- const $storefrontConfig = config.storefront;
147
- if (path === `${$storefrontConfig.apiBasePath ?? "/api"}/up`) {
148
- return;
149
- }
150
- const $shopConfig = getCurrentShopConfigForRequest(
151
- event,
152
- $storefrontConfig,
153
- config.app
154
- );
155
- if (!$shopConfig) {
156
- event.context.$log.debug(
157
- "Could not find shop config for this request",
158
- path
159
- );
160
- return;
161
- }
162
- const apiBasePath = getApiBasePath(
163
- $storefrontConfig,
164
- $shopConfig,
165
- config.app.baseURL
166
- );
167
- if (!event.context.$rpcContext) {
168
- event.context.$log.debug("Bootstrapping request: " + path);
169
- await bootstrap(
170
- event,
171
- $shopConfig,
172
- $storefrontConfig,
173
- apiBasePath,
174
- config
175
- );
176
- }
177
- if ($storefrontConfig.redirects?.enabled && !path.startsWith(apiBasePath) && originalPath !== "/__nuxt_error") {
178
- await useRedirects(event);
179
- }
180
- } catch (e) {
181
- console.error(e);
142
+ const { path, originalPath } = getBootstrapPath(event);
143
+ if (path.startsWith("/__nuxt")) {
144
+ return;
182
145
  }
146
+ if (path === "/favicon.ico") {
147
+ return;
148
+ }
149
+ const config = useRuntimeConfig(event);
150
+ const $storefrontConfig = config.storefront;
151
+ if (path === `${$storefrontConfig.apiBasePath ?? "/api"}/up`) {
152
+ return;
153
+ }
154
+ await tracer.startActiveSpan(
155
+ `storefront-nuxt.middleware/bootstrap`,
156
+ {
157
+ attributes: {
158
+ path,
159
+ originalPath
160
+ }
161
+ },
162
+ async (span) => {
163
+ try {
164
+ const $shopConfig = getCurrentShopConfigForRequest(
165
+ event,
166
+ $storefrontConfig,
167
+ config.app
168
+ );
169
+ if (!$shopConfig) {
170
+ event.context.$log.debug(
171
+ "Could not find shop config for this request",
172
+ path
173
+ );
174
+ return;
175
+ }
176
+ const apiBasePath = getApiBasePath(
177
+ $storefrontConfig,
178
+ $shopConfig,
179
+ config.app.baseURL
180
+ );
181
+ if (!event.context.$rpcContext) {
182
+ event.context.$log.debug("Bootstrapping request: " + path);
183
+ await bootstrap(
184
+ event,
185
+ $shopConfig,
186
+ $storefrontConfig,
187
+ apiBasePath,
188
+ config
189
+ );
190
+ }
191
+ if ($storefrontConfig.redirects?.enabled && !path.startsWith(apiBasePath) && originalPath !== "/__nuxt_error") {
192
+ await tracer.startActiveSpan(
193
+ `storefront-nuxt.middleware/redirects`,
194
+ {},
195
+ async (innerSpan) => {
196
+ await useRedirects(event);
197
+ innerSpan.end();
198
+ }
199
+ );
200
+ }
201
+ } catch (e) {
202
+ console.error(e);
203
+ span.setStatus({ code: SpanStatusCode.ERROR });
204
+ if (e instanceof Error) {
205
+ span.recordException(e);
206
+ }
207
+ }
208
+ span.end();
209
+ }
210
+ );
183
211
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
3
  "type": "module",
4
- "version": "8.1.5",
4
+ "version": "8.2.0",
5
5
  "description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
6
6
  "author": "SCAYLE Commerce Engine",
7
7
  "license": "MIT",
@@ -72,9 +72,9 @@
72
72
  "dependencies": {
73
73
  "@nuxt/kit": "^3.12.2",
74
74
  "@opentelemetry/api": "^1.9.0",
75
- "@scayle/h3-session": "^0.4.2",
75
+ "@scayle/h3-session": "0.5.0",
76
76
  "@scayle/storefront-core": "8.1.2",
77
- "@scayle/unstorage-compression-driver": "^0.2.0",
77
+ "@scayle/unstorage-compression-driver": "^0.2.2",
78
78
  "@vueuse/core": "12.0.0",
79
79
  "consola": "^3.2.3",
80
80
  "core-js": "^3.37.1",
@@ -105,7 +105,7 @@
105
105
  "h3": "1.13.0",
106
106
  "nitropack": "2.9.7",
107
107
  "node-mocks-http": "1.16.2",
108
- "nuxi": "3.16.0",
108
+ "nuxi": "3.17.0",
109
109
  "nuxt": "3.14.1592",
110
110
  "publint": "0.2.12",
111
111
  "vue-tsc": "2.1.10",