Created
October 8, 2019 17:04
-
-
Save garth/6e0d4a14734ba9326b4483c3adbbdb5f to your computer and use it in GitHub Desktop.
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 would be the client in the npm package | |
export const plausible: (arg: 'page' | 'trackPushState') => void = (window['plausible'] = | |
window['plausible'] || | |
function( | |
...args: any[] // eslint-disable-line | |
) { | |
;(window['plausible'].q = window['plausible'].q || []).push(args) | |
}) | |
const js = document.createElement('script') | |
js.id = 'plausible' | |
js.src = '/plausible/js/p.js' // the path might need to be configurable | |
js.async = true | |
document.head.appendChild(js) |
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
import proxy from 'http-proxy-middleware' | |
// proxy to plausible | |
app.use( // app is an express app | |
'/plausible', | |
proxy({ | |
target: 'https://plausible.io', | |
pathRewrite: { '^/plausible': '' }, | |
}) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment