@faststats/nuxt 0.10.0 → 0.10.2

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/dist/module.mjs CHANGED
@@ -3,7 +3,7 @@ import { addPlugin, addTypeTemplate, createResolver, defineNuxtModule, useLogger
3
3
  import { defu } from "defu";
4
4
  //#region src/module.ts
5
5
  const SDK_NAME = "@faststats/nuxt";
6
- const SDK_VERSION = "0.10.0";
6
+ const SDK_VERSION = "0.10.2";
7
7
  const faststatsModule = defineNuxtModule({
8
8
  meta: {
9
9
  name: "@faststats/nuxt",
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/faststats-dev/faststats-javascript.git"
6
6
  },
7
- "version": "0.10.0",
7
+ "version": "0.10.2",
8
8
  "type": "module",
9
9
  "main": "./dist/module.mjs",
10
10
  "types": "./dist/module.d.mts",
@@ -31,7 +31,7 @@
31
31
  "nuxt": "^3.12.0 || ^4.0.0"
32
32
  },
33
33
  "dependencies": {
34
- "@faststats/web": "^0.10.0",
34
+ "@faststats/web": "^0.10.2",
35
35
  "@nuxt/kit": "^4.5.2",
36
36
  "@nuxt/schema": "^4.5.2",
37
37
  "defu": "^6.1.7"
@@ -1,34 +1,15 @@
1
- import {
2
- type AnalyticsExtension,
3
- WebAnalytics,
4
- type WebAnalyticsOptions,
5
- } from "@faststats/web";
6
- import type { ErrorTrackingExtensionOptions } from "@faststats/web/error";
7
- import type { SessionReplayExtensionOptions } from "@faststats/web/replay";
1
+ import type { ModuleOptions } from "@faststats/nuxt";
2
+ import { type AnalyticsExtension, WebAnalytics } from "@faststats/web";
8
3
  import { defineNuxtPlugin, useRuntimeConfig } from "nuxt/app";
9
4
 
10
- type RuntimeOptions = Omit<WebAnalyticsOptions, "siteKey" | "extensions"> & {
11
- siteKey?: string;
12
- extensions?: {
13
- outboundLinks?: boolean;
14
- errorTracking?: boolean | ErrorTrackingExtensionOptions;
15
- webVitals?: boolean;
16
- sessionReplay?: boolean | SessionReplayExtensionOptions;
17
- };
18
- };
19
-
20
- function extensionOptions<T>(value: boolean | T): T {
21
- return (value === true ? {} : value) as T;
22
- }
23
-
24
5
  function normalizeVueError(error: unknown, info?: string): Error {
25
6
  if (error instanceof Error) return error;
26
- const message = typeof error === "string" ? error : String(error);
7
+ const message = String(error);
27
8
  return new Error(info ? `${info}: ${message}` : message);
28
9
  }
29
10
 
30
11
  export default defineNuxtPlugin(async (nuxtApp) => {
31
- const runtime = useRuntimeConfig().public.faststats as RuntimeOptions;
12
+ const runtime = useRuntimeConfig().public.faststats as ModuleOptions;
32
13
  if (!runtime?.siteKey) return;
33
14
  const { extensions: configured = {}, siteKey, ...options } = runtime;
34
15
  const extensions = (
@@ -40,7 +21,11 @@ export default defineNuxtPlugin(async (nuxtApp) => {
40
21
  : undefined,
41
22
  configured.errorTracking
42
23
  ? import("@faststats/web/error").then(({ errorTracking }) =>
43
- errorTracking(extensionOptions(configured.errorTracking)),
24
+ errorTracking(
25
+ typeof configured.errorTracking === "object"
26
+ ? configured.errorTracking
27
+ : {},
28
+ ),
44
29
  )
45
30
  : undefined,
46
31
  configured.webVitals
@@ -50,7 +35,11 @@ export default defineNuxtPlugin(async (nuxtApp) => {
50
35
  : undefined,
51
36
  configured.sessionReplay
52
37
  ? import("@faststats/web/replay").then(({ sessionReplay }) =>
53
- sessionReplay(extensionOptions(configured.sessionReplay)),
38
+ sessionReplay(
39
+ typeof configured.sessionReplay === "object"
40
+ ? configured.sessionReplay
41
+ : {},
42
+ ),
54
43
  )
55
44
  : undefined,
56
45
  ])