diff --git a/lib/recurly.js b/lib/recurly.js index 01e017e82..42424cc64 100644 --- a/lib/recurly.js +++ b/lib/recurly.js @@ -68,6 +68,7 @@ const DEFAULTS = { litle: { sessionId: undefined }, braintree: { deviceData: undefined } }, + report: false, risk: { threeDSecure: { preflightDeviceDataCollector: true } }, @@ -142,11 +143,14 @@ export class Recurly extends Emitter { this.readyState = 0; this.request = new Request({ recurly: this }); this.config = deepAssign({}, DEFAULTS); + if (options) this.configure(options); + this.bankAccount = { token: bankAccount.token.bind(this), bankInfo: bankAccount.bankInfo.bind(this) }; + this.reporter = new Reporter({ recurly: this }); this.Pricing = () => new SubscriptionPricing(this); // deprecated @@ -222,6 +226,8 @@ export class Recurly extends Emitter { * @param {Boolean} [options.cors] Enables data transmission over XHR+CORS * @param {Array} [options.required] Adds additional field requirements for * tokenization. ex: ['cvv'] + * @param {Boolean} [options.report] Enables remote event reports + * * @public */ configure (options) { @@ -262,6 +268,10 @@ export class Recurly extends Emitter { deepAssign(this.config.risk, options.risk); } + if ('report' in options) { + this.config.report = options.report; + } + if ('parent' in options) { this.config.parent = options.parent; } diff --git a/lib/recurly/reporter.js b/lib/recurly/reporter.js index 4ce51d24d..2ada802a6 100644 --- a/lib/recurly/reporter.js +++ b/lib/recurly/reporter.js @@ -55,7 +55,7 @@ export class Reporter { * @private */ get shouldDispatch () { - return this.recurly.isParent; + return this.recurly.isParent && this.recurly.config.report; } /** diff --git a/test/e2e/support/snapshots/desktop_edge/Edge-Remote/elements/card-element-945x1020.png b/test/e2e/support/snapshots/desktop_edge/Edge-Remote/elements/card-element-945x1020.png index 17809c123..256a531e1 100644 Binary files a/test/e2e/support/snapshots/desktop_edge/Edge-Remote/elements/card-element-945x1020.png and b/test/e2e/support/snapshots/desktop_edge/Edge-Remote/elements/card-element-945x1020.png differ diff --git a/test/e2e/support/snapshots/desktop_edge/Edge-Remote/hosted-fields/card-field-945x1020.png b/test/e2e/support/snapshots/desktop_edge/Edge-Remote/hosted-fields/card-field-945x1020.png index 0ee923a94..c3b8cdfc5 100644 Binary files a/test/e2e/support/snapshots/desktop_edge/Edge-Remote/hosted-fields/card-field-945x1020.png and b/test/e2e/support/snapshots/desktop_edge/Edge-Remote/hosted-fields/card-field-945x1020.png differ diff --git a/test/e2e/support/snapshots/desktop_edge/Edge-Remote/hosted-fields/distinct-fields-945x1020.png b/test/e2e/support/snapshots/desktop_edge/Edge-Remote/hosted-fields/distinct-fields-945x1020.png index e9f82a61b..503653122 100644 Binary files a/test/e2e/support/snapshots/desktop_edge/Edge-Remote/hosted-fields/distinct-fields-945x1020.png and b/test/e2e/support/snapshots/desktop_edge/Edge-Remote/hosted-fields/distinct-fields-945x1020.png differ diff --git a/test/e2e/support/snapshots/desktop_firefox/Firefox-Remote/elements/card-element-1280x951.png b/test/e2e/support/snapshots/desktop_firefox/Firefox-Remote/elements/card-element-1280x951.png index 6642d5fde..43a268850 100644 Binary files a/test/e2e/support/snapshots/desktop_firefox/Firefox-Remote/elements/card-element-1280x951.png and b/test/e2e/support/snapshots/desktop_firefox/Firefox-Remote/elements/card-element-1280x951.png differ diff --git a/test/e2e/support/snapshots/desktop_firefox/Firefox-Remote/elements/distinct-elements-1280x951.png b/test/e2e/support/snapshots/desktop_firefox/Firefox-Remote/elements/distinct-elements-1280x951.png index f74faa84c..b0f4760a3 100644 Binary files a/test/e2e/support/snapshots/desktop_firefox/Firefox-Remote/elements/distinct-elements-1280x951.png and b/test/e2e/support/snapshots/desktop_firefox/Firefox-Remote/elements/distinct-elements-1280x951.png differ diff --git a/test/e2e/support/snapshots/desktop_firefox/Firefox-Remote/hosted-fields/card-field-1280x951.png b/test/e2e/support/snapshots/desktop_firefox/Firefox-Remote/hosted-fields/card-field-1280x951.png index 92e2955c5..7e19d30b3 100644 Binary files a/test/e2e/support/snapshots/desktop_firefox/Firefox-Remote/hosted-fields/card-field-1280x951.png and b/test/e2e/support/snapshots/desktop_firefox/Firefox-Remote/hosted-fields/card-field-1280x951.png differ diff --git a/test/e2e/support/snapshots/desktop_firefox/Firefox-Remote/hosted-fields/distinct-fields-1280x951.png b/test/e2e/support/snapshots/desktop_firefox/Firefox-Remote/hosted-fields/distinct-fields-1280x951.png index c582b45ca..f77295c8d 100644 Binary files a/test/e2e/support/snapshots/desktop_firefox/Firefox-Remote/hosted-fields/distinct-fields-1280x951.png and b/test/e2e/support/snapshots/desktop_firefox/Firefox-Remote/hosted-fields/distinct-fields-1280x951.png differ diff --git a/test/unit/support/helpers.js b/test/unit/support/helpers.js index e196434c3..db1d2ec44 100644 --- a/test/unit/support/helpers.js +++ b/test/unit/support/helpers.js @@ -20,10 +20,12 @@ export function initRecurly (recurly, opts) { // prevents itinerant event logging workers from dispatching sinon.stub(recurly.reporter, 'send'); } + recurly.configure(merge({ publicKey: 'test', api: `${window.location.protocol}//${window.location.host}/api` }, opts)); + return recurly; }