Vanilla JS SDK Update
Vanilla JS SDK Update
Vanilla JS SDK Update
Dec 12, 2023
Dec 12, 2023
Dec 12, 2023
Christian Mathiesen
Christian Mathiesen
Christian Mathiesen
A few months ago, we announced our Vanilla Javascript SDK which can be used in any stack that runs Javascipt (including Node.js). Since launching the SDK, we've incorporated a great deal of feedback and greatly simplified the API and models.
For instance, working with the lifecycle of Flows has been greatly simplified:
// Init the SDK
const frigade = new Frigade('FRIGADE_API_KEY', { userId: "my-user-id" })
// Marking a flow as completed:
const flow = await frigade.getFlow('FLOW_ID')
await flow.complete()
// Marking a step in a flow as completed:
const flow = await frigade.getFlow('FLOW_ID')
const step = flow.steps.get('STEP_ID')
await step.start()
await step.complete()
Additionally, we've introduced global event handlers to easily trigger actions in your application as a user progresses through a Flow:
// This callback will be called when a the current user/group changes state in any flow
const callback = (updatedFlow, previousFlow) => {
console.log('Flow state changed:', flow.isCompleted)
console.log('Step state changed:', flow.steps.get('STEP_ID').isCompleted)
}
frigade.onStateChange(callback)
In the coming months, we'll continue to invest in the JS SDK as it becomes the foundation of all our Javascript-based SDKs. Get started with the Frigade Vanilla JS SDK here.
A few months ago, we announced our Vanilla Javascript SDK which can be used in any stack that runs Javascipt (including Node.js). Since launching the SDK, we've incorporated a great deal of feedback and greatly simplified the API and models.
For instance, working with the lifecycle of Flows has been greatly simplified:
// Init the SDK
const frigade = new Frigade('FRIGADE_API_KEY', { userId: "my-user-id" })
// Marking a flow as completed:
const flow = await frigade.getFlow('FLOW_ID')
await flow.complete()
// Marking a step in a flow as completed:
const flow = await frigade.getFlow('FLOW_ID')
const step = flow.steps.get('STEP_ID')
await step.start()
await step.complete()
Additionally, we've introduced global event handlers to easily trigger actions in your application as a user progresses through a Flow:
// This callback will be called when a the current user/group changes state in any flow
const callback = (updatedFlow, previousFlow) => {
console.log('Flow state changed:', flow.isCompleted)
console.log('Step state changed:', flow.steps.get('STEP_ID').isCompleted)
}
frigade.onStateChange(callback)
In the coming months, we'll continue to invest in the JS SDK as it becomes the foundation of all our Javascript-based SDKs. Get started with the Frigade Vanilla JS SDK here.
A few months ago, we announced our Vanilla Javascript SDK which can be used in any stack that runs Javascipt (including Node.js). Since launching the SDK, we've incorporated a great deal of feedback and greatly simplified the API and models.
For instance, working with the lifecycle of Flows has been greatly simplified:
// Init the SDK
const frigade = new Frigade('FRIGADE_API_KEY', { userId: "my-user-id" })
// Marking a flow as completed:
const flow = await frigade.getFlow('FLOW_ID')
await flow.complete()
// Marking a step in a flow as completed:
const flow = await frigade.getFlow('FLOW_ID')
const step = flow.steps.get('STEP_ID')
await step.start()
await step.complete()
Additionally, we've introduced global event handlers to easily trigger actions in your application as a user progresses through a Flow:
// This callback will be called when a the current user/group changes state in any flow
const callback = (updatedFlow, previousFlow) => {
console.log('Flow state changed:', flow.isCompleted)
console.log('Step state changed:', flow.steps.get('STEP_ID').isCompleted)
}
frigade.onStateChange(callback)
In the coming months, we'll continue to invest in the JS SDK as it becomes the foundation of all our Javascript-based SDKs. Get started with the Frigade Vanilla JS SDK here.