@schematichq/schematic-vue 0.1.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -2
- package/README.md +98 -0
- package/dist/schematic-vue.cjs.js +925 -166
- package/dist/schematic-vue.d.ts +26 -0
- package/dist/schematic-vue.esm.js +925 -166
- package/package.json +6 -5
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2023-2026 Schematic, Inc.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
22
|
-
|
package/README.md
CHANGED
|
@@ -137,6 +137,104 @@ const {
|
|
|
137
137
|
|
|
138
138
|
_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`._
|
|
139
139
|
|
|
140
|
+
### Company plan information
|
|
141
|
+
|
|
142
|
+
To access the current company's plan and trial status, you can use the `useSchematicPlan` composable:
|
|
143
|
+
|
|
144
|
+
```vue
|
|
145
|
+
<script setup lang="ts">
|
|
146
|
+
import { useSchematicPlan } from "@schematichq/schematic-vue";
|
|
147
|
+
|
|
148
|
+
const plan = useSchematicPlan();
|
|
149
|
+
</script>
|
|
150
|
+
|
|
151
|
+
<template>
|
|
152
|
+
<div v-if="!plan">No plan assigned</div>
|
|
153
|
+
<div v-else>
|
|
154
|
+
<p>Current plan: {{ plan.name }}</p>
|
|
155
|
+
|
|
156
|
+
<p v-if="plan.trialStatus === 'active'">
|
|
157
|
+
Trial ends: {{ plan.trialEndDate?.toLocaleDateString() }}
|
|
158
|
+
</p>
|
|
159
|
+
|
|
160
|
+
<p v-if="plan.trialStatus === 'expired'">
|
|
161
|
+
Your trial has ended. <a href="/upgrade">Upgrade now</a>
|
|
162
|
+
</p>
|
|
163
|
+
</div>
|
|
164
|
+
</template>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
The composable returns an object with the following properties:
|
|
168
|
+
|
|
169
|
+
| Property | Type | Description |
|
|
170
|
+
| --- | --- | --- |
|
|
171
|
+
| `id` | `string` | The plan ID |
|
|
172
|
+
| `name` | `string` | The plan name |
|
|
173
|
+
| `trialEndDate` | `Date \| undefined` | The trial end date, if the company has or had a trial |
|
|
174
|
+
| `trialStatus` | `"active" \| "expired" \| "converted" \| undefined` | The company's trial status: `active` if the trial is ongoing, `expired` if the trial ended without conversion, `converted` if the company converted to a paid plan, or `undefined` if the company has never trialed |
|
|
175
|
+
|
|
176
|
+
## Fallback Behavior
|
|
177
|
+
|
|
178
|
+
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).
|
|
179
|
+
|
|
180
|
+
### Flag Check Fallbacks
|
|
181
|
+
|
|
182
|
+
When flag checks cannot reach Schematic, they use fallback values in the following priority order:
|
|
183
|
+
|
|
184
|
+
1. Callsite fallback - fallback values can be provided directly in the composable options
|
|
185
|
+
2. Initialization defaults - fallback values configured via `flagCheckDefaults` or `flagValueDefaults` options when initializing the plugin
|
|
186
|
+
3. Default value - Returns `false` if no fallback is configured
|
|
187
|
+
|
|
188
|
+
```vue
|
|
189
|
+
<script setup lang="ts">
|
|
190
|
+
// Provide a fallback value at the callsite
|
|
191
|
+
import { useSchematicFlag } from "@schematichq/schematic-vue";
|
|
192
|
+
|
|
193
|
+
const isFeatureEnabled = useSchematicFlag("feature-flag", {
|
|
194
|
+
fallback: true, // Used if API request fails
|
|
195
|
+
});
|
|
196
|
+
</script>
|
|
197
|
+
|
|
198
|
+
<template>
|
|
199
|
+
<Feature v-if="isFeatureEnabled" />
|
|
200
|
+
<Fallback v-else />
|
|
201
|
+
</template>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
// Or configure defaults at initialization
|
|
206
|
+
import { createApp } from "vue";
|
|
207
|
+
import { SchematicPlugin } from "@schematichq/schematic-vue";
|
|
208
|
+
|
|
209
|
+
const app = createApp(App);
|
|
210
|
+
app.use(SchematicPlugin, {
|
|
211
|
+
publishableKey: "your-publishable-key",
|
|
212
|
+
flagValueDefaults: {
|
|
213
|
+
"feature-flag": true, // Used if API request fails and no callsite fallback
|
|
214
|
+
},
|
|
215
|
+
flagCheckDefaults: {
|
|
216
|
+
"another-flag": {
|
|
217
|
+
flag: "another-flag",
|
|
218
|
+
value: true,
|
|
219
|
+
reason: "Default value",
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Event Queueing and Retry
|
|
226
|
+
|
|
227
|
+
When events (track, identify) cannot be sent due to network issues, they are automatically queued and retried:
|
|
228
|
+
|
|
229
|
+
- Events are queued in memory (up to 100 events by default, configurable via `maxEventQueueSize`)
|
|
230
|
+
- Failed events are retried with exponential backoff (up to 5 attempts by default, configurable via `maxEventRetries`)
|
|
231
|
+
- Events are automatically flushed when the network connection is restored
|
|
232
|
+
- Events queued when the page is hidden are sent when the page becomes visible
|
|
233
|
+
|
|
234
|
+
### WebSocket Fallback
|
|
235
|
+
|
|
236
|
+
In WebSocket mode, if the WebSocket connection fails, the SDK will provide the last known value or the configured fallback values as [outlined above](/#flag-check-fallbacks). The WebSocket will also automatically attempt to re-establish it's connection with Schematic using an exponential backoff.
|
|
237
|
+
|
|
140
238
|
## Options API Support
|
|
141
239
|
|
|
142
240
|
While the primary API uses the Composition API, you can still use these composables in the Options API:
|