analytics-plugin-segment missing category fields
Hi @DavidWells, My team is using analytics-plugin-segment to send event to segment, and we noticed the segment can't receive category from the payload.
I debug in the plugin and found the code not handling the category fields.
I raised a PR already, could you please have a look. thanks
Added comment to PR https://github.com/DavidWells/analytics/pull/212
Can you verify the change isn't breaking? You can extend the base plugin and try out your new method.
import Analytics from 'analytics'
import segmentPlugin from '@analytics/segment'
const baseSegmentPlugin = segmentPlugin({
writeKey: '123-xyz'
})
const customSegmentPlugin = {
...baseSegmentPlugin,
...{
// Your custom page overide function
page: ({ payload, config }) => {
if (typeof analytics === 'undefined') return
const properties = payload.properties || {}
const name = properties.name || properties.title
const category = properties.category
analytics.page(category, name, properties, {
integrations: config.integrations,
...payload.options,
})
},
}
}
const analytics = Analytics({
app: 'awesome-app',
plugins: [
customSegmentPlugin
]
})
analytics.page()
Side note: You can override any plugin method like this and can use your new setup without waiting for PR to merge in
That's really handy to know how simple it is to override the methods!
Released with @analytics/[email protected]