@birdie-so/snippet 1.0.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/README.md ADDED
@@ -0,0 +1,122 @@
1
+ # @birdie-so/snippet
2
+
3
+ Easily integrate the Birdie screen recording snippet into your application using modern frameworks like **React**, **Vue**, **Angular**, or plain **JavaScript** — with full control over initialization, metadata, and event hooks.
4
+
5
+ > ⚡ This package is a helper utility for integrating Birdie.
6
+ > **You must have a Birdie account and a valid `clientId` to use this package.**
7
+ > It does **not work on its own** — visit [https://app.birdie.so](https://app.birdie.so) to get started.
8
+
9
+ > ⚡ The core logic is still loaded from our CDN. This package is just a light wrapper for easier integration and customization.
10
+
11
+ ![npm](https://img.shields.io/npm/v/@birdie-so/snippet?label=npm%20version)
12
+ ![license](https://img.shields.io/npm/l/@birdie-so/snippet)
13
+
14
+ ---
15
+
16
+ ## 🚀 Installation
17
+
18
+ ```bash
19
+ npm install @birdie-so/snippet
20
+ # or
21
+ yarn add @birdie-so/snippet
22
+ ```
23
+
24
+ ---
25
+
26
+ ## ✨ Quick Start
27
+
28
+ ### React / Vue / Angular / JS
29
+
30
+ ```js
31
+ import { initBirdie } from "@birdie-so/snippet";
32
+
33
+ initBirdie({
34
+ clientId: "YOUR_CLIENT_ID", // required
35
+
36
+ // Optional metadata available to recordings
37
+ metadata: {
38
+ user: {
39
+ id: "123",
40
+ email: "user@example.com",
41
+ },
42
+ },
43
+
44
+ // Optional hook once Birdie is ready
45
+ onReady(birdie) {
46
+ birdie.on("start", (data) => {
47
+ console.log("Recording started", data);
48
+ birdie.metadata = { dynamicKey: "value" };
49
+ });
50
+
51
+ birdie.on("stop", (data) => {
52
+ console.log("Recording stopped", data);
53
+ });
54
+ },
55
+ });
56
+ ```
57
+
58
+ ---
59
+
60
+ ## 🧠 How It Works
61
+
62
+ This package:
63
+
64
+ - Injects the Birdie CDN snippet dynamically using your `clientId`.
65
+ - Sets global `window.birdieSettings` before loading.
66
+ - Registers event callbacks once the Birdie SDK is ready (`window.birdie` is available).
67
+
68
+ Your original snippet like this:
69
+
70
+ ```html
71
+ <script>
72
+ window.birdieSettings = {
73
+ /* ... */
74
+ };
75
+ </script>
76
+ <script src="https://app.birdie.so/widget/embed/YOUR_CLIENT_ID"></script>
77
+ ```
78
+
79
+ Is now handled via code with `initBirdie()`.
80
+
81
+ ---
82
+
83
+ ## 🧩 Advanced
84
+
85
+ ### Get Birdie instance later
86
+
87
+ ```js
88
+ import { getBirdieInstance } from "birdie-snippet";
89
+
90
+ getBirdieInstance((birdie) => {
91
+ birdie.on("start", () => {
92
+ console.log("Recording started!");
93
+ });
94
+ });
95
+ ```
96
+
97
+ Or synchronously:
98
+
99
+ ```js
100
+ const birdie = getBirdieInstance();
101
+ if (birdie) {
102
+ birdie.metadata = { key: "value" };
103
+ }
104
+ ```
105
+
106
+ ---
107
+
108
+ ## 📘 Docs
109
+
110
+ For full documentation and integration examples, visit [our docs page](https://docs.birdie.so/birdie-docs/request-screen-recordings/installation/snippet)
111
+
112
+ ---
113
+
114
+ ## 🛠 Support
115
+
116
+ Need help? Reach out to us at [support@birdie.so](mailto:support@birdie.so)
117
+
118
+ ---
119
+
120
+ ## 📄 License
121
+
122
+ MIT
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@birdie-so/snippet",
3
+ "version": "1.0.0",
4
+ "description": "Helper for integrating the Birdie screen recording snippet into modern JavaScript apps. Requires a Birdie account.",
5
+ "main": "src/index.js",
6
+ "exports": {
7
+ ".": {
8
+ "require": "./src/index.js",
9
+ "import": "./src/index.js"
10
+ }
11
+ },
12
+ "types": "src/index.d.ts",
13
+ "keywords": [
14
+ "birdie",
15
+ "screen-recording",
16
+ "console-logs",
17
+ "network-logs",
18
+ "debug",
19
+ "snippet",
20
+ "frontend",
21
+ "support"
22
+ ],
23
+ "license": "MIT",
24
+ "author": "Birdie <support@birdie.so>",
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "homepage": "https://docs.birdie.so",
29
+ "files": [
30
+ "src/",
31
+ "README.md"
32
+ ]
33
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ export interface BirdieMetadata {
2
+ [key: string]: any;
3
+ }
4
+
5
+ export interface BirdieSettings {
6
+ /**
7
+ * Unique Birdie client ID.
8
+ */
9
+ clientId: string;
10
+
11
+ /**
12
+ * Optional metadata to pass to Birdie before recording starts.
13
+ */
14
+ metadata?: BirdieMetadata;
15
+
16
+ /**
17
+ * Callback when Birdie is fully loaded and available as `window.birdie`.
18
+ */
19
+ onReady?: (birdie: BirdieAPI) => void;
20
+ }
21
+
22
+ export interface BirdieAPI {
23
+ metadata: BirdieMetadata;
24
+ on(event: 'start' | 'stop', callback: (data: any) => void): void;
25
+ }
26
+
27
+ /**
28
+ * Initializes the Birdie widget by injecting the CDN script with your client ID.
29
+ * Automatically configures window.birdieSettings and registers optional metadata or event listeners.
30
+ */
31
+ export function initBirdie(settings: BirdieSettings): void;
32
+
33
+ /**
34
+ * Returns the current `window.birdie` instance if available, or null.
35
+ * You can also pass a callback to run once Birdie becomes available.
36
+ */
37
+ export function getBirdieInstance(callback?: (birdie: BirdieAPI) => void): BirdieAPI | null;
package/src/index.js ADDED
@@ -0,0 +1,57 @@
1
+ let _readyCallbacks = [];
2
+
3
+ export function initBirdie({ clientId, metadata, onReady, ...otherSettings }) {
4
+ if (!clientId) {
5
+ console.error('[Birdie] Missing required clientId in initBirdie()');
6
+ return;
7
+ }
8
+
9
+ if (typeof window === 'undefined') return;
10
+
11
+ // Always predefine birdieSettings first (or reuse if already present)
12
+ if (!window.birdieSettings) {
13
+ window.birdieSettings = {};
14
+ }
15
+
16
+ // Assign metadata and other settings first
17
+ window.birdieSettings.metadata = metadata;
18
+ Object.assign(window.birdieSettings, otherSettings);
19
+
20
+ // Assign onBirdieReady BEFORE appending the script
21
+ window.birdieSettings.onBirdieReady = () => {
22
+ _readyCallbacks.forEach(cb => cb(window.birdie));
23
+ _readyCallbacks = [];
24
+ };
25
+
26
+ // Queue the onReady handler
27
+ if (onReady) {
28
+ registerBirdieReadyCallback(onReady);
29
+ }
30
+
31
+ // Inject script if not already
32
+ if (!document.getElementById('birdie-snippet')) {
33
+ const script = document.createElement('script');
34
+ script.src = `https://app.birdie.so/widget/embed/${clientId}`;
35
+ script.async = true;
36
+ script.id = 'birdie-snippet';
37
+ document.body.appendChild(script);
38
+ }
39
+ }
40
+
41
+ function registerBirdieReadyCallback(callback) {
42
+ if (window.birdie) {
43
+ callback(window.birdie);
44
+ } else {
45
+ _readyCallbacks.push(callback);
46
+ }
47
+ }
48
+
49
+ export function getBirdieInstance(onReady) {
50
+ if (window.birdie) {
51
+ onReady?.(window.birdie);
52
+ return window.birdie;
53
+ } else {
54
+ registerBirdieReadyCallback(onReady);
55
+ return null;
56
+ }
57
+ }