Skip to content

Commit

Permalink
Instantiates reporter only on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissrogers committed Jan 4, 2024
1 parent 774e5c5 commit 6aba2f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/recurly.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/support/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 6aba2f6

Please sign in to comment.