schematic-vue is a client-side Vue library for Schematic which provides composables to track events, check flags, and more. schematic-vue provides the same capabilities as schematic-js, for Vue apps.
You can use the SchematicPlugin to make Schematic available throughout your Vue application:
To set the user context for events and flag checks, you can use the identify function provided by the useSchematicEvents composable:
To learn more about identifying companies with the keys map, see key management in Schematic public docs.
Once you’ve set the context with identify, you can track events:
If you want to record large numbers of the same event at once, or perhaps measure usage in terms of a unit like tokens or memory, you can optionally specify a quantity for your event:
To check a flag, you can use the useSchematicFlag composable:
You can check entitlements (i.e., company access to a feature) using a flag check as well, and using the useSchematicEntitlement composable you can get additional data to render various feature states:
Note: useSchematicIsPending is checking if entitlement data has been loaded, typically via identify. It should, therefore, be used to wrap flag and entitlement checks, but never the initial call to identify.
To access the current company’s plan and trial status, you can use the useSchematicPlan composable:
The composable returns an object with the following properties:
The SDK includes built-in fallback behavior you can use to ensure your application continues to function even when unable to reach Schematic (e.g., during service disruptions or network issues).
When flag checks cannot reach Schematic, they use fallback values in the following priority order:
flagCheckDefaults or flagValueDefaults options when initializing the pluginfalse if no fallback is configuredWhen events (track, identify) cannot be sent due to network issues, they are automatically queued and retried:
maxEventQueueSize)maxEventRetries)In WebSocket mode, if the WebSocket connection fails, the SDK will provide the last known value or the configured fallback values as outlined above. The WebSocket will also automatically attempt to re-establish it’s connection with Schematic using an exponential backoff.
While the primary API uses the Composition API, you can still use these composables in the Options API:
For debugging and development, Schematic supports two special modes:
Enables console logging of all Schematic operations:
Prevents network requests and returns fallback values for all flag checks:
Offline mode automatically enables debug mode to help with troubleshooting.
If you need more control over the Schematic client initialization, you can create a client instance and pass it to the plugin:
You can override the client for a specific component by passing a client option to any composable:
All composables are SSR-compatible and work seamlessly with Nuxt and other Vue SSR frameworks:
MIT
Need help? Please open a GitHub issue or reach out to support@schematichq.com and we’ll be happy to assist.