Git Product home page Git Product logo

Comments (6)

LiuuY avatar LiuuY commented on August 30, 2024 4

Come across the same problem, as @joernroeder said, I just pass a modifier to .connectToHistory:

const modifier = function (location) {
    const loc = window.location;
    location.path = `${loc.origin}${loc.pathname}${loc.hash}`;
    return location;
};

from piwik-react-router.

joernroeder avatar joernroeder commented on August 30, 2024

have you seen and applied the post in the piwik faq? https://piwik.org/faq/how-to/faq_188/

from piwik-react-router.

regdos avatar regdos commented on August 30, 2024

Yes, but this is not my case because url sended to piwik not contain hash.

After analyze code and testing when i add remove initial slash

currentPath = currentPath.replace(/^\//, '');

before line https://github.com/joernroeder/piwik-react-router/blob/master/index.js#L58
url send to piwik is correct (contain context and hash)

from piwik-react-router.

joernroeder avatar joernroeder commented on August 30, 2024

if i understand you right, your main problem is the loos of the context path. is that correct?
You could add the basename (in your case context) to the history object to prefix the app path.

If all the URLs in your app are relative to some other "base" URL, use the basename option. This option transparently adds the given string to the front of all URLs you use.

https://github.com/ReactTraining/history#using-a-base-url

Alternatively you could proxy the history.listen callback and pass down your modified path via loc.path to set the currentPath via https://github.com/joernroeder/piwik-react-router/blob/master/index.js#L51

hope that helps!

cheers jรถrn

from piwik-react-router.

joernroeder avatar joernroeder commented on August 30, 2024

@regdos after thinking about the proxy/modifier today i found other use cases to modify the location (e.g. to add campain parameters or state from outside react). I've ended up adding the functionality of History Modifiers directly into .connectToHistory. Please head over to the docs to see if it works well for you. I am excited about your feedback.

from piwik-react-router.

joernroeder avatar joernroeder commented on August 30, 2024

@regdos could you resolve the issue? I'm closing this issue for now as the possibility to manipulate the current location before it gets passed to the tracker exists in the module since this version (v0.9.0).

Thanks for opening this issue as it leaded to a new useful feature of this module and feel free to reopen it if you need any help. cheers

from piwik-react-router.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.