Switch to web-specific screens and $pageview event (#7777)
parent
0d6ef76605
commit
87ca70edb1
|
@ -91,7 +91,7 @@
|
|||
"linkifyjs": "^4.0.0-beta.4",
|
||||
"lodash": "^4.17.20",
|
||||
"maplibre-gl": "^1.15.2",
|
||||
"matrix-analytics-events": "github:matrix-org/matrix-analytics-events.git#b183e6316826be11bbcc82d44b8f71921acd9d76",
|
||||
"matrix-analytics-events": "github:matrix-org/matrix-analytics-events.git#bdabdd63280f052cedeeb0c25443f3d55f7c7108",
|
||||
"matrix-events-sdk": "^0.0.1-beta.6",
|
||||
"matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop",
|
||||
"matrix-widget-api": "^0.1.0-beta.18",
|
||||
|
|
|
@ -23,6 +23,7 @@ import PlatformPeg from './PlatformPeg';
|
|||
import SdkConfig from './SdkConfig';
|
||||
import { MatrixClientPeg } from "./MatrixClientPeg";
|
||||
import SettingsStore from "./settings/SettingsStore";
|
||||
import { ScreenName } from "./PosthogTrackers";
|
||||
|
||||
/* Posthog analytics tracking.
|
||||
*
|
||||
|
@ -148,20 +149,20 @@ export class PosthogAnalytics {
|
|||
}
|
||||
}
|
||||
|
||||
// we persist the last `$screen_name` and send it for all events until it is replaced
|
||||
private lastScreen: ScreenName = "Loading";
|
||||
|
||||
private sanitizeProperties = (properties: posthog.Properties): posthog.Properties => {
|
||||
// Callback from posthog to sanitize properties before sending them to the server.
|
||||
//
|
||||
// Here we sanitize posthog's built in properties which leak PII e.g. url reporting.
|
||||
// See utils.js _.info.properties in posthog-js.
|
||||
|
||||
// Replace the $current_url with a redacted version.
|
||||
// $redacted_current_url is injected by this class earlier in capture(), as its generation
|
||||
// is async and can't be done in this non-async callback.
|
||||
if (!properties['$redacted_current_url']) {
|
||||
logger.log("$redacted_current_url not set in sanitizeProperties, will drop $current_url entirely");
|
||||
if (properties["eventName"] === "$pageview") {
|
||||
this.lastScreen = properties["$current_url"];
|
||||
}
|
||||
properties['$current_url'] = properties['$redacted_current_url'];
|
||||
delete properties['$redacted_current_url'];
|
||||
// We inject a screen identifier in $current_url as per https://posthog.com/tutorials/spa
|
||||
properties["$current_url"] = this.lastScreen;
|
||||
|
||||
if (this.anonymity == Anonymity.Anonymous) {
|
||||
// drop referrer information for anonymous users
|
||||
|
@ -204,7 +205,7 @@ export class PosthogAnalytics {
|
|||
return;
|
||||
}
|
||||
const { origin, hash, pathname } = window.location;
|
||||
properties['$redacted_current_url'] = getRedactedCurrentLocation(origin, hash, pathname);
|
||||
properties["redactedCurrentUrl"] = getRedactedCurrentLocation(origin, hash, pathname);
|
||||
this.posthog.capture(eventName, {
|
||||
...this.propertiesForNextEvent,
|
||||
...properties,
|
||||
|
|
|
@ -15,25 +15,25 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import { PureComponent, SyntheticEvent } from "react";
|
||||
import { Screen as ScreenEvent } from "matrix-analytics-events/types/typescript/Screen";
|
||||
import { WebScreen as ScreenEvent } from "matrix-analytics-events/types/typescript/WebScreen";
|
||||
import { Interaction as InteractionEvent } from "matrix-analytics-events/types/typescript/Interaction";
|
||||
|
||||
import PageType from "./PageTypes";
|
||||
import Views from "./Views";
|
||||
import { PosthogAnalytics } from "./PosthogAnalytics";
|
||||
|
||||
export type ScreenName = ScreenEvent["screenName"];
|
||||
export type ScreenName = ScreenEvent["$current_url"];
|
||||
export type InteractionName = InteractionEvent["name"];
|
||||
|
||||
const notLoggedInMap: Record<Exclude<Views, Views.LOGGED_IN>, ScreenName> = {
|
||||
[Views.LOADING]: "WebLoading",
|
||||
[Views.LOADING]: "Loading",
|
||||
[Views.WELCOME]: "Welcome",
|
||||
[Views.LOGIN]: "Login",
|
||||
[Views.REGISTER]: "Register",
|
||||
[Views.FORGOT_PASSWORD]: "ForgotPassword",
|
||||
[Views.COMPLETE_SECURITY]: "WebCompleteSecurity",
|
||||
[Views.E2E_SETUP]: "WebE2ESetup",
|
||||
[Views.SOFT_LOGOUT]: "WebSoftLogout",
|
||||
[Views.COMPLETE_SECURITY]: "CompleteSecurity",
|
||||
[Views.E2E_SETUP]: "E2ESetup",
|
||||
[Views.SOFT_LOGOUT]: "SoftLogout",
|
||||
};
|
||||
|
||||
const loggedInPageTypeMap: Record<PageType, ScreenName> = {
|
||||
|
@ -70,8 +70,8 @@ export default class PosthogTrackers {
|
|||
? loggedInPageTypeMap[this.pageType]
|
||||
: notLoggedInMap[this.view];
|
||||
PosthogAnalytics.instance.trackEvent<ScreenEvent>({
|
||||
eventName: "$screen",
|
||||
screenName,
|
||||
eventName: "$pageview",
|
||||
$current_url: screenName,
|
||||
durationMs,
|
||||
});
|
||||
}
|
||||
|
@ -80,8 +80,8 @@ export default class PosthogTrackers {
|
|||
if (!screenName) return;
|
||||
this.override = screenName;
|
||||
PosthogAnalytics.instance.trackEvent<ScreenEvent>({
|
||||
eventName: "$screen",
|
||||
screenName,
|
||||
eventName: "$pageview",
|
||||
$current_url: screenName,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -94,14 +94,14 @@ export default class UserSettingsDialog extends React.Component<IProps, IState>
|
|||
_td("General"),
|
||||
"mx_UserSettingsDialog_settingsIcon",
|
||||
<GeneralUserSettingsTab closeSettingsFn={this.props.onFinished} />,
|
||||
"WebUserSettingsGeneral",
|
||||
"UserSettingsGeneral",
|
||||
));
|
||||
tabs.push(new Tab(
|
||||
UserTab.Appearance,
|
||||
_td("Appearance"),
|
||||
"mx_UserSettingsDialog_appearanceIcon",
|
||||
<AppearanceUserSettingsTab />,
|
||||
"WebUserSettingsAppearance",
|
||||
"UserSettingsAppearance",
|
||||
));
|
||||
if (SettingsStore.getValue(UIFeature.Flair)) {
|
||||
tabs.push(new Tab(
|
||||
|
@ -109,7 +109,7 @@ export default class UserSettingsDialog extends React.Component<IProps, IState>
|
|||
_td("Flair"),
|
||||
"mx_UserSettingsDialog_flairIcon",
|
||||
<FlairUserSettingsTab />,
|
||||
"WebUserSettingFlair",
|
||||
"UserSettingFlair",
|
||||
));
|
||||
}
|
||||
tabs.push(new Tab(
|
||||
|
@ -117,28 +117,28 @@ export default class UserSettingsDialog extends React.Component<IProps, IState>
|
|||
_td("Notifications"),
|
||||
"mx_UserSettingsDialog_bellIcon",
|
||||
<NotificationUserSettingsTab />,
|
||||
"WebUserSettingsNotifications",
|
||||
"UserSettingsNotifications",
|
||||
));
|
||||
tabs.push(new Tab(
|
||||
UserTab.Preferences,
|
||||
_td("Preferences"),
|
||||
"mx_UserSettingsDialog_preferencesIcon",
|
||||
<PreferencesUserSettingsTab closeSettingsFn={this.props.onFinished} />,
|
||||
"WebUserSettingsPreferences",
|
||||
"UserSettingsPreferences",
|
||||
));
|
||||
tabs.push(new Tab(
|
||||
UserTab.Keyboard,
|
||||
_td("Keyboard"),
|
||||
"mx_UserSettingsDialog_keyboardIcon",
|
||||
<KeyboardUserSettingsTab />,
|
||||
"WebUserSettingsKeyboard",
|
||||
"UserSettingsKeyboard",
|
||||
));
|
||||
tabs.push(new Tab(
|
||||
UserTab.Sidebar,
|
||||
_td("Sidebar"),
|
||||
"mx_UserSettingsDialog_sidebarIcon",
|
||||
<SidebarUserSettingsTab />,
|
||||
"WebUserSettingsSidebar",
|
||||
"UserSettingsSidebar",
|
||||
));
|
||||
|
||||
if (SettingsStore.getValue(UIFeature.Voip)) {
|
||||
|
@ -147,7 +147,7 @@ export default class UserSettingsDialog extends React.Component<IProps, IState>
|
|||
_td("Voice & Video"),
|
||||
"mx_UserSettingsDialog_voiceIcon",
|
||||
<VoiceUserSettingsTab />,
|
||||
"WebUserSettingsVoiceVideo",
|
||||
"UserSettingsVoiceVideo",
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ export default class UserSettingsDialog extends React.Component<IProps, IState>
|
|||
_td("Security & Privacy"),
|
||||
"mx_UserSettingsDialog_securityIcon",
|
||||
<SecurityUserSettingsTab closeSettingsFn={this.props.onFinished} />,
|
||||
"WebUserSettingsSecurityPrivacy",
|
||||
"UserSettingsSecurityPrivacy",
|
||||
));
|
||||
// Show the Labs tab if enabled or if there are any active betas
|
||||
if (SdkConfig.get()['showLabsSettings']
|
||||
|
@ -167,7 +167,7 @@ export default class UserSettingsDialog extends React.Component<IProps, IState>
|
|||
_td("Labs"),
|
||||
"mx_UserSettingsDialog_labsIcon",
|
||||
<LabsUserSettingsTab />,
|
||||
"WebUserSettingsLabs",
|
||||
"UserSettingsLabs",
|
||||
));
|
||||
}
|
||||
if (this.state.mjolnirEnabled) {
|
||||
|
@ -176,7 +176,7 @@ export default class UserSettingsDialog extends React.Component<IProps, IState>
|
|||
_td("Ignored users"),
|
||||
"mx_UserSettingsDialog_mjolnirIcon",
|
||||
<MjolnirUserSettingsTab />,
|
||||
"WebUserSettingMjolnir",
|
||||
"UserSettingMjolnir",
|
||||
));
|
||||
}
|
||||
tabs.push(new Tab(
|
||||
|
@ -184,7 +184,7 @@ export default class UserSettingsDialog extends React.Component<IProps, IState>
|
|||
_td("Help & About"),
|
||||
"mx_UserSettingsDialog_helpIcon",
|
||||
<HelpUserSettingsTab closeSettingsFn={() => this.props.onFinished(true)} />,
|
||||
"WebUserSettingsHelpAbout",
|
||||
"UserSettingsHelpAbout",
|
||||
));
|
||||
|
||||
return tabs;
|
||||
|
|
|
@ -6249,9 +6249,9 @@ mathml-tag-names@^2.1.3:
|
|||
resolved "https://registry.yarnpkg.com/mathml-tag-names/-/mathml-tag-names-2.1.3.tgz#4ddadd67308e780cf16a47685878ee27b736a0a3"
|
||||
integrity sha512-APMBEanjybaPzUrfqU0IMU5I0AswKMH7k8OTLs0vvV4KZpExkTkY87nR/zpbuTPj+gARop7aGUbl11pnDfW6xg==
|
||||
|
||||
"matrix-analytics-events@github:matrix-org/matrix-analytics-events.git#b183e6316826be11bbcc82d44b8f71921acd9d76":
|
||||
"matrix-analytics-events@github:matrix-org/matrix-analytics-events.git#bdabdd63280f052cedeeb0c25443f3d55f7c7108":
|
||||
version "0.0.1"
|
||||
resolved "https://codeload.github.com/matrix-org/matrix-analytics-events/tar.gz/b183e6316826be11bbcc82d44b8f71921acd9d76"
|
||||
resolved "https://codeload.github.com/matrix-org/matrix-analytics-events/tar.gz/bdabdd63280f052cedeeb0c25443f3d55f7c7108"
|
||||
|
||||
matrix-events-sdk@^0.0.1-beta.6:
|
||||
version "0.0.1-beta.6"
|
||||
|
|
Loading…
Reference in New Issue