@guardian/ophan-tracker-js 2.1.1 → 2.1.2-next.1

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 (115) hide show
  1. package/NPM-dist/adblock-detection.js +20 -0
  2. package/NPM-dist/attention.js +126 -0
  3. package/NPM-dist/campaign.js +23 -0
  4. package/NPM-dist/click-path-capture.js +68 -0
  5. package/NPM-dist/components.js +168 -0
  6. package/{assets → NPM-dist}/contribution.js +4 -13
  7. package/NPM-dist/core.js +230 -0
  8. package/{assets → NPM-dist}/embed.js +3 -6
  9. package/{assets → NPM-dist}/fb-instant.js +2 -5
  10. package/NPM-dist/heatmap.js +34 -0
  11. package/{assets → NPM-dist}/holidays.js +3 -6
  12. package/{assets → NPM-dist}/http-status.js +4 -6
  13. package/NPM-dist/iframe-tracking.js +80 -0
  14. package/NPM-dist/interactive.js +17 -0
  15. package/{assets → NPM-dist}/jobs-courses.js +3 -6
  16. package/{assets → NPM-dist}/jobs.js +3 -6
  17. package/NPM-dist/manage-my-account.js +29 -0
  18. package/{assets → NPM-dist}/membership.js +4 -13
  19. package/NPM-dist/ng.js +46 -0
  20. package/NPM-dist/perf.js +36 -0
  21. package/NPM-dist/privatebrowsing.js +66 -0
  22. package/{assets → NPM-dist}/r2.js +3 -12
  23. package/{assets → NPM-dist}/smart-news.js +4 -10
  24. package/NPM-dist/support.js +28 -0
  25. package/NPM-dist/tests/click-path-capture.test.js +44 -0
  26. package/NPM-dist/tests/components.test.js +47 -0
  27. package/NPM-dist/tests/core.test.js +161 -0
  28. package/NPM-dist/tests/heatmap.test.js +45 -0
  29. package/NPM-dist/tests/transmit.test.js +118 -0
  30. package/NPM-dist/transmit.js +126 -0
  31. package/NPM-dist/types/abtest.js +1 -0
  32. package/NPM-dist/types/acquisition.js +1 -0
  33. package/NPM-dist/types/adblock-detection.d.ts +4 -0
  34. package/NPM-dist/types/attention.d.ts +9 -0
  35. package/NPM-dist/types/campaign.d.ts +1 -0
  36. package/NPM-dist/types/click-path-capture.d.ts +14 -0
  37. package/NPM-dist/types/component-event.js +1 -0
  38. package/NPM-dist/types/component-type.js +1 -0
  39. package/NPM-dist/types/components.d.ts +60 -0
  40. package/NPM-dist/types/consent.js +1 -0
  41. package/NPM-dist/types/contribution.d.ts +5 -0
  42. package/NPM-dist/types/core.d.ts +64 -0
  43. package/NPM-dist/types/embed.d.ts +5 -0
  44. package/NPM-dist/types/event.js +1 -0
  45. package/NPM-dist/types/fb-instant.d.ts +4 -0
  46. package/NPM-dist/types/heatmap.d.ts +5 -0
  47. package/NPM-dist/types/holidays.d.ts +5 -0
  48. package/NPM-dist/types/http-status.d.ts +5 -0
  49. package/NPM-dist/types/iframe-tracking.d.ts +1 -0
  50. package/NPM-dist/types/inpageclick.js +1 -0
  51. package/NPM-dist/types/interaction.js +1 -0
  52. package/NPM-dist/types/interactive.d.ts +1 -0
  53. package/NPM-dist/types/jobs-courses.d.ts +5 -0
  54. package/NPM-dist/types/jobs.d.ts +5 -0
  55. package/NPM-dist/types/link.js +1 -0
  56. package/NPM-dist/types/manage-my-account.d.ts +7 -0
  57. package/NPM-dist/types/media.js +1 -0
  58. package/NPM-dist/types/membership.d.ts +5 -0
  59. package/NPM-dist/types/ng.d.ts +26 -0
  60. package/NPM-dist/types/perf.d.ts +2 -0
  61. package/NPM-dist/types/platform.js +1 -0
  62. package/NPM-dist/types/printproduct.js +1 -0
  63. package/NPM-dist/types/privatebrowsing.d.ts +6 -0
  64. package/NPM-dist/types/product.js +1 -0
  65. package/NPM-dist/types/r2.d.ts +4 -0
  66. package/NPM-dist/types/smart-news.d.ts +5 -0
  67. package/NPM-dist/types/subscription.js +1 -0
  68. package/NPM-dist/types/support.d.ts +9 -0
  69. package/NPM-dist/types/tests/click-path-capture.test.d.ts +1 -0
  70. package/NPM-dist/types/tests/components.test.d.ts +1 -0
  71. package/NPM-dist/types/tests/core.test.d.ts +1 -0
  72. package/NPM-dist/types/tests/heatmap.test.d.ts +1 -0
  73. package/NPM-dist/types/tests/transmit.test.d.ts +1 -0
  74. package/NPM-dist/types/transmit.d.ts +17 -0
  75. package/NPM-dist/types/types/abtest.d.ts +28 -0
  76. package/NPM-dist/types/types/acquisition.d.ts +116 -0
  77. package/NPM-dist/types/types/component-event.d.ts +86 -0
  78. package/NPM-dist/types/types/component-type.d.ts +1 -0
  79. package/NPM-dist/types/types/consent.d.ts +40 -0
  80. package/NPM-dist/types/types/event.d.ts +106 -0
  81. package/NPM-dist/types/types/inpageclick.d.ts +11 -0
  82. package/NPM-dist/types/types/interaction.d.ts +17 -0
  83. package/NPM-dist/types/types/link.d.ts +14 -0
  84. package/NPM-dist/types/types/media.d.ts +98 -0
  85. package/NPM-dist/types/types/platform.d.ts +10 -0
  86. package/NPM-dist/types/types/printproduct.d.ts +27 -0
  87. package/NPM-dist/types/types/product.d.ts +53 -0
  88. package/NPM-dist/types/types/subscription.d.ts +60 -0
  89. package/NPM-dist/types/types/utmparameters.d.ts +26 -0
  90. package/NPM-dist/types/utmparameters.js +1 -0
  91. package/NPM-dist/types/vendor/adBlockDetectionLib.d.ts +4 -0
  92. package/NPM-dist/types/visibility.d.ts +5 -0
  93. package/NPM-dist/types/witness.d.ts +5 -0
  94. package/NPM-dist/vendor/adBlockDetectionLib.js +312 -0
  95. package/NPM-dist/visibility.js +22 -0
  96. package/{assets → NPM-dist}/witness.js +3 -6
  97. package/package.json +18 -8
  98. package/readme.md +98 -11
  99. package/assets/adblock-detection.js +0 -19
  100. package/assets/attention.js +0 -160
  101. package/assets/campaign.js +0 -25
  102. package/assets/click-path-capture.js +0 -80
  103. package/assets/components.js +0 -199
  104. package/assets/core.js +0 -282
  105. package/assets/heatmap.js +0 -53
  106. package/assets/iframe-tracking.js +0 -88
  107. package/assets/interactive.js +0 -17
  108. package/assets/manage-my-account.js +0 -38
  109. package/assets/ng.js +0 -41
  110. package/assets/perf.js +0 -40
  111. package/assets/privatebrowsing.js +0 -71
  112. package/assets/support.js +0 -34
  113. package/assets/transmit.js +0 -143
  114. package/assets/vendor/adBlockDetectionLib.js +0 -366
  115. package/assets/visibility.js +0 -23
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ declare namespace _default {
2
+ let record: (obj: import("./ng.js").EventPayload, f?: (() => void) | undefined) => void;
3
+ let viewId: string;
4
+ }
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ declare namespace _default {
2
+ let record: (obj: import("./ng.js").EventPayload, f?: (() => void) | undefined) => void;
3
+ let viewId: string;
4
+ }
5
+ export default _default;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export default exports;
2
+ declare namespace exports {
3
+ export { sendInitialEvent };
4
+ export let record: (obj: import("./ng.js").EventPayload, f?: (() => void) | undefined) => void;
5
+ export let viewId: string;
6
+ }
7
+ declare function sendInitialEvent(url?: string, referrer?: string): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ declare namespace _default {
2
+ let record: (obj: import("./ng.js").EventPayload, f?: (() => void) | undefined) => void;
3
+ let viewId: string;
4
+ }
5
+ export default _default;
@@ -0,0 +1,26 @@
1
+ import './click-path-capture';
2
+ import './perf';
3
+ import './iframe-tracking';
4
+ export * from './types/abtest';
5
+ export * from './types/acquisition';
6
+ export * from './types/subscription';
7
+ export * from './types/interaction';
8
+ export * from './types/inpageclick';
9
+ export * from './types/printproduct';
10
+ export * from './types/product';
11
+ export * from './types/platform';
12
+ export * from './types/media';
13
+ export * from './types/consent';
14
+ export * from './types/component-type';
15
+ export * from './types/component-event';
16
+ export * from './types/event';
17
+ import { EventPayload } from "./types/event";
18
+ interface NG {
19
+ record: (event: EventPayload, callback?: Function) => void;
20
+ pageViewId: string;
21
+ viewId: string;
22
+ trackComponentAttention: (name: string, el: HTMLElement, visibilityThreshold: number) => void;
23
+ setEventEmitter: (event: Object) => void;
24
+ }
25
+ declare let ng: NG;
26
+ export default ng;
@@ -0,0 +1,2 @@
1
+ export default perf;
2
+ declare const perf: Performance;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ declare namespace _default {
2
+ export function init(): void;
3
+ export { privateBrowsingMode };
4
+ }
5
+ export default _default;
6
+ declare function privateBrowsingMode(callback: any): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ declare namespace _default {
2
+ let viewId: string;
3
+ }
4
+ export default _default;
@@ -0,0 +1,5 @@
1
+ declare namespace _default {
2
+ let record: (obj: import("./ng.js").EventPayload, f?: (() => void) | undefined) => void;
3
+ let viewId: string;
4
+ }
5
+ export default _default;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ declare namespace _default {
2
+ export { init };
3
+ export { sendInitialEvent };
4
+ export let record: (obj: import("./ng.js").EventPayload, f?: (() => void) | undefined) => void;
5
+ export let viewId: string;
6
+ }
7
+ export default _default;
8
+ declare function init(): void;
9
+ declare function sendInitialEvent(url?: string, referrer?: string): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import { EventPayload } from "./types/event";
2
+ declare const _default: {
3
+ sendInitial: (obj: Record<string, any>) => void;
4
+ sendMore: (obj: EventPayload, f?: (() => void) | undefined) => void;
5
+ viewId: string;
6
+ bumpViewId: () => void;
7
+ };
8
+ export default _default;
9
+ /**
10
+ * Exports for testing purposes.
11
+ */
12
+ export declare const _testExports: {
13
+ generatePageViewId: () => string;
14
+ smartEncode: (value: string | number) => string;
15
+ isDefined: (v: any) => boolean;
16
+ buildQueryString: (obj: Record<string, any>) => string;
17
+ };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Represents the AbTest on the web and apps
3
+ */
4
+ export interface AbTest {
5
+ /**
6
+ * the test that the user is participating in
7
+ */
8
+ name: string;
9
+ /**
10
+ * the variant that they are seeing
11
+ */
12
+ variant: string;
13
+ /**
14
+ * whether the test has been completed or not
15
+ */
16
+ complete?: boolean;
17
+ /**
18
+ * the campaign codes associated with the variant
19
+ */
20
+ campaignCodes?: Array<string>;
21
+ }
22
+ export interface AbTestInfo {
23
+ /**
24
+ * On the left-hand side of the map, .
25
+ * On the right-hand side of the map, the variant that they are seeing.
26
+ */
27
+ tests: Array<AbTest>;
28
+ }
@@ -0,0 +1,116 @@
1
+ import type { AbTestInfo } from "./abtest";
2
+ import type { PrintOptions } from "./printproduct";
3
+ import type { TComponentType } from "./component-type";
4
+ import type { TPlatform } from "./platform";
5
+ import type { Product } from "./product";
6
+ /**
7
+ * A query string parameter
8
+ */
9
+ export type QueryParameter = {
10
+ /**
11
+ * The name of the query string parameter
12
+ */
13
+ name: string;
14
+ /**
15
+ * The value of the query string parameter
16
+ */
17
+ value: string;
18
+ };
19
+ export type TPaymentFrequency = "ONE_OFF" | "MONTHLY" | "ANNUALLY" | "QUARTERLY" | "SIX_MONTHLY";
20
+ export type TPaymentProvider = "STRIPE" | "PAYPAL" | "GOCARDLESS" | "IN_APP_PURCHASE" | "STRIPE_APPLE_PAY" | "STRIPE_PAYMENT_REQUEST_BUTTON" | "SUBSCRIBE_WITH_GOOGLE" | "AMAZON_PAY" | "STRIPE_SEPA";
21
+ export type TAcquisitionSource = "GUARDIAN_WEB" |
22
+ /**
23
+ * @deprecated DO NOT USE
24
+ */
25
+ "GUARDIAN_APPS" | "EMAIL" | "SOCIAL" | "SEARCH" | "PPC" | "DIRECT" | "GUARDIAN_APP_IOS" | "GUARDIAN_APP_ANDROID" | "APPLE_NEWS" | "GOOGLE_AMP" | "YOUTUBE";
26
+ /**
27
+ * Represents monetary contribution made by a reader via this page.
28
+ */
29
+ export interface Acquisition {
30
+ /**
31
+ * Product type
32
+ */
33
+ product: Product;
34
+ /**
35
+ * If the payment is a one off or reccuring
36
+ */
37
+ paymentFrequency: TPaymentFrequency;
38
+ /**
39
+ * Currency code (ISO 4217 3-character, upper-case, eg USD, GBP)
40
+ */
41
+ currency: string;
42
+ /**
43
+ * Contributed amount in units of the currency received
44
+ */
45
+ amount: number;
46
+ /**
47
+ * The payment provider the user paid with
48
+ */
49
+ paymentProvider?: TPaymentProvider;
50
+ /**
51
+ * The campaign code of the campaign that the user came from
52
+ */
53
+ campaignCode?: Array<string>;
54
+ /**
55
+ * The ab tests the user was in on dotcom
56
+ */
57
+ abTests?: AbTestInfo;
58
+ /**
59
+ * ISO-3166-aplha-2 country code representing where the user is from. It is either the country of the card used, or the country of the contributor's address
60
+ */
61
+ countryCode?: string;
62
+ /**
63
+ * Page view id of the page the reader was on that lead them through to the contribution page e.g. by clicking on the Contribute Now button in the Epic component
64
+ */
65
+ referrerPageViewId?: string;
66
+ /**
67
+ * Url of the page the reader was on that lead them through to the contribution page e.g. by clicking on the Contribute Now button in the Epic component
68
+ */
69
+ referrerUrl?: string;
70
+ /**
71
+ * An ID that can be used to distinguish different instances of a given component type
72
+ */
73
+ componentId?: string;
74
+ /**
75
+ * The type of component that the acquisition came from
76
+ */
77
+ componentTypeV2?: TComponentType;
78
+ /**
79
+ * The source of the acquisition
80
+ */
81
+ source?: TAcquisitionSource;
82
+ /**
83
+ * Extra parameters only applicable to print products
84
+ */
85
+ printOptions?: PrintOptions;
86
+ /**
87
+ * Platform on which the acquisition occurred e.g. Contributions, S&C
88
+ */
89
+ platform?: TPlatform;
90
+ /**
91
+ * Length of the discount in months
92
+ */
93
+ discountLengthInMonths?: number;
94
+ /**
95
+ * Amount of discount, as a percentage
96
+ */
97
+ discountPercentage?: number;
98
+ /**
99
+ * Promo code for the acquisition. Only applicable to subscriptions.
100
+ */
101
+ promoCode?: string;
102
+ /**
103
+ * Any additional labels.
104
+ * In particular, extra information that is needed to calculate Annualised Value
105
+ * for this Acquisition (e.g. promotions like Guardian Weekly Six For Six) can go here.
106
+ */
107
+ labels?: Array<string>;
108
+ /**
109
+ * The identity id of a user
110
+ */
111
+ identityId?: string;
112
+ /**
113
+ * Query string parameters associated with an acquisition
114
+ */
115
+ queryParameters?: Array<QueryParameter>;
116
+ }
@@ -0,0 +1,86 @@
1
+ import type { AbTest } from "./abtest";
2
+ import type { Product } from "./product";
3
+ import { TComponentType } from "./component-type";
4
+ export type TAction =
5
+ /**
6
+ * The component was inserted into its container (e.g. a web page or view in an app)
7
+ **/
8
+ "INSERT"
9
+ /**
10
+ * The component was in view on screen
11
+ **/
12
+ | "VIEW"
13
+ /**
14
+ * The component was expanded (e.g. "see more").
15
+ * Not a navigation away to another page
16
+ **/
17
+ | "EXPAND"
18
+ /**
19
+ * A "like", thumbs up, etc.
20
+ **/
21
+ | "LIKE"
22
+ /**
23
+ * A "dislike", thumbs down, etc.
24
+ **/
25
+ | "DISLIKE"
26
+ /**
27
+ * A subscription to a service, newsletter, etc.
28
+ **/
29
+ | "SUBSCRIBE"
30
+ /**
31
+ * Selection of an answer in a quiz
32
+ **/
33
+ | "ANSWER"
34
+ /**
35
+ * A vote in a poll
36
+ **/
37
+ | "VOTE"
38
+ /**
39
+ * A single click on the component which is not covered by
40
+ * any of the existing Actions.
41
+ **/
42
+ | "CLICK"
43
+ /**
44
+ * User sign in to Guardian Identity account
45
+ **/
46
+ | "SIGN_IN"
47
+ /**
48
+ * User creates a Guardian Identity account
49
+ **/
50
+ | "CREATE_ACCOUNT"
51
+ /**
52
+ * User Consent
53
+ **/
54
+ | "ACCEPT_DEFAULT_CONSENT" | "MANAGE_CONSENT" | "CONSENT_ACCEPT_ALL" | "CONSENT_REJECT_ALL"
55
+ /**
56
+ * The component sticks in the screen
57
+ **/
58
+ | "STICK"
59
+ /**
60
+ * The component is closed
61
+ **/
62
+ | "CLOSE"
63
+ /**
64
+ * The component is returned to its original location
65
+ **/
66
+ | "RETURN";
67
+ export interface Component {
68
+ name: string;
69
+ loadTimeMs?: number;
70
+ }
71
+ interface ComponentV2 {
72
+ componentType: TComponentType;
73
+ id?: string;
74
+ products?: Array<Product>;
75
+ campaignCode?: string;
76
+ labels?: Array<string>;
77
+ }
78
+ export interface ComponentEvent {
79
+ component: ComponentV2;
80
+ action: TAction;
81
+ value?: string;
82
+ id?: string;
83
+ abTest?: AbTest;
84
+ targetingAbTest?: AbTest;
85
+ }
86
+ export {};
@@ -0,0 +1 @@
1
+ export type TComponentType = "READERS_QUESTIONS_ATOM" | "QANDA_ATOM" | "PROFILE_ATOM" | "GUIDE_ATOM" | "TIMELINE_ATOM" | "NEWSLETTER_SUBSCRIPTION" | "SURVEYS_QUESTIONS" | "ACQUISITIONS_EPIC" | "ACQUISITIONS_ENGAGEMENT_BANNER" | "ACQUISITIONS_THANK_YOU_EPIC" | "ACQUISITIONS_HEADER" | "ACQUISITIONS_FOOTER" | "ACQUISITIONS_INTERACTIVE_SLICE" | "ACQUISITIONS_NUGGET" | "ACQUISITIONS_STANDFIRST" | "ACQUISITIONS_THRASHER" | "ACQUISITIONS_EDITORIAL_LINK" | "ACQUISITIONS_MANAGE_MY_ACCOUNT" | "ACQUISITIONS_BUTTON" | "ACQUISITIONS_OTHER" | "APP_ADVERT" | "APP_AUDIO" | "APP_BUTTON" | "APP_CARD" | "APP_CROSSWORDS" | "APP_ENGAGEMENT_BANNER" | "APP_EPIC" | "APP_GALLERY" | "APP_LINK" | "APP_NAVIGATION_ITEM" | "APP_SCREEN" | "APP_THRASHER" | "APP_VIDEO" | "AUDIO_ATOM" | "CHART_ATOM" | "ACQUISITIONS_MERCHANDISING" | "ACQUISITIONS_HOUSE_ADS" | "SIGN_IN_GATE" | "ACQUISITIONS_SUBSCRIPTIONS_BANNER" | "MOBILE_STICKY_AD" | "IDENTITY_AUTHENTICATION" | "RETENTION_ENGAGEMENT_BANNER" | "ACQUISITION_SUPPORT_SITE" | "RETENTION_EPIC" | "CONSENT" | "LIVE_BLOG_PINNED_POST" | "STICKY_VIDEO" | "KEY_EVENT_CARD" | "RETENTION_HEADER" | "SLIDESHOW" | "APP_FEATURE" | "CARD" | "CAROUSEL" | "CONTAINER";
@@ -0,0 +1,40 @@
1
+ /** A user’s recorded tracking consent. Because the consent data can come in
2
+ * different formats from different sources, the jurisdiction field determines
3
+ * the format of consentData.
4
+ **/
5
+ export interface Consent {
6
+ /**
7
+ * The jurisdiction is a tag for the consent data: TCF, CCPA, or AUS if the
8
+ * consent has been successfully parsed in one of those formats; or
9
+ * OTHER otherwise.
10
+ **/
11
+ consentJurisdiction: TJurisdiction;
12
+ /**
13
+ * If the jurisdiction is TCF, CCPA, or AUS, consentData contains a
14
+ * successfully interpreted consent value the corresponding type (for TCF
15
+ * this is a base-64-encoded consent string, and for CCPA and AUS it’s
16
+ * either the string "true" or "false" – where "true" means the user has
17
+ * given their consent). If the jurisdiction is OTHER, then consentData
18
+ * contains the unparsed consent data, in the format
19
+ * key1:value1,key2:value2,….
20
+ **/
21
+ consent: string;
22
+ /**
23
+ * consentUUID is an identifier for the consent, for debugging.
24
+ **/
25
+ consentUUID?: string;
26
+ /**
27
+ * cmp version for debugging
28
+ **/
29
+ cmpVersion?: string;
30
+ }
31
+ /**
32
+ * For a recognised/successfully parsed consent, a value of TCF, USNAT, CCPA, or AUS
33
+ * indicates which jurisdiction the consent is for. OTHER marks a consent
34
+ * that was not successfully parsed into one of these formats.
35
+ *
36
+ * - TCF is Europe’s [Transparency & Consent Framework](https://iabeurope.eu/transparency-consent-framework/).
37
+ * - CCPA is the [California Consumer Privacy Act](https://oag.ca.gov/privacy/ccpa). This has now been deprecated and replaced by USNAT: https://github.com/guardian/ophan/pull/5974
38
+ * - AUS is for Australian consents, using a version of the CCPA.
39
+ **/
40
+ export type TJurisdiction = "TCF" | "USNAT" | "CCPA" | "AUS" | "OTHER";
@@ -0,0 +1,106 @@
1
+ import type { Consent } from "./consent";
2
+ import type { ComponentEvent } from "./component-event";
3
+ import type { InPageClick } from "./inpageclick";
4
+ import type { AbTestInfo } from "./abtest";
5
+ import type { AudioEvent, VideoEvent } from "./media";
6
+ import type { TMembershipTier, TSubscriptionType } from "./subscription";
7
+ import type { TPlatform } from "./platform";
8
+ import type { Acquisition } from "./acquisition";
9
+ import { Interaction } from "./interaction";
10
+ /**
11
+ * Details about a page view - only populated for _PAGE_VIEW
12
+ * event types
13
+ **/
14
+ interface PageView {
15
+ /** Url of the page served */
16
+ url: string;
17
+ /** The platform that served this page */
18
+ platform?: TPlatform;
19
+ /** Some approximation of the content type */
20
+ contentType?: string;
21
+ /** URL of the referrer to this page view */
22
+ ref?: string;
23
+ /** The number of days in the previous week that the device has had a page view */
24
+ daysVisitedInLastWeek?: number;
25
+ /** Total number of days on which this browser has visited the guardian */
26
+ totalDaysVisited?: number;
27
+ /** Calculated average days between recent visits */
28
+ averageDaysBetweenRecentVisits?: number;
29
+ /** Is this browser a regular visitor to the Guardian */
30
+ regular?: boolean;
31
+ subscriptionType?: TSubscriptionType;
32
+ membershipTier?: TMembershipTier;
33
+ navigationType?: PerformanceNavigationTiming["type"];
34
+ from?: string;
35
+ to?: string;
36
+ tz?: string;
37
+ visibilityState?: string;
38
+ }
39
+ export interface AttentionTime {
40
+ /** Attention time spent on this page view in milliseconds */
41
+ attentionMs: number;
42
+ /** Map of component name to time in ms */
43
+ componentAttention?: {
44
+ [key: string]: number;
45
+ };
46
+ }
47
+ interface AssetPerformanceData {
48
+ /** The name of the metric being captured */
49
+ name: string;
50
+ /** Value of window.performance.now at which metric was captured */
51
+ timing: number;
52
+ }
53
+ interface WebPerformanceData {
54
+ /** Time in ms that dns lookup took */
55
+ dns: number;
56
+ /** Time in ms that connection to the server took */
57
+ connection: number;
58
+ /** Time to first byte */
59
+ firstByte: number;
60
+ /** First byte to last byte */
61
+ lastByte: number;
62
+ /** From last byte of doc to start of domContentLoaded */
63
+ domContentLoadedEvent: number;
64
+ /** domContentLoaded to start of load event */
65
+ loadEvent: number;
66
+ /** The navigation type */
67
+ navType: number;
68
+ /** Number of redirects on current domain */
69
+ redirectCount: number;
70
+ /** List of custom Asset performance data */
71
+ assetsPerformance?: AssetPerformanceData[];
72
+ }
73
+ interface Component {
74
+ /** The name of this component */
75
+ name: string;
76
+ /** How long, in milliseconds, that the component took to load */
77
+ loadTimeMs?: number;
78
+ }
79
+ interface LazyComponents {
80
+ /** The set of components that were loaded lazily on this page */
81
+ components: Component[];
82
+ }
83
+ export type TEdition = "UK" | "US" | "AU" | "International" | "Europe";
84
+ export interface EventPayload extends Partial<Consent> {
85
+ /** If the user is logged in, the identity user id */
86
+ userId?: string;
87
+ pageView?: PageView;
88
+ attention?: AttentionTime;
89
+ performance?: WebPerformanceData;
90
+ audio?: AudioEvent;
91
+ video?: VideoEvent;
92
+ ab?: AbTestInfo;
93
+ lazyComponents?: LazyComponents;
94
+ inPageClick?: InPageClick;
95
+ interaction?: Interaction;
96
+ inPrivateBrowsingMode?: boolean;
97
+ adUnitWasHidden?: boolean;
98
+ acquisition?: Acquisition;
99
+ componentEvent?: ComponentEvent;
100
+ /** Experience contains information about the rendering of the page, e.g.: dotcom-rendering */
101
+ experiences?: Array<string>;
102
+ edition?: TEdition;
103
+ /** The set of component names that were rendered on this page, e.g.: ["nav3","nav2","sub-nav","footer"] */
104
+ renderedComponents?: Array<string>;
105
+ }
106
+ export {};
@@ -0,0 +1,11 @@
1
+ import { LinkName } from "./link";
2
+ export interface InPageClick {
3
+ /**
4
+ * the component that contained the item clicked on
5
+ */
6
+ component?: string;
7
+ /**
8
+ * The link name associated with the element clicked.
9
+ */
10
+ linkName?: LinkName;
11
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Represents an interaction on the web or apps
3
+ */
4
+ export interface Interaction {
5
+ /**
6
+ * Key for the interaction.
7
+ */
8
+ component: string;
9
+ /**
10
+ * Value associated with the interaction
11
+ */
12
+ value?: string;
13
+ /**
14
+ * The id of the atom that the interaction has come from
15
+ */
16
+ atomId?: string;
17
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Represents the position and location of a link within the Guardian site.
3
+ * We hope to enhance this structure to include a better representation of what the links
4
+ * actually mean, but for now we just report exactly what the web site tells us,
5
+ * which is a hierarchical list of named items e.g.
6
+ * "more","container-2 | highlights","Front | /uk"
7
+ * "article","news | group-1+ | card-3","container-1 | headlines","Front | /uk"
8
+ */
9
+ export type LinkName = {
10
+ /**
11
+ * List of link names, most specific first
12
+ */
13
+ raw?: string[];
14
+ };