1.0.8 • Published 1 year ago
sherpajs-events v1.0.8
SherpaJS Events
Connect to event tracking platforms like PostHog using Metadapter Event and create event tracking endpoints for SherpaJS an agnostic and modular serverless platform.
!CAUTION Vercel doesn't support AJV regularly, we are working on a fix, but as of now, validation doesn't work on Vercel.
Features
- ✅ SherpaJS Module, an Agnostic and Modular Serverless Platform
- ✅ Log event using Metadapter Event
- ✅ Supports PostHog
Installation
npm install sherpajs-events
Example Usage
Services are loaded using Metadapter Event. The id
is the eventID that is logged with your event platform. The schema
is optional, but uses AJV schema.
// sherpa.server.ts
import Events, { Service, ServiceType } from "sherpajs-events";
export default Events.load({
service: Service(ServiceType.Skeleton, undefined),
events: {
"test": {
id: "test",
schema: {
type: "object",
properties: {
foo: {type: "integer"},
bar: {type: "string"}
},
required: ["foo"],
additionalProperties: false
}
},
"test2": {
id: "test2"
}
}
});
Endpoint POST:/test
Body
{
"foo": true
}
Response
400 Bad Request
Property 'foo': must be integer
Endpoint POST:/test
Body
Hello World
Response
400 Bad Request
Request body must be in JSON format.
Endpoint POST:/test
Body
{
"foo": 3,
"bar": "hello world"
}
Response
201 Created
Successfully Logged Event
Endpoint POST:/test2
Body
{
"test": "hello world",
}
Response
201 Created
Successfully Logged Event
Endpoint POST:/test2
Body
{
"test": true,
}
Response
201 Created
Successfully Logged Event