@reservamos/browser-analytics 1.0.11 → 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.11";
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) => {
@@ -14010,12 +14010,21 @@ function trackCustomEvent(eventName, eventData = {}, meta = {}) {
14010
14010
  trackEventError(eventName, error, eventData);
14011
14011
  }
14012
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
+ }
14013
14020
  const CreateAnonymousProfileSchema = z.object({
14014
14021
  email: z.string().email().optional(),
14015
14022
  phone: z.string().optional(),
14016
14023
  cpf: z.string().optional(),
14017
14024
  passport: z.string().optional(),
14018
- rg: z.string().optional()
14025
+ rg: z.string().optional(),
14026
+ firstName: z.string().optional(),
14027
+ lastName: z.string().optional()
14019
14028
  }).refine((data) => data.email || data.phone, {
14020
14029
  message: "At least one of 'email' or 'phone' must be provided"
14021
14030
  });
@@ -14023,6 +14032,7 @@ function getAnonymousProfilePayload(values, identifiersProps) {
14023
14032
  let identifier_key = "phone";
14024
14033
  let identifier_value = values.phone || "";
14025
14034
  const identifiers = [];
14035
+ const details = {};
14026
14036
  if (values.email) {
14027
14037
  identifier_key = "email";
14028
14038
  identifier_value = values.email;
@@ -14035,11 +14045,15 @@ function getAnonymousProfilePayload(values, identifiersProps) {
14035
14045
  "phone",
14036
14046
  "salesforceid"
14037
14047
  ];
14048
+ const allowedKeysDetails = ["name", "firstName", "lastName"];
14038
14049
  Object.entries(values).forEach(([key, value]) => {
14039
- if (allowedKeys.includes(key.toLowerCase()) && value) {
14050
+ key = isCamelCase(key) ? key : key.toLocaleLowerCase();
14051
+ if (allowedKeys.includes(key) && value) {
14040
14052
  if (key !== identifier_key) {
14041
14053
  identifiers.push({ key, value });
14042
14054
  }
14055
+ } else if (allowedKeysDetails.includes(key) && value) {
14056
+ details[key] = value;
14043
14057
  }
14044
14058
  });
14045
14059
  if (identifiersProps.length) {
@@ -14048,7 +14062,7 @@ function getAnonymousProfilePayload(values, identifiersProps) {
14048
14062
  return {
14049
14063
  identifier_key,
14050
14064
  identifier_value,
14051
- details: {},
14065
+ details,
14052
14066
  identifiers
14053
14067
  };
14054
14068
  }