@cfxlabsinc/b2b-services
    Preparing search index...

    Rules that are configured per customer to trigger rewards on certain events

    Hierarchy (View Summary)

    Index
    db: B2bDatabase
    rewardEventNamesCache: ServiceCache<string[]>
    • Match event and event data to the rules defined for the given customer

      If multiple rules match, the first one is returned

      Parameters

      • __namedParameters: { customerId: string; data: object; event: string }
        • customerId: string
        • data: object

          Data associated with the event, compared against rule matchers

        • event: string

      Returns Promise<RewardAmount | null>

      Reward amount that this event qualifies for. null if no active rules match.

    • Creates or updates the reward event config for the given customer + event (INSERT ... ON CONFLICT DO UPDATE, keyed on the (customer, event) unique index). In case of update, rules replace the previous values (rather than merge).

      Parameters

      Returns Promise<
          | { ok: true; value: RewardEventConfig }
          | { error: ServiceError; ok: false },
      >