1import { d as w, f as x, g as A, p as F, y as U } from "./chunk-xgti9j2t.js"; 2import { Ai as G, Bi as W, G as j, Kn as L, No as f, Nr as V, Pi as z, Ro as b, _r as H, fi as u, fo as q, gt as n, in as X, kt as J, l as K, la as Y, ni as Z, nt as E, oo as Q, pa as tt, ta as it, wr as ot, z as et } from "./chunk-c97c17u8.js"; 3import { M as nt } from "./chunk-l3jkbhly.js"; 4import { a as st, p as at } from "./chunk-k52vj1ic.js"; 5import { o as rt } from "./chunk-l24fzhmb.js"; 6import { A as ct } from "./chunk-jrtaqqwj.js"; 7import { o as lt, t as v } from "./chunk-pesy0vb6.js"; 8import { D as ht, a as ut, f as I, o as pt } from "./chunk-llc8ry2a.js"; 9import { D as dt, i as gt, j as mt, ut as ft } from "./chunk-fbjoug0d.js"; 10import { a as vt } from "./chunk-ewplex8i.js"; 11import { n as Ct } from "./chunk-c18gpzrj.js"; 12import { r as _t } from "./chunk-c9rg1mp5.js"; 13import { t as Pt } from "./chunk-kyqvtgtk.js"; 14import { N, X as kt, Y as St, b as yt, ft as wt, gt as At, l as T, mt as Gt, pt as C, w as l, y as Lt, z as O } from "./chunk-w0x32net.js"; 15import { d as bt, h as Et, p as It } from "./chunk-bhnvkbxx.js"; 16import { ot as Nt } from "./chunk-f2v2cgea.js"; 17import { a as Tt, c as Ot, s as Dt, t as Rt } from "./chunk-og5uebri.js"; 18import { Cr as $t, Dn as Bt, Rn as Mt, Tt as xt, Wn as Ft, en as Ut, jr as Wt, or as jt, pt as Vt } from "./chunk-go6pvd0a.js"; 19import { n as zt, t as Ht } from "./chunk-k4et3zlq.js"; 20import { i as qt, p as Xt } from "./chunk-hul0ult7.js"; 21import { n as Jt } from "./chunk-lmnwxprc.js"; 22import { n as Kt, r as Yt, t as Zt } from "./chunk-ilfhy0in.js"; 23import { n as Qt } from "./chunk-ohg30iel.js"; 24import { $ as ti } from "./chunk-iuhjzybw.js"; 25import { t as ii } from "./chunk-o4f8w5yc.js"; 26function oi(t) { 27 return t.get(p); 28} 29function D(t) { 30 return { 31 latitude: t.latitude, 32 longitude: t.longitude, 33 altitude: t.altitude, 34 accuracy: t.accuracy, 35 altitudeAccuracy: t.altitudeAccuracy, 36 heading: t.heading, 37 speed: t.speed 38 }; 39} 40function ei(t) { 41 return { 42 code: t.code, 43 message: t.message, 44 PERMISSION_DENIED: t.PERMISSION_DENIED, 45 POSITION_UNAVAILABLE: t.POSITION_UNAVAILABLE, 46 TIMEOUT: t.TIMEOUT 47 }; 48} 49function ni() { 50 return [ 51 _, 52 k, 53 d, 54 P, 55 S, 56 { 57 provide: p, 58 useFactory: oi, 59 deps: [Zt] 60 }, 61 xt(R), 62 wt($), 63 Mt(B) 64 ]; 65} 66var p, _, P, k, h, d, R, S, y, $, B; 67function M() { 68 return (M = ii((() => { 69 U(), z(), nt(), at(), rt(), ct(), lt(), ht(), ft(), vt(), Ct(), _t(), Pt(), pt(), At(), It(), Nt(), St(), Ot(), Wt(), Ht(), Xt(), qt(), Jt(), Yt(), Qt(), ti(), Bt(), Y(), p = (() => { 70 var t = class extends Kt {}; 71 let s = (t.ɵfac = (() => { 72 let i; 73 return function(o) { 74 return (i || (i = G(t)))(o || t); 75 }; 76 })(), t.ɵprov = u({ 77 token: t, 78 factory: t.ɵfac 79 }), t); 80 return s = ot([zt({ 81 key: "vnGeolocation", 82 product: mt.SF 83 })], s), s; 84 })(), _ = (() => { 85 var t; 86 let s = class { 87 constructor() { 88 x(this, t), this.config = n(p), F(this, t, n(dt)); 89 } 90 get positionChanges() { 91 if (this.isSyntheticAgent()) return et; 92 if (!this.changesSubject) { 93 this.changesSubject = new j(); 94 let o = this.geolocationApi.watchPosition((r) => this.onPositionChanged(r), (r) => this.onPositionFailed(r, o), this.config.watchOptions); 95 } 96 return this.changesSubject; 97 } 98 isSyntheticAgent() { 99 let o = w(this, t)?.navigator?.userAgent ?? ""; 100 return o.endsWith("DatadogSynthetics") || o.endsWith("Frontend-Automation"); 101 } 102 onPositionChanged(o) { 103 this.changesSubject.next({ 104 timestamp: o.timestamp, 105 coords: D(o.coords) 106 }); 107 } 108 onPositionFailed(o, r) { 109 o.code === o.PERMISSION_DENIED && this.geolocationApi.clearWatch(r), this.changesSubject.error(ei(o)); 110 } 111 get geolocationApi() { 112 return w(this, t).navigator.geolocation; 113 } 114 }; 115 return t = /* @__PURE__ */ new WeakMap(), s.ɵfac = function(i) { 116 return new (i || s)(); 117 }, s.ɵprov = u({ 118 token: s, 119 factory: s.ɵfac 120 }), s; 121 })(), P = (() => { 122 let t = class { 123 constructor() { 124 this.config = n(p), this.cookieService = n(N), this.dateTimeService = n(Ut); 125 } 126 read() { 127 let i = this.cookieService.get(l.GeoLocation)?.trim(); 128 return i ? JSON.parse(i) : null; 129 } 130 write(i) { 131 let o = this.calculateExpiration(); 132 this.cookieService.putObject(l.GeoLocation, i, o ? { expires: o } : void 0); 133 } 134 delete() { 135 this.cookieService.remove(l.GeoLocation); 136 } 137 calculateExpiration() { 138 if (!this.config.cookieExpirationMilliseconds) return;
139 let i = this.dateTimeService.now(); 140 return i.setTime(i.getTime() + this.config.cookieExpirationMilliseconds), i; 141 } 142 }; 143 return t.ɵfac = function(s) { 144 return new (s || t)(); 145 }, t.ɵprov = u({ 146 token: t, 147 factory: t.ɵfac 148 }), t; 149 })(), k = (() => { 150 let t = class { 151 constructor() { 152 this.api = n(yt), this.config = n(p), this.urlService = n(ut), this.httpClient = n(st), this.logger = n(C), this.platform = n(I); 153 } 154 mapGeolocation(i) { 155 let o = this.api.get("mappedgeolocation", i), r = f({}); 156 if (this.config.clientApiUrl && this.platform.isBrowser) { 157 let a = this.urlService.parse(this.config.clientApiUrl); 158 a.search.append("latitude", i.latitude.toString()), a.search.append("longitude", i.longitude.toString()), r = this.httpClient.get(a.absUrl()).pipe(tt(2)); 159 } 160 return q([o, r]).pipe(L((a) => { 161 let c = { 162 locationId: null, 163 locationName: null, 164 city: null, 165 state: null, 166 zip: null, 167 country: null, 168 locationNameClient: null, 169 cityClient: null, 170 countryClient: null, 171 postCodeClient: null, 172 stateClient: null 173 }; 174 return a[0].location && (c.locationId = a[0].location.locationId, c.locationName = a[0].location.locationName, c.city = a[0].location.city, c.state = a[0].location.state, c.zip = a[0].location.zip, c.country = a[0].location.country), a[1] && (c.locationNameClient = a[1].locality, c.cityClient = a[1].city, c.countryClient = a[1].countryName, c.postCodeClient = a[1].postcode, c.stateClient = a[1].principalSubdivision), c; 175 }), W({ error: (a) => { 176 this.logger.errorRemote("VanillaGeolocation failed mapping api response.", a); 177 } })); 178 } 179 }; 180 return t.ɵfac = function(s) { 181 return new (s || t)(); 182 }, t.ɵprov = u({ 183 token: t, 184 factory: t.ɵfac 185 }), t; 186 })(), h = "VanillaGeolocation", d = (() => { 187 let t = class { 188 constructor() { 189 this.config = n(p), this.browserApi = n(_), this.cookie = n(P), this.resource = n(k), this.log = n(C), this.timer = n(Lt), this.nativeApp = n(O), this.lastPosition = null, this.positionSubject = new Q(1), this.isWatchBrowserPositionChangesStarted = !1; 190 } 191 get currentPosition() { 192 return this.lastPosition; 193 } 194 get positionChanges() { 195 return this.positionSubject; 196 } 197 watchBrowserPositionChanges() { 198 this.config.useBrowserGeolocation && !this.isWatchBrowserPositionChangesStarted && (this.isWatchBrowserPositionChangesStarted = !0, this.watchPositionChanges()); 199 } 200 watchNativePositionChanges() { 201 this.nativeApp.isNative && (this.nativeApp.eventsFromNative.pipe(b((i) => i.eventName?.toUpperCase() === T.GEO_LOCATION_POSITION)).subscribe((i) => { 202 let o = i.parameters || {}, r = { 203 timestamp: Math.floor(o.time * 1e3), 204 coords: D(o) 205 }; 206 this.isLastPositionEqualToNewPosition(r) || this.mapGeolocation(r); 207 }), this.nativeApp.sendToNative({ eventName: T.GET_GEO_LOCATION_POSITION })); 208 } 209 restoreLastPositionFromCookie() { 210 this.lastPosition = this.cookie.read(), this.lastPosition && (this.positionSubject.next(this.lastPosition), this.log.debug("VanillaGeolocation restored this position from the cookie
210:", this.lastPosition)); 211 } 212 clearPositionForGood() { 213 this.lastPosition = null, this.cookie.delete(); 214 } 215 watchPositionChanges() { 216 this.browserApi.positionChanges.subscribe({ 217 next: (i) => this.onPositionChanged(i), 218 error: (i) => this.onPositionError(i) 219 }); 220 } 221 onPositionChanged(i) { 222 if (this.isLastPositionEqualToNewPosition(i)) return; 223 let o = Math.max(0, this.config.minimumUpdateIntervalMilliseconds - (i.timestamp - (this.lastPosition?.timestamp ?? 0))); 224 this.log.debug(`${h} received new coordinates at time ${i.timestamp}. Mapping them to a location on backend in ${o} milliseconds. New coordinates:`, i.coords), this.timer.clearTimeout(this.timeoutId), this.timeoutId = this.timer.setTimeout(() => this.mapGeolocation(i), o); 225 } 226 mapGeolocation(i) { 227 this.log.infoRemote(`${h} mapping new coordinates.`), this.resource.mapGeolocation(i.coords).subscribe({ 228 next: (o) => { 229 this.log.debug(`${h} mapped new coordinates to following location. Writing it all to '${l.GeoLocation}' cookie.`, o), this.log.infoRemote(`${h} mapped new coordinates to '${l.GeoLocation}' cookie. StateClient:${o?.stateClient}, CountryClient:${o?.countryClient}, Country:${o?.country}`), this.setLastPosition(i, o); 230 }, 231 error: (o) => { 232 this.log.errorRemote(`${h} failed mapping new coordinates. Using them with null mapped location. Writing it all to '${l.GeoLocation}' cookie. Error:`, o), this.setLastPosition(i, null); 233 } 234 }); 235 } 236 onPositionError(i) { 237 i.code === i.PERMISSION_DENIED ? (this.log.debug(`${h} is disabled by user in the browser.`), this.clearPositionForGood()) : this.log.warn(`${h} failed to watch the position. Using the last one and watch continues. Error:`, i), this.positionSubject.error(i); 238 } 239 isLastPositionEqualToNewPosition(i) { 240 return this.lastPosition && gt(i.coords, this.lastPosition.coords) ? (this.log.debug(`${h} received same coordinates as the last position has. Only updating timestamp to ${i.timestamp}. Writing it all to '${l.GeoLocation}' cookie. Last position:`, this.lastPosition), this.setLastPosition(i, this.lastPosition.mappedLocation, { publishEvent: !1 }), !0) : !1; 241 } 242 setLastPosition(i, o, r) { 243 this.lastPosition = { 244 coords: i.coords, 245 timestamp: i.timestamp, 246 mappedLocation: o 247 }, this.cookie.write(this.lastPosition), (!r || r.publishEvent) && (this.log.infoRemote("VanillaGeolocation sending position changed event."), this.positionSubject.next(this.lastPosition)); 248 } 249 }; 250 return t.ɵfac = function(s) { 251 return new (s || t)(); 252 }, t.ɵprov = u({ 253 token: t, 254 factory: t.ɵfac, 255 providedIn: "root" 256 }), t; 257 })(), R = (() => { 258 let t = class { 259 constructor() { 260 this.config = n(p), this.geolocationService = n(d), this.coreGeolocationService = n(Rt), this.user = n(bt), this.trackingService = n(Tt), this.nativeAppService = n(O), this.cookieService = n(N); 261 } 262 onFeatureInit() { 263 return A(this, null, function* () { 264 yield E(this.config.whenReady), this.geolocationService.clearPositionForGood(), this.config.watchBrowserPositionOnAppStart && this.geolocationService.watchBrowserPositionChanges(), this.geolocationService.restoreLastPositionFromCookie(), this.geolocationService.watchNativePositionChanges(), this.coreGeolocationService.set(this.geolocationService), this.trackGeolocationEventAfterLogin(); 265 }); 266 } 267 trackGeolocationEventAfterLogin() { 268 this.geolocationService.positionChanges.pipe(X(), it((i, o) => this.user.isAuthenticated ? f({ 269 geolocation: i, 270 index: o 271 }) : (this.cookieService.remove(l.VnGeolocationTracking), this.user.events.pipe(b((r) => r instanceof Et), L(() => ({ 272 geolocation: i, 273 index: o 274 }))))), H(({ geolocation: i, index: o }) => f({ 275 geolocation: i, 276 index: o + 1 277 }).pipe(J(500))), Z(3)).subscribe(({ geolocation: i, index: o }) => { 278 !this.cookieService.get(l.VnGeolocationTracking) && this.user.workflowType == 0 && this.sendToGA(i), o == 2 && this.cookieService.put(l.VnGeolocationTracking, "1"); 279 }); 280 } 281 sendToGA(i) { 282 this.trackingService.triggerEvent(Dt.Geolocation, { 283 "user.profile.accountID": this.user.accountId, 284 "native.nativeMode": this.nativeAppService.nativeMode, 285 GEO_LATITUDE: i.coords.latitude, 286 GEO_LONGITUDE: i.coords.longitude, 287 GEO_ALTITUDE: i.coords.altitude, 288 GEO_ACCURACY: i.coords.accuracy, 289 GEO_ALT_ACCURACY: i.coords.altitudeAccuracy, 290 GEO_HEADING: i.coords.heading, 291 GEO_SPEED: i.coords.speed 292 }); 293 } 294 }; 295 return t.ɵfac = function(s) { 296 return new (s || t)(); 297 }, t.ɵprov = u({ 298 token: t, 299 factory: t.ɵfac 300 }), t; 301 })(), S = (() => { 302 let t = class { 303 constructor() { 304 this.geolocationService = n(d), this.geolocationService.positionChanges.pipe(v()).subscribe((i) => this.currentPosition = i); 305 } 306 getPosition(i) { 307 let o = this.currentPosition; 308 if (!o) throw new Error("Currently there is no position resolved by browser so its properties cannot't be accessed. Returning zero would be misleading as far as it's a valid value. Check HasPosition first."); 309 return i(o) || 0; 310 } 311 getLocation(i) { 312 let o = this.currentPosition?.mappedLocation; 313 return o && i(o) || ""; 314 } 315 hasPosition() { 316 return !!this.currentPosition; 317 } 318 }; 319 return t.ɵfac = function(s) { 320 return new (s || t)(); 321 }, t.ɵprov = u({ 322 token: t, 323 factory: t.ɵfac 324 }), t; 325 })(), y = ["geolocation"], $ = (() => { 326 let t = class { 327 constructor() { 328 this.dslRecorderService = n(Gt), this.dslTimeConverter = n(Ft), this.geolocationService = n(d), this.geolocationDslResolver = n(S); 329 let i = n(kt); 330 this.geolocationService.positionChanges.pipe(v()).subscribe(() => i.invalidate(y)); 331 } 332 getProviders() { 333 let i = this.dslRecorderService.createRecordable("geolocation"), o = this.geolocationDslResolver; 334 return c("HasPosition", () => o.hasPosition()), r("Timestamp", (e) => this.dslTimeConverter.fromTimeToDsl(new Vt(e.timestamp, $t.ZERO))), r("Latitude", (e) => e.coords.latitude), r("Longitude", (e) => e.coords.longitude), r("Altitude", (e) => e.coords.altitude), r("Accuracy", (e) => e.coords.accuracy), r("AltitudeAccuracy", (e) => e.coords.altitudeAccuracy), r("Heading", (e) => e.coords.heading), r("Speed", (e) => e.coords.speed), a("LocationId", (e) => e.locationId), a("LocationName", (e) => e.locationName), a("City", (e) => e.city), a("State", (e) => e.state), a("Zip", (e) => e.zip), a("Country", (e) => e.country), a("LocationNameClient", (e) => e.locationNameClient), a("CityClient", (e) => e.cityClient), a("StateClient", (e) =>
334 e.stateClient), a("PostCodeClient", (e) => e.postCodeClient), a("CountryClient", (e) => e.countryClient), { Geolocation: i }; 335 function r(e, g) { 336 c(e, () => o.getPosition((m) => g(m))); 337 } 338 function a(e, g) { 339 c(e, () => o.getLocation((m) => g(m))); 340 } 341 function c(e, g) { 342 i.createProperty({ 343 name: e, 344 get: g, 345 deps: y 346 }); 347 } 348 } 349 }; 350 return t.ɵfac = function(s) { 351 return new (s || t)(); 352 }, t.ɵprov = u({ 353 token: t, 354 factory: t.ɵfac 355 }), t; 356 })(), B = (() => { 357 let t = class extends jt { 358 constructor() { 359 super(...arguments), this.geolocationService = n(d), this.log = n(C), this.platform = n(I), this.destroyRef = n(K); 360 } 361 getLazyContext() { 362 return A(this, null, function* () { 363 let i = this.platform.isBrowser ? 1e4 : 0; 364 return yield E(this.geolocationService.positionChanges.pipe(V(i), v(this.destroyRef))).catch(() => (this.log.warn("positionChanges failed of timed out in GeolocationContextProvider."), {})), { 365 kind: "multi", 366 state: this.geolocationService.currentPosition?.mappedLocation?.stateClient ? { key: this.geolocationService.currentPosition?.mappedLocation.stateClient } : void 0, 367 country: this.geolocationService.currentPosition?.mappedLocation?.countryClient ? { key: this.geolocationService.currentPosition?.mappedLocation.countryClient } : void 0 368 }; 369 }); 370 } 371 }; 372 return t.ɵfac = (() => { 373 let s; 374 return function(i) { 375 return (s || (s = G(t)))(i || t); 376 }; 377 })(), t.ɵprov = u({ 378 token: t, 379 factory: t.ɵfac 380 }), t; 381 })(); 382 })))(); 383} 384M(); 385export { d as GeolocationService, h as LOG_PREFIX, ni as provide }; 386 387//# sourceMappingURL=chunk-b5xaszcg.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.