From 6aba2f630ec377bff491a8fe366cb1c79e8bc7d5 Mon Sep 17 00:00:00 2001 From: Christopher Rogers Date: Thu, 4 Jan 2024 12:07:19 -0800 Subject: [PATCH] Instantiates reporter only on demand --- lib/recurly.js | 5 ++++- test/unit/support/helpers.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/recurly.js b/lib/recurly.js index 01e017e82..6e3339d1c 100644 --- a/lib/recurly.js +++ b/lib/recurly.js @@ -142,12 +142,15 @@ 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 }); + + if (options && options.report) this.reporter = new Reporter({ recurly: this }); this.Pricing = () => new SubscriptionPricing(this); // deprecated this.Pricing.Checkout = () => new CheckoutPricing(this); diff --git a/test/unit/support/helpers.js b/test/unit/support/helpers.js index e196434c3..e79f6fdac 100644 --- a/test/unit/support/helpers.js +++ b/test/unit/support/helpers.js @@ -18,7 +18,7 @@ export function initRecurly (recurly, opts) { recurly = new Recurly; // prevents itinerant event logging workers from dispatching - sinon.stub(recurly.reporter, 'send'); + if (recurly.reporter) sinon.stub(recurly.reporter, 'send'); } recurly.configure(merge({ publicKey: 'test',