o11y 266.16.0 → 266.18.0

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.
@@ -21,7 +21,9 @@ declare class Utility {
21
21
  generateUniqueId(length?: number): string;
22
22
  getXpath(_element: HTMLElement): string;
23
23
  getAge(timestamp: number): number;
24
- getConnectionType(): string;
24
+ private _getNavigatorSafe;
25
+ private _hasEffectiveConnectionType;
26
+ getConnectionType(): string | undefined;
25
27
  clone<T>(value: T): T;
26
28
  definedValueOrDefault<T>(value: T, defaultValue: T): T;
27
29
  getGlobal(): typeof globalThis;
@@ -21,7 +21,9 @@ declare class Utility {
21
21
  generateUniqueId(length?: number): string;
22
22
  getXpath(_element: HTMLElement): string;
23
23
  getAge(timestamp: number): number;
24
- getConnectionType(): string;
24
+ private _getNavigatorSafe;
25
+ private _hasEffectiveConnectionType;
26
+ getConnectionType(): string | undefined;
25
27
  clone<T>(value: T): T;
26
28
  definedValueOrDefault<T>(value: T, defaultValue: T): T;
27
29
  getGlobal(): typeof globalThis;
@@ -21,7 +21,9 @@ declare class Utility {
21
21
  generateUniqueId(length?: number): string;
22
22
  getXpath(_element: HTMLElement): string;
23
23
  getAge(timestamp: number): number;
24
- getConnectionType(): string;
24
+ private _getNavigatorSafe;
25
+ private _hasEffectiveConnectionType;
26
+ getConnectionType(): string | undefined;
25
27
  clone<T>(value: T): T;
26
28
  definedValueOrDefault<T>(value: T, defaultValue: T): T;
27
29
  getGlobal(): typeof globalThis;
@@ -21,7 +21,9 @@ declare class Utility {
21
21
  generateUniqueId(length?: number): string;
22
22
  getXpath(_element: HTMLElement): string;
23
23
  getAge(timestamp: number): number;
24
- getConnectionType(): string;
24
+ private _getNavigatorSafe;
25
+ private _hasEffectiveConnectionType;
26
+ getConnectionType(): string | undefined;
25
27
  clone<T>(value: T): T;
26
28
  definedValueOrDefault<T>(value: T, defaultValue: T): T;
27
29
  getGlobal(): typeof globalThis;
@@ -273,14 +273,27 @@ class Utility {
273
273
  getAge(timestamp) {
274
274
  return timestamp - this._timeOrigin;
275
275
  }
276
- getConnectionType() {
277
- var _a;
278
- let connectionType;
279
- if (typeof navigator !== 'undefined') {
280
- const expNav = navigator;
281
- connectionType = (_a = expNav === null || expNav === void 0 ? void 0 : expNav.connection) === null || _a === void 0 ? void 0 : _a.effectiveType;
276
+ _getNavigatorSafe() {
277
+ try {
278
+ return typeof navigator !== 'undefined' ? navigator : undefined;
279
+ }
280
+ catch (_a) {
281
+ return undefined;
282
282
  }
283
- return connectionType;
283
+ }
284
+ _hasEffectiveConnectionType(value) {
285
+ if (typeof value !== 'object' || value === null || !('connection' in value)) {
286
+ return false;
287
+ }
288
+ const connection = value.connection;
289
+ return (typeof connection === 'object' &&
290
+ connection !== null &&
291
+ 'effectiveType' in connection &&
292
+ typeof connection.effectiveType === 'string');
293
+ }
294
+ getConnectionType() {
295
+ const nav = this._getNavigatorSafe();
296
+ return this._hasEffectiveConnectionType(nav) ? nav.connection.effectiveType : undefined;
284
297
  }
285
298
  clone(value) {
286
299
  return JSON.parse(JSON.stringify(value));
@@ -298,9 +311,9 @@ class Utility {
298
311
  throw new Error('Unable to locate globalThis or self');
299
312
  }
300
313
  getIsBeaconSupported() {
301
- var _a;
302
314
  const g = this.getGlobal();
303
- return typeof ((_a = g.navigator) === null || _a === void 0 ? void 0 : _a.sendBeacon) === 'function' && typeof g.Blob === 'function';
315
+ const nav = this._getNavigatorSafe();
316
+ return typeof (nav === null || nav === void 0 ? void 0 : nav.sendBeacon) === 'function' && typeof g.Blob === 'function';
304
317
  }
305
318
  estimateObjectSize(object) {
306
319
  const objectSet = new Set();