Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.
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

Description

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);
});

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions