mirror of https://github.com/vector-im/riot-web
Declare return types for all public methods, even void ones
parent
e4722ee457
commit
7b4a7711b2
|
@ -269,7 +269,7 @@ export class PosthogAnalytics {
|
||||||
return this.enabled;
|
return this.enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public setAnonymity(anonymity: Anonymity) {
|
public setAnonymity(anonymity: Anonymity): void {
|
||||||
// Update this.anonymity.
|
// Update this.anonymity.
|
||||||
// This is public for testing purposes, typically you want to call updateAnonymityFromSettings
|
// This is public for testing purposes, typically you want to call updateAnonymityFromSettings
|
||||||
// to ensure this value is in step with the user's settings.
|
// to ensure this value is in step with the user's settings.
|
||||||
|
@ -283,17 +283,17 @@ export class PosthogAnalytics {
|
||||||
this.anonymity = anonymity;
|
this.anonymity = anonymity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async identifyUser(userId: string) {
|
public async identifyUser(userId: string): Promise<void> {
|
||||||
if (this.anonymity == Anonymity.Pseudonymous) {
|
if (this.anonymity == Anonymity.Pseudonymous) {
|
||||||
this.posthog.identify(await hashHex(userId));
|
this.posthog.identify(await hashHex(userId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getAnonymity() {
|
public getAnonymity(): Anonymity {
|
||||||
return this.anonymity;
|
return this.anonymity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public logout() {
|
public logout(): void {
|
||||||
if (this.enabled) {
|
if (this.enabled) {
|
||||||
this.posthog.reset();
|
this.posthog.reset();
|
||||||
}
|
}
|
||||||
|
@ -311,7 +311,7 @@ export class PosthogAnalytics {
|
||||||
public async trackAnonymousEvent<E extends IAnonymousEvent>(
|
public async trackAnonymousEvent<E extends IAnonymousEvent>(
|
||||||
eventName: E["eventName"],
|
eventName: E["eventName"],
|
||||||
properties: E["properties"],
|
properties: E["properties"],
|
||||||
) {
|
): Promise<void> {
|
||||||
if (this.anonymity == Anonymity.Disabled) return;
|
if (this.anonymity == Anonymity.Disabled) return;
|
||||||
await this.capture(eventName, properties);
|
await this.capture(eventName, properties);
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,7 @@ export class PosthogAnalytics {
|
||||||
eventName: E["eventName"],
|
eventName: E["eventName"],
|
||||||
roomId: string,
|
roomId: string,
|
||||||
properties: Omit<E["properties"], "roomId">,
|
properties: Omit<E["properties"], "roomId">,
|
||||||
) {
|
): Promise<void> {
|
||||||
const updatedProperties = {
|
const updatedProperties = {
|
||||||
...properties,
|
...properties,
|
||||||
hashedRoomId: roomId ? await hashHex(roomId) : null,
|
hashedRoomId: roomId ? await hashHex(roomId) : null,
|
||||||
|
@ -328,7 +328,7 @@ export class PosthogAnalytics {
|
||||||
await this.trackPseudonymousEvent(eventName, updatedProperties);
|
await this.trackPseudonymousEvent(eventName, updatedProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async trackPageView(durationMs: number) {
|
public async trackPageView(durationMs: number): Promise<void> {
|
||||||
const hash = window.location.hash;
|
const hash = window.location.hash;
|
||||||
|
|
||||||
let screen = null;
|
let screen = null;
|
||||||
|
@ -343,7 +343,7 @@ export class PosthogAnalytics {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updatePlatformSuperProperties() {
|
public async updatePlatformSuperProperties(): Promise<void> {
|
||||||
// Update super properties in posthog with our platform (app version, platform).
|
// Update super properties in posthog with our platform (app version, platform).
|
||||||
// These properties will be subsequently passed in every event.
|
// These properties will be subsequently passed in every event.
|
||||||
//
|
//
|
||||||
|
@ -353,7 +353,7 @@ export class PosthogAnalytics {
|
||||||
this.registerSuperProperties(this.platformSuperProperties);
|
this.registerSuperProperties(this.platformSuperProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateAnonymityFromSettings(userId?: string) {
|
public async updateAnonymityFromSettings(userId?: string): Promise<void> {
|
||||||
// Update this.anonymity based on the user's analytics opt-in settings
|
// Update this.anonymity based on the user's analytics opt-in settings
|
||||||
// Identify the user (via hashed user ID) to posthog if anonymity is pseudonmyous
|
// Identify the user (via hashed user ID) to posthog if anonymity is pseudonmyous
|
||||||
this.setAnonymity(PosthogAnalytics.getAnonymityFromSettings());
|
this.setAnonymity(PosthogAnalytics.getAnonymityFromSettings());
|
||||||
|
|
Loading…
Reference in New Issue