@guardian/commercial-core 33.0.1 → 34.1.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.
Files changed (35) hide show
  1. package/dist/cjs/ad-sizes.d.ts +1 -1
  2. package/dist/cjs/ad-sizes.js +1 -1
  3. package/dist/cjs/constants/index.d.ts +3 -3
  4. package/dist/cjs/constants/index.js +3 -3
  5. package/dist/cjs/event-timer.d.ts +1 -1
  6. package/dist/cjs/geo/geo-utils.js +7 -13
  7. package/dist/cjs/geo/get-locale.js +0 -1
  8. package/dist/cjs/global.d.ts +1 -1
  9. package/dist/cjs/index.d.ts +15 -15
  10. package/dist/cjs/index.js +12 -12
  11. package/dist/cjs/send-commercial-metrics.d.ts +1 -1
  12. package/dist/cjs/send-commercial-metrics.js +3 -2
  13. package/dist/cjs/targeting/build-page-targeting.d.ts +6 -5
  14. package/dist/cjs/targeting/build-page-targeting.js +10 -9
  15. package/dist/cjs/targeting/content.d.ts +2 -2
  16. package/dist/cjs/targeting/personalised.d.ts +2 -2
  17. package/dist/cjs/targeting/personalised.js +1 -1
  18. package/dist/cjs/targeting/session.d.ts +2 -2
  19. package/dist/cjs/targeting/shared.js +1 -1
  20. package/dist/cjs/targeting/viewport.d.ts +1 -1
  21. package/dist/cjs/targeting/youtube-ima.d.ts +2 -2
  22. package/dist/cjs/targeting/youtube-ima.js +1 -1
  23. package/dist/cjs/types.d.ts +2 -2
  24. package/dist/esm/geo/geo-utils.js +7 -13
  25. package/dist/esm/geo/get-locale.js +0 -1
  26. package/dist/esm/send-commercial-metrics.js +2 -1
  27. package/dist/esm/targeting/build-page-targeting.d.ts +2 -1
  28. package/dist/esm/targeting/build-page-targeting.js +2 -1
  29. package/dist/esm/targeting/personalised.d.ts +1 -1
  30. package/dist/esm/targeting/youtube-ima.d.ts +1 -1
  31. package/package.json +8 -6
  32. package/dist/cjs/geo/country-code.d.ts +0 -3
  33. package/dist/cjs/geo/country-code.js +0 -32
  34. package/dist/esm/geo/country-code.d.ts +0 -3
  35. package/dist/esm/geo/country-code.js +0 -29
@@ -1,4 +1,4 @@
1
- import type { Breakpoint } from './breakpoint';
1
+ import type { Breakpoint } from './breakpoint.js';
2
2
  type AdSizeString = 'fluid' | `${number},${number}`;
3
3
  /**
4
4
  * Store ad sizes in a way that is compatible with google-tag but also accessible via
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findAppliedSizesForBreakpoint = exports.createAdSize = exports.slotSizeMappings = exports.getAdSize = exports.outstreamSizes = exports.standardAdSizes = exports.adSizes = exports.AdSize = exports._ = void 0;
4
- const breakpoint_1 = require("./breakpoint");
4
+ const breakpoint_1 = require("./breakpoint.js");
5
5
  /**
6
6
  * Store ad sizes in a way that is compatible with google-tag but also accessible via
7
7
  * more semantic `width`/`height` properties and keep things readonly.
@@ -1,3 +1,3 @@
1
- export { AD_LABEL_HEIGHT } from './ad-label-height';
2
- export { PREBID_TIMEOUT } from './prebid-timeout';
3
- export { TOP_ABOVE_NAV_HEIGHT } from './top-above-nav-height';
1
+ export { AD_LABEL_HEIGHT } from './ad-label-height.js';
2
+ export { PREBID_TIMEOUT } from './prebid-timeout.js';
3
+ export { TOP_ABOVE_NAV_HEIGHT } from './top-above-nav-height.js';
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TOP_ABOVE_NAV_HEIGHT = exports.PREBID_TIMEOUT = exports.AD_LABEL_HEIGHT = void 0;
4
- var ad_label_height_1 = require("./ad-label-height");
4
+ var ad_label_height_1 = require("./ad-label-height.js");
5
5
  Object.defineProperty(exports, "AD_LABEL_HEIGHT", { enumerable: true, get: function () { return ad_label_height_1.AD_LABEL_HEIGHT; } });
6
- var prebid_timeout_1 = require("./prebid-timeout");
6
+ var prebid_timeout_1 = require("./prebid-timeout.js");
7
7
  Object.defineProperty(exports, "PREBID_TIMEOUT", { enumerable: true, get: function () { return prebid_timeout_1.PREBID_TIMEOUT; } });
8
- var top_above_nav_height_1 = require("./top-above-nav-height");
8
+ var top_above_nav_height_1 = require("./top-above-nav-height.js");
9
9
  Object.defineProperty(exports, "TOP_ABOVE_NAV_HEIGHT", { enumerable: true, get: function () { return top_above_nav_height_1.TOP_ABOVE_NAV_HEIGHT; } });
@@ -1,4 +1,4 @@
1
- import type { ConnectionType, NetworkInformation } from './types';
1
+ import type { ConnectionType, NetworkInformation } from './types.js';
2
2
  declare global {
3
3
  interface Navigator {
4
4
  readonly connection?: NetworkInformation;
@@ -1,22 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._ = exports.isInRow = exports.isInAuOrNz = exports.isInUsOrCa = exports.isInNewZealand = exports.isInAustralia = exports.isInCanada = exports.isInUsa = exports.isInUk = void 0;
4
- const country_code_1 = require("./country-code");
5
- // cache the users location so we only have to look it up once
6
- let geo;
7
- const currentGeoLocation = () => {
8
- geo = geo ?? (0, country_code_1.getCountryCode)();
9
- return geo;
10
- };
11
- const isInUk = () => currentGeoLocation() === 'GB';
4
+ const get_locale_1 = require("./get-locale.js");
5
+ const isInUk = () => (0, get_locale_1.getLocale)() === 'GB';
12
6
  exports.isInUk = isInUk;
13
- const isInUsa = () => currentGeoLocation() === 'US';
7
+ const isInUsa = () => (0, get_locale_1.getLocale)() === 'US';
14
8
  exports.isInUsa = isInUsa;
15
- const isInCanada = () => currentGeoLocation() === 'CA';
9
+ const isInCanada = () => (0, get_locale_1.getLocale)() === 'CA';
16
10
  exports.isInCanada = isInCanada;
17
- const isInAustralia = () => currentGeoLocation() === 'AU';
11
+ const isInAustralia = () => (0, get_locale_1.getLocale)() === 'AU';
18
12
  exports.isInAustralia = isInAustralia;
19
- const isInNewZealand = () => currentGeoLocation() === 'NZ';
13
+ const isInNewZealand = () => (0, get_locale_1.getLocale)() === 'NZ';
20
14
  exports.isInNewZealand = isInNewZealand;
21
15
  const isInUsOrCa = () => (0, exports.isInUsa)() || (0, exports.isInCanada)();
22
16
  exports.isInUsOrCa = isInUsOrCa;
@@ -26,6 +20,6 @@ const isInRow = () => !(0, exports.isInUk)() && !(0, exports.isInUsOrCa)() && !(
26
20
  exports.isInRow = isInRow;
27
21
  exports._ = {
28
22
  resetModule: () => {
29
- geo = undefined;
23
+ (0, get_locale_1.__resetCachedValue)();
30
24
  },
31
25
  };
@@ -15,7 +15,6 @@ const editionToGeolocationMap = {
15
15
  AU: 'AU',
16
16
  };
17
17
  const editionToGeolocation = (editionKey) => editionToGeolocationMap[editionKey];
18
- // just used for tests
19
18
  const __resetCachedValue = () => (locale = undefined);
20
19
  exports.__resetCachedValue = __resetCachedValue;
21
20
  /**
@@ -1,4 +1,4 @@
1
- import type { CoreGuardian } from './types';
1
+ import type { CoreGuardian } from './types.js';
2
2
  declare global {
3
3
  interface Window {
4
4
  guardian: CoreGuardian;
@@ -1,15 +1,15 @@
1
- export { isAdBlockInUse } from './detect-ad-blocker';
2
- export { EventTimer } from './event-timer';
3
- export { adSizes } from './ad-sizes';
4
- export * as constants from './constants';
5
- export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './send-commercial-metrics';
6
- export { buildPageTargeting } from './targeting/build-page-targeting';
7
- export { postMessage } from './messenger/post-message';
8
- export { buildImaAdTagUrl } from './targeting/youtube-ima';
9
- export { getPermutivePFPSegments } from './permutive';
10
- export { isEligibleForTeads } from './targeting/teads-eligibility';
11
- export { hashEmailForClient } from './email-hash';
12
- export { globalAdEvents } from './global-ad-events';
13
- export type { AdSize, SizeMapping, SlotName } from './ad-sizes';
14
- export type { PageTargeting } from './targeting/build-page-targeting';
15
- export type { AdsConfigDisabled, AdsConfigUSNATorAus, AdsConfigTCFV2, } from './types';
1
+ export { isAdBlockInUse } from './detect-ad-blocker.js';
2
+ export { EventTimer } from './event-timer.js';
3
+ export { adSizes } from './ad-sizes.js';
4
+ export * as constants from './constants/index.js';
5
+ export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './send-commercial-metrics.js';
6
+ export { buildPageTargeting } from './targeting/build-page-targeting.js';
7
+ export { postMessage } from './messenger/post-message.js';
8
+ export { buildImaAdTagUrl } from './targeting/youtube-ima.js';
9
+ export { getPermutivePFPSegments } from './permutive.js';
10
+ export { isEligibleForTeads } from './targeting/teads-eligibility.js';
11
+ export { hashEmailForClient } from './email-hash.js';
12
+ export { globalAdEvents } from './global-ad-events.js';
13
+ export type { AdSize, SizeMapping, SlotName } from './ad-sizes.js';
14
+ export type { PageTargeting } from './targeting/build-page-targeting.js';
15
+ export type { AdsConfigDisabled, AdsConfigUSNATorAus, AdsConfigTCFV2, } from './types.js';
package/dist/cjs/index.js CHANGED
@@ -34,27 +34,27 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.globalAdEvents = exports.hashEmailForClient = exports.isEligibleForTeads = exports.getPermutivePFPSegments = exports.buildImaAdTagUrl = exports.buildPageTargeting = exports.initCommercialMetrics = exports.bypassCommercialMetricsSampling = exports.constants = exports.adSizes = exports.EventTimer = exports.isAdBlockInUse = void 0;
37
- var detect_ad_blocker_1 = require("./detect-ad-blocker");
37
+ var detect_ad_blocker_1 = require("./detect-ad-blocker.js");
38
38
  Object.defineProperty(exports, "isAdBlockInUse", { enumerable: true, get: function () { return detect_ad_blocker_1.isAdBlockInUse; } });
39
- var event_timer_1 = require("./event-timer");
39
+ var event_timer_1 = require("./event-timer.js");
40
40
  Object.defineProperty(exports, "EventTimer", { enumerable: true, get: function () { return event_timer_1.EventTimer; } });
41
- var ad_sizes_1 = require("./ad-sizes");
41
+ var ad_sizes_1 = require("./ad-sizes.js");
42
42
  Object.defineProperty(exports, "adSizes", { enumerable: true, get: function () { return ad_sizes_1.adSizes; } });
43
- exports.constants = __importStar(require("./constants"));
44
- var send_commercial_metrics_1 = require("./send-commercial-metrics");
43
+ exports.constants = __importStar(require("./constants/index.js"));
44
+ var send_commercial_metrics_1 = require("./send-commercial-metrics.js");
45
45
  Object.defineProperty(exports, "bypassCommercialMetricsSampling", { enumerable: true, get: function () { return send_commercial_metrics_1.bypassCommercialMetricsSampling; } });
46
46
  Object.defineProperty(exports, "initCommercialMetrics", { enumerable: true, get: function () { return send_commercial_metrics_1.initCommercialMetrics; } });
47
- var build_page_targeting_1 = require("./targeting/build-page-targeting");
47
+ var build_page_targeting_1 = require("./targeting/build-page-targeting.js");
48
48
  Object.defineProperty(exports, "buildPageTargeting", { enumerable: true, get: function () { return build_page_targeting_1.buildPageTargeting; } });
49
- var post_message_1 = require("./messenger/post-message");
49
+ var post_message_1 = require("./messenger/post-message.js");
50
50
  Object.defineProperty(exports, "postMessage", { enumerable: true, get: function () { return post_message_1.postMessage; } });
51
- var youtube_ima_1 = require("./targeting/youtube-ima");
51
+ var youtube_ima_1 = require("./targeting/youtube-ima.js");
52
52
  Object.defineProperty(exports, "buildImaAdTagUrl", { enumerable: true, get: function () { return youtube_ima_1.buildImaAdTagUrl; } });
53
- var permutive_1 = require("./permutive");
53
+ var permutive_1 = require("./permutive.js");
54
54
  Object.defineProperty(exports, "getPermutivePFPSegments", { enumerable: true, get: function () { return permutive_1.getPermutivePFPSegments; } });
55
- var teads_eligibility_1 = require("./targeting/teads-eligibility");
55
+ var teads_eligibility_1 = require("./targeting/teads-eligibility.js");
56
56
  Object.defineProperty(exports, "isEligibleForTeads", { enumerable: true, get: function () { return teads_eligibility_1.isEligibleForTeads; } });
57
- var email_hash_1 = require("./email-hash");
57
+ var email_hash_1 = require("./email-hash.js");
58
58
  Object.defineProperty(exports, "hashEmailForClient", { enumerable: true, get: function () { return email_hash_1.hashEmailForClient; } });
59
- var global_ad_events_1 = require("./global-ad-events");
59
+ var global_ad_events_1 = require("./global-ad-events.js");
60
60
  Object.defineProperty(exports, "globalAdEvents", { enumerable: true, get: function () { return global_ad_events_1.globalAdEvents; } });
@@ -1,4 +1,4 @@
1
- import type { ConnectionType } from './types';
1
+ import type { ConnectionType } from './types.js';
2
2
  type Metric = {
3
3
  name: string;
4
4
  value: number;
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkConsent = exports._ = void 0;
4
4
  exports.bypassCommercialMetricsSampling = bypassCommercialMetricsSampling;
5
5
  exports.initCommercialMetrics = initCommercialMetrics;
6
+ const consent_manager_1 = require("@guardian/consent-manager");
6
7
  const libs_1 = require("@guardian/libs");
7
- const event_timer_1 = require("./event-timer");
8
+ const event_timer_1 = require("./event-timer.js");
8
9
  var Endpoints;
9
10
  (function (Endpoints) {
10
11
  Endpoints["CODE"] = "//performance-events.code.dev-guardianapis.com/commercial-metrics";
@@ -129,7 +130,7 @@ const addVisibilityListeners = () => {
129
130
  window.addEventListener('pagehide', listener, { once: true });
130
131
  };
131
132
  const checkConsent = async () => {
132
- const consentState = await (0, libs_1.onConsent)();
133
+ const consentState = await (0, consent_manager_1.onConsent)();
133
134
  if (consentState.tcfv2) {
134
135
  // TCFv2 mode - check for consent
135
136
  const consents = consentState.tcfv2.consents;
@@ -1,8 +1,9 @@
1
- import type { ConsentState, CountryCode } from '@guardian/libs';
2
- import type { AdManagerGroup, Frequency } from './personalised';
3
- import type { SharedTargeting } from './shared';
4
- import { getLocalHour } from './shared';
5
- import type { TrueOrFalse } from './types';
1
+ import type { ConsentState } from '@guardian/consent-manager';
2
+ import type { CountryCode } from '@guardian/libs';
3
+ import type { AdManagerGroup, Frequency } from './personalised.js';
4
+ import type { SharedTargeting } from './shared.js';
5
+ import { getLocalHour } from './shared.js';
6
+ import type { TrueOrFalse } from './types.js';
6
7
  type PartialWithNulls<T> = {
7
8
  [P in keyof T]?: T[P] | null;
8
9
  };
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLocalHour = exports.filterValues = exports.buildPageTargeting = void 0;
4
+ const consent_manager_1 = require("@guardian/consent-manager");
4
5
  const libs_1 = require("@guardian/libs");
5
- const event_timer_1 = require("../event-timer");
6
- const get_locale_1 = require("../geo/get-locale");
7
- const content_1 = require("./content");
8
- const personalised_1 = require("./personalised");
9
- const session_1 = require("./session");
10
- const shared_1 = require("./shared");
6
+ const event_timer_1 = require("../event-timer.js");
7
+ const get_locale_1 = require("../geo/get-locale.js");
8
+ const content_1 = require("./content.js");
9
+ const personalised_1 = require("./personalised.js");
10
+ const session_1 = require("./session.js");
11
+ const shared_1 = require("./shared.js");
11
12
  Object.defineProperty(exports, "getLocalHour", { enumerable: true, get: function () { return shared_1.getLocalHour; } });
12
- const viewport_1 = require("./viewport");
13
+ const viewport_1 = require("./viewport.js");
13
14
  const filterValues = (pageTargets) => {
14
15
  const filtered = {};
15
16
  for (const key in pageTargets) {
@@ -86,14 +87,14 @@ const buildPageTargeting = ({ adFree, abTestParticipations, consentState, isSign
86
87
  };
87
88
  const viewportTargeting = (0, viewport_1.getViewportTargeting)({
88
89
  viewPortWidth: getViewport().width,
89
- cmpBannerWillShow: !libs_1.cmp.hasInitialised() || libs_1.cmp.willShowPrivacyMessageSync(),
90
+ cmpBannerWillShow: !consent_manager_1.cmp.hasInitialised() || consent_manager_1.cmp.willShowPrivacyMessageSync(),
90
91
  });
91
92
  const personalisedTargeting = (0, personalised_1.getPersonalisedTargeting)({
92
93
  state: consentState,
93
94
  youtube,
94
95
  });
95
96
  const consentlessTargeting = {};
96
- if (!(0, libs_1.getConsentFor)('googletag', consentState)) {
97
+ if (!(0, consent_manager_1.getConsentFor)('googletag', consentState)) {
97
98
  consentlessTargeting.firstvisit = isFirstVisit(referrer) ? 't' : 'f';
98
99
  }
99
100
  const pageTargets = {
@@ -1,5 +1,5 @@
1
- import type { SharedTargeting } from './shared';
2
- import type { False, True } from './types';
1
+ import type { SharedTargeting } from './shared.js';
2
+ import type { False, True } from './types.js';
3
3
  declare const videoLengths: readonly ["25", "30", "60", "90", "120", "150", "180", "210", "240", "270", "300"];
4
4
  /**
5
5
  * Content Targeting comes from the server
@@ -1,5 +1,5 @@
1
- import type { ConsentState, TCEventStatusCode } from '@guardian/libs';
2
- import type { False, NotApplicable, True } from './types';
1
+ import type { ConsentState, TCEventStatusCode } from '@guardian/consent-manager';
2
+ import type { False, NotApplicable, True } from './types.js';
3
3
  declare const frequency: readonly ["0", "1", "2", "3", "4", "5", "6-9", "10-15", "16-19", "20-29", "30plus"];
4
4
  type Frequency = (typeof frequency)[number];
5
5
  declare const adManagerGroups: readonly ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPersonalisedTargeting = void 0;
4
4
  const libs_1 = require("@guardian/libs");
5
- const permutive_1 = require("../permutive");
5
+ const permutive_1 = require("../permutive.js");
6
6
  /* -- Types -- */
7
7
  const frequency = [
8
8
  '0',
@@ -1,6 +1,6 @@
1
1
  import type { CountryCode } from '@guardian/libs';
2
- import type { UserId } from '../targeting/build-page-targeting';
3
- import type { False, True } from './types';
2
+ import type { UserId } from '../targeting/build-page-targeting.js';
3
+ import type { False, True } from './types.js';
4
4
  declare const referrers: readonly [{
5
5
  readonly id: "facebook";
6
6
  readonly match: "facebook.com";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLocalHour = exports.getSharedTargeting = exports._ = void 0;
4
- const pick_targeting_values_1 = require("./pick-targeting-values");
4
+ const pick_targeting_values_1 = require("./pick-targeting-values.js");
5
5
  const surges = {
6
6
  0: '0',
7
7
  50: '5',
@@ -1,4 +1,4 @@
1
- import type { False, True } from './types';
1
+ import type { False, True } from './types.js';
2
2
  /**
3
3
  * Viewport Targeting
4
4
  *
@@ -1,5 +1,5 @@
1
- import type { ConsentState } from '@guardian/libs';
2
- import type { CustomParams } from './types';
1
+ import type { ConsentState } from '@guardian/consent-manager';
2
+ import type { CustomParams } from './types.js';
3
3
  type BuildImaAdTagUrl = {
4
4
  adUnit: string;
5
5
  customParams: CustomParams;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildImaAdTagUrl = void 0;
4
4
  const libs_1 = require("@guardian/libs");
5
- const build_page_targeting_1 = require("./build-page-targeting");
5
+ const build_page_targeting_1 = require("./build-page-targeting.js");
6
6
  /**
7
7
  * @param {Record<string, MaybeArray<string|number|boolean>>
8
8
  * Follows https://support.google.com/admanager/answer/1080597
@@ -1,6 +1,6 @@
1
1
  import type { EventPayload } from '@guardian/ophan-tracker-js';
2
- import type { EventTimer } from './event-timer';
3
- import type { PageTargeting } from './targeting/build-page-targeting';
2
+ import type { EventTimer } from './event-timer.js';
3
+ import type { PageTargeting } from './targeting/build-page-targeting.js';
4
4
  type ConnectionType = 'bluetooth' | 'cellular' | 'ethernet' | 'mixed' | 'none' | 'other' | 'unknown' | 'wifi';
5
5
  interface NetworkInformation extends EventTarget {
6
6
  readonly type?: ConnectionType;
@@ -1,20 +1,14 @@
1
- import { getCountryCode } from './country-code.js';
2
- // cache the users location so we only have to look it up once
3
- let geo;
4
- const currentGeoLocation = () => {
5
- geo = geo ?? getCountryCode();
6
- return geo;
7
- };
8
- export const isInUk = () => currentGeoLocation() === 'GB';
9
- export const isInUsa = () => currentGeoLocation() === 'US';
10
- export const isInCanada = () => currentGeoLocation() === 'CA';
11
- export const isInAustralia = () => currentGeoLocation() === 'AU';
12
- export const isInNewZealand = () => currentGeoLocation() === 'NZ';
1
+ import { __resetCachedValue, getLocale } from './get-locale.js';
2
+ export const isInUk = () => getLocale() === 'GB';
3
+ export const isInUsa = () => getLocale() === 'US';
4
+ export const isInCanada = () => getLocale() === 'CA';
5
+ export const isInAustralia = () => getLocale() === 'AU';
6
+ export const isInNewZealand = () => getLocale() === 'NZ';
13
7
  export const isInUsOrCa = () => isInUsa() || isInCanada();
14
8
  export const isInAuOrNz = () => isInAustralia() || isInNewZealand();
15
9
  export const isInRow = () => !isInUk() && !isInUsOrCa() && !isInAuOrNz();
16
10
  export const _ = {
17
11
  resetModule: () => {
18
- geo = undefined;
12
+ __resetCachedValue();
19
13
  },
20
14
  };
@@ -12,7 +12,6 @@ const editionToGeolocationMap = {
12
12
  AU: 'AU',
13
13
  };
14
14
  const editionToGeolocation = (editionKey) => editionToGeolocationMap[editionKey];
15
- // just used for tests
16
15
  export const __resetCachedValue = () => (locale = undefined);
17
16
  /**
18
17
  * Fetches the user's current location as an ISO 3166-1 alpha-2 string e.g. 'GB', 'AU' etc
@@ -1,4 +1,5 @@
1
- import { getMeasures, isNonNullable, log, onConsent } from '@guardian/libs';
1
+ import { onConsent } from '@guardian/consent-manager';
2
+ import { getMeasures, isNonNullable, log } from '@guardian/libs';
2
3
  import { EventTimer } from './event-timer.js';
3
4
  var Endpoints;
4
5
  (function (Endpoints) {
@@ -1,4 +1,5 @@
1
- import type { ConsentState, CountryCode } from '@guardian/libs';
1
+ import type { ConsentState } from '@guardian/consent-manager';
2
+ import type { CountryCode } from '@guardian/libs';
2
3
  import type { AdManagerGroup, Frequency } from './personalised.js';
3
4
  import type { SharedTargeting } from './shared.js';
4
5
  import { getLocalHour } from './shared.js';
@@ -1,4 +1,5 @@
1
- import { cmp, getConsentFor, getCookie, isString } from '@guardian/libs';
1
+ import { cmp, getConsentFor } from '@guardian/consent-manager';
2
+ import { getCookie, isString } from '@guardian/libs';
2
3
  import { supportsPerformanceAPI } from '../event-timer.js';
3
4
  import { getLocale } from '../geo/get-locale.js';
4
5
  import { getContentTargeting } from './content.js';
@@ -1,4 +1,4 @@
1
- import type { ConsentState, TCEventStatusCode } from '@guardian/libs';
1
+ import type { ConsentState, TCEventStatusCode } from '@guardian/consent-manager';
2
2
  import type { False, NotApplicable, True } from './types.js';
3
3
  declare const frequency: readonly ["0", "1", "2", "3", "4", "5", "6-9", "10-15", "16-19", "20-29", "30plus"];
4
4
  type Frequency = (typeof frequency)[number];
@@ -1,4 +1,4 @@
1
- import type { ConsentState } from '@guardian/libs';
1
+ import type { ConsentState } from '@guardian/consent-manager';
2
2
  import type { CustomParams } from './types.js';
3
3
  type BuildImaAdTagUrl = {
4
4
  adUnit: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/commercial-core",
3
- "version": "33.0.1",
3
+ "version": "34.1.0",
4
4
  "description": "Guardian advertising business logic",
5
5
  "homepage": "https://github.com/guardian/commercial#readme",
6
6
  "bugs": {
@@ -32,21 +32,23 @@
32
32
  "./package.json": "./package.json"
33
33
  },
34
34
  "peerDependencies": {
35
- "@guardian/libs": "^31.0.0"
35
+ "@guardian/libs": "^32.0.0",
36
+ "@guardian/consent-manager": "^1.0.0"
36
37
  },
37
38
  "dependencies": {
38
- "@guardian/libs": "31.0.0"
39
+ "@guardian/libs": "32.0.0",
40
+ "@guardian/consent-manager": "1.0.0"
39
41
  },
40
42
  "devDependencies": {
41
43
  "@guardian/ophan-tracker-js": "2.8.0",
42
44
  "@types/jest": "30.0.0",
43
- "@types/node": "25.5.0",
45
+ "@types/node": "25.6.0",
44
46
  "jest": "30.3.0",
45
47
  "jest-environment-jsdom": "30.3.0",
46
48
  "jest-environment-jsdom-global": "4.0.0",
47
- "ts-jest": "29.4.6",
49
+ "ts-jest": "29.4.9",
48
50
  "tsc-alias": "1.8.16",
49
- "type-fest": "5.5.0",
51
+ "type-fest": "5.6.0",
50
52
  "typescript": "5.9.3"
51
53
  },
52
54
  "publishConfig": {
@@ -1,3 +0,0 @@
1
- import type { CountryCode } from '@guardian/libs';
2
- declare const getCountryCode: () => CountryCode;
3
- export { getCountryCode };
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCountryCode = void 0;
4
- const libs_1 = require("@guardian/libs");
5
- const editionToCountryCodeMap = {
6
- UK: 'GB',
7
- US: 'US',
8
- AU: 'AU',
9
- };
10
- const editionToCountryCode = (editionKey = 'UK') => editionToCountryCodeMap[editionKey];
11
- const countryCookieName = 'GU_geo_country';
12
- const countryOverrideName = 'gu.geo.override';
13
- /*
14
- This method can be used as a non async way of getting the country code
15
- after init has been called. Returning locale should cover all/most
16
- of the cases but if a race condition happen or the cookie is not set,
17
- we keep fallbacks to cookie or geo from edition.
18
- */
19
- const getCountryCode = () => {
20
- const pageEdition = window.guardian.config.page.edition;
21
- const maybeCountryOverride = libs_1.storage.local.get(countryOverrideName);
22
- const countryOverride = (0, libs_1.isString)(maybeCountryOverride)
23
- ? maybeCountryOverride
24
- : null;
25
- return (countryOverride ??
26
- (0, libs_1.getCookie)({
27
- name: countryCookieName,
28
- shouldMemoize: true,
29
- }) ??
30
- editionToCountryCode(pageEdition));
31
- };
32
- exports.getCountryCode = getCountryCode;
@@ -1,3 +0,0 @@
1
- import type { CountryCode } from '@guardian/libs';
2
- declare const getCountryCode: () => CountryCode;
3
- export { getCountryCode };
@@ -1,29 +0,0 @@
1
- import { getCookie, isString, storage } from '@guardian/libs';
2
- const editionToCountryCodeMap = {
3
- UK: 'GB',
4
- US: 'US',
5
- AU: 'AU',
6
- };
7
- const editionToCountryCode = (editionKey = 'UK') => editionToCountryCodeMap[editionKey];
8
- const countryCookieName = 'GU_geo_country';
9
- const countryOverrideName = 'gu.geo.override';
10
- /*
11
- This method can be used as a non async way of getting the country code
12
- after init has been called. Returning locale should cover all/most
13
- of the cases but if a race condition happen or the cookie is not set,
14
- we keep fallbacks to cookie or geo from edition.
15
- */
16
- const getCountryCode = () => {
17
- const pageEdition = window.guardian.config.page.edition;
18
- const maybeCountryOverride = storage.local.get(countryOverrideName);
19
- const countryOverride = isString(maybeCountryOverride)
20
- ? maybeCountryOverride
21
- : null;
22
- return (countryOverride ??
23
- getCookie({
24
- name: countryCookieName,
25
- shouldMemoize: true,
26
- }) ??
27
- editionToCountryCode(pageEdition));
28
- };
29
- export { getCountryCode };