Snacktime
Snacktime is a wrapper for the Launched LA internal database that will replicate into Snowflake. It is an enhanced place to store event-driven data.
Usage
import Snacktime from '@launched-la/snacktime'
const snacktime = Snacktime({
awsRegion: 'us-east-2',
shopifyDomain: 'hb-launched.myshopify.com',
})
// bundle updates:
await snacktime.recordAction({
label: 'UpdatedBundle',
bundleId: 123,
customerId: 123,
chargeId: 123,
updates: [
{
label: 'DeletedSubscription',
subscriptionId: 123,
variantId: 123,
variantTitle: '2 / Sleepy Sloths'
},
{
label: 'CreatedSubscription',
subscriptionId: 123,
variantId: 123,
variantTitle: '3 / Sleepy Sloths'
},
{
label: 'ChangedQuantity',
subscriptionId: 123,
variantId: 123,
variantTitle: '3 / Spook-a-boo',
oldQuantity: 1,
newQuantity: 2,
},
],
})
// changing ship date:
await snacktime.recordAction({
label: 'ChangedShipDate',
bundleId: 123,
customerId: 123,
chargeId: 123,
subscriptionIds: [123, 123, 123],
oldDate: '2020-10-18',
newDate: '2020-10-20',
})
// cancellations:
await snacktime.recordAction({
label: 'CancelledBundle',
bundleId: 123,
customerId: 123,
chargeId: 123,
reason: 'Too expensive',
subscriptionIds: [123, 123, 123],
})
// storing data
// :value accepts number, string, object, and will store/parse intelligently
// the data row will be created or updated, no need to specify
await snacktime.saveData({
resource: 'Customer',
resourceId: 123,
namespace: 'snacks',
key: 'numberOfChips',
value: 5,
})