Skip to content

Commit

Permalink
feat(sdk-analytics) fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
oidacra committed Dec 19, 2024
1 parent 975514f commit c427657
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions core-web/libs/sdk/analytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit c427657

Please sign in to comment.