Skip to content

Commit

Permalink
chore: update clarity version (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardodouradol authored Apr 23, 2024
1 parent 155d5f4 commit 0e42186
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 21 deletions.
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 16.14.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@sentry/integrations": "^6.19.7",
"@sentry/react": "^6.19.7",
"@sentry/tracing": "^6.19.7",
"clarity-js": "^0.7.24",
"clarity-js": "^0.7.32",
"jest-environment-jsdom": "^29.7.0",
"mixpanel-browser": "^2.49.0",
"react": "^18.2.0"
Expand Down
1 change: 1 addition & 0 deletions src/initializers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const clarityInitializer = (
track: true,
content: true,
});
clarity.consent();
}
};

Expand Down
19 changes: 1 addition & 18 deletions src/providers/setups/clarity/clarity.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,15 @@ jest.mock('clarity-js', () => ({
clarity: {
identify: jest.fn(),
set: jest.fn(),
consent: jest.fn(),
},
}));

describe('ClarityProvider', () => {
it('dispatchUserIdentification should call clarity.identify with correct arguments', () => {
const userId = 'user123';

ClarityProvider.userIdentification(userId, '');

expect(clarity.identify).toHaveBeenCalledWith(userId);
});

it('dispatchCustomEvent should call clarity.set with correct arguments', () => {
const eventName = 'clickEvent';
const properties = { key: 'value' };

ClarityProvider.customEvent(eventName, properties);

expect(clarity.set).toHaveBeenCalledWith(eventName, 'customEvent');
});

it('dispatchScreenEvent should call clarity.set with correct arguments', () => {
const screenName = 'HomeScreen';

ClarityProvider.screenEvent(screenName);

expect(clarity.set).toHaveBeenCalledWith(screenName, 'screen');
});
});
3 changes: 1 addition & 2 deletions src/providers/setups/clarity/clarity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ const dispatchUserIdentification = (
id: string,
userProperties: IUserProperties,
): void => {
clarity.consent();
clarity.identify(id);
};

const dispatchCustomEvent = (
event: string,
properties: PropertiesType,
): void => {
clarity.set(event, 'customEvent');
};

const dispatchScreenEvent = (screen: string): void => {
clarity.set(screen, 'screen');
};

const ClarityProvider: ProviderType = {
Expand Down

0 comments on commit 0e42186

Please sign in to comment.