-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add telemetry to standalone example (#47)
* Add telemetry to standalone example * Test for lints in CI
- Loading branch information
1 parent
e7c59a8
commit e4b2798
Showing
4 changed files
with
30 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const BASE_URL = "http://localhost:8888"; | ||
|
||
class Telemetry { | ||
async log(endpoint: string, payload: object) { | ||
let url = `${BASE_URL}/${endpoint}`; | ||
|
||
let response = await fetch(url, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json" | ||
}, | ||
body: JSON.stringify(payload) | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error(`Failed to log with status: ${response.statusText} `); | ||
} | ||
} | ||
} | ||
|
||
if (typeof window !== "undefined") { | ||
window.telemetry = new Telemetry(); | ||
} |