Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hotjar): event.replaceAll is not a function #1354

Merged
merged 2 commits into from
Aug 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/integrations/Hotjar/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ class Hotjar {
track(rudderElement) {
logger.debug('===In Hotjar track===');

const { event } = rudderElement.message;
let { event } = rudderElement.message;

if (!event) {
logger.error('Event name not present');
logger.error('Event name is not present');
return;
}

Expand All @@ -67,7 +67,14 @@ class Hotjar {

// event name must not exceed 750 characters and can only contain alphanumeric, underscores, and dashes.
// Ref - https://help.hotjar.com/hc/en-us/articles/4405109971095#the-events-api-call
window.hj('event', event.replace(/\s\s+/g, ' ').substring(0, 750).replaceAll(' ', '_'));
if (event.length > 750) {
event = event.substring(0, 750);
}
event = event.replace(/ /g, '_');

if (event) {
window.hj('event', event);
}
}

page() {
Expand Down
Loading