Skip to main content
Version: Next

ChargingManager

Handles pay-per-event charging.

Index

Constructors

constructor

Methods

calculateMaxEventChargeCountWithinLimit

  • calculateMaxEventChargeCountWithinLimit(eventName): number
  • How many events of a given type can still be charged for before reaching the limit; If the event is not registered, returns Infinity (free of charge)


    Parameters

    • eventName: string

    Returns number

calculatePushDataLimits

  • calculatePushDataLimits<T>(__namedParameters): { eventsToCharge: Record<string, number>; limitedItems: T[] }
  • Helper to calculate how many items can be pushed within charging limits. Returns the limited items and count to charge.


    Parameters

    • __namedParameters: { eventName: undefined | string; isDefaultDataset: boolean; items: T | T[] }
      • eventName: undefined | string
      • isDefaultDataset: boolean
      • items: T | T[]

    Returns { eventsToCharge: Record<string, number>; limitedItems: T[] }

    • eventsToCharge: Record<string, number>
    • limitedItems: T[]

charge

  • Charge for a specified number of events - sub-operations of the Actor.

    This method attempts to charge for the specified number of events, but may charge fewer if doing so would exceed the total budget limit (maxTotalChargeUsd).


    Parameters

    • options: ChargeOptions

      The name of the event to charge for and the number of events to be charged.

    Returns Promise<ChargeResult>

getChargedEventCount

  • getChargedEventCount(eventName): number
  • Get the number of events with given name that the Actor has charged for so far.


    Parameters

    • eventName: string

    Returns number

getMaxTotalChargeUsd

  • getMaxTotalChargeUsd(): number
  • Get the maximum amount of money that the Actor is allowed to charge.


    Returns number

getPricingInfo

init

  • init(): Promise<void>
  • Initialize the ChargingManager by loading pricing information and charging state via Apify API.


    Returns Promise<void>