@scayle/storefront-nuxt 7.64.1 → 7.65.1

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,32 @@
1
1
  # @scayle/storefront-nuxt
2
2
 
3
+ ## 7.65.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @scayle/storefront-core@7.48.1
9
+
10
+ ## 7.65.0
11
+
12
+ ### Minor Changes
13
+
14
+ - Add OpenTelemetry instrumentation to RPC methods
15
+
16
+ This release adds the beginning of native instrumentation to the `@scayle/storefront-nuxt` package.
17
+
18
+ If you are using the OpenTelemetry SDK in your application, a `Span` will now be created for calls to RPC methods. The `Span` will be named `storefront-nuxt.rpc/[method]` and have the following attributes:
19
+
20
+ - `rpc.method` the method name
21
+ - `rpc.server` `'storefront-nuxt.rpc'`
22
+ - `rpc.payload` the payload passed to the RPC
23
+ - `server.address` the hostname of the server
24
+ - `server.port` the port of the server
25
+
26
+ Additionally, the `Span`'s status will be set to `ERROR` or `OK` depending on the result of the RPC call.
27
+
28
+ If you are not using the `@opentelemetry/sdk` in your application, this change will have no impact. A reference implementation of the OpenTelemetry SDK will be included in a future Storefront Boilerplate release.
29
+
3
30
  ## 7.64.1
4
31
 
5
32
  ### Patch Changes
package/dist/module.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
+ "version": "7.65.0",
3
4
  "configKey": "storefront",
4
5
  "compatibility": {
5
6
  "nuxt": "^3.9.0"
6
- },
7
- "version": "7.64.0"
7
+ }
8
8
  }
package/dist/module.mjs CHANGED
@@ -40,9 +40,11 @@ export default {
40
40
  }`;
41
41
  }
42
42
  const PACKAGE_NAME = "@scayle/storefront-nuxt";
43
+ const PACKAGE_VERSION = "7.65.0";
43
44
  const module = defineNuxtModule({
44
45
  meta: {
45
46
  name: PACKAGE_NAME,
47
+ version: PACKAGE_VERSION,
46
48
  configKey: "storefront",
47
49
  compatibility: {
48
50
  nuxt: "^3.9.0"
@@ -207,6 +209,7 @@ const module = defineNuxtModule({
207
209
  nitroConfig.replace["process.env.SFC_OMIT_MD5"] = yn(
208
210
  process.env.SFC_OMIT_MD5
209
211
  );
212
+ nitroConfig.replace.__sfc_version = PACKAGE_VERSION;
210
213
  nitroConfig.virtual = {
211
214
  ...nitroConfig.virtual,
212
215
  "#virtual/storage-drivers": createVirtualDriverImport(
@@ -214,6 +217,21 @@ const module = defineNuxtModule({
214
217
  )
215
218
  };
216
219
  });
220
+ nuxt.hooks.hook("nitro:init", (nitro) => {
221
+ nitro.hooks.hook("rollup:before", (_nitro, rollupConfig) => {
222
+ const existingHandler = rollupConfig.onwarn;
223
+ rollupConfig.onwarn = (warning, handler) => {
224
+ if (warning.code === "THIS_IS_UNDEFINED" && warning.loc?.file?.includes("@opentelemetry")) {
225
+ return;
226
+ }
227
+ if (existingHandler) {
228
+ existingHandler(warning, handler);
229
+ } else {
230
+ handler(warning);
231
+ }
232
+ };
233
+ });
234
+ });
217
235
  nuxt.options.alias["#rpcMethods"] = appResolve(
218
236
  options.rpcDir ?? "./rpcMethods"
219
237
  );
@@ -1,41 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<boolean | void | string[] | import("@scayle/storefront-core").ShopUser | import("@scayle/storefront-core").Product | import("@scayle/storefront-core").BasketResponseData<import("@scayle/storefront-core").Product, import("@scayle/storefront-core").Variant> | {
2
- type: "failure";
3
- statusCode: number;
4
- basket: import("@scayle/storefront-core").BasketResponseData<import("@scayle/storefront-core").Product, import("@scayle/storefront-core").Variant>;
5
- } | {
6
- readonly type: "success";
7
- readonly basket: import("@scayle/storefront-core").BasketResponseData<import("@scayle/storefront-core").Product, import("@scayle/storefront-core").Variant>;
8
- } | {
9
- readonly type: "failure";
10
- readonly basket: import("@scayle/storefront-core").BasketResponseData<import("@scayle/storefront-core").Product, import("@scayle/storefront-core").Variant>;
11
- readonly errors: import("@aboutyou/backbone/helpers/BapiClient").AddOrUpdateItemError[];
12
- } | import("@scayle/storefront-core").BrandsEndpointResponseData | import("@scayle/storefront-core").Brand | {
13
- categories: import("@scayle/storefront-core").Category[];
14
- activeNode: undefined;
15
- } | import("@scayle/storefront-core").Category | {
16
- categories: import("@scayle/storefront-core").Category;
17
- activeNode: import("@scayle/storefront-core").Category;
18
- } | import("@scayle/storefront-core").Order | import("@scayle/storefront-core").Product[] | {
19
- products: import("@scayle/storefront-core").Product[];
20
- pagination: import("@aboutyou/backbone/endpoints/products/productsByIds").Pagination;
21
- } | {
22
- filters: import("@aboutyou/backbone").FiltersEndpointResponseData;
23
- unfilteredCount: number;
24
- } | {
25
- count: number;
26
- } | import("@scayle/storefront-core").TypeaheadSuggestionsEndpointResponseData | import("@scayle/storefront-core").SearchV2SuggestionsEndpointResponseData | import("@scayle/storefront-core").SearchEntity | import("@aboutyou/backbone/endpoints/shopconfiguration/shopconfiguration").ShopConfigurationResponseData | {
27
- user: import("@scayle/storefront-core").ShopUser | undefined;
28
- } | import("@scayle/storefront-core").WishlistResponseData | Response | import("@scayle/storefront-core").ShopUserAddress[] | import("@aboutyou/backbone/endpoints/variants/variantsByIds").VariantDetail[] | import("@aboutyou/backbone").NavigationAllEndpointResponseData | import("@scayle/storefront-core").NavigationTree | {
29
- success: true;
30
- } | {
31
- success: false;
32
- } | {
33
- result: true;
34
- } | {
35
- result: false;
36
- } | import("@scayle/storefront-core").PromotionsResponseData | {
37
- [k: string]: string;
38
- } | {
39
- message: string;
40
- } | null>>;
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
41
2
  export default _default;
@@ -1,21 +1,57 @@
1
- import { defineEventHandler, readBody, createError } from "h3";
1
+ import { defineEventHandler, readBody, createError, getRequestURL } from "h3";
2
2
  import { purifySensitiveData } from "@scayle/storefront-core";
3
+ import { trace, SpanStatusCode } from "@opentelemetry/api";
3
4
  import { handler } from "../handler.mjs";
4
5
  import { resolveError } from "../error/handler.mjs";
6
+ const tracer = trace.getTracer(
7
+ "storefront-nuxt",
8
+ "__sfc_version"
9
+ );
5
10
  export default defineEventHandler(async (event) => {
6
11
  const pathComponents = event.path.split("?")[0].split("/");
7
12
  const method = pathComponents[pathComponents.length - 1];
8
13
  const body = await readBody(event);
14
+ const url = getRequestURL(event, {
15
+ xForwardedHost: true,
16
+ xForwardedProto: true
17
+ });
9
18
  const payloadToBeLogged = JSON.stringify(
10
19
  purifySensitiveData(
11
20
  typeof body?.payload !== "object" ? { [typeof body?.payload]: body?.payload } : body?.payload
12
21
  )
13
22
  );
14
23
  event.context.$rpcContext.log.space("sfc").debug(`RPC Handler: ${method}, Payload: ${payloadToBeLogged}`);
15
- try {
16
- return await handler(method, body?.payload, event.context.$rpcContext);
17
- } catch (e) {
18
- event.context.$rpcContext.log.space("sfc").error(`RPC Handler failed: ${method}`, e);
19
- return createError(resolveError(e));
20
- }
24
+ return await tracer.startActiveSpan(
25
+ `storefront-nuxt.rpc/${method}`,
26
+ {
27
+ attributes: {
28
+ // https://opentelemetry.io/docs/specs/semconv/rpc/rpc-spans/#common-attributes
29
+ "rpc.method": method,
30
+ "rpc.service": "storefront-nuxt.rpc",
31
+ "rpc.payload": payloadToBeLogged,
32
+ "server.address": url.hostname,
33
+ "server.port": url.port
34
+ }
35
+ },
36
+ async (span) => {
37
+ let result;
38
+ try {
39
+ result = await handler(method, body?.payload, event.context.$rpcContext);
40
+ if (result instanceof Response && !result.ok) {
41
+ span.setStatus({ code: SpanStatusCode.ERROR });
42
+ } else {
43
+ span.setStatus({ code: SpanStatusCode.OK });
44
+ }
45
+ } catch (e) {
46
+ event.context.$rpcContext.log.space("sfc").error(`RPC Handler failed: ${method}`, e);
47
+ result = createError(resolveError(e));
48
+ if (e instanceof Error) {
49
+ span.recordException(e);
50
+ }
51
+ span.setStatus({ code: SpanStatusCode.ERROR });
52
+ }
53
+ span.end();
54
+ return result;
55
+ }
56
+ );
21
57
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
3
  "type": "module",
4
- "version": "7.64.1",
4
+ "version": "7.65.1",
5
5
  "description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
6
6
  "author": "SCAYLE Commerce Engine",
7
7
  "license": "MIT",
@@ -61,8 +61,9 @@
61
61
  },
62
62
  "dependencies": {
63
63
  "@nuxt/kit": "3.11.1",
64
+ "@opentelemetry/api": "1.8.0",
64
65
  "@scayle/h3-session": "0.3.6",
65
- "@scayle/storefront-core": "7.48.0",
66
+ "@scayle/storefront-core": "7.48.1",
66
67
  "@scayle/unstorage-compression-driver": "0.1.3",
67
68
  "@vueuse/core": "10.9.0",
68
69
  "consola": "3.2.3",
@@ -84,7 +85,7 @@
84
85
  "@nuxt/test-utils": "3.12.0",
85
86
  "@scayle/eslint-config-storefront": "3.2.7",
86
87
  "@scayle/eslint-plugin-vue-composable": "0.1.1",
87
- "@types/node": "20.12.6",
88
+ "@types/node": "20.12.7",
88
89
  "dprint": "0.45.1",
89
90
  "eslint": "8.57.0",
90
91
  "eslint-formatter-gitlab": "5.1.0",
@@ -93,7 +94,7 @@
93
94
  "nuxt": "3.11.1",
94
95
  "publint": "0.2.7",
95
96
  "vitest": "1.4.0",
96
- "vue-tsc": "2.0.11"
97
+ "vue-tsc": "2.0.12"
97
98
  },
98
99
  "peerDependencies": {
99
100
  "h3": "^1.10.0",