Skip to content

Commit

Permalink
stats.plutojl.org
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Jul 7, 2021
1 parent ed69c0b commit 63befc7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion frontend/common/Binder.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ export const request_binder = (build_url) =>

export const start_binder = async ({ setStatePromise, connect, launch_params }) => {
try {
fetch(`https://cdn.jsdelivr.net/gh/fonsp/pluto-usage-counter@1/binder-start.txt?skip_sw`).catch(() => {})
// view stats on https://stats.plutojl.org/
fetch(`https://stats.plutojl.org/count?p=/binder-start#skip_sw`, { cache: "no-cache" }).catch(() => {})
await setStatePromise(
immer((state) => {
state.binder_phase = BinderPhase.requesting
Expand Down
14 changes: 11 additions & 3 deletions frontend/components/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ export class Editor extends Component {
}))

let index
if (typeof(index_or_id) === 'number') {

if (typeof index_or_id === "number") {
index = index_or_id
} else {
/* if the input is not an integer, try interpreting it as a cell id */
Expand Down Expand Up @@ -722,11 +722,19 @@ patch: ${JSON.stringify(
binder_phase: this.state.offer_binder ? BinderPhase.wait_for_user : null,
})
})()
fetch(`https://cdn.jsdelivr.net/gh/fonsp/pluto-usage-counter@1/article-view.txt?skip_sw`).catch(() => {})
// view stats on https://stats.plutojl.org/
fetch(`https://stats.plutojl.org/count?p=/article-view#skip_sw`, { cache: "no-cache" }).catch(() => {})
} else {
this.connect()
}

setInterval(() => {
if (!this.state.static_preview && document.visibilityState === "visible") {
// view stats on https://stats.plutojl.org/
fetch(`https://stats.plutojl.org/count?p=/editing/${window?.version_info?.pluto ?? "unknown"}#skip_sw`, { cache: "no-cache" }).catch(() => {})
}
}, 1000 * 10)

// Not completely happy with this yet, but it will do for now - DRAL
this.bonds_changes_to_apply_when_done = []
this.js_init_set = new Set()
Expand Down
2 changes: 1 addition & 1 deletion frontend/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const allowList = ["www.gstatic.com", "fonts.gstatic.com", "fonts.googleapis.com

function shouldCache(request) {
const url = new URL(request.url)
return request.method === "GET" && allowList.includes(url.host) && !url.search.includes("skip_sw")
return request.method === "GET" && allowList.includes(url.host) && !url.toString().includes("skip_sw")
}

self.addEventListener("fetch", (event) => {
Expand Down

0 comments on commit 63befc7

Please sign in to comment.