benjaminhoffman / gatsby-plugin-segment-js

Gatsby plugin for segment.com's analytic.js snippet
https://www.npmjs.com/package/gatsby-plugin-segment-js
MIT License
40 stars 28 forks source link

Question: where does `{ trackPage }` come from? #15

Closed i8ramin closed 4 years ago

i8ramin commented 5 years ago

Hi. Looking at the source for gatsby-brower.js, where exactly does the 2nd paramter { trackPage } come from?

exports.onRouteUpdate = ({}, { trackPage }) => {

https://github.com/benjaminhoffman/gatsby-plugin-segment-js/blob/master/src/gatsby-browser.js#L1

According to the Gatsby Browser API docs, onRouteUpdate has only 1 parameter, de-structured as { location, prevLocation }

lsirivong commented 5 years ago

Maybe the docs updated since this was posted, but the second parameter is the pluginOptions object (aka the object of options in gatsby-config.js).

https://github.com/gatsbyjs/gatsby/blob/e9605d5640318c8e30030de08449c30cb420c3a2/packages/gatsby/src/utils/api-browser-docs.js#L66

benjaminhoffman commented 5 years ago

haha, tis gatsby! so many un-published nuances of their API. things seem to keep changing.

did this solve your Q? wants to add something into our docs about this?

i just merged your other PR btw.