GithubHelp home page GithubHelp logo

Comments (4)

dustinlarimer avatar dustinlarimer commented on June 12, 2024

Yeah, this was dropped in favor of using the client.url() method and internal resources config for building URLs. The issue was that this writePath design made it super difficult to customize the URL when proxying writes through an intermediary service. I suppose this wording should be removed from the README file. Nice catch!

from keen-tracking.js.

Ramblurr avatar Ramblurr commented on June 12, 2024

What's the recommended way to achieve "writepath" like features?

We're proxying writes through our own server, and it doesn't use the /3.0/projects/... url format.

So to override the path I am doing this very hacky thing

var writePath = "/api/analytics/events"; // our custom prefix
client.config.resources.events = client.config.resources.events.replace("/3.0/projects/{projectId}/events", writePath);

from keen-tracking.js.

dustinlarimer avatar dustinlarimer commented on June 12, 2024

@Ramblurr these resources are managed via the internal resources map you found, and can be accessed w/ the client.resources() method. This map is used to construct URLs with client.url('some-key'). We've named the defaults according to corresponding API resources.

Here are a few examples:

{
  'projectId': '{protocol}://{host}/3.0/projects/{projectId}',
  'events': '{protocol}://{host}/3.0/projects/{projectId}/events'
}

Those values wrapped in brackets are replaced with matching props from the client instance's configuration. This is all meant to create some options with regard to building out URLs.

You can rewire (and then access) the events endpoint like so:

client.resources({
  'events': '{protocol}://{host}/api/analytics/events'
});

client.url('events');
// returns https://your-host.com/api/analytics/events

You could also just hardwire the protocol and host in this way too, if you prefer.

Does this help answer the question? Sorry for the speed-bump!

from keen-tracking.js.

dustinlarimer avatar dustinlarimer commented on June 12, 2024

@Ramblurr was this answer helpful? Closing for now, but please let me know if I can add any more info or context here-

from keen-tracking.js.

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.