@scayle/storefront-nuxt 7.64.0 → 7.65.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,34 @@
1
1
  # @scayle/storefront-nuxt
2
2
 
3
+ ## 7.65.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add OpenTelemetry instrumentation to RPC methods
8
+
9
+ This release adds the beginning of native instrumentation to the `@scayle/storefront-nuxt` package.
10
+
11
+ 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:
12
+
13
+ - `rpc.method` the method name
14
+ - `rpc.server` `'storefront-nuxt.rpc'`
15
+ - `rpc.payload` the payload passed to the RPC
16
+ - `server.address` the hostname of the server
17
+ - `server.port` the port of the server
18
+
19
+ Additionally, the `Span`'s status will be set to `ERROR` or `OK` depending on the result of the RPC call.
20
+
21
+ 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.
22
+
23
+ ## 7.64.1
24
+
25
+ ### Patch Changes
26
+
27
+ - Format code with dprint
28
+ - Updated dependencies
29
+ - @scayle/unstorage-compression-driver@0.1.3
30
+ - @scayle/h3-session@0.3.6
31
+
3
32
  ## 7.64.0
4
33
 
5
34
  ### Minor Changes
@@ -14,8 +43,8 @@
14
43
 
15
44
  ```ts
16
45
  const { data: externalIDPRedirects } = await useIDP({
17
- queryParams: { redirectTo: '/account' },
18
- })
46
+ queryParams: { redirectTo: "/account" },
47
+ });
19
48
  ```
20
49
 
21
50
  Please note that `code` and `state` are not supported as these are used by the SCAYLE Authentication API.
@@ -434,16 +463,16 @@ There is an `unwrap` function exported by this package (>=7.55.0) that can be us
434
463
  Before:
435
464
 
436
465
  ```typescript
437
- toCurrency(100, { currency: 'EUR' })
438
- formatPrice(100, { currencyFractionDigits: 2 })
466
+ toCurrency(100, { currency: "EUR" });
467
+ formatPrice(100, { currencyFractionDigits: 2 });
439
468
  ```
440
469
 
441
470
  After:
442
471
 
443
472
  ```typescript
444
- const { formatCurrency } = useFormatHelpers()
445
- formatCurrency(100, { currency: 'EUR' })
446
- formatCurrency(100, { style: 'decimal', currencyFractionDigits: 2 })
473
+ const { formatCurrency } = useFormatHelpers();
474
+ formatCurrency(100, { currency: "EUR" });
475
+ formatCurrency(100, { style: "decimal", currencyFractionDigits: 2 });
447
476
  ```
448
477
 
449
478
  ## 7.44.1
package/dist/module.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
+ "version": "7.64.1",
3
4
  "configKey": "storefront",
4
5
  "compatibility": {
5
6
  "nuxt": "^3.9.0"
6
- },
7
- "version": "7.63.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.64.1";
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.0",
4
+ "version": "7.65.0",
5
5
  "description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
6
6
  "author": "SCAYLE Commerce Engine",
7
7
  "license": "MIT",
@@ -49,8 +49,8 @@
49
49
  "dev": "nuxi dev playground",
50
50
  "dev:build": "nuxi build playground",
51
51
  "prep": "nuxi prepare playground",
52
- "format": "prettier --ignore-unknown --log-level warn --check .",
53
- "format:fix": "prettier --ignore-unknown --log-level warn --write .",
52
+ "format": "dprint check",
53
+ "format:fix": "dprint fmt",
54
54
  "lint": "eslint . --format gitlab",
55
55
  "lint:fix": "eslint . --fix",
56
56
  "typecheck": "vue-tsc --noEmit -p tsconfig.check.json",
@@ -61,9 +61,10 @@
61
61
  },
62
62
  "dependencies": {
63
63
  "@nuxt/kit": "3.11.1",
64
- "@scayle/h3-session": "0.3.5",
64
+ "@opentelemetry/api": "1.8.0",
65
+ "@scayle/h3-session": "0.3.6",
65
66
  "@scayle/storefront-core": "7.48.0",
66
- "@scayle/unstorage-compression-driver": "0.1.2",
67
+ "@scayle/unstorage-compression-driver": "0.1.3",
67
68
  "@vueuse/core": "10.9.0",
68
69
  "consola": "3.2.3",
69
70
  "core-js": "3.36.1",
@@ -82,19 +83,18 @@
82
83
  "@nuxt/module-builder": "0.5.5",
83
84
  "@nuxt/schema": "3.11.1",
84
85
  "@nuxt/test-utils": "3.12.0",
85
- "@scayle/eslint-config-storefront": "3.2.6",
86
+ "@scayle/eslint-config-storefront": "3.2.7",
86
87
  "@scayle/eslint-plugin-vue-composable": "0.1.1",
87
- "@scayle/prettier-config-storefront": "2.0.2",
88
- "@types/node": "20.12.5",
88
+ "@types/node": "20.12.7",
89
+ "dprint": "0.45.1",
89
90
  "eslint": "8.57.0",
90
91
  "eslint-formatter-gitlab": "5.1.0",
91
92
  "h3": "1.11.1",
92
93
  "node-mocks-http": "1.14.1",
93
94
  "nuxt": "3.11.1",
94
- "prettier": "3.0.0",
95
95
  "publint": "0.2.7",
96
96
  "vitest": "1.4.0",
97
- "vue-tsc": "2.0.11"
97
+ "vue-tsc": "2.0.12"
98
98
  },
99
99
  "peerDependencies": {
100
100
  "h3": "^1.10.0",