Skip to content

Commit

Permalink
Add validation to ensure label key is present before sending event to…
Browse files Browse the repository at this point in the history
… Hiive (#91)

* Add a validation check for the Hiive event label key

* Add console.error

* Add console.error
  • Loading branch information
mr-vara authored Jul 31, 2024
1 parent dd99ac0 commit 1b19a02
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/helpers/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import { HiiveAnalytics, HiiveEvent } from "@newfold-labs/js-utility-ui-analytic
import { HIIVE_ANALYTICS_CATEGORY } from "../constants";

export const trackHiiveEvent = (action, data) => {
// Check if the label key for the event is present and not empty
const labelKey = data.label_key;
if (labelKey && !data[labelKey]) {
// eslint-disable-next-line no-console
console.error(`Missing or empty '${labelKey}' in Hiive event data`, data);
return;
}

data = {
...data,
page: window.location.href, // todo: check if this is what we want.
Expand Down

0 comments on commit 1b19a02

Please sign in to comment.