@reservamos/browser-analytics 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13308,7 +13308,6 @@ const viewResultsSchema = z.object({
13308
13308
  "Route": z.string().min(1, "Route is required"),
13309
13309
  "product": productValidation
13310
13310
  });
13311
- const TrackTestEventSchema = z.object({});
13312
13311
  const InitConfigSchema = z.object({
13313
13312
  /**
13314
13313
  * The Mixpanel token used for authenticating API requests.
@@ -13369,7 +13368,6 @@ const SchemaErrorFormatter = (error) => {
13369
13368
  });
13370
13369
  };
13371
13370
  const eventSchemas = {
13372
- "Track Test": TrackTestEventSchema,
13373
13371
  "Search": searchSchema,
13374
13372
  "Seat Change": seatChangeSchema,
13375
13373
  "Interest In Home": interestInHomeSchema,
@@ -13382,9 +13380,6 @@ const eventSchemas = {
13382
13380
  };
13383
13381
  function parseEventProps(eventName, eventData) {
13384
13382
  const eventSchema = eventSchemas[eventName] || customEventSchema;
13385
- if (!eventSchema) {
13386
- throw { message: `Event ${eventName} not found` };
13387
- }
13388
13383
  try {
13389
13384
  eventSchema.parse(eventData);
13390
13385
  } catch (error) {
@@ -13453,6 +13448,17 @@ function flattenEventData(data) {
13453
13448
  return flattenedData;
13454
13449
  }, {});
13455
13450
  }
13451
+ function trackEventError(eventName, error) {
13452
+ try {
13453
+ mixpanelService.track("Track Event Error", {
13454
+ "Failed Event Name": eventName,
13455
+ "Error Message": (error == null ? void 0 : error.message) ?? "Failed to track event",
13456
+ "Validation Errors": (error == null ? void 0 : error.errors) || []
13457
+ });
13458
+ } catch (trackingError) {
13459
+ console.error("Failed to track error event:", trackingError);
13460
+ }
13461
+ }
13456
13462
  async function trackEvent(eventName, eventProperties, meta = {}) {
13457
13463
  if (!mixpanelService.isReady()) {
13458
13464
  throw new Error("Mixpanel is not initialized.");
@@ -13475,6 +13481,7 @@ async function trackEvent(eventName, eventProperties, meta = {}) {
13475
13481
  mixpanelService.track(eventName, properties);
13476
13482
  } catch (error) {
13477
13483
  console.error(`Error tracking event '${eventName}':`, error);
13484
+ trackEventError(eventName, error);
13478
13485
  }
13479
13486
  }
13480
13487
  function extractTrackingParams() {
@@ -13499,7 +13506,7 @@ function trackCustomEvent(eventName, eventData = {}, meta = {}) {
13499
13506
  trackEvent(eventName, eventData, meta);
13500
13507
  } catch (error) {
13501
13508
  console.error("Error trackCustomEvent:", error);
13502
- return;
13509
+ trackEventError(eventName, error);
13503
13510
  }
13504
13511
  }
13505
13512
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
@@ -16070,6 +16077,7 @@ async function identify(userId, properties = {}) {
16070
16077
  }
16071
16078
  } catch (error) {
16072
16079
  console.error("Error identifying user", error);
16080
+ trackEventError("Identify", error);
16073
16081
  }
16074
16082
  }
16075
16083
  const origin = window.location.origin;