@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,98 @@
1
+ export type TVideoEventType =
2
+ /**
3
+ * The media has been requested.
4
+ * Currently, it appears this event is only received for pre-roll videos.
5
+ */
6
+ "video:content:request"
7
+ /**
8
+ * The media is ready to play.
9
+ */
10
+ | "video:content:ready"
11
+ /**
12
+ * The media has started playing.
13
+ */
14
+ | "video:content:play"
15
+ /**
16
+ * The media has played a quarter of the way through.
17
+ * Currently, it appears that pre-roll videos do not send this event.
18
+ */
19
+ | "video:content:25"
20
+ /**
21
+ * The media has played half way though.
22
+ * Currently, it appears that pre-roll videos do not send this event.
23
+ */
24
+ | "video:content:50"
25
+ /**
26
+ * The media has played three quarters of the way though.
27
+ * Currently, it appears that pre-roll videos do not send this event.
28
+ */
29
+ | "video:content:75"
30
+ /**
31
+ * The media has played to the end.
32
+ * NB: "END" is a reserved word in thrift apparently
33
+ */
34
+ | "video:content:end";
35
+ /**
36
+ * Details about media playback progress
37
+ * Note: currently only guardian-hosted videos are reported.
38
+ */
39
+ export interface AudioEvent {
40
+ /**
41
+ * The id of the media asset, e.g. gu-audio-454297906
42
+ * This matches up with the media id within the content api.
43
+ */
44
+ id: string;
45
+ /**
46
+ * The event type.
47
+ */
48
+ eventType: TAudioEventType;
49
+ }
50
+ export type TAudioEventType =
51
+ /**
52
+ * The media has been requested.
53
+ * Currently, it appears this event is only received for pre-roll videos.
54
+ */
55
+ "audio:content:request"
56
+ /**
57
+ * The media is ready to play.
58
+ */
59
+ | "audio:content:ready"
60
+ /**
61
+ * The media has started playing.
62
+ */
63
+ | "audio:content:play"
64
+ /**
65
+ * The media has played a quarter of the way through.
66
+ * Currently, it appears that pre-roll videos do not send this event.
67
+ */
68
+ | "audio:content:25"
69
+ /**
70
+ * The media has played half way though.
71
+ * Currently, it appears that pre-roll videos do not send this event.
72
+ */
73
+ | "audio:content:50"
74
+ /**
75
+ * The media has played three quarters of the way though.
76
+ * Currently, it appears that pre-roll videos do not send this event.
77
+ */
78
+ | "audio:content:75"
79
+ /**
80
+ * The media has played to the end.
81
+ * NB: "END" is a reserved word in thrift apparently
82
+ */
83
+ | "audio:content:end";
84
+ /**
85
+ * Details about media playback progress
86
+ * Note: currently only guardian-hosted videos are reported.
87
+ */
88
+ export interface VideoEvent {
89
+ /**
90
+ * The id of the media asset, e.g. gu-video-454297906
91
+ * This matches up with the media id within the content api.
92
+ */
93
+ id: string;
94
+ /**
95
+ * The event type.
96
+ */
97
+ eventType: TVideoEventType;
98
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The platform that served this request to the reader.
3
+ **/
4
+ export type TPlatform = "r2" | "next-gen" | "ios-native-app" | "android-native-app"
5
+ /**
6
+ * Served as a result of embedding a media item on a third party site.
7
+ * Note therefore you should not typically include this as a guardian
8
+ * "page view".
9
+ **/
10
+ | "embed" | "membership" | "facebook-instant-article" | "amp" | "witness" | "jobs" | "contribution" | "yahoo" | "amazon-echo" | "apple-news" | "windows-native-app" | "scribd" | "support" | "subscribe" | "manage-my-account" | "smart-news" | "editions";
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Differentiates between the (many) different types of print product
3
+ **/
4
+ export type TPrintProduct = "voucher-saturday" | "voucher-saturday-plus" | "voucher-weekly-and-saturday" | "voucher-weekly-and-saturday-plus" | "voucher-sunday" | "voucher-sunday-plus"
5
+ /**
6
+ * DEPRECATED DO NOT USE
7
+ * This enum has a spelling mistake. Use VOUCHER_WEEKEND (27) instead
8
+ **/
9
+ | "voucher-weekend"
10
+ /**
11
+ * DEPRECATED DO NOT USE
12
+ * This enum has a spelling mistake. Use VOUCHER_WEEKEND_PLUS (28) instead
13
+ **/
14
+ | "voucher-weekend-plus" | "voucher-sixday" | "voucher-sixday-plus" | "voucher-everyday" | "voucher-everyday-plus" | "home-delivery-saturday" | "home-delivery-saturday-plus" | "home-delivery-weekly-and-saturday" | "home-delivery-weekly-and-saturday-plus" | "home-delivery-sunday" | "home-delivery-sunday-plus" | "home-delivery-weekend" | "home-delivery-weekend-plus" | "home-delivery-sixday" | "home-delivery-sixday-plus" | "home-delivery-everyday" | "home-delivery-everyday-plus" | "guardian-weekly" | "guardian-weekly-plus";
15
+ /**
16
+ * Extra parameters only applicable to print products
17
+ */
18
+ export interface PrintOptions {
19
+ /**
20
+ * Differentiates between the (many) different types of print product
21
+ */
22
+ product: TPrintProduct;
23
+ /**
24
+ * The delivery country of the print subscription
25
+ */
26
+ deliveryCountryCode: string;
27
+ }
@@ -0,0 +1,53 @@
1
+ export type Product =
2
+ /**
3
+ * A one-off contribution
4
+ */
5
+ "CONTRIBUTION"
6
+ /**
7
+ * A recurring contribution
8
+ */
9
+ | "RECURRING_CONTRIBUTION"
10
+ /**
11
+ * A Membership Supporter signup
12
+ */
13
+ | "MEMBERSHIP_SUPPORTER"
14
+ /**
15
+ * A Membership Patron signup
16
+ */
17
+ | "MEMBERSHIP_PATRON"
18
+ /**
19
+ * A Membership Partner signup
20
+ */
21
+ | "MEMBERSHIP_PARTNER"
22
+ /**
23
+ * A digital subscription
24
+ */
25
+ | "DIGITAL_SUBSCRIPTION"
26
+ /**
27
+ * DEPRECATED DO NOT USE
28
+ */
29
+ | "PAPER_SUBSCRIPTION_EVERYDAY"
30
+ /**
31
+ * DEPRECATED DO NOT USE
32
+ */
33
+ | "PAPER_SUBSCRIPTION_SIXDAY"
34
+ /**
35
+ * DEPRECATED DO NOT USE
36
+ */
37
+ | "PAPER_SUBSCRIPTION_WEEKEND"
38
+ /**
39
+ * DEPRECATED DO NOT USE
40
+ */
41
+ | "PAPER_SUBSCRIPTION_SUNDAY"
42
+ /**
43
+ * A paper subscription
44
+ */
45
+ | "PRINT_SUBSCRIPTION"
46
+ /**
47
+ * An app premium tier signup
48
+ */
49
+ | "APP_PREMIUM_TIER"
50
+ /**
51
+ * Supporter plus tier.
52
+ */
53
+ | "SUPPORTER_PLUS";
@@ -0,0 +1,60 @@
1
+ /**
2
+ * What type of subscription the user has (or had) for the app
3
+ */
4
+ export type TSubscriptionType =
5
+ /**
6
+ * No subscription in place, and no previous record of a subscription on this device.
7
+ */
8
+ 1
9
+ /**
10
+ * User has an active subscription via the device's store.
11
+ *
12
+ * In json, "play" or "apple" are supported as synonyms of this value.
13
+ */
14
+ | 2
15
+ /**
16
+ * User has an active subscription as part of a print bundle.
17
+ */
18
+ | 4
19
+ /**
20
+ * No subscription in place, but user did previously have a subscription via the
21
+ * device's store which is now expired.
22
+ *
23
+ * In json, "play:expired" and "apple:expired" are supported as synonyms of this value.
24
+ */
25
+ | 3
26
+ /**
27
+ * No subscription in place, but user did previously have a subscription as
28
+ * part of a print bundle which is now expired.
29
+ *
30
+ * In json, "print:expired" is supported as a synonym of this value.
31
+ */
32
+ | 5
33
+ /**
34
+ * User has an active digital pack subscription.
35
+ */
36
+ | 6;
37
+ /**
38
+ * What tier of membership the user is currently part of.
39
+ */
40
+ export type TMembershipTier =
41
+ /**
42
+ * The user is a friend.
43
+ */
44
+ 1
45
+ /**
46
+ * The user is a Guardian employee.
47
+ */
48
+ | 2
49
+ /**
50
+ * The user is a supporter.
51
+ */
52
+ | 3
53
+ /**
54
+ * The user is a partner.
55
+ */
56
+ | 4
57
+ /**
58
+ * The user is a patron.
59
+ */
60
+ | 5;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * A set of UTM parameters
3
+ * https://en.wikipedia.org/wiki/UTM_parameters
4
+ */
5
+ interface UtmParameters {
6
+ /**
7
+ * Identifies which site sent the traffic
8
+ */
9
+ utmSource?: string;
10
+ /**
11
+ * Identifies what type of link was used, such as cost per click or email.
12
+ */
13
+ utmMedium?: string;
14
+ /**
15
+ * Identifies a specific product promotion or strategic campaign.
16
+ */
17
+ utmCampaign?: string;
18
+ /**
19
+ * Identifies search terms.
20
+ */
21
+ utmTerm?: string;
22
+ /**
23
+ * Identifies what specifically was clicked to bring the user to the site, such as a banner ad or a text link. It is often used for A/B testing and content-targeted ads.
24
+ */
25
+ utmContent?: string;
26
+ }
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,4 @@
1
+ declare namespace _default {
2
+ function init(options: any): void;
3
+ }
4
+ export default _default;
@@ -0,0 +1,5 @@
1
+ declare namespace _default {
2
+ function state(): DocumentVisibilityState;
3
+ let changeEvent: string | undefined;
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,312 @@
1
+ // Generated by CoffeeScript 2.7.0
2
+ // TLDR; This is stripped down from the IAB ad block detection library.
3
+ // https://github.com/InteractiveAdvertisingBureau/AdBlockDetection
4
+ // The aforementioned library is not well maintained
5
+ // and had work in progress network adblocking detection
6
+ var init = function () {
7
+ var ofs = 'offset', cl = 'client';
8
+ var noop = function () { };
9
+ var testedOnce = false;
10
+ var testExecuting = false;
11
+ var isOldIEevents = window.addEventListener === undefined;
12
+ /**
13
+ * Options set with default options initialized
14
+ *
15
+ */
16
+ var _options = {
17
+ loopDelay: 50,
18
+ maxLoop: 5,
19
+ debug: false,
20
+ found: noop,
21
+ notfound: noop,
22
+ complete: noop,
23
+ };
24
+ var listeners = []; // event response listeners
25
+ var baitNode = null;
26
+ var quickBait = {
27
+ cssClass: 'ad-slot pub_300x250 pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links',
28
+ };
29
+ var baitTriggers = {
30
+ nullProps: [ofs + 'Parent'],
31
+ zeroProps: [],
32
+ };
33
+ baitTriggers.zeroProps = [
34
+ ofs + 'Height',
35
+ ofs + 'Left',
36
+ ofs + 'Top',
37
+ ofs + 'Width',
38
+ ofs + 'Height',
39
+ cl + 'Height',
40
+ cl + 'Width',
41
+ ];
42
+ // result object
43
+ var exeResult = {
44
+ quick: null,
45
+ remote: null,
46
+ };
47
+ var findResult = null; // result of test for ad blocker
48
+ var timerIds = {
49
+ test: 0,
50
+ download: 0,
51
+ };
52
+ function isFunc(fn) {
53
+ return typeof fn == 'function';
54
+ }
55
+ /**
56
+ * Make a DOM element
57
+ */
58
+ function makeEl(tag, attributes) {
59
+ var k, v, el, attr = attributes;
60
+ var d = document;
61
+ el = d.createElement(tag);
62
+ if (attr) {
63
+ for (k in attr) {
64
+ if (attr.hasOwnProperty(k)) {
65
+ el.setAttribute(k, attr[k]);
66
+ }
67
+ }
68
+ }
69
+ return el;
70
+ }
71
+ function attachEventListener(dom, eventName, handler) {
72
+ if (isOldIEevents) {
73
+ dom.attachEvent('on' + eventName, handler);
74
+ }
75
+ else {
76
+ dom.addEventListener(eventName, handler, false);
77
+ }
78
+ }
79
+ function log(message, isError) {
80
+ if (!_options.debug && !isError) {
81
+ return;
82
+ }
83
+ if (window.console && window.console.log) {
84
+ if (isError) {
85
+ console.error('[ABD] ' + message);
86
+ }
87
+ else {
88
+ console.log('[ABD] ' + message);
89
+ }
90
+ }
91
+ }
92
+ function beginTest(bait) {
93
+ log('start beginTest');
94
+ if (findResult == true) {
95
+ return;
96
+ }
97
+ testExecuting = true;
98
+ castBait(bait);
99
+ exeResult.quick = 'testing';
100
+ timerIds.test = setTimeout(function () {
101
+ reelIn(bait, 1);
102
+ }, 5);
103
+ }
104
+ /**
105
+ * Create the bait node to see how the browser page reacts
106
+ */
107
+ function castBait(bait) {
108
+ var i, d = document, b = d.body;
109
+ var t;
110
+ var baitStyle = 'width: 1px !important; height: 1px !important; position: absolute !important; left: -10000px !important; top: -1000px !important;';
111
+ if (bait == null || typeof bait == 'string') {
112
+ log('invalid bait being cast');
113
+ return;
114
+ }
115
+ if (bait.style != null) {
116
+ baitStyle += bait.style;
117
+ }
118
+ baitNode = makeEl('div', {
119
+ class: bait.cssClass,
120
+ style: baitStyle,
121
+ });
122
+ log('adding bait node to DOM');
123
+ b.appendChild(baitNode);
124
+ // touch these properties
125
+ for (i = 0; i < baitTriggers.nullProps.length; i++) {
126
+ t = baitNode[baitTriggers.nullProps[i]];
127
+ }
128
+ for (i = 0; i < baitTriggers.zeroProps.length; i++) {
129
+ t = baitNode[baitTriggers.zeroProps[i]];
130
+ }
131
+ }
132
+ /**
133
+ * Run tests to see if browser has taken the bait and blocked the bait element
134
+ */
135
+ function reelIn(bait, attemptNum) {
136
+ var i, k, v;
137
+ var body = document.body;
138
+ var found = false;
139
+ if (baitNode == null) {
140
+ log('recast bait');
141
+ castBait(bait || quickBait);
142
+ }
143
+ if (typeof bait == 'string') {
144
+ log('invalid bait used', true);
145
+ if (clearBaitNode()) {
146
+ setTimeout(function () {
147
+ testExecuting = false;
148
+ }, 5);
149
+ }
150
+ return;
151
+ }
152
+ if (timerIds.test > 0) {
153
+ clearTimeout(timerIds.test);
154
+ timerIds.test = 0;
155
+ }
156
+ // test for issues
157
+ if (body.getAttribute('abp') !== null) {
158
+ log('found adblock body attribute');
159
+ found = true;
160
+ }
161
+ for (i = 0; i < baitTriggers.nullProps.length; i++) {
162
+ if (baitNode[baitTriggers.nullProps[i]] == null) {
163
+ if (attemptNum > 4)
164
+ found = true;
165
+ log('found adblock null attr: ' + baitTriggers.nullProps[i]);
166
+ break;
167
+ }
168
+ if (found == true) {
169
+ break;
170
+ }
171
+ }
172
+ for (i = 0; i < baitTriggers.zeroProps.length; i++) {
173
+ if (found == true) {
174
+ break;
175
+ }
176
+ if (baitNode[baitTriggers.zeroProps[i]] == 0) {
177
+ if (attemptNum > 4)
178
+ found = true;
179
+ log('found adblock zero attr: ' + baitTriggers.zeroProps[i]);
180
+ }
181
+ }
182
+ if (window.getComputedStyle !== undefined) {
183
+ var baitTemp = window.getComputedStyle(baitNode, null);
184
+ if (baitTemp.getPropertyValue('display') == 'none' ||
185
+ baitTemp.getPropertyValue('visibility') == 'hidden') {
186
+ if (attemptNum > 4)
187
+ found = true;
188
+ log('found adblock computedStyle indicator');
189
+ }
190
+ }
191
+ testedOnce = true;
192
+ if (found || attemptNum++ >= _options.maxLoop) {
193
+ findResult = found;
194
+ log('exiting test loop - value: ' + findResult);
195
+ notifyListeners();
196
+ if (clearBaitNode()) {
197
+ setTimeout(function () {
198
+ testExecuting = false;
199
+ }, 5);
200
+ }
201
+ }
202
+ else {
203
+ timerIds.test = setTimeout(function () {
204
+ reelIn(bait, attemptNum);
205
+ }, _options.loopDelay);
206
+ }
207
+ }
208
+ function clearBaitNode() {
209
+ if (baitNode === null) {
210
+ return true;
211
+ }
212
+ try {
213
+ if (isFunc(baitNode.remove)) {
214
+ baitNode.remove();
215
+ }
216
+ document.body.removeChild(baitNode);
217
+ }
218
+ catch (ex) { }
219
+ baitNode = null;
220
+ return true;
221
+ }
222
+ /**
223
+ * Halt the test and any pending timeouts
224
+ */
225
+ function stopFishing() {
226
+ if (timerIds.test > 0) {
227
+ clearTimeout(timerIds.test);
228
+ }
229
+ if (timerIds.download > 0) {
230
+ clearTimeout(timerIds.download);
231
+ }
232
+ clearBaitNode();
233
+ }
234
+ /**
235
+ * Fire all registered listeners
236
+ */
237
+ function notifyListeners() {
238
+ var i, funcs;
239
+ if (findResult === null) {
240
+ return;
241
+ }
242
+ for (i = 0; i < listeners.length; i++) {
243
+ funcs = listeners[i];
244
+ try {
245
+ if (funcs != null) {
246
+ if (isFunc(funcs['complete'])) {
247
+ funcs['complete'](findResult);
248
+ }
249
+ if (findResult && isFunc(funcs['found'])) {
250
+ funcs['found']();
251
+ }
252
+ else if (findResult === false && isFunc(funcs['notfound'])) {
253
+ funcs['notfound']();
254
+ }
255
+ }
256
+ }
257
+ catch (ex) {
258
+ log('Failure in notify listeners ' + ex.Message, true);
259
+ }
260
+ }
261
+ }
262
+ /**
263
+ * Attaches event listener or fires if events have already passed.
264
+ */
265
+ function attachOrFire() {
266
+ var fireNow = false;
267
+ var fn;
268
+ if (document.readyState) {
269
+ if (document.readyState == 'complete') {
270
+ fireNow = true;
271
+ }
272
+ }
273
+ fn = function () {
274
+ beginTest(quickBait, false);
275
+ };
276
+ if (fireNow) {
277
+ fn();
278
+ }
279
+ else {
280
+ attachEventListener(window, 'load', fn);
281
+ }
282
+ }
283
+ /**
284
+ * Public interface of adblock detector
285
+ */
286
+ return function (options) {
287
+ var k, v, funcs;
288
+ if (!options) {
289
+ return;
290
+ }
291
+ funcs = {
292
+ complete: noop,
293
+ found: noop,
294
+ notfound: noop,
295
+ };
296
+ for (k in options) {
297
+ if (options.hasOwnProperty(k)) {
298
+ if (k == 'complete' || k == 'found' || k == 'notFound') {
299
+ funcs[k.toLowerCase()] = options[k];
300
+ }
301
+ else {
302
+ _options[k] = options[k];
303
+ }
304
+ }
305
+ }
306
+ listeners.push(funcs);
307
+ attachOrFire();
308
+ };
309
+ };
310
+ export default {
311
+ init: init(),
312
+ };
@@ -0,0 +1,22 @@
1
+ export default {
2
+ state: () => document.visibilityState ||
3
+ document.webkitVisibilityState ||
4
+ document.mozVisibilityState ||
5
+ document.msVisibilityState,
6
+ changeEvent: getChangeEvent(),
7
+ };
8
+ function getChangeEvent() {
9
+ if (document.visibilityState) {
10
+ return 'visibilitychange';
11
+ }
12
+ else if (document.webkitVisibilityState) {
13
+ return 'webkitvisibilitychange';
14
+ }
15
+ else if (document.mozVisibilityState) {
16
+ return 'mozvisibilitychange';
17
+ }
18
+ else if (document.msVisibilityState) {
19
+ return 'msvisibilitychange';
20
+ }
21
+ return undefined;
22
+ }
@@ -1,11 +1,8 @@
1
1
  // Generated by CoffeeScript 2.7.0
2
2
  import core from './core.js';
3
-
4
- import transmit from './transmit.js';
5
-
3
+ import transmit from './transmit';
6
4
  core.init('witness');
7
-
8
5
  export default {
9
- record: transmit.sendMore,
10
- viewId: transmit.viewId,
6
+ record: transmit.sendMore,
7
+ viewId: transmit.viewId,
11
8
  };