@entropyinternet/alertsboo-helpers
v0.1.18
Published
This package contains types and helper functions for the Alerts Boo project.
Readme
Alerts Boo Helpers & Types
This package contains types and helper functions for the Alerts Boo project.
Usage
$ npm install --save @entropyinternet/alertsboo-helpersimport type { Alert } from '@entropyinternet/alertsboo-helpers';Update Version
$ npm install --save @entropyinternet/[email protected]Building
Every npm release must update the version number in package.json.
$ yarn install
$ yarn build
$ npm publish --access publicBilling Patterns
We use DynamoDB for tracking billable events.
Credits Based Billing
We sell credits to customers as a simplified way to measure usage. Our actual expense per credit is a blend of costs. Our profit margin will fluctuate based on the price we sell credits at.
We use DynamoDB to track both the blend of costs, and the credits.
1 credit = blend of costs (~$0.01 expense)
PriceA = 100 credits sold for $10 (90% profit)
PriceB = 1000 credits sold for $70 (85% profit)Session Based Billing
We report credit usage to customers by the "run" aka "session". For example, customer is watching an Instagram account for updates. If that account posts a new story, the run session looks like this:
- Volunteer Android relays the push notification to our webhook listener
- Listener retrieves IG data from RapidAPI vendor (expense)
- Listener attributes earnings to volunteer (expense)
- Listener uses Ai credits (expense)
- Listener costs cloud resources (expense)
- Other misc variable costs related to this run (expense)
The entire timeline of events is a "run". We use DynamoDB to track the costs of each run. The "sessionID" is the unique identifier for the run.
At each expense, we report the cost to DynamoDB.
But the run isn't done yet. There is still more accounting to do:
- Calculate the cost of run and translate to credits
- Report N credits consumed to DynamoDB
- Reflect the updated balance in customer's wallet
And costs don't directly translate 1:1 from to a run. Some costs are shared "batch" costs. However for simplicity we get customers to pay credits the entire cost of batch. Thus do not use credits as a reflection of margins (margins will tend to be higher).
