Comments (6)
Just added the ability to do ahoy.configure({headers: ...})
on master.
from ahoy.js.
Hey @Startouf, I'm facing the same problem due to JWT. I'm using jwt_sessions as my authentication framework which authentications via a Authorization
header.
I ended up forking ajoy.js
and implementing support for headers
as an additional configuration parameter. You can take a look here under the issue_23
branch: https://github.com/krsyoung/ahoy.js/tree/issue_23
It is pretty bad at the moment but works. In my frontend Vue code I just make a call to set the header once the user has authenticated:
// this.$ahoy is my ahoy instance
this.$ahoy.setHeader('Authorization', 'Bearer: ' + accessToken)
My situation is even more complicated as I need to decode the token on the backend before I can access the current user. I solved this by creating a custom user method for ahoy (called ahoy_user
) that manually performs the decode and then returns the user.
What did you end up doing? Could my branch work for you?
from ahoy.js.
I'm reading the JWT token + user ID from custom headers named X-user-Token
and X-user-email
so I'm not sure your branch would work if you are just reading from Authorization
I am using the simple_token_authentication
gem
from ahoy.js.
Ah, the change I made in my branch is really just to allow ahoy.js to support any arbitrary headers. I think in your case it would be as simple as:
// set customer HTTP headers for ahoy
ahoy.setHeader('X-user-token', 'xxx')
ahoy.setHeader('X-user-email', 'xxx')
I also ate a lot of turkey over the past couple of days so I can't really say I'm 100% confident!
from ahoy.js.
@krsyoung I started using your branch and it works great. One thing is I needed to set useBeacon
to false to get the headers to send when tracking events.
Since it seems like there's sufficient interest in this feature, can we submit a pull for this?
from ahoy.js.
I'm game if @ankane is supportive.
Good call on the useBeacon
@golmansax!
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.