dashcam 0.2.1
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 +160 -0
- package/examples/crash-test.js +11 -0
- package/examples/github-issue.sh +1 -0
- package/examples/protocol.html +22 -0
- package/index.js +70 -0
- package/lib.js +64 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
<img src="https://user-images.githubusercontent.com/318295/204898620-922afee0-5415-46a9-a84f-ae6237001bf0.png" height="50" alt="Replayable"/>
|
|
2
|
+
|
|
3
|
+
# CLI + SDK
|
|
4
|
+
|
|
5
|
+
Why double-back when you can capture it the first time? Playback and share exactly what happened with Replayable's desktop replay buffer.
|
|
6
|
+
|
|
7
|
+
This package allows you to control the Replayable desktop application from the CLI or SDK.
|
|
8
|
+
|
|
9
|
+
You can easily embed desktop replays within git commits, pull requests, bug reports, jira tickets, and even within log files.
|
|
10
|
+
|
|
11
|
+
Desktop replays are a great way to share context behind problems and document the application state within logs, tickets and more.
|
|
12
|
+
|
|
13
|
+
<a href="https://www.loom.com/share/ea9c2831013a4b5eb996bd47f8178f4e">
|
|
14
|
+
<p>Capture bugs with replayable. - Watch Video</p>
|
|
15
|
+
<img style="max-width:300px;" src="https://cdn.loom.com/sessions/thumbnails/ea9c2831013a4b5eb996bd47f8178f4e-with-play.gif">
|
|
16
|
+
</a>
|
|
17
|
+
|
|
18
|
+
## Quick Setup
|
|
19
|
+
|
|
20
|
+
### Install Replayable Desktop
|
|
21
|
+
|
|
22
|
+
First, [install Replayable Desktop](https://replayable.io/?betacode=CLIENTRY). Replayable Desktop runs in the background giving you access to a buffer of video.
|
|
23
|
+
|
|
24
|
+
### Install this package
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npm install replayable -g
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
# Table of contents
|
|
31
|
+
|
|
32
|
+
- [CLI + SDK](#cli--sdk)
|
|
33
|
+
- [Quick Setup](#quick-setup)
|
|
34
|
+
- [Examples](#examples)
|
|
35
|
+
- [CLI](#cli)
|
|
36
|
+
- [GitHub CLI](#github-cli)
|
|
37
|
+
- [NodeJS SDK](#nodejs-sdk)
|
|
38
|
+
- [Javascript Integration](#javascript-integration)
|
|
39
|
+
- [Advanced Usage](#advanced-usage)
|
|
40
|
+
|
|
41
|
+
# Examples
|
|
42
|
+
|
|
43
|
+
Also see the examples folder.
|
|
44
|
+
|
|
45
|
+
## CLI
|
|
46
|
+
|
|
47
|
+
### Create a Replay
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
$ replayable
|
|
51
|
+
https://replayable.io/replay/123?share=xyz
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Return a rich markdown link
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
$ replayable --md
|
|
58
|
+
|
|
59
|
+
[](https://replayable.io/replay/123?share=xyz)
|
|
60
|
+
|
|
61
|
+
Watch [Replayable - New Replay](https://replayable.io/replay/123?share=xyz) on Replayable
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Set a replay title
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
$ replayable -t "My New Title"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Attach the last 20 CLI commands to the replay
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
$ history -20 | replayable
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Attach a logfile to the replay
|
|
77
|
+
|
|
78
|
+
This will attach the mac system log to the replay.
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
$ cat /var/log/system.log | replayable
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## GitHub CLI
|
|
85
|
+
|
|
86
|
+
The following examples depend on having the [GitHub CLI](https://cli.github.com/) installed.
|
|
87
|
+
|
|
88
|
+
### Create a github issue with a replay in the description
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
$ gh issue create -w -t "Title" -b "`replayable --md`"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
This is where it gets really cool. For example, this single command will create a GitHub issue with a video replay and the mac system logs.
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
gh issue create -w -t "Title" -b "`cat /var/log/system.log | replayable --md`"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Create a github pull request with a replay in the description
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
$ gh pr create -w -t "Title" -b "`replayable --md`"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Append a 30 second replay to a commit
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
$ git commit -am "`replayable`"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## NodeJS SDK
|
|
113
|
+
|
|
114
|
+
```js
|
|
115
|
+
const replayable = require("replayable");
|
|
116
|
+
|
|
117
|
+
process.on("uncaughtException", async (err) => {
|
|
118
|
+
let replay = await replayable.createReplay({
|
|
119
|
+
title: "uncaughtException",
|
|
120
|
+
description: err,
|
|
121
|
+
});
|
|
122
|
+
console.log("Replayable", replay);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
throw new Error("Throw makes it go boom!");
|
|
127
|
+
}, 3000);
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Javascript Integration
|
|
131
|
+
|
|
132
|
+
Note that this example does not require any library to be installed as the app exposes the protocol natively.
|
|
133
|
+
|
|
134
|
+
```js
|
|
135
|
+
window.onerror = function myErrorHandler() {
|
|
136
|
+
window.open("replayable://replay/create", "_blank");
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
setTimeout(() => {
|
|
140
|
+
throw new Error("Throw makes it go boom!");
|
|
141
|
+
}, 3000);
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
# Advanced Usage
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
Usage: replayable create [options]
|
|
148
|
+
|
|
149
|
+
Create a replay and output the resulting url or markdown. Will launch desktop app for local editing before publishing.
|
|
150
|
+
|
|
151
|
+
Options:
|
|
152
|
+
-t, --title <string> Title of the replay. Automatically generated if not supplied.
|
|
153
|
+
-d, --description [text] Replay markdown body. This may also be piped in: `cat README.md | replayable create`
|
|
154
|
+
--md Returns code for a rich markdown image link.
|
|
155
|
+
-h, --help display help for command
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Ideas
|
|
159
|
+
|
|
160
|
+
It would be possible to string this along in [a git hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to publish with every commit.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const replayable = require("./index");
|
|
2
|
+
|
|
3
|
+
process.on("uncaughtException", async (err) => {
|
|
4
|
+
console.error(err);
|
|
5
|
+
let replay = await replayable.createReplay();
|
|
6
|
+
console.log("Replayable", replay);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
setTimeout(() => {
|
|
10
|
+
throw new Error("Throw makes it go boom!");
|
|
11
|
+
}, 3000);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
gh issue create -w -t "Title" -b "`replayable --md`"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title></title>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<a href="replayable://replay/create" target="_blank">Create Replay</a>
|
|
9
|
+
<a href="#" onClick="causeError()">Throw an Error</a>
|
|
10
|
+
<script>
|
|
11
|
+
window.onerror = function myErrorHandler(errorMsg, url, lineNumber) {
|
|
12
|
+
console.log('onError', errorMsg)
|
|
13
|
+
window.location= "replayable://replay/create";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
causeError = () => {
|
|
17
|
+
throw new Error("Throw makes it go boom!");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
</script>
|
|
21
|
+
</body>
|
|
22
|
+
</html>
|
package/index.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const lib = require("./lib");
|
|
4
|
+
const { program } = require("commander");
|
|
5
|
+
|
|
6
|
+
let stdin = "";
|
|
7
|
+
|
|
8
|
+
program
|
|
9
|
+
.name("replayable")
|
|
10
|
+
.description(
|
|
11
|
+
"Upgrade your bug reports, pulls, and readmes with clips from local development"
|
|
12
|
+
)
|
|
13
|
+
.version("0.0.9");
|
|
14
|
+
|
|
15
|
+
program.showHelpAfterError();
|
|
16
|
+
|
|
17
|
+
program
|
|
18
|
+
.command("create", { isDefault: true })
|
|
19
|
+
.description(
|
|
20
|
+
"Create a replay and output the resulting url or markdown. Will launch desktop app for local editing before publishing."
|
|
21
|
+
)
|
|
22
|
+
.option(
|
|
23
|
+
"-t, --title <string>",
|
|
24
|
+
"Title of the replay. Automatically generated if not supplied."
|
|
25
|
+
)
|
|
26
|
+
.option(
|
|
27
|
+
"-d, --description [text]",
|
|
28
|
+
"Replay markdown body. This may also be piped in: `cat README.md | replayable create`"
|
|
29
|
+
)
|
|
30
|
+
.option("--md", "Returns code for a rich markdown image link.")
|
|
31
|
+
.action(async function (str, options) {
|
|
32
|
+
try {
|
|
33
|
+
let description = this.opts().description;
|
|
34
|
+
if (stdin) {
|
|
35
|
+
description = stdin;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let result = await lib.createReplay({
|
|
39
|
+
title: this.opts().title,
|
|
40
|
+
description,
|
|
41
|
+
private: this.opts().private,
|
|
42
|
+
md: this.opts().md,
|
|
43
|
+
png: this.opts().png,
|
|
44
|
+
});
|
|
45
|
+
console.log(result);
|
|
46
|
+
} catch (e) {
|
|
47
|
+
console.log("Error: ", e);
|
|
48
|
+
}
|
|
49
|
+
process.exit(0);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (process.stdin.isTTY) {
|
|
53
|
+
program.parse(process.argv);
|
|
54
|
+
} else {
|
|
55
|
+
process.stdin.on("error", function () {});
|
|
56
|
+
process.stdin.on("readable", function () {
|
|
57
|
+
var chunk = this.read();
|
|
58
|
+
|
|
59
|
+
if (chunk !== null) {
|
|
60
|
+
stdin += chunk;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
process.stdin.on("end", function () {
|
|
64
|
+
program.parse(process.argv);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (module.parent) {
|
|
69
|
+
module.exports = lib;
|
|
70
|
+
}
|
package/lib.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const ipc = require("node-ipc").default;
|
|
2
|
+
const clc = require("cli-color");
|
|
3
|
+
|
|
4
|
+
ipc.config.id = "replayable-cli";
|
|
5
|
+
ipc.config.retry = 1500;
|
|
6
|
+
ipc.config.silent = true;
|
|
7
|
+
ipc.config.maxRetries = 0;
|
|
8
|
+
|
|
9
|
+
const connectToIpc = function () {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
ipc.connectTo("replayable");
|
|
12
|
+
ipc.of.replayable.on("connect", resolve);
|
|
13
|
+
ipc.of.replayable.on("error", (e) => {
|
|
14
|
+
if (e.code === "ENOENT") {
|
|
15
|
+
console.log(
|
|
16
|
+
clc.red("Could not connect to Replayable Desktop App. Is it running?")
|
|
17
|
+
);
|
|
18
|
+
console.log(
|
|
19
|
+
clc.yellow(
|
|
20
|
+
"You may need to download and install the app from https://bit.ly/3ipoQLJ"
|
|
21
|
+
)
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
ipc.of.replayable.on("disconnect", function () {
|
|
26
|
+
console.log("Disconnected from Replayable");
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const createReplay = async function (options = {}) {
|
|
32
|
+
options.md = options.md || false;
|
|
33
|
+
|
|
34
|
+
options.title = options.title || false;
|
|
35
|
+
options.description = options.description || null;
|
|
36
|
+
|
|
37
|
+
await connectToIpc();
|
|
38
|
+
|
|
39
|
+
return new Promise(async (resolve, reject) => {
|
|
40
|
+
ipc.of.replayable.on(
|
|
41
|
+
"upload", //any event or message type your server listens for
|
|
42
|
+
function (data) {
|
|
43
|
+
if (options.md) {
|
|
44
|
+
resolve(data.replay.markdown);
|
|
45
|
+
} else {
|
|
46
|
+
resolve(data.replay.shareLink);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
reject(
|
|
53
|
+
"Replayable Desktop App did not respond in time. Did you publish a replay?"
|
|
54
|
+
);
|
|
55
|
+
}, 60000 * 5);
|
|
56
|
+
|
|
57
|
+
ipc.of.replayable.emit("create", {
|
|
58
|
+
title: options.title,
|
|
59
|
+
description: options.description,
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
module.exports = { createReplay };
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dashcam",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Fix bugs, close pulls, and update your team with desktop instant replay.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"prepare": "husky install"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"replayable": "index.js"
|
|
12
|
+
},
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"cli-color": "^2.0.3",
|
|
17
|
+
"commander": "^9.4.0",
|
|
18
|
+
"husky": "^7.0.4",
|
|
19
|
+
"node-ipc": "^10.1.0",
|
|
20
|
+
"yargs": "^17.3.1"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"husky": "^7.0.0"
|
|
24
|
+
}
|
|
25
|
+
}
|