forked from matter-labs/zksync-web-era-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds rudder analytics (matter-labs#662)
* feat: adds rudder analytics * fix: build fix - only run code on client side --------- Co-authored-by: Antonio <[email protected]>
- Loading branch information
1 parent
f868af3
commit 2aedac6
Showing
5 changed files
with
52 additions
and
1 deletion.
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
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,30 @@ | ||
import { defineClientConfig } from '@vuepress/client' | ||
|
||
export default defineClientConfig({ | ||
enhance({ app, router }) { | ||
|
||
if (!__VUEPRESS_SSR__) { | ||
router.isReady().then(() => { | ||
|
||
const rudderScript = document.createElement('script') | ||
rudderScript.innerHTML = ` | ||
rudderanalytics = window.rudderanalytics=[]; | ||
for(var methods=["load","page","track","identify","reset"],i=0;i<methods.length;i++){var method=methods[i];rudderanalytics[method]=function(a){return function(){rudderanalytics.push([a].concat(Array.prototype.slice.call(arguments)))}}(method)} | ||
rudderanalytics.load(__RUDDER_WRITE_KEY__, __RUDDERSTACK_DATA_PLANE_URL__); | ||
`; | ||
document.head.appendChild(rudderScript) | ||
|
||
const rudderSDK = document.createElement('script') | ||
rudderSDK.src = `https://cdn.rudderlabs.com/rudder-analytics.min.js` | ||
rudderSDK.onload = function() { | ||
rudderanalytics.page(); | ||
|
||
router.afterEach(function (to) { | ||
rudderanalytics.page(); | ||
}) | ||
} | ||
document.head.appendChild(rudderSDK) | ||
}) | ||
}; | ||
} | ||
}) |
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
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