Comments (4)
Agree with @jsharpe-mr that would be nice to have more granular control over documentReady()
.
In our case we install & use ahoy via npm/yarn. However, importing the module automatically executes documentReady()
and starts it, before we get a chance to set up ahoy with variables necessary for its correct function (e.g. urlPrefix
, authentication headers).
At least when building as a node module, would be nice to skip documentReady()
to make the library more standalone.
from ahoy.js.
Hey @jsharpe-mr, I think a vast majority of users either don't need to configure Ahoy or are able to configure it before the document is ready, so I don't think it makes sense for all of those users to have to call it manually.
from ahoy.js.
I'm using ahoy.js
in webpacker installed via yarn. What is the recommended practice for configuring ahoy.js
with this setup?
I think I'm running into the same issue where documentReady
runs before I'm able to configure the library.
from ahoy.js.
I'm also using ahoy.js
in a webpacker environment and am facing the same issue. The way I'm handling this is by temporarily assigning the config object to window.ahoy
, allowing ahoy to pull that object in on instantiation (see relevant ahoy logic), and resetting window.ahoy
to its original value:
initAhoy() {
// desired configuration
let ahoyConfig = { cookies: false };
// back up current window.ahoy value
let oldAhoy = window.ahoy;
// assign window.ahoy to the config object,
// ahoy.js will use it for configuration once instantiated
window.ahoy = ahoyConfig;
this.ahoy = require('ahoy.js').default;
// restore previous window.ahoy value
window.ahoy = oldAhoy;
}
I'm not sure if this is the best approach, but it works fairly well for my use case.
from ahoy.js.
Related Issues (20)
- ahoy.js does not track click events for a-tags that contain HTML tags. Is it intentional? HOT 3
- Click event is duplicated when redirect from A.html to B.html HOT 2
- Add the option to keep the ahoy_visit cookie alive HOT 2
- Why visitsUrl and eventsUrl should use double // on my side HOT 1
- Update the no-jquery branch HOT 1
- Support skipping certain tracked events inside a [data-no-track] tagged element HOT 10
- TypeError: Illegal invocation HOT 3
- Add debug messaging around sendbeacon HOT 1
- Cross-Origin Read Blocking (CORB) blocked cross-origin response HOT 1
- Why did you remove #trackAll ? (just curious) HOT 2
- [Idea] Remove TailwindCSS classes from "class" attribute in ahoy.js HOT 1
- Open to moving some helper functions to exports?
- [Idea] The ability to update a visit, or be able to start a visit programmatically.
- Next js and ahoy HOT 1
- Expo Support? HOT 2
- Using useBeacon: true results in NS_ERROR_FAILURES on events HOT 1
- [Idea] Extra attributes on clicks HOT 1
- [idea] trackSubmits could include the action url
- [help] NextJS + Ahoy
- Issue with SSR: window is not defined HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ahoy.js.