-
-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a Google Analytics plugin #14
Comments
Hi, @fmvilas I'd really love to contribute and help with the development of the studio. I'd love to start by fixing current open issues. and is there a slack group for the ongoing development of the studio? |
Hey! Sure, you can join us at asyncapi.com/slack-invite. There's a #tooling channel there. Thanks! |
@fmvilas Developers can manually enable/disable the plugin from the codebase right? |
Yeah, the way to configure the plugins you want to load is to edit this file here: https://github.com/asyncapi/studio/blob/master/config/plugins.json. |
@fmvilas Can i change the _app.js to a functional component? or is there a specific reason why you're using class component? |
No problem. Feel free to change it. |
@fmvilas I'm having issue with plugin path after adding a plugin to the plugins.json file. |
In the plugins.json file i just pass it like this |
mmmm not sure. Can you push a PR so I can try myself? |
@fmvilas try using the existing code by adding sentry path to the list of plugins in the |
Oh! I know what's happening. Plugins are always loaded from cd plugins/google-analytics
## Make sure the package name and version are correct. Something like `@asyncapistudio/plugin-google-analytics` and version `0.1.0` or whatever you prefer.
npm link Then go back to the project root directory and tell it you want to use the linked package: cd ../.. # Back to project root dir
npm link @asyncapistudio/plugin-google-analytics # or the package name you chose And now on the plugins.json file, you have to specify it like this: {
"plugins": [
"@asyncapistudio/plugin-google-analytics"
]
} Hope that makes sense :) |
Yeah it makes sense . One more thing @fmvilas how do i make the plugin subscribe to an event on page render? |
@fmvilas is the event.on for subscribing and event.emit for triggering? |
Yes! But you probably will have to emit the event yourself when a page is rendered. And also subscribe on the plugin side, of course. I recommend you to have a look at the Node.js EventEmitter, which is what we're using right now. |
@fmvilas I was able to resolve this problem, so don't worry looking into it. |
@fmvilas How do i make the plugin subscribe to the event? I already define a |
Oh, I completely missed your messages above. Glad you were able to solve it. Bear in mind that That means you'll have to create an eventing system for the front end. Something like this but only imported in frontend. |
Ok I'll do that. But how can i make the plugin subscribe to an event? |
@fmvilas I'm trying to make the plugin subscribe to the |
Yeah, I think that's the best way. |
@fmvilas when I subscribe to the event from a different file and I trigger it in the app.js render it doesn't work. For instance, when I call event names from the app.js to check the list of subscribed events, it returns an empty array. Except I call both the subscribe and trigger event within the page render function in the app.js |
@magicmatatjahu can you have a look? I really don't have much time to dig into code 😓 👶 🍼 |
@AceTheCreator I answered in the PR :) I know @fmvilas that you are very busy, but please, in the free time, check my comment, because (probably) we cannot use plugins on the client side. More info is in comment. Maybe you had this case in mind when you wrote issue's description, so let us know 😅 |
This issue has been automatically marked as stale because it has not had recent activity 😴 |
This issue has been automatically marked as stale because it has not had recent activity 😴 |
Since we're going with a different implementation of Studio (as a SPA app, rather than using NextJS) I'm closing this issue. In addition, the implementation of the current plugins works only on NodeJS and not in the browser (#37 (comment)), so we have to redefine them - probably have two types, for the frontend (asyncapi/asyncapi-react#433) and backend (#86). |
Description
We used to have Google Analytics hardcoded (see #13). However, some people may not want to use it so it's better if we make it a plugin instead.
Implementation suggestion
src/pages/_app.js
file and make it trigger a new kind of event on therender
function. For instance, something like apage:render
event. Make sure this event is only triggered on the client-side render.initialize
andpageview
call when a new event comes in.Hints
The code for triggering/subscribing to events is on
src/lib/events.js
. However, this library was created for the backend and it imports theconfig
lib, which may contain secrets. If we use theevents
lib on the frontend, these secrets may be exposed on the browser. Watch out!The text was updated successfully, but these errors were encountered: