@schibsted/pulse-tracker-proxy 1.0.0 → 2.0.0-alpha.2

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ALLOWED_METHODS = exports.MESSAGE_TYPE_RETURN_ERROR = exports.MESSAGE_TYPE_RETURN = exports.MESSAGE_TYPE_INVOKE = exports.MESSAGE_TYPE_ACK = exports.MESSAGE_TYPE_REQUEST = exports.MESSAGE_PREFIX = void 0;
3
+ exports.TPAAS_ALLOWED_METHODS = exports.MESSAGE_TYPE_RETURN_ERROR = exports.MESSAGE_TYPE_RETURN = exports.MESSAGE_TYPE_INVOKE = exports.MESSAGE_TYPE_ACK = exports.MESSAGE_TYPE_REQUEST = exports.MESSAGE_PREFIX = void 0;
4
4
  exports.isPulseProxyMessage = isPulseProxyMessage;
5
5
  // Sync the content between files below this line:
6
6
  exports.MESSAGE_PREFIX = 'pulse-tracker-proxy';
@@ -9,7 +9,54 @@ exports.MESSAGE_TYPE_ACK = `${exports.MESSAGE_PREFIX}:ack`;
9
9
  exports.MESSAGE_TYPE_INVOKE = `${exports.MESSAGE_PREFIX}:invoke`;
10
10
  exports.MESSAGE_TYPE_RETURN = `${exports.MESSAGE_PREFIX}:return`;
11
11
  exports.MESSAGE_TYPE_RETURN_ERROR = `${exports.MESSAGE_PREFIX}:return-error`;
12
- exports.ALLOWED_METHODS = ['track'];
12
+ exports.TPAAS_ALLOWED_METHODS = [
13
+ 'trackAnonymousViewUIElement',
14
+ 'trackEngagementForm',
15
+ 'trackEngagementHealthUIElement',
16
+ 'trackEngagementOffer',
17
+ 'trackEngagementTeaser',
18
+ 'trackEngagementUIElement',
19
+ 'trackEngagementVideo',
20
+ 'trackEngagementVideoAd',
21
+ 'trackEngagementWidget',
22
+ 'trackCompletedHealthAction',
23
+ 'trackImpressionAdSlot',
24
+ 'trackImpressionForm',
25
+ 'trackImpressionHealthUIElement',
26
+ 'trackImpressionOffer',
27
+ 'trackImpressionPlayer',
28
+ 'trackImpressionTeaser',
29
+ 'trackImpressionUIElement',
30
+ 'trackImpressionWidget',
31
+ 'trackLeaveArticle',
32
+ 'trackLeaveAudio',
33
+ 'trackLeaveError',
34
+ 'trackLeaveFrontpage',
35
+ 'trackLeaveLandingpage',
36
+ 'trackLeaveListing',
37
+ 'trackLeaveLockedArticle',
38
+ 'trackLeaveLockedAudio',
39
+ 'trackLeaveLockedVideo',
40
+ 'trackLeavePage',
41
+ 'trackLeaveVideoPage',
42
+ 'trackLeaveWeather',
43
+ 'trackViewArticle',
44
+ 'trackViewAudio',
45
+ 'trackViewError',
46
+ 'trackViewFrontpage',
47
+ 'trackViewHealthPage',
48
+ 'trackViewLandingpage',
49
+ 'trackViewListing',
50
+ 'trackViewLockedArticle',
51
+ 'trackViewLockedAudio',
52
+ 'trackViewLockedVideo',
53
+ 'trackViewPage',
54
+ 'trackViewTitle',
55
+ 'trackViewVideo',
56
+ 'trackViewVideoPage',
57
+ 'trackViewWeather',
58
+ 'trackWatchAudioPlayer',
59
+ ];
13
60
  function isPulseProxyMessage(message) {
14
61
  return (message !== null &&
15
62
  typeof message === 'object' &&
@@ -4,7 +4,7 @@ exports.getPulseTrackerProxy = getPulseTrackerProxy;
4
4
  const consts_1 = require("./consts");
5
5
  const load_autotracker_1 = require("./load-autotracker");
6
6
  const send_message_1 = require("./send-message");
7
- const tracker_proxy_1 = require("./tracker-proxy");
7
+ const tracker_tpaas_proxy_1 = require("./tracker-tpaas-proxy");
8
8
  /**
9
9
  * Pulse Tracker Proxy System Architecture
10
10
  * --------------------------------------
@@ -83,7 +83,7 @@ function getPulseTrackerProxy({ provider, autotrackerVersion = '3', window = glo
83
83
  }
84
84
  clearTimeout(ackTimeout);
85
85
  debug(`[Pulse Tracker Proxy] Ack Request successful (attempt: ${i + 1})`);
86
- return new tracker_proxy_1.PulseTrackerProxyImpl(target, debug);
86
+ return new tracker_tpaas_proxy_1.PulseTpaasProxyImpl(target, debug);
87
87
  }
88
88
  clearTimeout(ackTimeout);
89
89
  debug('[Pulse Tracker Proxy] Retries exhausted. Target did not respond. Failing.');
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.PulseTrackerProxyImpl = void 0;
7
+ exports.decorateWithProxyVersion = decorateWithProxyVersion;
7
8
  const consts_1 = require("./consts");
8
9
  const send_message_1 = require("./send-message");
9
10
  const version_json_1 = __importDefault(require("./version.json"));
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PulseTpaasProxyImpl = void 0;
4
+ exports.createPulseTpaasProxy = createPulseTpaasProxy;
5
+ const consts_1 = require("./consts");
6
+ const tracker_proxy_1 = require("./tracker-proxy");
7
+ const PulseTpaasMethodsMixin = Object.fromEntries(consts_1.TPAAS_ALLOWED_METHODS.map((methodName) => {
8
+ return [
9
+ methodName,
10
+ function (...args) {
11
+ this.debug('[Pulse Tracker Proxy] Calling `track`', args);
12
+ const [input, ...rest] = args;
13
+ const modifiedArgs = [(0, tracker_proxy_1.decorateWithProxyVersion)(input), ...rest];
14
+ return this.invoke({ method: methodName, args: modifiedArgs });
15
+ },
16
+ ];
17
+ }));
18
+ function createPulseTpaasProxy() {
19
+ return class extends tracker_proxy_1.PulseTrackerProxyImpl {
20
+ constructor(target, debug) {
21
+ super(target, debug);
22
+ debug('[Pulse TPaaS Proxy] Initialized');
23
+ Object.assign(this, PulseTpaasMethodsMixin);
24
+ }
25
+ };
26
+ }
27
+ exports.PulseTpaasProxyImpl = createPulseTpaasProxy();
@@ -1 +1 @@
1
- { "PROXY_VERSION": "1.0.0", "GIT_COMMIT": "6ca09707" }
1
+ { "PROXY_VERSION": "2.0.0-alpha.2", "GIT_COMMIT": "83bff6f2" }
@@ -5,7 +5,54 @@ export const MESSAGE_TYPE_ACK = `${MESSAGE_PREFIX}:ack`;
5
5
  export const MESSAGE_TYPE_INVOKE = `${MESSAGE_PREFIX}:invoke`;
6
6
  export const MESSAGE_TYPE_RETURN = `${MESSAGE_PREFIX}:return`;
7
7
  export const MESSAGE_TYPE_RETURN_ERROR = `${MESSAGE_PREFIX}:return-error`;
8
- export const ALLOWED_METHODS = ['track'];
8
+ export const TPAAS_ALLOWED_METHODS = [
9
+ 'trackAnonymousViewUIElement',
10
+ 'trackEngagementForm',
11
+ 'trackEngagementHealthUIElement',
12
+ 'trackEngagementOffer',
13
+ 'trackEngagementTeaser',
14
+ 'trackEngagementUIElement',
15
+ 'trackEngagementVideo',
16
+ 'trackEngagementVideoAd',
17
+ 'trackEngagementWidget',
18
+ 'trackCompletedHealthAction',
19
+ 'trackImpressionAdSlot',
20
+ 'trackImpressionForm',
21
+ 'trackImpressionHealthUIElement',
22
+ 'trackImpressionOffer',
23
+ 'trackImpressionPlayer',
24
+ 'trackImpressionTeaser',
25
+ 'trackImpressionUIElement',
26
+ 'trackImpressionWidget',
27
+ 'trackLeaveArticle',
28
+ 'trackLeaveAudio',
29
+ 'trackLeaveError',
30
+ 'trackLeaveFrontpage',
31
+ 'trackLeaveLandingpage',
32
+ 'trackLeaveListing',
33
+ 'trackLeaveLockedArticle',
34
+ 'trackLeaveLockedAudio',
35
+ 'trackLeaveLockedVideo',
36
+ 'trackLeavePage',
37
+ 'trackLeaveVideoPage',
38
+ 'trackLeaveWeather',
39
+ 'trackViewArticle',
40
+ 'trackViewAudio',
41
+ 'trackViewError',
42
+ 'trackViewFrontpage',
43
+ 'trackViewHealthPage',
44
+ 'trackViewLandingpage',
45
+ 'trackViewListing',
46
+ 'trackViewLockedArticle',
47
+ 'trackViewLockedAudio',
48
+ 'trackViewLockedVideo',
49
+ 'trackViewPage',
50
+ 'trackViewTitle',
51
+ 'trackViewVideo',
52
+ 'trackViewVideoPage',
53
+ 'trackViewWeather',
54
+ 'trackWatchAudioPlayer',
55
+ ];
9
56
  export function isPulseProxyMessage(message) {
10
57
  return (message !== null &&
11
58
  typeof message === 'object' &&
@@ -1,7 +1,7 @@
1
1
  import { MESSAGE_TYPE_REQUEST } from './consts';
2
2
  import { loadAutotracker } from './load-autotracker';
3
3
  import { sendMessage } from './send-message';
4
- import { PulseTrackerProxyImpl } from './tracker-proxy';
4
+ import { PulseTpaasProxyImpl } from './tracker-tpaas-proxy';
5
5
  /**
6
6
  * Pulse Tracker Proxy System Architecture
7
7
  * --------------------------------------
@@ -80,7 +80,7 @@ export function getPulseTrackerProxy({ provider, autotrackerVersion = '3', windo
80
80
  }
81
81
  clearTimeout(ackTimeout);
82
82
  debug(`[Pulse Tracker Proxy] Ack Request successful (attempt: ${i + 1})`);
83
- return new PulseTrackerProxyImpl(target, debug);
83
+ return new PulseTpaasProxyImpl(target, debug);
84
84
  }
85
85
  clearTimeout(ackTimeout);
86
86
  debug('[Pulse Tracker Proxy] Retries exhausted. Target did not respond. Failing.');
@@ -8,7 +8,7 @@ import version from './version.json';
8
8
  * @param input - The original event input to be decorated
9
9
  * @returns The input with added proxyVersion in the tracker object
10
10
  */
11
- function decorateWithProxyVersion(input) {
11
+ export function decorateWithProxyVersion(input) {
12
12
  const tracker = 'tracker' in input && typeof input.tracker === 'object' ? input.tracker : {};
13
13
  return {
14
14
  ...input,
@@ -0,0 +1,23 @@
1
+ import { TPAAS_ALLOWED_METHODS } from './consts';
2
+ import { decorateWithProxyVersion, PulseTrackerProxyImpl } from './tracker-proxy';
3
+ const PulseTpaasMethodsMixin = Object.fromEntries(TPAAS_ALLOWED_METHODS.map((methodName) => {
4
+ return [
5
+ methodName,
6
+ function (...args) {
7
+ this.debug('[Pulse Tracker Proxy] Calling `track`', args);
8
+ const [input, ...rest] = args;
9
+ const modifiedArgs = [decorateWithProxyVersion(input), ...rest];
10
+ return this.invoke({ method: methodName, args: modifiedArgs });
11
+ },
12
+ ];
13
+ }));
14
+ export function createPulseTpaasProxy() {
15
+ return class extends PulseTrackerProxyImpl {
16
+ constructor(target, debug) {
17
+ super(target, debug);
18
+ debug('[Pulse TPaaS Proxy] Initialized');
19
+ Object.assign(this, PulseTpaasMethodsMixin);
20
+ }
21
+ };
22
+ }
23
+ export const PulseTpaasProxyImpl = createPulseTpaasProxy();
@@ -1 +1 @@
1
- { "PROXY_VERSION": "1.0.0", "GIT_COMMIT": "6ca09707" }
1
+ { "PROXY_VERSION": "2.0.0-alpha.2", "GIT_COMMIT": "83bff6f2" }