@plentymarkets/shop-core 1.24.0 → 1.25.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/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@plentymarkets/shop-core",
3
3
  "configKey": "shopCore",
4
- "version": "1.24.0",
4
+ "version": "1.25.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -168,7 +168,7 @@ const module$1 = defineNuxtModule({
168
168
  configId: _options.configId,
169
169
  experimental: {
170
170
  enableSSRMetrics: _options.experimental?.enableSSRMetrics ?? false,
171
- enablePlentyAnalytics: _options.experimental?.enablePlentyAnalytics ?? true
171
+ enablePlentyLogs: _options.experimental?.enablePlentyLogs ?? true
172
172
  },
173
173
  middlewareSSRUrl: _options.middlewareSSRUrl,
174
174
  logger: {
@@ -245,7 +245,7 @@ export type ShopCoreConfig = ${genInlineTypeImport(projectRootResolver.resolve("
245
245
  });
246
246
  addPlugin(resolver.resolve("./runtime/plugins/sdk"));
247
247
  addPlugin(resolver.resolve("./runtime/plugins/cache-control.server"));
248
- addPlugin(resolver.resolve("./runtime/plugins/analytics.client"));
248
+ addPlugin(resolver.resolve("./runtime/plugins/logs.client"));
249
249
  addImports({
250
250
  name: "useSdk",
251
251
  as: "useSdk",
@@ -312,9 +312,9 @@ export type ShopCoreConfig = ${genInlineTypeImport(projectRootResolver.resolve("
312
312
  from: resolver.resolve("./runtime/composables/useT")
313
313
  });
314
314
  addImports({
315
- name: "usePlentyAnalytics",
316
- as: "usePlentyAnalytics",
317
- from: resolver.resolve("./runtime/composables/usePlentyAnalytics")
315
+ name: "usePlentyLogs",
316
+ as: "usePlentyLogs",
317
+ from: resolver.resolve("./runtime/composables/usePlentyLogs")
318
318
  });
319
319
  addImports({
320
320
  name: "getSSRMetrics",
@@ -0,0 +1,2 @@
1
+ import type { ShopLogEventInput } from '../types/log-events.js';
2
+ export declare const usePlentyLogs: (event: ShopLogEventInput) => void;
@@ -1,5 +1,5 @@
1
1
  import { useNuxtApp } from "#app";
2
- export const usePlentyAnalytics = (event) => {
2
+ export const usePlentyLogs = (event) => {
3
3
  if (!import.meta.client) return;
4
4
  const { $trackEvent } = useNuxtApp();
5
5
  $trackEvent(event);
@@ -1,10 +1,10 @@
1
- import type { PlentyAnalyticsEventInput } from '../types/analytics-events.js';
1
+ import type { ShopLogEventInput } from '../types/log-events.js';
2
2
  declare const _default: import("#app").Plugin<{
3
- trackEvent: (_event: PlentyAnalyticsEventInput) => void;
3
+ trackEvent: (_event: ShopLogEventInput) => void;
4
4
  collectEvents: () => Promise<void>;
5
5
  stopCollectInterval: () => void;
6
6
  }> & import("#app").ObjectPlugin<{
7
- trackEvent: (_event: PlentyAnalyticsEventInput) => void;
7
+ trackEvent: (_event: ShopLogEventInput) => void;
8
8
  collectEvents: () => Promise<void>;
9
9
  stopCollectInterval: () => void;
10
10
  }>;
@@ -1,5 +1,6 @@
1
1
  import { defineNuxtPlugin, useRuntimeConfig, useState } from "#app";
2
- import { createAnalyticsTracker } from "../utils/analyticsTracker.js";
2
+ import { createLogsTracker } from "../utils/logTracker.js";
3
+ import { useSdk } from "../composables/useSdk.js";
3
4
  export default defineNuxtPlugin(() => {
4
5
  const config = useRuntimeConfig();
5
6
  let trackEvent = (_event) => {
@@ -8,12 +9,12 @@ export default defineNuxtPlugin(() => {
8
9
  };
9
10
  let stopCollectInterval = () => {
10
11
  };
11
- if (config.public.shopCore.experimental.enablePlentyAnalytics) {
12
- const queue = useState("plenty-analytics-event-queue", () => []);
13
- const fetcher = async (payload) => {
14
- console.log("[plenty-analytics] mock send", payload);
12
+ if (config.public.shopCore.experimental.enablePlentyLogs) {
13
+ const queue = useState("plenty-log-event-queue", () => []);
14
+ const sendLogs = async (payload) => {
15
+ return useSdk().plentysystems.doAddShopLogs(payload);
15
16
  };
16
- const tracker = createAnalyticsTracker({ queue, fetcher });
17
+ const tracker = createLogsTracker({ queue, fetcher: sendLogs });
17
18
  trackEvent = tracker.trackEvent;
18
19
  collectEvents = tracker.collectEvents;
19
20
  stopCollectInterval = tracker.stopCollectInterval;
@@ -6,3 +6,4 @@ export * from './notification.js';
6
6
  export * from './localization.js';
7
7
  export * from './module.js';
8
8
  export * from './ssr-metrics.js';
9
+ export * from './log-events.js';
@@ -6,3 +6,4 @@ export * from "./notification.js";
6
6
  export * from "./localization.js";
7
7
  export * from "./module.js";
8
8
  export * from "./ssr-metrics.js";
9
+ export * from "./log-events.js";
@@ -0,0 +1,5 @@
1
+ import type { ISODateString, ShopLogEvent } from "@plentymarkets/shop-api";
2
+ export declare const toISODateString: (value: Date | string) => ISODateString;
3
+ export type ShopLogEventInput = Omit<ShopLogEvent, 'triggeredAt'> & {
4
+ triggeredAt?: ISODateString;
5
+ };
@@ -4,7 +4,7 @@ export interface ModuleOptions {
4
4
  configId: number;
5
5
  experimental?: {
6
6
  enableSSRMetrics?: boolean;
7
- enablePlentyAnalytics?: boolean;
7
+ enablePlentyLogs?: boolean;
8
8
  };
9
9
  middlewareSSRUrl?: string;
10
10
  logger?: {
@@ -0,0 +1,17 @@
1
+ import type { ShopLogEvent } from '@plentymarkets/shop-api';
2
+ import type { ShopLogEventInput } from '../types/log-events.js';
3
+ interface QueueRef {
4
+ value: ShopLogEvent[];
5
+ }
6
+ interface LogsTrackerDeps {
7
+ queue: QueueRef;
8
+ fetcher: (payload: ShopLogEvent[]) => Promise<unknown>;
9
+ intervalMs?: number;
10
+ }
11
+ export declare const createLogsTracker: (deps: LogsTrackerDeps) => {
12
+ trackEvent: (event: ShopLogEventInput) => void;
13
+ collectEvents: () => Promise<void>;
14
+ startCollectInterval: () => void;
15
+ stopCollectInterval: () => void;
16
+ };
17
+ export {};
@@ -1,4 +1,4 @@
1
- export const createAnalyticsTracker = (deps) => {
1
+ export const createLogsTracker = (deps) => {
2
2
  const { queue, fetcher, intervalMs = 1e4 } = deps;
3
3
  let flushInterval = null;
4
4
  const trackEvent = (event) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plentymarkets/shop-core",
3
- "version": "1.24.0",
3
+ "version": "1.25.0",
4
4
  "description": "Core module for PlentyONE Shop",
5
5
  "repository": {
6
6
  "type": "git",
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@noble/hashes": "^2.0.1",
53
- "@plentymarkets/shop-api": "^0.168.0",
53
+ "@plentymarkets/shop-api": "^0.170.0",
54
54
  "@vue-storefront/sdk": "^3.4.1",
55
55
  "cookie-es": "^2.0.0",
56
56
  "knitwork": "^1.3.0",
@@ -1,2 +0,0 @@
1
- import type { PlentyAnalyticsEventInput } from '../types/analytics-events.js';
2
- export declare const usePlentyAnalytics: (event: PlentyAnalyticsEventInput) => void;
@@ -1,14 +0,0 @@
1
- export type ISODateString = string & {
2
- readonly __brand: 'ISODateString';
3
- };
4
- export declare const toISODateString: (value: Date | string) => ISODateString;
5
- export interface PlentyAnalyticsEvent {
6
- name: string;
7
- loggableType: string;
8
- loggableId: string;
9
- payload: Record<string, unknown>;
10
- triggeredAt: ISODateString;
11
- }
12
- export type PlentyAnalyticsEventInput = Omit<PlentyAnalyticsEvent, 'triggeredAt'> & {
13
- triggeredAt?: ISODateString;
14
- };
@@ -1,16 +0,0 @@
1
- import type { PlentyAnalyticsEvent, PlentyAnalyticsEventInput } from '../types/analytics-events.js';
2
- interface QueueRef {
3
- value: PlentyAnalyticsEvent[];
4
- }
5
- interface AnalyticsTrackerDeps {
6
- queue: QueueRef;
7
- fetcher: (payload: PlentyAnalyticsEvent[]) => Promise<unknown>;
8
- intervalMs?: number;
9
- }
10
- export declare const createAnalyticsTracker: (deps: AnalyticsTrackerDeps) => {
11
- trackEvent: (event: PlentyAnalyticsEventInput) => void;
12
- collectEvents: () => Promise<void>;
13
- startCollectInterval: () => void;
14
- stopCollectInterval: () => void;
15
- };
16
- export {};