From c42765723f4f9c6ea278e91b38e997a90d84b659 Mon Sep 17 00:00:00 2001 From: Arcadio Quintero Date: Thu, 19 Dec 2024 12:06:39 -0500 Subject: [PATCH] feat(sdk-analytics) fix test --- core-web/libs/sdk/analytics/README.md | 6 +++--- .../dotAnalytics/shared/dot-content-analytics.utils.spec.ts | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core-web/libs/sdk/analytics/README.md b/core-web/libs/sdk/analytics/README.md index 69e4dc40159..d62334579ae 100644 --- a/core-web/libs/sdk/analytics/README.md +++ b/core-web/libs/sdk/analytics/README.md @@ -53,13 +53,13 @@ function App() { ### Tracking Custom Events -Use the `useAnalyticsTracker` hook to track custom events: +Use the `useContentAnalytics` hook to track custom events: ```tsx -import { useAnalyticsTracker } from '@dotcms/analytics/react'; +import { useContentAnalytics } from '@dotcms/analytics/react'; function Activity({ title, urlTitle }) { - const { track } = useAnalyticsTracker(); + const { track } = useContentAnalytics(); // First parameter: custom event name to identify the action // Second parameter: object with properties you want to track diff --git a/core-web/libs/sdk/analytics/src/lib/dotAnalytics/shared/dot-content-analytics.utils.spec.ts b/core-web/libs/sdk/analytics/src/lib/dotAnalytics/shared/dot-content-analytics.utils.spec.ts index e659057bff3..efcd28ba093 100644 --- a/core-web/libs/sdk/analytics/src/lib/dotAnalytics/shared/dot-content-analytics.utils.spec.ts +++ b/core-web/libs/sdk/analytics/src/lib/dotAnalytics/shared/dot-content-analytics.utils.spec.ts @@ -158,9 +158,12 @@ describe('Analytics Utils', () => { it('should create page view data with basic properties', () => { const result = getBrowserEventData(mockLocation); + const mockDate = new Date('2024-01-01T00:00:00Z'); + const expectedOffset = mockDate.getTimezoneOffset(); + expect(result).toEqual( expect.objectContaining({ - local_tz_offset: 300, + local_tz_offset: expectedOffset, page_title: 'Test Page', doc_path: '/page', doc_host: 'example.com',