Wire up bunch of interaction events into Posthog (#7707)
This commit is contained in:
parent
5620b83d34
commit
999e1b7421
12 changed files with 120 additions and 26 deletions
|
@ -14,8 +14,9 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { PureComponent } from "react";
|
||||
import { PureComponent, SyntheticEvent } from "react";
|
||||
import { Screen as ScreenEvent } from "matrix-analytics-events/types/typescript/Screen";
|
||||
import { Interaction as InteractionEvent } from "matrix-analytics-events/types/typescript/Interaction";
|
||||
|
||||
import PageType from "./PageTypes";
|
||||
import Views from "./Views";
|
||||
|
@ -88,6 +89,21 @@ export default class PosthogTrackers {
|
|||
this.override = null;
|
||||
this.trackPage();
|
||||
}
|
||||
|
||||
public static trackInteraction(name: InteractionEvent["name"], ev?: SyntheticEvent): void {
|
||||
let interactionType: InteractionEvent["interactionType"];
|
||||
if (ev?.type === "click") {
|
||||
interactionType = "Pointer";
|
||||
} else if (ev?.type.startsWith("key")) {
|
||||
interactionType = "Keyboard";
|
||||
}
|
||||
|
||||
PosthogAnalytics.instance.trackEvent<InteractionEvent>({
|
||||
eventName: "Interaction",
|
||||
interactionType,
|
||||
name,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class PosthogScreenTracker extends PureComponent<{ screenName: ScreenName }> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue