Description
I'm writing an 'enrichment' plugin that should add a property to any event that comes through track
. However, the value of this property relies on a value added to events via an integration (the Amplitude Actions integration to be specific). Here is the code I'm using to register my plugin:
const testPlugin: Plugin = {
name: "Session Replay Events",
type: "enrichment",
version: "1.0.0",
isLoaded: () => true,
load: loadMethod,
track: trackMethod,
};
SegmentAnalytics.load({
writeKey: <api key>,
plugins: [testPlugin],
});
When debugging this, I've inspected the code and observed that testPlugin
(red arrow in below screenshot) is always added before the Actions enrichment plugin (blue arrow in below screenshot)
I believe the ordering is occurring due to the ordering of plugins
vs remotePlugins
in this code snippet.
I'd like to have my plugin be registered in load() so that we can enrich all events, including those emitted immediately on page load (as opposed to registering my plugin after load(), which means it will not capture those initial events).
Because of the ordering, when I console log via my track
method, the ctx.event.integrations
object is empty, as the Amplitude Actions integration has not yet been processed:
Is there any way I can have my testPlugin be registered in load()
, but have its track calls execute after those from remotely loaded plugins?