Skip to content
David Gonzalez edited this page May 5, 2017 · 16 revisions

Description

Pastebins in SeeCodeRun can be shared and you can know when that happens.

API Navigation

Pastebin events are part of the external communications SeeCodeRun offers.

Commands

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.

Example

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_".

Events

SeeCodeRun publishes two types of events when users share pastebins: UI and System events.

UI Events

"shareLinkShown"

Every time the user clicks on the share button, this event will be emitted.

"shareLinkCopied"

Every time the user copies the share link, this event will be emitted.

"shareLinkClicked"

Every time the user clicks the share link, this event will be emitted.

System events

"shareLinkUsed"

Every time a user creates a pastebin based on the shown link, this event will be emitted.

LifeCycle

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.

Usage

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}

Try it!

This fiddle shows how it works.

Note: Due to cross-origin constraints, the "most" elegant way of publishing SeeCodeRun events is via Firebase.