@guardian/commercial-core 0.37.1 → 0.40.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 (41) hide show
  1. package/dist/cjs/ad-sizes.d.ts +1 -1
  2. package/dist/cjs/ad-sizes.js +10 -10
  3. package/dist/cjs/index.d.ts +11 -0
  4. package/dist/cjs/index.js +13 -1
  5. package/dist/cjs/targeting/pick-targeting-values.d.ts +2 -2
  6. package/dist/cjs/targeting/viewport.d.ts +6 -1
  7. package/dist/cjs/targeting/viewport.js +2 -3
  8. package/dist/cjs/third-party-tags/facebook-pixel.d.ts +5 -0
  9. package/dist/cjs/third-party-tags/facebook-pixel.js +5 -0
  10. package/dist/cjs/third-party-tags/ias.d.ts +5 -0
  11. package/dist/cjs/third-party-tags/ias.js +5 -0
  12. package/dist/cjs/third-party-tags/inizio.d.ts +5 -0
  13. package/dist/cjs/third-party-tags/inizio.js +5 -0
  14. package/dist/cjs/third-party-tags/permutive.d.ts +4 -0
  15. package/dist/cjs/third-party-tags/permutive.js +4 -0
  16. package/dist/cjs/third-party-tags/remarketing.d.ts +5 -0
  17. package/dist/cjs/third-party-tags/remarketing.js +5 -0
  18. package/dist/cjs/third-party-tags/twitter-uwt.d.ts +5 -0
  19. package/dist/cjs/third-party-tags/twitter-uwt.js +5 -0
  20. package/dist/cjs/types.d.ts +2 -1
  21. package/dist/esm/ad-sizes.d.ts +1 -1
  22. package/dist/esm/ad-sizes.js +10 -10
  23. package/dist/esm/index.d.ts +11 -0
  24. package/dist/esm/index.js +6 -0
  25. package/dist/esm/targeting/pick-targeting-values.d.ts +2 -2
  26. package/dist/esm/targeting/viewport.d.ts +6 -1
  27. package/dist/esm/targeting/viewport.js +2 -3
  28. package/dist/esm/third-party-tags/facebook-pixel.d.ts +5 -0
  29. package/dist/esm/third-party-tags/facebook-pixel.js +5 -0
  30. package/dist/esm/third-party-tags/ias.d.ts +5 -0
  31. package/dist/esm/third-party-tags/ias.js +5 -0
  32. package/dist/esm/third-party-tags/inizio.d.ts +5 -0
  33. package/dist/esm/third-party-tags/inizio.js +5 -0
  34. package/dist/esm/third-party-tags/permutive.d.ts +4 -0
  35. package/dist/esm/third-party-tags/permutive.js +4 -0
  36. package/dist/esm/third-party-tags/remarketing.d.ts +5 -0
  37. package/dist/esm/third-party-tags/remarketing.js +5 -0
  38. package/dist/esm/third-party-tags/twitter-uwt.d.ts +5 -0
  39. package/dist/esm/third-party-tags/twitter-uwt.js +5 -0
  40. package/dist/esm/types.d.ts +2 -1
  41. package/package.json +6 -5
@@ -4,7 +4,7 @@ export declare type AdSize = Readonly<{
4
4
  height: number;
5
5
  toString: () => AdSizeString;
6
6
  }>;
7
- export declare type SizeKeys = 'billboard' | 'leaderboard' | 'mpu' | 'halfPage' | 'portrait' | 'skyscraper' | 'mobilesticky' | 'fluid' | 'outOfPage' | 'googleCard' | 'video' | 'outstreamDesktop' | 'outstreamGoogleDesktop' | 'outstreamMobile' | 'merchandisingHighAdFeature' | 'merchandisingHigh' | 'merchandising' | 'inlineMerchandising' | 'fabric' | 'empty' | '970x250' | '728x90' | '300x250' | '300x600' | '300x1050' | '160x600';
7
+ export declare type SizeKeys = '160x600' | '300x1050' | '300x250' | '300x600' | '728x90' | '970x250' | 'billboard' | 'empty' | 'fabric' | 'fluid' | 'googleCard' | 'halfPage' | 'inlineMerchandising' | 'leaderboard' | 'merchandising' | 'merchandisingHigh' | 'merchandisingHighAdFeature' | 'mobilesticky' | 'mpu' | 'outOfPage' | 'outstreamDesktop' | 'outstreamGoogleDesktop' | 'outstreamMobile' | 'portrait' | 'skyscraper' | 'video';
8
8
  export declare const adSizes: Record<SizeKeys, AdSize>;
9
9
  export declare const getAdSize: (size: SizeKeys) => AdSize;
10
10
  export declare const _: {
@@ -12,27 +12,27 @@ const createAdSize = (width, height) => {
12
12
  const adSizesPartial = {
13
13
  // standard ad sizes
14
14
  billboard: createAdSize(970, 250),
15
+ halfPage: createAdSize(300, 600),
15
16
  leaderboard: createAdSize(728, 90),
17
+ mobilesticky: createAdSize(320, 50),
16
18
  mpu: createAdSize(300, 250),
17
- halfPage: createAdSize(300, 600),
18
19
  portrait: createAdSize(300, 1050),
19
20
  skyscraper: createAdSize(160, 600),
20
- mobilesticky: createAdSize(320, 50),
21
21
  // dfp proprietary ad sizes
22
22
  fluid: createAdSize(0, 0),
23
- outOfPage: createAdSize(1, 1),
24
23
  googleCard: createAdSize(300, 274),
24
+ outOfPage: createAdSize(1, 1),
25
25
  // guardian proprietary ad sizes
26
- video: createAdSize(620, 1),
26
+ empty: createAdSize(2, 2),
27
+ fabric: createAdSize(88, 71),
28
+ inlineMerchandising: createAdSize(88, 85),
29
+ merchandising: createAdSize(88, 88),
30
+ merchandisingHigh: createAdSize(88, 87),
31
+ merchandisingHighAdFeature: createAdSize(88, 89),
27
32
  outstreamDesktop: createAdSize(620, 350),
28
33
  outstreamGoogleDesktop: createAdSize(550, 310),
29
34
  outstreamMobile: createAdSize(300, 197),
30
- merchandisingHighAdFeature: createAdSize(88, 89),
31
- merchandisingHigh: createAdSize(88, 87),
32
- merchandising: createAdSize(88, 88),
33
- inlineMerchandising: createAdSize(88, 85),
34
- fabric: createAdSize(88, 71),
35
- empty: createAdSize(2, 2),
35
+ video: createAdSize(620, 1),
36
36
  };
37
37
  exports.adSizes = {
38
38
  ...adSizesPartial,
@@ -14,3 +14,14 @@ export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments,
14
14
  export { buildAdsConfigWithConsent, disabledAds } from './ad-targeting-youtube';
15
15
  export type { AdsConfig, AdsConfigBasic, AdsConfigDisabled, AdTargetingBuilder, CustomParams, } from './types';
16
16
  export * as constants from './constants';
17
+ export type { ContentTargeting } from './targeting/content';
18
+ export { getContentTargeting } from './targeting/content';
19
+ export type { PersonalisedTargeting } from './targeting/personalised';
20
+ export { getPersonalisedTargeting } from './targeting/personalised';
21
+ export type { SessionTargeting } from './targeting/session';
22
+ export { getSessionTargeting } from './targeting/session';
23
+ export type { SharedTargeting } from './targeting/shared';
24
+ export { getSharedTargeting } from './targeting/shared';
25
+ export type { ViewportTargeting } from './targeting/viewport';
26
+ export { getViewportTargeting } from './targeting/viewport';
27
+ export { pickTargetingValues } from './targeting/pick-targeting-values';
package/dist/cjs/index.js CHANGED
@@ -20,7 +20,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
20
20
  return result;
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.constants = exports.disabledAds = exports.buildAdsConfigWithConsent = exports.getPermutivePFPSegments = exports.getPermutiveSegments = exports.clearPermutiveSegments = exports.isAdBlockInUse = exports.getAdSize = exports.adSizes = exports.sendCommercialMetrics = exports.EventTimer = exports.remarketing = exports.inizio = exports.twitter = exports.fbPixel = exports.permutive = exports.ias = void 0;
23
+ exports.pickTargetingValues = exports.getViewportTargeting = exports.getSharedTargeting = exports.getSessionTargeting = exports.getPersonalisedTargeting = exports.getContentTargeting = exports.constants = exports.disabledAds = exports.buildAdsConfigWithConsent = exports.getPermutivePFPSegments = exports.getPermutiveSegments = exports.clearPermutiveSegments = exports.isAdBlockInUse = exports.getAdSize = exports.adSizes = exports.sendCommercialMetrics = exports.EventTimer = exports.remarketing = exports.inizio = exports.twitter = exports.fbPixel = exports.permutive = exports.ias = void 0;
24
24
  var ias_1 = require("./third-party-tags/ias");
25
25
  Object.defineProperty(exports, "ias", { enumerable: true, get: function () { return ias_1.ias; } });
26
26
  var permutive_1 = require("./third-party-tags/permutive");
@@ -50,3 +50,15 @@ var ad_targeting_youtube_1 = require("./ad-targeting-youtube");
50
50
  Object.defineProperty(exports, "buildAdsConfigWithConsent", { enumerable: true, get: function () { return ad_targeting_youtube_1.buildAdsConfigWithConsent; } });
51
51
  Object.defineProperty(exports, "disabledAds", { enumerable: true, get: function () { return ad_targeting_youtube_1.disabledAds; } });
52
52
  exports.constants = __importStar(require("./constants"));
53
+ var content_1 = require("./targeting/content");
54
+ Object.defineProperty(exports, "getContentTargeting", { enumerable: true, get: function () { return content_1.getContentTargeting; } });
55
+ var personalised_1 = require("./targeting/personalised");
56
+ Object.defineProperty(exports, "getPersonalisedTargeting", { enumerable: true, get: function () { return personalised_1.getPersonalisedTargeting; } });
57
+ var session_1 = require("./targeting/session");
58
+ Object.defineProperty(exports, "getSessionTargeting", { enumerable: true, get: function () { return session_1.getSessionTargeting; } });
59
+ var shared_1 = require("./targeting/shared");
60
+ Object.defineProperty(exports, "getSharedTargeting", { enumerable: true, get: function () { return shared_1.getSharedTargeting; } });
61
+ var viewport_1 = require("./targeting/viewport");
62
+ Object.defineProperty(exports, "getViewportTargeting", { enumerable: true, get: function () { return viewport_1.getViewportTargeting; } });
63
+ var pick_targeting_values_1 = require("./targeting/pick-targeting-values");
64
+ Object.defineProperty(exports, "pickTargetingValues", { enumerable: true, get: function () { return pick_targeting_values_1.pickTargetingValues; } });
@@ -1,5 +1,5 @@
1
1
  import type { ConditionalExcept } from 'type-fest';
2
- declare type ValidTargetingObject<Base> = ConditionalExcept<Base, null | undefined | '' | readonly [] | readonly [''] | boolean | number>;
2
+ declare type ValidTargetingObject<Base> = ConditionalExcept<Base, null | undefined | '' | readonly [] | readonly [''] | never[] | boolean | number>;
3
3
  /**
4
4
  * Picks only keys with targeting values from an object.
5
5
  * A targeting values is defined as either:
@@ -21,5 +21,5 @@ declare type ValidTargetingObject<Base> = ConditionalExcept<Base, null | undefin
21
21
  * clean.invalid
22
22
  * ```
23
23
  */
24
- export declare const pickTargetingValues: <T extends Record<string, string | readonly string[] | undefined>>(obj: T) => import("type-fest").Except<T, NonNullable<{ [Key in keyof T]: T[Key] extends number | boolean | "" | readonly [] | readonly [""] | null | undefined ? Key : never; }[keyof T]>>;
24
+ export declare const pickTargetingValues: <T extends Record<string, string | readonly string[] | undefined>>(obj: T) => import("type-fest").Except<T, NonNullable<{ [Key in keyof T]: T[Key] extends number | boolean | "" | never[] | readonly [] | readonly [""] | null | undefined ? Key : never; }[keyof T]>>;
25
25
  export {};
@@ -39,4 +39,9 @@ export declare type ViewportTargeting = {
39
39
  */
40
40
  skinsize: 'l' | 's';
41
41
  };
42
- export declare const getViewportTargeting: (viewPortWidth: number, cmpBannerWillShow: boolean) => ViewportTargeting;
42
+ declare type Viewport = {
43
+ viewPortWidth: number;
44
+ cmpBannerWillShow: boolean;
45
+ };
46
+ export declare const getViewportTargeting: ({ viewPortWidth, cmpBannerWillShow, }: Viewport) => ViewportTargeting;
47
+ export {};
@@ -5,12 +5,11 @@ exports.getViewportTargeting = void 0;
5
5
  const findBreakpoint = (width) => {
6
6
  if (width >= 980)
7
7
  return 'desktop';
8
- if (width >= 740)
8
+ if (width >= 660)
9
9
  return 'tablet';
10
10
  return 'mobile';
11
11
  };
12
- /* -- Targeting -- */
13
- const getViewportTargeting = (viewPortWidth, cmpBannerWillShow) => {
12
+ const getViewportTargeting = ({ viewPortWidth, cmpBannerWillShow, }) => {
14
13
  // Don’t show inskin if if a privacy message will be shown
15
14
  const inskin = cmpBannerWillShow ? 'f' : 't';
16
15
  return {
@@ -1,2 +1,7 @@
1
1
  import type { GetThirdPartyTag } from '../types';
2
+ /**
3
+ * tracking pixel
4
+ * https://en-gb.facebook.com/business/learn/facebook-ads-pixel
5
+ * @param {} {shouldRun}
6
+ */
2
7
  export declare const fbPixel: GetThirdPartyTag;
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fbPixel = void 0;
4
+ /**
5
+ * tracking pixel
6
+ * https://en-gb.facebook.com/business/learn/facebook-ads-pixel
7
+ * @param {} {shouldRun}
8
+ */
4
9
  const fbPixel = ({ shouldRun }) => ({
5
10
  shouldRun,
6
11
  url: `https://www.facebook.com/tr?id=279880532344561&ev=PageView&noscript=1`,
@@ -1,2 +1,7 @@
1
1
  import type { GetThirdPartyTag } from '../types';
2
+ /**
3
+ * IAS script filters bad ads
4
+ * https://integralads.com/uk/
5
+ * @param {} {shouldRun}
6
+ */
2
7
  export declare const ias: GetThirdPartyTag;
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ias = void 0;
4
+ /**
5
+ * IAS script filters bad ads
6
+ * https://integralads.com/uk/
7
+ * @param {} {shouldRun}
8
+ */
4
9
  const ias = ({ shouldRun }) => ({
5
10
  shouldRun,
6
11
  url: '//cdn.adsafeprotected.com/iasPET.1.js',
@@ -1,4 +1,9 @@
1
1
  import type { GetThirdPartyTag } from '../types';
2
+ /**
3
+ * Allows creatives to show survey
4
+ * https://trello.com/c/wHffHVF1/171-integrate-and-test-inizio
5
+ * @param {} {shouldRun}
6
+ */
2
7
  export declare const inizio: GetThirdPartyTag;
3
8
  export declare const _: {
4
9
  onLoad: () => void;
@@ -21,6 +21,11 @@ const onLoad = () => {
21
21
  },
22
22
  });
23
23
  };
24
+ /**
25
+ * Allows creatives to show survey
26
+ * https://trello.com/c/wHffHVF1/171-integrate-and-test-inizio
27
+ * @param {} {shouldRun}
28
+ */
24
29
  const inizio = ({ shouldRun }) => ({
25
30
  shouldRun,
26
31
  url: '//cdn.brandmetrics.com/survey/script/e96d04c832084488a841a06b49b8fb2d.js',
@@ -1,2 +1,6 @@
1
1
  import type { GetThirdPartyTag } from '../types';
2
+ /**
3
+ * Permutive script updates local user segmentation data
4
+ * @param {} {shouldRun}
5
+ */
2
6
  export declare const permutive: GetThirdPartyTag;
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.permutive = void 0;
4
+ /**
5
+ * Permutive script updates local user segmentation data
6
+ * @param {} {shouldRun}
7
+ */
4
8
  const permutive = ({ shouldRun }) => ({
5
9
  shouldRun,
6
10
  url: '//cdn.permutive.com/d6691a17-6fdb-4d26-85d6-b3dd27f55f08-web.js',
@@ -1,2 +1,7 @@
1
1
  import type { GetThirdPartyTag } from '../types';
2
+ /**
3
+ * Google conversion tracking
4
+ * https://support.google.com/google-ads/answer/6095821
5
+ * @param {} {shouldRun}
6
+ */
2
7
  export declare const remarketing: GetThirdPartyTag;
@@ -8,6 +8,11 @@ const onLoad = () => {
8
8
  google_remarketing_only: true,
9
9
  });
10
10
  };
11
+ /**
12
+ * Google conversion tracking
13
+ * https://support.google.com/google-ads/answer/6095821
14
+ * @param {} {shouldRun}
15
+ */
11
16
  const remarketing = ({ shouldRun }) => ({
12
17
  shouldRun,
13
18
  url: '//www.googleadservices.com/pagead/conversion_async.js',
@@ -1,2 +1,7 @@
1
1
  import type { GetThirdPartyTag } from '../types';
2
+ /**
3
+ * tracking pixel
4
+ * https://business.twitter.com/en/help/campaign-measurement-and-analytics/conversion-tracking-for-websites.html
5
+ * @param {} {shouldRun}
6
+ */
2
7
  export declare const twitter: GetThirdPartyTag;
@@ -2,6 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.twitter = void 0;
4
4
  const twitter_script_1 = require("../__vendor/twitter-script");
5
+ /**
6
+ * tracking pixel
7
+ * https://business.twitter.com/en/help/campaign-measurement-and-analytics/conversion-tracking-for-websites.html
8
+ * @param {} {shouldRun}
9
+ */
5
10
  const twitter = ({ shouldRun }) => ({
6
11
  shouldRun,
7
12
  name: 'twitter',
@@ -1,3 +1,4 @@
1
+ import type { VendorName } from '@guardian/consent-management-platform/dist/types';
1
2
  export declare type TagAttribute = {
2
3
  name: string;
3
4
  value: string;
@@ -10,7 +11,7 @@ export declare type ThirdPartyTag = {
10
11
  loaded?: boolean;
11
12
  onLoad?: () => void;
12
13
  shouldRun: boolean;
13
- name?: string;
14
+ name?: VendorName;
14
15
  url?: string;
15
16
  useImage?: boolean;
16
17
  };
@@ -4,7 +4,7 @@ export declare type AdSize = Readonly<{
4
4
  height: number;
5
5
  toString: () => AdSizeString;
6
6
  }>;
7
- export declare type SizeKeys = 'billboard' | 'leaderboard' | 'mpu' | 'halfPage' | 'portrait' | 'skyscraper' | 'mobilesticky' | 'fluid' | 'outOfPage' | 'googleCard' | 'video' | 'outstreamDesktop' | 'outstreamGoogleDesktop' | 'outstreamMobile' | 'merchandisingHighAdFeature' | 'merchandisingHigh' | 'merchandising' | 'inlineMerchandising' | 'fabric' | 'empty' | '970x250' | '728x90' | '300x250' | '300x600' | '300x1050' | '160x600';
7
+ export declare type SizeKeys = '160x600' | '300x1050' | '300x250' | '300x600' | '728x90' | '970x250' | 'billboard' | 'empty' | 'fabric' | 'fluid' | 'googleCard' | 'halfPage' | 'inlineMerchandising' | 'leaderboard' | 'merchandising' | 'merchandisingHigh' | 'merchandisingHighAdFeature' | 'mobilesticky' | 'mpu' | 'outOfPage' | 'outstreamDesktop' | 'outstreamGoogleDesktop' | 'outstreamMobile' | 'portrait' | 'skyscraper' | 'video';
8
8
  export declare const adSizes: Record<SizeKeys, AdSize>;
9
9
  export declare const getAdSize: (size: SizeKeys) => AdSize;
10
10
  export declare const _: {
@@ -9,27 +9,27 @@ const createAdSize = (width, height) => {
9
9
  const adSizesPartial = {
10
10
  // standard ad sizes
11
11
  billboard: createAdSize(970, 250),
12
+ halfPage: createAdSize(300, 600),
12
13
  leaderboard: createAdSize(728, 90),
14
+ mobilesticky: createAdSize(320, 50),
13
15
  mpu: createAdSize(300, 250),
14
- halfPage: createAdSize(300, 600),
15
16
  portrait: createAdSize(300, 1050),
16
17
  skyscraper: createAdSize(160, 600),
17
- mobilesticky: createAdSize(320, 50),
18
18
  // dfp proprietary ad sizes
19
19
  fluid: createAdSize(0, 0),
20
- outOfPage: createAdSize(1, 1),
21
20
  googleCard: createAdSize(300, 274),
21
+ outOfPage: createAdSize(1, 1),
22
22
  // guardian proprietary ad sizes
23
- video: createAdSize(620, 1),
23
+ empty: createAdSize(2, 2),
24
+ fabric: createAdSize(88, 71),
25
+ inlineMerchandising: createAdSize(88, 85),
26
+ merchandising: createAdSize(88, 88),
27
+ merchandisingHigh: createAdSize(88, 87),
28
+ merchandisingHighAdFeature: createAdSize(88, 89),
24
29
  outstreamDesktop: createAdSize(620, 350),
25
30
  outstreamGoogleDesktop: createAdSize(550, 310),
26
31
  outstreamMobile: createAdSize(300, 197),
27
- merchandisingHighAdFeature: createAdSize(88, 89),
28
- merchandisingHigh: createAdSize(88, 87),
29
- merchandising: createAdSize(88, 88),
30
- inlineMerchandising: createAdSize(88, 85),
31
- fabric: createAdSize(88, 71),
32
- empty: createAdSize(2, 2),
32
+ video: createAdSize(620, 1),
33
33
  };
34
34
  export const adSizes = {
35
35
  ...adSizesPartial,
@@ -14,3 +14,14 @@ export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments,
14
14
  export { buildAdsConfigWithConsent, disabledAds } from './ad-targeting-youtube';
15
15
  export type { AdsConfig, AdsConfigBasic, AdsConfigDisabled, AdTargetingBuilder, CustomParams, } from './types';
16
16
  export * as constants from './constants';
17
+ export type { ContentTargeting } from './targeting/content';
18
+ export { getContentTargeting } from './targeting/content';
19
+ export type { PersonalisedTargeting } from './targeting/personalised';
20
+ export { getPersonalisedTargeting } from './targeting/personalised';
21
+ export type { SessionTargeting } from './targeting/session';
22
+ export { getSessionTargeting } from './targeting/session';
23
+ export type { SharedTargeting } from './targeting/shared';
24
+ export { getSharedTargeting } from './targeting/shared';
25
+ export type { ViewportTargeting } from './targeting/viewport';
26
+ export { getViewportTargeting } from './targeting/viewport';
27
+ export { pickTargetingValues } from './targeting/pick-targeting-values';
package/dist/esm/index.js CHANGED
@@ -13,3 +13,9 @@ export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments,
13
13
  export { buildAdsConfigWithConsent, disabledAds } from './ad-targeting-youtube';
14
14
  import * as constants_1 from './constants';
15
15
  export { constants_1 as constants };
16
+ export { getContentTargeting } from './targeting/content';
17
+ export { getPersonalisedTargeting } from './targeting/personalised';
18
+ export { getSessionTargeting } from './targeting/session';
19
+ export { getSharedTargeting } from './targeting/shared';
20
+ export { getViewportTargeting } from './targeting/viewport';
21
+ export { pickTargetingValues } from './targeting/pick-targeting-values';
@@ -1,5 +1,5 @@
1
1
  import type { ConditionalExcept } from 'type-fest';
2
- declare type ValidTargetingObject<Base> = ConditionalExcept<Base, null | undefined | '' | readonly [] | readonly [''] | boolean | number>;
2
+ declare type ValidTargetingObject<Base> = ConditionalExcept<Base, null | undefined | '' | readonly [] | readonly [''] | never[] | boolean | number>;
3
3
  /**
4
4
  * Picks only keys with targeting values from an object.
5
5
  * A targeting values is defined as either:
@@ -21,5 +21,5 @@ declare type ValidTargetingObject<Base> = ConditionalExcept<Base, null | undefin
21
21
  * clean.invalid
22
22
  * ```
23
23
  */
24
- export declare const pickTargetingValues: <T extends Record<string, string | readonly string[] | undefined>>(obj: T) => import("type-fest").Except<T, NonNullable<{ [Key in keyof T]: T[Key] extends number | boolean | "" | readonly [] | readonly [""] | null | undefined ? Key : never; }[keyof T]>>;
24
+ export declare const pickTargetingValues: <T extends Record<string, string | readonly string[] | undefined>>(obj: T) => import("type-fest").Except<T, NonNullable<{ [Key in keyof T]: T[Key] extends number | boolean | "" | never[] | readonly [] | readonly [""] | null | undefined ? Key : never; }[keyof T]>>;
25
25
  export {};
@@ -39,4 +39,9 @@ export declare type ViewportTargeting = {
39
39
  */
40
40
  skinsize: 'l' | 's';
41
41
  };
42
- export declare const getViewportTargeting: (viewPortWidth: number, cmpBannerWillShow: boolean) => ViewportTargeting;
42
+ declare type Viewport = {
43
+ viewPortWidth: number;
44
+ cmpBannerWillShow: boolean;
45
+ };
46
+ export declare const getViewportTargeting: ({ viewPortWidth, cmpBannerWillShow, }: Viewport) => ViewportTargeting;
47
+ export {};
@@ -2,12 +2,11 @@
2
2
  const findBreakpoint = (width) => {
3
3
  if (width >= 980)
4
4
  return 'desktop';
5
- if (width >= 740)
5
+ if (width >= 660)
6
6
  return 'tablet';
7
7
  return 'mobile';
8
8
  };
9
- /* -- Targeting -- */
10
- export const getViewportTargeting = (viewPortWidth, cmpBannerWillShow) => {
9
+ export const getViewportTargeting = ({ viewPortWidth, cmpBannerWillShow, }) => {
11
10
  // Don’t show inskin if if a privacy message will be shown
12
11
  const inskin = cmpBannerWillShow ? 'f' : 't';
13
12
  return {
@@ -1,2 +1,7 @@
1
1
  import type { GetThirdPartyTag } from '../types';
2
+ /**
3
+ * tracking pixel
4
+ * https://en-gb.facebook.com/business/learn/facebook-ads-pixel
5
+ * @param {} {shouldRun}
6
+ */
2
7
  export declare const fbPixel: GetThirdPartyTag;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * tracking pixel
3
+ * https://en-gb.facebook.com/business/learn/facebook-ads-pixel
4
+ * @param {} {shouldRun}
5
+ */
1
6
  export const fbPixel = ({ shouldRun }) => ({
2
7
  shouldRun,
3
8
  url: `https://www.facebook.com/tr?id=279880532344561&ev=PageView&noscript=1`,
@@ -1,2 +1,7 @@
1
1
  import type { GetThirdPartyTag } from '../types';
2
+ /**
3
+ * IAS script filters bad ads
4
+ * https://integralads.com/uk/
5
+ * @param {} {shouldRun}
6
+ */
2
7
  export declare const ias: GetThirdPartyTag;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * IAS script filters bad ads
3
+ * https://integralads.com/uk/
4
+ * @param {} {shouldRun}
5
+ */
1
6
  export const ias = ({ shouldRun }) => ({
2
7
  shouldRun,
3
8
  url: '//cdn.adsafeprotected.com/iasPET.1.js',
@@ -1,4 +1,9 @@
1
1
  import type { GetThirdPartyTag } from '../types';
2
+ /**
3
+ * Allows creatives to show survey
4
+ * https://trello.com/c/wHffHVF1/171-integrate-and-test-inizio
5
+ * @param {} {shouldRun}
6
+ */
2
7
  export declare const inizio: GetThirdPartyTag;
3
8
  export declare const _: {
4
9
  onLoad: () => void;
@@ -18,6 +18,11 @@ const onLoad = () => {
18
18
  },
19
19
  });
20
20
  };
21
+ /**
22
+ * Allows creatives to show survey
23
+ * https://trello.com/c/wHffHVF1/171-integrate-and-test-inizio
24
+ * @param {} {shouldRun}
25
+ */
21
26
  export const inizio = ({ shouldRun }) => ({
22
27
  shouldRun,
23
28
  url: '//cdn.brandmetrics.com/survey/script/e96d04c832084488a841a06b49b8fb2d.js',
@@ -1,2 +1,6 @@
1
1
  import type { GetThirdPartyTag } from '../types';
2
+ /**
3
+ * Permutive script updates local user segmentation data
4
+ * @param {} {shouldRun}
5
+ */
2
6
  export declare const permutive: GetThirdPartyTag;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Permutive script updates local user segmentation data
3
+ * @param {} {shouldRun}
4
+ */
1
5
  export const permutive = ({ shouldRun }) => ({
2
6
  shouldRun,
3
7
  url: '//cdn.permutive.com/d6691a17-6fdb-4d26-85d6-b3dd27f55f08-web.js',
@@ -1,2 +1,7 @@
1
1
  import type { GetThirdPartyTag } from '../types';
2
+ /**
3
+ * Google conversion tracking
4
+ * https://support.google.com/google-ads/answer/6095821
5
+ * @param {} {shouldRun}
6
+ */
2
7
  export declare const remarketing: GetThirdPartyTag;
@@ -5,6 +5,11 @@ const onLoad = () => {
5
5
  google_remarketing_only: true,
6
6
  });
7
7
  };
8
+ /**
9
+ * Google conversion tracking
10
+ * https://support.google.com/google-ads/answer/6095821
11
+ * @param {} {shouldRun}
12
+ */
8
13
  export const remarketing = ({ shouldRun }) => ({
9
14
  shouldRun,
10
15
  url: '//www.googleadservices.com/pagead/conversion_async.js',
@@ -1,2 +1,7 @@
1
1
  import type { GetThirdPartyTag } from '../types';
2
+ /**
3
+ * tracking pixel
4
+ * https://business.twitter.com/en/help/campaign-measurement-and-analytics/conversion-tracking-for-websites.html
5
+ * @param {} {shouldRun}
6
+ */
2
7
  export declare const twitter: GetThirdPartyTag;
@@ -1,4 +1,9 @@
1
1
  import { twitterScript as insertSnippet } from '../__vendor/twitter-script';
2
+ /**
3
+ * tracking pixel
4
+ * https://business.twitter.com/en/help/campaign-measurement-and-analytics/conversion-tracking-for-websites.html
5
+ * @param {} {shouldRun}
6
+ */
2
7
  export const twitter = ({ shouldRun }) => ({
3
8
  shouldRun,
4
9
  name: 'twitter',
@@ -1,3 +1,4 @@
1
+ import type { VendorName } from '@guardian/consent-management-platform/dist/types';
1
2
  export declare type TagAttribute = {
2
3
  name: string;
3
4
  value: string;
@@ -10,7 +11,7 @@ export declare type ThirdPartyTag = {
10
11
  loaded?: boolean;
11
12
  onLoad?: () => void;
12
13
  shouldRun: boolean;
13
- name?: string;
14
+ name?: VendorName;
14
15
  url?: string;
15
16
  useImage?: boolean;
16
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/commercial-core",
3
- "version": "0.37.1",
3
+ "version": "0.40.0",
4
4
  "description": "Guardian advertising business logic",
5
5
  "homepage": "https://github.com/guardian/commercial-core#readme",
6
6
  "bugs": {
@@ -41,12 +41,12 @@
41
41
  },
42
42
  "prettier": "@guardian/prettier",
43
43
  "devDependencies": {
44
- "@commitlint/cli": "^15.0.0",
45
- "@commitlint/config-conventional": "^15.0.0",
44
+ "@commitlint/cli": "^16.1.0",
45
+ "@commitlint/config-conventional": "^16.0.0",
46
46
  "@guardian/ab-core": "^2.0.0",
47
- "@guardian/consent-management-platform": "^8.0.1",
47
+ "@guardian/consent-management-platform": "^10.1.0",
48
48
  "@guardian/eslint-config-typescript": "^0.7.0",
49
- "@guardian/libs": "3.5.1",
49
+ "@guardian/libs": "3.6.1",
50
50
  "@guardian/prettier": "^0.7.0",
51
51
  "@octokit/core": "^3.5.1",
52
52
  "@semantic-release/github": "^8.0.2",
@@ -56,6 +56,7 @@
56
56
  "@typescript-eslint/eslint-plugin": "^5.5.0",
57
57
  "@typescript-eslint/parser": "^5.5.0",
58
58
  "commitizen": "^4.2.4",
59
+ "conventional-changelog-conventionalcommits": "^4.6.3",
59
60
  "cz-conventional-changelog": "^3.3.0",
60
61
  "eslint": "^8.4.1",
61
62
  "eslint-config-prettier": "^8.3.0",