-
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.
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_".
SeeCodeRun publishes two types of events when users share pastebins: UI and System events.
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.
Every time a user creates a pastebin based on the shown link, this event will be emitted.
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.