Skip to content

Commit

Permalink
fix(GA4): object.formEntries is not a function
Browse files Browse the repository at this point in the history
  • Loading branch information
mihir-4116 committed Sep 8, 2023
1 parent 11664fe commit 4311875
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = [
name: 'All Integrations - CDN',
path: 'dist/legacy/js-integrations/*.min.js',
gzip: true,
limit: '446.5 kB',
limit: '447.0 kB',
},
{
name: 'Core - NPM',
Expand Down
21 changes: 15 additions & 6 deletions src/integrations/GA4/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,21 @@ const formatAndValidateEventName = (eventName) => {
* @param {*} params
* @returns
*/
const removeInvalidParams = (params) =>
Object.fromEntries(
Object.entries(params).filter(
([key, value]) => key === 'items' || (typeof value !== 'object' && !isBlank(value)),
),
);
const removeInvalidParams = (params) => {
const validParams = {};

if (typeof params === 'object' && !Array.isArray(params)) {
const keys = Object.keys(params);
keys.forEach((key) => {
const value = params[key];
if (key === 'items' || (typeof value !== 'object' && !isBlank(value))) {
validParams[key] = value;
}
});
return validParams;
}
return params;
};

/**
* Returns custom parameters for ga4 event payload
Expand Down

0 comments on commit 4311875

Please sign in to comment.