@reservamos/browser-analytics 1.1.2-alpha.0 → 1.1.2

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.
@@ -13395,7 +13395,7 @@ function loadNoop(_src, onload) {
13395
13395
  onload();
13396
13396
  }
13397
13397
  var mixpanel = init_as_module(loadNoop);
13398
- const version = "1.1.2-alpha.0";
13398
+ const version = "1.1.2";
13399
13399
  const MIXPANEL_DISTINCT_ID_CACHE_KEY = "mp_distinct_id";
13400
13400
  const EVENT_SOURCE_SUPER_PROPERTY = {
13401
13401
  "Event Source": "sdk"
@@ -13849,6 +13849,7 @@ function isTrackerReady() {
13849
13849
  return mixpanelService.isReady();
13850
13850
  }
13851
13851
  let currentCoordinates = null;
13852
+ let currentSource = null;
13852
13853
  const GEOLOCATION_PERMISSION_KEY = "geolocationPermissionTimestamp";
13853
13854
  const GEOLOCATION_CACHE_KEY = "geolocationCache";
13854
13855
  const GEOLOCATION_TRACK_EVENT = "Geolocation Requested";
@@ -13915,6 +13916,7 @@ function restoreCoordinatesFromStorage() {
13915
13916
  const cache = loadCoordinatesFromStorage();
13916
13917
  if (cache) {
13917
13918
  currentCoordinates = { lat: cache.lat, long: cache.long };
13919
+ currentSource = "browser";
13918
13920
  }
13919
13921
  }
13920
13922
  function isPermissionTimestampValid(lastPermissionTimestamp) {
@@ -13951,6 +13953,9 @@ function buildGeolocationEventProperties(data) {
13951
13953
  properties.latitude = data.lat;
13952
13954
  properties.longitude = data.long;
13953
13955
  }
13956
+ if (data.source !== void 0) {
13957
+ properties.geolocation_source = data.source;
13958
+ }
13954
13959
  return properties;
13955
13960
  }
13956
13961
  function buildGeolocationProfileProperties(data) {
@@ -13962,6 +13967,9 @@ function buildGeolocationProfileProperties(data) {
13962
13967
  properties.latitude = data.lat;
13963
13968
  properties.longitude = data.long;
13964
13969
  }
13970
+ if (data.source !== void 0) {
13971
+ properties.geolocation_source = data.source;
13972
+ }
13965
13973
  return properties;
13966
13974
  }
13967
13975
  function syncGeolocationToMixpanel(data) {
@@ -13987,7 +13995,8 @@ function init() {
13987
13995
  updatedAt: cache.updatedAt,
13988
13996
  lat: cache.lat,
13989
13997
  long: cache.long,
13990
- accuracy: cache.accuracy
13998
+ accuracy: cache.accuracy,
13999
+ source: "browser"
13991
14000
  });
13992
14001
  resolve(currentCoordinates);
13993
14002
  return;
@@ -14004,6 +14013,7 @@ function init() {
14004
14013
  (geolocation) => {
14005
14014
  const { latitude: lat, longitude: long, accuracy } = geolocation.coords;
14006
14015
  currentCoordinates = { lat, long };
14016
+ currentSource = "browser";
14007
14017
  saveCoordinatesToStorage(currentCoordinates, updatedAt, accuracy);
14008
14018
  updatePermissionTimestamp(now);
14009
14019
  syncGeolocationToMixpanel({
@@ -14011,7 +14021,8 @@ function init() {
14011
14021
  updatedAt,
14012
14022
  lat,
14013
14023
  long,
14014
- accuracy
14024
+ accuracy,
14025
+ source: "browser"
14015
14026
  });
14016
14027
  resolve(currentCoordinates);
14017
14028
  },
@@ -14031,9 +14042,13 @@ function init() {
14031
14042
  function getCoordinates() {
14032
14043
  return currentCoordinates;
14033
14044
  }
14045
+ function getGeolocationSource() {
14046
+ return currentSource;
14047
+ }
14034
14048
  const geolocationService = {
14035
14049
  init,
14036
- getCoordinates
14050
+ getCoordinates,
14051
+ getGeolocationSource
14037
14052
  };
14038
14053
  const FP_TRIGGER_EVENTS = ["Search", "View Results"];
14039
14054
  const EXTRA_UTM_FIELDS = {
@@ -14104,10 +14119,14 @@ async function trackEvent(eventName, eventProperties, meta = {}) {
14104
14119
  const fingerprint = await fingerprintService.getFingerprint(cacheOnly);
14105
14120
  const defaultCoordinates = {};
14106
14121
  const coordinates = geolocationService.getCoordinates();
14122
+ const geolocationSource = geolocationService.getGeolocationSource();
14107
14123
  if (coordinates) {
14108
14124
  defaultCoordinates.latitude = coordinates.lat;
14109
14125
  defaultCoordinates.longitude = coordinates.long;
14110
14126
  }
14127
+ if (geolocationSource) {
14128
+ defaultCoordinates.geolocation_source = geolocationSource;
14129
+ }
14111
14130
  const defaultProperties = {
14112
14131
  "User Fingerprint": fingerprint
14113
14132
  };