@guardian/commercial-core 5.2.1 → 5.3.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.
@@ -28,6 +28,7 @@ interface EventTimerProperties {
28
28
  type?: ConnectionType;
29
29
  downlink?: number;
30
30
  effectiveType?: string;
31
+ offlineCount?: number;
31
32
  adSlotsInline?: number;
32
33
  adSlotsTotal?: number;
33
34
  pageHeightVH?: number;
@@ -93,20 +93,15 @@ class EventTimer {
93
93
  },
94
94
  ],
95
95
  };
96
- this.properties =
97
- 'connection' in window.navigator
98
- ? {
99
- type: 'type' in window.navigator.connection
100
- ? window.navigator.connection.type
101
- : undefined,
102
- downlink: 'downlink' in window.navigator.connection
103
- ? window.navigator.connection.downlink
104
- : undefined,
105
- effectiveType: 'effectiveType' in window.navigator.connection
106
- ? window.navigator.connection.effectiveType
107
- : undefined,
108
- }
109
- : {};
96
+ this.properties = {
97
+ offlineCount: window.guardian.offlineCount,
98
+ };
99
+ if (window.navigator.connection) {
100
+ this.properties.type = window.navigator.connection.type;
101
+ this.properties.downlink = window.navigator.connection.downlink;
102
+ this.properties.effectiveType =
103
+ window.navigator.connection.effectiveType;
104
+ }
110
105
  }
111
106
  /**
112
107
  * Adds an event timer property
@@ -3,7 +3,7 @@ import type { GoogleTagParams, GoogleTrackConversionObject, GuardianWindowConfig
3
3
  import type { EventTimer } from '.';
4
4
  declare global {
5
5
  interface Navigator {
6
- readonly connection: NetworkInformation;
6
+ readonly connection?: NetworkInformation;
7
7
  }
8
8
  interface Window {
9
9
  google_trackConversion?: (arg0: GoogleTrackConversionObject) => void;
@@ -15,6 +15,7 @@ declare global {
15
15
  guardian: {
16
16
  commercialTimer?: EventTimer;
17
17
  config: GuardianWindowConfig;
18
+ offlineCount?: number;
18
19
  };
19
20
  ga: UniversalAnalytics.ga | null;
20
21
  readonly navigator: Navigator;
@@ -15,6 +15,7 @@ type EventProperties = {
15
15
  type?: ConnectionType;
16
16
  downlink?: number;
17
17
  effectiveType?: string;
18
+ offlineCount?: number;
18
19
  };
19
20
  declare enum Endpoints {
20
21
  CODE = "//performance-events.code.dev-guardianapis.com/commercial-metrics",
@@ -28,6 +28,7 @@ interface EventTimerProperties {
28
28
  type?: ConnectionType;
29
29
  downlink?: number;
30
30
  effectiveType?: string;
31
+ offlineCount?: number;
31
32
  adSlotsInline?: number;
32
33
  adSlotsTotal?: number;
33
34
  pageHeightVH?: number;
@@ -90,20 +90,15 @@ class EventTimer {
90
90
  },
91
91
  ],
92
92
  };
93
- this.properties =
94
- 'connection' in window.navigator
95
- ? {
96
- type: 'type' in window.navigator.connection
97
- ? window.navigator.connection.type
98
- : undefined,
99
- downlink: 'downlink' in window.navigator.connection
100
- ? window.navigator.connection.downlink
101
- : undefined,
102
- effectiveType: 'effectiveType' in window.navigator.connection
103
- ? window.navigator.connection.effectiveType
104
- : undefined,
105
- }
106
- : {};
93
+ this.properties = {
94
+ offlineCount: window.guardian.offlineCount,
95
+ };
96
+ if (window.navigator.connection) {
97
+ this.properties.type = window.navigator.connection.type;
98
+ this.properties.downlink = window.navigator.connection.downlink;
99
+ this.properties.effectiveType =
100
+ window.navigator.connection.effectiveType;
101
+ }
107
102
  }
108
103
  /**
109
104
  * Adds an event timer property
@@ -3,7 +3,7 @@ import type { GoogleTagParams, GoogleTrackConversionObject, GuardianWindowConfig
3
3
  import type { EventTimer } from '.';
4
4
  declare global {
5
5
  interface Navigator {
6
- readonly connection: NetworkInformation;
6
+ readonly connection?: NetworkInformation;
7
7
  }
8
8
  interface Window {
9
9
  google_trackConversion?: (arg0: GoogleTrackConversionObject) => void;
@@ -15,6 +15,7 @@ declare global {
15
15
  guardian: {
16
16
  commercialTimer?: EventTimer;
17
17
  config: GuardianWindowConfig;
18
+ offlineCount?: number;
18
19
  };
19
20
  ga: UniversalAnalytics.ga | null;
20
21
  readonly navigator: Navigator;
@@ -15,6 +15,7 @@ type EventProperties = {
15
15
  type?: ConnectionType;
16
16
  downlink?: number;
17
17
  effectiveType?: string;
18
+ offlineCount?: number;
18
19
  };
19
20
  declare enum Endpoints {
20
21
  CODE = "//performance-events.code.dev-guardianapis.com/commercial-metrics",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/commercial-core",
3
- "version": "5.2.1",
3
+ "version": "5.3.0",
4
4
  "description": "Guardian advertising business logic",
5
5
  "homepage": "https://github.com/guardian/commercial-core#readme",
6
6
  "bugs": {