mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Added Posthog event sending to trackEvent function (#19716)
refs PA-37 As we add Posthog to the stack we want to send the existing events we track to it, as well as opening up the method to teams to use in their initiatives. --------- Co-authored-by: Chris Raible <chris@ghost.org>
This commit is contained in:
parent
f49b5ab78d
commit
7c407af642
1 changed files with 6 additions and 2 deletions
|
@ -26,9 +26,9 @@ async function hashEmail(email) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sends a tracking event to Plausible, if installed.
|
||||
* Sends a tracking event to Plausible and Posthog, if installed.
|
||||
*
|
||||
* By default, Plausible is not installed, in which case this function no-ops.
|
||||
* By default, Plausible and Posthog are not installed, in which case this function no-ops.
|
||||
*
|
||||
* @param {string} eventName A string name for the event being tracked
|
||||
* @param {Object} [props={}] An optional object of properties to include with the event
|
||||
|
@ -38,6 +38,10 @@ export function trackEvent(eventName, props = {}) {
|
|||
(window.plausible.q = window.plausible.q || []).push(arguments);
|
||||
};
|
||||
window.plausible(eventName, {props: props});
|
||||
|
||||
if (isPosthogLoaded()) {
|
||||
window.posthog.capture(eventName, props);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue