@birdie-so/snippet 1.0.0 → 1.1.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 CHANGED
@@ -43,15 +43,41 @@ initBirdie({
43
43
 
44
44
  // Optional hook once Birdie is ready
45
45
  onReady(birdie) {
46
+ // you can register for the following events
47
+ birdie.on("recorderOpen", (data) => {
48
+ console.log("Recorder tab is opened", data);
49
+ });
46
50
  birdie.on("start", (data) => {
47
51
  console.log("Recording started", data);
48
52
  birdie.metadata = { dynamicKey: "value" };
49
53
  });
50
-
54
+ birdie.on("pause", (data) => {
55
+ console.log("Recording paused", data);
56
+ });
57
+ birdie.on("resume", (data) => {
58
+ console.log("Recording resumed", data);
59
+ });
51
60
  birdie.on("stop", (data) => {
52
61
  console.log("Recording stopped", data);
53
62
  });
54
- },
63
+ birdie.on("restart", (data) => {
64
+ console.log("Recording restarted", data);
65
+ });
66
+ birdie.on("captureStarted", (data) => {
67
+ console.log("Capturing logs started", data);
68
+ });
69
+ birdie.on("captureStopped", (data) => {
70
+ console.log("Capturing logs stopped", data);
71
+ });
72
+ birdie.on("recordingSent", (data) => {
73
+ // data.link contains the link to the video
74
+ console.log("A new recording has been sent", data);
75
+ });
76
+ birdie.on("recorderClose", (data) => {
77
+ console.log("Recorder tab was closed", data);
78
+ });
79
+ }
80
+
55
81
  });
56
82
  ```
57
83
 
@@ -85,7 +111,7 @@ Is now handled via code with `initBirdie()`.
85
111
  ### Get Birdie instance later
86
112
 
87
113
  ```js
88
- import { getBirdieInstance } from "birdie-snippet";
114
+ import { getBirdieInstance } from "@birdie-so/snippet";
89
115
 
90
116
  getBirdieInstance((birdie) => {
91
117
  birdie.on("start", () => {
package/package.json CHANGED
@@ -1,14 +1,10 @@
1
1
  {
2
2
  "name": "@birdie-so/snippet",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Helper for integrating the Birdie screen recording snippet into modern JavaScript apps. Requires a Birdie account.",
5
+ "type": "module",
5
6
  "main": "src/index.js",
6
- "exports": {
7
- ".": {
8
- "require": "./src/index.js",
9
- "import": "./src/index.js"
10
- }
11
- },
7
+ "exports": { ".": "./src/index.js" },
12
8
  "types": "src/index.d.ts",
13
9
  "keywords": [
14
10
  "birdie",
package/src/index.d.ts CHANGED
@@ -21,7 +21,7 @@ export interface BirdieSettings {
21
21
 
22
22
  export interface BirdieAPI {
23
23
  metadata: BirdieMetadata;
24
- on(event: 'start' | 'stop', callback: (data: any) => void): void;
24
+ on(event: 'start' | 'stop' | 'captureStarted' | 'captureStopped' | 'pause' | 'restart' | 'resume' | 'recorderClose' | 'recorderOpen' | 'recordingSent', callback: (data: any) => void): void;
25
25
  }
26
26
 
27
27
  /**
package/src/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  let _readyCallbacks = [];
2
2
 
3
3
  export function initBirdie({ clientId, metadata, onReady, ...otherSettings }) {
4
+
5
+
6
+
4
7
  if (!clientId) {
5
8
  console.error('[Birdie] Missing required clientId in initBirdie()');
6
9
  return;
@@ -17,9 +20,8 @@ export function initBirdie({ clientId, metadata, onReady, ...otherSettings }) {
17
20
  window.birdieSettings.metadata = metadata;
18
21
  Object.assign(window.birdieSettings, otherSettings);
19
22
 
20
- // Assign onBirdieReady BEFORE appending the script
21
23
  window.birdieSettings.onBirdieReady = () => {
22
- _readyCallbacks.forEach(cb => cb(window.birdie));
24
+ _readyCallbacks.forEach(cb => { try { cb(window.birdie); } catch(e) { console.error('[Birdie] onReady error', e); }});
23
25
  _readyCallbacks = [];
24
26
  };
25
27
 
@@ -36,9 +38,17 @@ export function initBirdie({ clientId, metadata, onReady, ...otherSettings }) {
36
38
  script.id = 'birdie-snippet';
37
39
  document.body.appendChild(script);
38
40
  }
41
+ // if (!document.getElementById('birdie-snippet')) {
42
+ // const script = document.createElement('script');
43
+ // script.src = `https://birdie.eu.ngrok.io/snippet/index.local.min.js`;
44
+ // script.async = true;
45
+ // script.id = 'birdie-snippet';
46
+ // document.body.appendChild(script);
47
+ // }
39
48
  }
40
49
 
41
50
  function registerBirdieReadyCallback(callback) {
51
+ if (typeof window === 'undefined') return;
42
52
  if (window.birdie) {
43
53
  callback(window.birdie);
44
54
  } else {
@@ -47,6 +57,7 @@ function registerBirdieReadyCallback(callback) {
47
57
  }
48
58
 
49
59
  export function getBirdieInstance(onReady) {
60
+ if (typeof window === 'undefined') return null;
50
61
  if (window.birdie) {
51
62
  onReady?.(window.birdie);
52
63
  return window.birdie;