I have run:
npm i guess-webpack
In my webpack.mix.js I have:
const { GuessPlugin } = require('guess-webpack');
mix.webpackConfig({
plugins: [
new GuessPlugin({
GA: '123456789',
jwt: {
private_key: "-----BEGIN PRIVATE KEY-----\nSomething!!!\n-----END PRIVATE KEY-----\n",
client_email: "example@example.com",
},
//debug: true,
runtime: {
delegate: false
}
}),
Till now, it is working and when I uncomment the debug: true, it returns all the routes and probabilities like so:
Initial mapping between routes and probability
{
"/": [{
"route": "/example-1",
"probability": 0.16031746031746033
}, {
"route": "/example-2",
"probability": 0.10031746031746033
}]
...
...
...
}
But now the problem is that when I want to get the data from guess() function which is inside guess-webpack/api into my vue application in order to get the routes and probabilities, it returns:
[Vue warn]: Error in mounted hook: "TypeError: (intermediate value).__GUESS__ is undefined"
.
.
.
TypeError: (intermediate value).__GUESS__ is undefined
My code that generates the above error is:
import Vue from 'vue';
new Vue({
el: '#app',
data() {
return {}
},
mounted() {
const { guess } = require('guess-webpack/api');
if (typeof window !== 'undefined') {
console.log(guess()); //This is undefined!
}
}
I have access to `__GUESS__` and its method which is `p` in my console but when I run `__GUESS__.p()`, it returns `undefined`.
What's inside guess-webpack/api:
export const guess = (params: any) =>
((typeof window === 'undefined' ? global : window) as any).__GUESS__.guess(params);
How to get routes and probabilities with guess-webpack and guess-webpack/api in vuejs?