feat: add more tracking events (#6866)

Added most tracking events

what is missing:
- still need a way to track events in blocksuite
- some events may not 100% accurate of the one defined in the PRD
This commit is contained in:
pengx17
2024-05-13 03:36:32 +00:00
parent bd1733b2a9
commit 3e23878e0f
37 changed files with 433 additions and 69 deletions
@@ -28,6 +28,13 @@ export class TelemetryService extends Service {
track_pageview: true,
persistence: 'localStorage',
});
mixpanel.register({
appVersion: runtimeConfig.appVersion,
environment: runtimeConfig.appBuildType,
editorVersion: runtimeConfig.editorVersion,
isSelfHosted: Boolean(runtimeConfig.isSelfHosted),
isDesktop: environment.isDesktop,
});
}
const account = this.auth.session.account$.value;
this.updateIdentity(account);
@@ -1,7 +1,29 @@
import { Service } from '@toeverything/infra';
import { mixpanel } from '@affine/core/utils';
import { createEvent, Service } from '@toeverything/infra';
import { combineLatest, distinctUntilChanged, map, skip } from 'rxjs';
import { Workbench } from '../entities/workbench';
export const WorkbenchLocationChanged = createEvent<string>(
'WorkbenchLocationChanged'
);
export class WorkbenchService extends Service {
constructor() {
super();
combineLatest([this.workbench.location$, this.workbench.basename$])
.pipe(
map(([location, basename]) => basename + location.pathname),
distinctUntilChanged(),
skip(1)
)
.subscribe(newLocation => {
this.eventBus.root.emit(WorkbenchLocationChanged, newLocation);
mixpanel.track_pageview({
location: newLocation,
});
});
}
workbench = this.framework.createEntity(Workbench);
}