Skip to content

Commit

Permalink
fix: microsoft clarity identify error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Sai Sankeerth committed Nov 25, 2024
1 parent 134d779 commit 4e02266
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,17 @@ class MicrosoftClarity {
if (context?.traits?.customPageId) {
customPageId = context.traits.customPageId;
}
window.clarity('identify', userId, sessionId, customPageId);
if (context?.traits) {
const { traits } = context;
const keys = Object.keys(traits);
keys.forEach(key => {
window.clarity('set', key, traits[key]);
});
}
window.clarity('identify', userId, sessionId, customPageId).then(() => {

Check warning on line 58 in packages/analytics-js-integrations/src/integrations/MicrosoftClarity/browser.js

View check run for this annotation

Codecov / codecov/patch

packages/analytics-js-integrations/src/integrations/MicrosoftClarity/browser.js#L58

Added line #L58 was not covered by tests
if (context?.traits) {
const { traits } = context;
const keys = Object.keys(traits);
keys.forEach(key => {
window.clarity('set', key, traits[key]);

Check warning on line 63 in packages/analytics-js-integrations/src/integrations/MicrosoftClarity/browser.js

View check run for this annotation

Codecov / codecov/patch

packages/analytics-js-integrations/src/integrations/MicrosoftClarity/browser.js#L60-L63

Added lines #L60 - L63 were not covered by tests
});
}
}).catch(error => {
logger.error('Error in identify call', error);

Check warning on line 67 in packages/analytics-js-integrations/src/integrations/MicrosoftClarity/browser.js

View check run for this annotation

Codecov / codecov/patch

packages/analytics-js-integrations/src/integrations/MicrosoftClarity/browser.js#L67

Added line #L67 was not covered by tests
});
}
}

Expand Down

0 comments on commit 4e02266

Please sign in to comment.