Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

event.type comes through as "page" for track events #670

Open
dannyshaw opened this issue Apr 5, 2022 · 0 comments
Open

event.type comes through as "page" for track events #670

dannyshaw opened this issue Apr 5, 2022 · 0 comments

Comments

@dannyshaw
Copy link

dannyshaw commented Apr 5, 2022

I'm not sure if this is expected behaviour, I'm trying to write an enrichment plugin that fetches extra data for events before sending them off. It's working pretty well, but I need to differentiate between tracks and pages but both calls come through as event.type === 'page'. Is this expected?

async function enrichEventProperties(ctx) {
  let event = ctx.event;
  console.log(event.type);   // Always 'page'
  await enrichProperties(event);
  ctx.event = event;
  return ctx;
}

const eventEnrichmentPlugin = {
  name: 'Event Enrichment Plugin',
  version: '0.0.1',
  isLoaded: () => true,
  load: () => Promise.resolve(),
  type: 'enrichment',
  page: enrichEventProperties,
  track: enrichEventProperties,
};

global.analytics.ready(function () {
  global.analytics.register(eventEnrichmentPlugin);
});
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant