You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-07 21:23:00 +03:00
Wire up bunch of interaction events into Posthog (#7707)
This commit is contained in:
committed by
GitHub
parent
5620b83d34
commit
999e1b7421
@@ -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 }> {
|
||||
|
Reference in New Issue
Block a user