@reservamos/browser-analytics 1.0.10 → 1.0.12

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.
@@ -954,27 +954,37 @@ declare const CreateAnonymousProfileSchema: z.ZodEffects<z.ZodObject<{
954
954
  cpf: z.ZodOptional<z.ZodString>;
955
955
  passport: z.ZodOptional<z.ZodString>;
956
956
  rg: z.ZodOptional<z.ZodString>;
957
+ firstName: z.ZodOptional<z.ZodString>;
958
+ lastName: z.ZodOptional<z.ZodString>;
957
959
  }, "strip", z.ZodTypeAny, {
958
960
  email?: string | undefined;
959
961
  phone?: string | undefined;
962
+ firstName?: string | undefined;
963
+ lastName?: string | undefined;
960
964
  cpf?: string | undefined;
961
965
  passport?: string | undefined;
962
966
  rg?: string | undefined;
963
967
  }, {
964
968
  email?: string | undefined;
965
969
  phone?: string | undefined;
970
+ firstName?: string | undefined;
971
+ lastName?: string | undefined;
966
972
  cpf?: string | undefined;
967
973
  passport?: string | undefined;
968
974
  rg?: string | undefined;
969
975
  }>, {
970
976
  email?: string | undefined;
971
977
  phone?: string | undefined;
978
+ firstName?: string | undefined;
979
+ lastName?: string | undefined;
972
980
  cpf?: string | undefined;
973
981
  passport?: string | undefined;
974
982
  rg?: string | undefined;
975
983
  }, {
976
984
  email?: string | undefined;
977
985
  phone?: string | undefined;
986
+ firstName?: string | undefined;
987
+ lastName?: string | undefined;
978
988
  cpf?: string | undefined;
979
989
  passport?: string | undefined;
980
990
  rg?: string | undefined;
@@ -13409,7 +13409,7 @@ function loadNoop(_src, onload) {
13409
13409
  onload();
13410
13410
  }
13411
13411
  var mixpanel = init_as_module(loadNoop);
13412
- const version = "1.0.10";
13412
+ const version = "1.0.12";
13413
13413
  const MIXPANEL_DISTINCT_ID_CACHE_KEY = "mp_distinct_id";
13414
13414
  function init$2(mixpanelToken, debug = false, proxyUrl) {
13415
13415
  return new Promise((resolve) => {
@@ -13959,6 +13959,7 @@ async function trackEvent(eventName, eventProperties, meta = {}) {
13959
13959
  try {
13960
13960
  validatorService.parseEventProps(eventName, eventProperties);
13961
13961
  const cacheOnly = !FP_TRIGGER_EVENTS.includes(eventName);
13962
+ mixpanelService.getMixpanelDistinctId();
13962
13963
  const fingerprint = await fingerprintService.getFingerprint(cacheOnly);
13963
13964
  const defaultCoordinates = {};
13964
13965
  const coordinates = geolocationService.getCoordinates();
@@ -14009,12 +14010,21 @@ function trackCustomEvent(eventName, eventData = {}, meta = {}) {
14009
14010
  trackEventError(eventName, error, eventData);
14010
14011
  }
14011
14012
  }
14013
+ function isCamelCase(word) {
14014
+ if (!word || word.includes(" ")) return false;
14015
+ if (word[0] !== word[0].toLowerCase()) return false;
14016
+ if (/[^a-zA-Z]/.test(word)) return false;
14017
+ if (!/[A-Z]/.test(word)) return false;
14018
+ return true;
14019
+ }
14012
14020
  const CreateAnonymousProfileSchema = z.object({
14013
14021
  email: z.string().email().optional(),
14014
14022
  phone: z.string().optional(),
14015
14023
  cpf: z.string().optional(),
14016
14024
  passport: z.string().optional(),
14017
- rg: z.string().optional()
14025
+ rg: z.string().optional(),
14026
+ firstName: z.string().optional(),
14027
+ lastName: z.string().optional()
14018
14028
  }).refine((data) => data.email || data.phone, {
14019
14029
  message: "At least one of 'email' or 'phone' must be provided"
14020
14030
  });
@@ -14022,6 +14032,7 @@ function getAnonymousProfilePayload(values, identifiersProps) {
14022
14032
  let identifier_key = "phone";
14023
14033
  let identifier_value = values.phone || "";
14024
14034
  const identifiers = [];
14035
+ const details = {};
14025
14036
  if (values.email) {
14026
14037
  identifier_key = "email";
14027
14038
  identifier_value = values.email;
@@ -14034,11 +14045,15 @@ function getAnonymousProfilePayload(values, identifiersProps) {
14034
14045
  "phone",
14035
14046
  "salesforceid"
14036
14047
  ];
14048
+ const allowedKeysDetails = ["name", "firstName", "lastName"];
14037
14049
  Object.entries(values).forEach(([key, value]) => {
14038
- if (allowedKeys.includes(key.toLowerCase()) && value) {
14050
+ key = isCamelCase(key) ? key : key.toLocaleLowerCase();
14051
+ if (allowedKeys.includes(key) && value) {
14039
14052
  if (key !== identifier_key) {
14040
14053
  identifiers.push({ key, value });
14041
14054
  }
14055
+ } else if (allowedKeysDetails.includes(key) && value) {
14056
+ details[key] = value;
14042
14057
  }
14043
14058
  });
14044
14059
  if (identifiersProps.length) {
@@ -14047,7 +14062,7 @@ function getAnonymousProfilePayload(values, identifiersProps) {
14047
14062
  return {
14048
14063
  identifier_key,
14049
14064
  identifier_value,
14050
- details: {},
14065
+ details,
14051
14066
  identifiers
14052
14067
  };
14053
14068
  }