-
Notifications
You must be signed in to change notification settings - Fork 5
Pastebin API
Pastebins in SeeCodeRun can be shared and you can know when that happens.
Pastebin events are part of the external communications SeeCodeRun offers.
This command is used by the Share UI element to copy pastebins. Be aware that the copy is made based on the content the original pastebin had at the time of copying. You can share pastebins so others can work independently based on your current work by taking your current URL and add a ":" right before your pastebin ID starts. A pastebin ID is a unique identifier that lets SeeCodeRun recover your previous work on the platform, it is the string that goes after "https://seecode.run/#".
Note: Do not forget your SeeCodeRun URL(or pastebin id). Otherwise, it will be forever lost in our pastebin sea.
Normally, your browser shows an URL like this one: "https://seecode.run/#-KhF_XVS9OsV8sFl2Ek_", to share the pastebin it should look like this "https://seecode.run/#:-KhF_XVS9OsV8sFl2Ek_". Once the URL is loaded, a new copy of the curretn content of the original pastebin is created.
SeeCodeRun publishes two types of events when users share pastebins: UI and System events.
There events are emitted once the the user interacts with the Share UI element.
Every time the user clicks on the share button, this event will be emitted.
Every time the user copies the share link, this event will be emitted.
Every time the user clicks the share link, this event will be emitted.
These events are responses from SeeCodeRun to user actions.
Every time a user creates a pastebin based via share command, this event will be emitted. Either the user used the command directly, or the link shown in the Share UI element.
Previous events are connected as follows: "shareLinkShown" --> "shareLinkCopied" or "shareLinkClicked" --> "shareLinkUsed".
Note: There are cases not done via SeeCodeRun UI. Well, it is a URL, once you got the link you can use it afterwards or use the URL share command ":" to create it.
To listen pastebin share events, provide the pastebin id and the path "content/share/events":
var shareEventsFirebase =
new Firebase(
`https://seecoderun.firebaseio.com/test/-KhGIb91d_T3gIjfW5dq/content/share/events`
);
shareEventsFirebase
.limitToLast(1)
.on('child_added',
function child_added(snapshot) {
var data = snapshot.val();
console.log(data);
});
Once you listen to the reference data changes, each event data will look like this:
{event: "shareLinkShown", timestamp: 1491716254084}
This fiddle shows how it works.