@shiftengineering/folio 0.1.12 → 0.1.13
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/README.md +49 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -245,17 +245,23 @@ function FolioProjectManager() {
|
|
|
245
245
|
|
|
246
246
|
## Google Analytics 4 Integration
|
|
247
247
|
|
|
248
|
-
Folio
|
|
248
|
+
Folio supports analytics event tracking that can be used with Google Analytics 4 or any other analytics provider. This feature enables tracking key user interactions and provides visibility into how users engage with the application.
|
|
249
249
|
|
|
250
250
|
### Configuration
|
|
251
251
|
|
|
252
|
-
|
|
252
|
+
#### For Google Analytics 4
|
|
253
|
+
|
|
254
|
+
To enable built-in Google Analytics 4 tracking, add the measurement ID to your environment variables provided to the docker container:
|
|
253
255
|
|
|
254
256
|
```
|
|
255
257
|
VITE_GA4_MEASUREMENT_ID=G-XXXXXXXXXX
|
|
256
258
|
```
|
|
257
259
|
|
|
258
|
-
When this environment variable is present, Folio will automatically initialize GA4 and
|
|
260
|
+
When this environment variable is present, Folio will automatically initialize GA4 and send events to Google Analytics.
|
|
261
|
+
|
|
262
|
+
#### For Any Analytics Provider
|
|
263
|
+
|
|
264
|
+
**Important:** Even if you don't configure GA4, you can still capture all analytics events by providing the `onAnalyticsEvent` callback to the `FolioProvider`. This gives you complete flexibility to use any analytics provider of your choice.
|
|
259
265
|
|
|
260
266
|
### Events Tracked
|
|
261
267
|
|
|
@@ -269,6 +275,29 @@ The following events are tracked automatically:
|
|
|
269
275
|
6. `switch_project` - When a user switches between projects
|
|
270
276
|
7. `file_view` - When a user views a file
|
|
271
277
|
|
|
278
|
+
### Analytics Event Structure
|
|
279
|
+
|
|
280
|
+
All analytics events follow this structure:
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
export type AnalyticsEvent =
|
|
284
|
+
| { name: "page_view"; data: { pathname: string; projectId?: string } }
|
|
285
|
+
| { name: "chat_sent"; data: { query: string } }
|
|
286
|
+
| { name: "highlight"; data: { filePath: string; selectionLength: number } }
|
|
287
|
+
| { name: "add_to_chat"; data: { filePath: string; snippetSize: number } }
|
|
288
|
+
| { name: "extract"; data: { filePath: string; extractor: string } }
|
|
289
|
+
| {
|
|
290
|
+
name: "switch_project";
|
|
291
|
+
data: { fromProjectId: string; toProjectId: string };
|
|
292
|
+
}
|
|
293
|
+
| { name: "file_view"; data: { filePath: string } };
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Each event has:
|
|
297
|
+
|
|
298
|
+
- A `name` property identifying the event type
|
|
299
|
+
- A `data` object with event-specific parameters
|
|
300
|
+
|
|
272
301
|
### Host Integration
|
|
273
302
|
|
|
274
303
|
If you're embedding Folio in your application, you can access the analytics event stream by providing the `onAnalyticsEvent` callback to the `FolioProvider`:
|
|
@@ -290,6 +319,13 @@ function YourApp() {
|
|
|
290
319
|
if (window.mixpanel) {
|
|
291
320
|
window.mixpanel.track(event.name, event.data);
|
|
292
321
|
}
|
|
322
|
+
|
|
323
|
+
// Example: Send to custom analytics endpoint
|
|
324
|
+
fetch('https://your-analytics-api.com/track', {
|
|
325
|
+
method: 'POST',
|
|
326
|
+
headers: { 'Content-Type': 'application/json' },
|
|
327
|
+
body: JSON.stringify(event)
|
|
328
|
+
});
|
|
293
329
|
};
|
|
294
330
|
|
|
295
331
|
return (
|
|
@@ -317,7 +353,7 @@ window.addEventListener("folio-analytics", (event) => {
|
|
|
317
353
|
});
|
|
318
354
|
```
|
|
319
355
|
|
|
320
|
-
Both approaches allow host applications to consume the same events
|
|
356
|
+
Both approaches allow host applications to consume the same events regardless of whether GA4 is configured, enabling integration with any analytics service or custom tracking solution.
|
|
321
357
|
|
|
322
358
|
## API Reference
|
|
323
359
|
|
|
@@ -414,14 +450,14 @@ Hook for adding one or more directories with files to a project. Directory names
|
|
|
414
450
|
|
|
415
451
|
The library exports these TypeScript types:
|
|
416
452
|
|
|
417
|
-
| Type | Description
|
|
418
|
-
| -------------------- |
|
|
419
|
-
| `FolioFile` | Represents a file in Folio. Contains properties: `id`, `name`, `blobUrl`, `parentId` (null for root items), and `isDirectory` (boolean)
|
|
420
|
-
| `FolioProject` | Represents a project in Folio
|
|
421
|
-
| `MetadataValue` | Represents metadata values that can be nested. Can be a string, number, boolean, null, object, or array of these types
|
|
422
|
-
| `DirectoryEntry` | Represents a directory with metadata and files to be added to Folio. Contains properties: `directoryName`, `directoryMetadata` (now supports nested objects), and `files`
|
|
423
|
-
| `AnalyticsEvent` |
|
|
424
|
-
| `FolioEmbedProps` | Props for the FolioEmbed component
|
|
425
|
-
| `FolioProviderProps` | Props for the FolioProvider component
|
|
453
|
+
| Type | Description |
|
|
454
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
455
|
+
| `FolioFile` | Represents a file in Folio. Contains properties: `id`, `name`, `blobUrl`, `parentId` (null for root items), and `isDirectory` (boolean) |
|
|
456
|
+
| `FolioProject` | Represents a project in Folio |
|
|
457
|
+
| `MetadataValue` | Represents metadata values that can be nested. Can be a string, number, boolean, null, object, or array of these types |
|
|
458
|
+
| `DirectoryEntry` | Represents a directory with metadata and files to be added to Folio. Contains properties: `directoryName`, `directoryMetadata` (now supports nested objects), and `files` |
|
|
459
|
+
| `AnalyticsEvent` | A union type for analytics events sent by Folio. Each event has a `name` property (like "page_view" or "file_view") and a `data` object with event-specific parameters. See the [Analytics Event Structure](#analytics-event-structure) section for details on all event types. |
|
|
460
|
+
| `FolioEmbedProps` | Props for the FolioEmbed component |
|
|
461
|
+
| `FolioProviderProps` | Props for the FolioProvider component |
|
|
426
462
|
|
|
427
463
|
## License
|