diff --git a/frontend/common/Binder.js b/frontend/common/Binder.js index 6882fc544b..06c0db8c7d 100644 --- a/frontend/common/Binder.js +++ b/frontend/common/Binder.js @@ -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 diff --git a/frontend/components/Editor.js b/frontend/components/Editor.js index 3b0d6050e0..1723873c7d 100644 --- a/frontend/components/Editor.js +++ b/frontend/components/Editor.js @@ -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 */ @@ -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() diff --git a/frontend/sw.js b/frontend/sw.js index ac2d44b40b..30d90d2eb7 100644 --- a/frontend/sw.js +++ b/frontend/sw.js @@ -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) => {