Upgrade eslint-plugin-matrix-org to 1.2.1
This upgrade came with a number of new lints that needed to be fixed across the code base. Primarily: explicit return types on functions, and explicit visibility modifiers on class members.
This commit is contained in:
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
Copyright 2023 New Vector Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { FC } from "react";
|
||||
import { Trans } from "react-i18next";
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ export class PosthogAnalytics {
|
||||
return this.internalInstance;
|
||||
}
|
||||
|
||||
constructor(private readonly posthog: PostHog) {
|
||||
private constructor(private readonly posthog: PostHog) {
|
||||
const posthogConfig: PosthogSettings = {
|
||||
project_api_key: Config.get().posthog?.api_key,
|
||||
api_host: Config.get().posthog?.api_host,
|
||||
@@ -183,7 +183,7 @@ export class PosthogAnalytics {
|
||||
return properties;
|
||||
};
|
||||
|
||||
private registerSuperProperties(properties: Properties) {
|
||||
private registerSuperProperties(properties: Properties): void {
|
||||
if (this.enabled) {
|
||||
this.posthog.register(properties);
|
||||
}
|
||||
@@ -202,7 +202,7 @@ export class PosthogAnalytics {
|
||||
eventName: string,
|
||||
properties: Properties,
|
||||
options?: CaptureOptions
|
||||
) {
|
||||
): void {
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
@@ -213,7 +213,7 @@ export class PosthogAnalytics {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
setAnonymity(anonymity: Anonymity): void {
|
||||
private setAnonymity(anonymity: Anonymity): void {
|
||||
// Update this.anonymity.
|
||||
// To update the anonymity typically you want to call updateAnonymityFromSettings
|
||||
// to ensure this value is in step with the user's settings.
|
||||
@@ -236,7 +236,9 @@ export class PosthogAnalytics {
|
||||
.join("");
|
||||
}
|
||||
|
||||
private async identifyUser(analyticsIdGenerator: () => string) {
|
||||
private async identifyUser(
|
||||
analyticsIdGenerator: () => string
|
||||
): Promise<void> {
|
||||
if (this.anonymity == Anonymity.Pseudonymous && this.enabled) {
|
||||
// Check the user's account_data for an analytics ID to use. Storing the ID in account_data allows
|
||||
// different devices to send the same ID.
|
||||
@@ -271,7 +273,7 @@ export class PosthogAnalytics {
|
||||
}
|
||||
}
|
||||
|
||||
async getAnalyticsId() {
|
||||
private async getAnalyticsId(): Promise<string | null> {
|
||||
const client: MatrixClient = window.matrixclient;
|
||||
let accountAnalyticsId;
|
||||
if (widget) {
|
||||
@@ -291,7 +293,9 @@ export class PosthogAnalytics {
|
||||
return null;
|
||||
}
|
||||
|
||||
async hashedEcAnalyticsId(accountAnalyticsId: string): Promise<string> {
|
||||
private async hashedEcAnalyticsId(
|
||||
accountAnalyticsId: string
|
||||
): Promise<string> {
|
||||
const client: MatrixClient = window.matrixclient;
|
||||
const posthogIdMaterial = "ec" + accountAnalyticsId + client.getUserId();
|
||||
const bufferForPosthogId = await crypto.subtle.digest(
|
||||
@@ -304,7 +308,7 @@ export class PosthogAnalytics {
|
||||
.join("");
|
||||
}
|
||||
|
||||
async setAccountAnalyticsId(analyticsID: string) {
|
||||
private async setAccountAnalyticsId(analyticsID: string): Promise<void> {
|
||||
if (!widget) {
|
||||
const client = window.matrixclient;
|
||||
|
||||
@@ -335,7 +339,7 @@ export class PosthogAnalytics {
|
||||
this.updateAnonymityAndIdentifyUser(optInAnalytics);
|
||||
}
|
||||
|
||||
private updateSuperProperties() {
|
||||
private updateSuperProperties(): void {
|
||||
// Update super properties in posthog with our platform (app version, platform).
|
||||
// These properties will be subsequently passed in every event.
|
||||
//
|
||||
|
||||
@@ -36,18 +36,22 @@ export class CallEndedTracker {
|
||||
maxParticipantsCount: 0,
|
||||
};
|
||||
|
||||
cacheStartCall(time: Date) {
|
||||
public cacheStartCall(time: Date): void {
|
||||
this.cache.startTime = time;
|
||||
}
|
||||
|
||||
cacheParticipantCountChanged(count: number) {
|
||||
public cacheParticipantCountChanged(count: number): void {
|
||||
this.cache.maxParticipantsCount = Math.max(
|
||||
count,
|
||||
this.cache.maxParticipantsCount
|
||||
);
|
||||
}
|
||||
|
||||
track(callId: string, callParticipantsNow: number, sendInstantly: boolean) {
|
||||
public track(
|
||||
callId: string,
|
||||
callParticipantsNow: number,
|
||||
sendInstantly: boolean
|
||||
): void {
|
||||
PosthogAnalytics.instance.trackEvent<CallEnded>(
|
||||
{
|
||||
eventName: "CallEnded",
|
||||
@@ -67,7 +71,7 @@ interface CallStarted extends IPosthogEvent {
|
||||
}
|
||||
|
||||
export class CallStartedTracker {
|
||||
track(callId: string) {
|
||||
public track(callId: string): void {
|
||||
PosthogAnalytics.instance.trackEvent<CallStarted>({
|
||||
eventName: "CallStarted",
|
||||
callId: callId,
|
||||
@@ -86,19 +90,19 @@ export class SignupTracker {
|
||||
signupEnd: new Date(0),
|
||||
};
|
||||
|
||||
cacheSignupStart(time: Date) {
|
||||
public cacheSignupStart(time: Date): void {
|
||||
this.cache.signupStart = time;
|
||||
}
|
||||
|
||||
getSignupEndTime() {
|
||||
public getSignupEndTime(): Date {
|
||||
return this.cache.signupEnd;
|
||||
}
|
||||
|
||||
cacheSignupEnd(time: Date) {
|
||||
public cacheSignupEnd(time: Date): void {
|
||||
this.cache.signupEnd = time;
|
||||
}
|
||||
|
||||
track() {
|
||||
public track(): void {
|
||||
PosthogAnalytics.instance.trackEvent<Signup>({
|
||||
eventName: "Signup",
|
||||
signupDuration: Date.now() - this.cache.signupStart.getTime(),
|
||||
@@ -112,7 +116,7 @@ interface Login extends IPosthogEvent {
|
||||
}
|
||||
|
||||
export class LoginTracker {
|
||||
track() {
|
||||
public track(): void {
|
||||
PosthogAnalytics.instance.trackEvent<Login>({
|
||||
eventName: "Login",
|
||||
});
|
||||
@@ -127,7 +131,7 @@ interface MuteMicrophone {
|
||||
}
|
||||
|
||||
export class MuteMicrophoneTracker {
|
||||
track(targetIsMute: boolean, callId: string) {
|
||||
public track(targetIsMute: boolean, callId: string): void {
|
||||
PosthogAnalytics.instance.trackEvent<MuteMicrophone>({
|
||||
eventName: "MuteMicrophone",
|
||||
targetMuteState: targetIsMute ? "mute" : "unmute",
|
||||
@@ -143,7 +147,7 @@ interface MuteCamera {
|
||||
}
|
||||
|
||||
export class MuteCameraTracker {
|
||||
track(targetIsMute: boolean, callId: string) {
|
||||
public track(targetIsMute: boolean, callId: string): void {
|
||||
PosthogAnalytics.instance.trackEvent<MuteCamera>({
|
||||
eventName: "MuteCamera",
|
||||
targetMuteState: targetIsMute ? "mute" : "unmute",
|
||||
@@ -158,7 +162,7 @@ interface UndecryptableToDeviceEvent {
|
||||
}
|
||||
|
||||
export class UndecryptableToDeviceEventTracker {
|
||||
track(callId: string) {
|
||||
public track(callId: string): void {
|
||||
PosthogAnalytics.instance.trackEvent<UndecryptableToDeviceEvent>({
|
||||
eventName: "UndecryptableToDeviceEvent",
|
||||
callId,
|
||||
@@ -174,7 +178,7 @@ interface QualitySurveyEvent {
|
||||
}
|
||||
|
||||
export class QualitySurveyEventTracker {
|
||||
track(callId: string, feedbackText: string, stars: number) {
|
||||
public track(callId: string, feedbackText: string, stars: number): void {
|
||||
PosthogAnalytics.instance.trackEvent<QualitySurveyEvent>({
|
||||
eventName: "QualitySurvey",
|
||||
callId,
|
||||
@@ -190,7 +194,7 @@ interface CallDisconnectedEvent {
|
||||
}
|
||||
|
||||
export class CallDisconnectedEventTracker {
|
||||
track(reason?: DisconnectReason) {
|
||||
public track(reason?: DisconnectReason): void {
|
||||
PosthogAnalytics.instance.trackEvent<CallDisconnectedEvent>({
|
||||
eventName: "CallDisconnected",
|
||||
reason,
|
||||
|
||||
@@ -39,9 +39,9 @@ const maxRejoinMs = 2 * 60 * 1000; // 2 minutes
|
||||
* Span processor that extracts certain metrics from spans to send to PostHog
|
||||
*/
|
||||
export class PosthogSpanProcessor implements SpanProcessor {
|
||||
async forceFlush(): Promise<void> {}
|
||||
public async forceFlush(): Promise<void> {}
|
||||
|
||||
onStart(span: Span): void {
|
||||
public onStart(span: Span): void {
|
||||
// Hack: Yield to allow attributes to be set before processing
|
||||
Promise.resolve().then(() => {
|
||||
switch (span.name) {
|
||||
@@ -55,7 +55,7 @@ export class PosthogSpanProcessor implements SpanProcessor {
|
||||
});
|
||||
}
|
||||
|
||||
onEnd(span: ReadableSpan): void {
|
||||
public onEnd(span: ReadableSpan): void {
|
||||
switch (span.name) {
|
||||
case "matrix.groupCallMembership":
|
||||
this.onGroupCallMembershipEnd(span);
|
||||
@@ -157,7 +157,7 @@ export class PosthogSpanProcessor implements SpanProcessor {
|
||||
/**
|
||||
* Shutdown the processor.
|
||||
*/
|
||||
shutdown(): Promise<void> {
|
||||
public shutdown(): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,20 @@
|
||||
import { Attributes } from "@opentelemetry/api";
|
||||
/*
|
||||
Copyright 2023 New Vector Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { AttributeValue, Attributes } from "@opentelemetry/api";
|
||||
import { hrTimeToMicroseconds } from "@opentelemetry/core";
|
||||
import {
|
||||
SpanProcessor,
|
||||
@@ -6,7 +22,21 @@ import {
|
||||
Span,
|
||||
} from "@opentelemetry/sdk-trace-base";
|
||||
|
||||
const dumpAttributes = (attr: Attributes) =>
|
||||
const dumpAttributes = (
|
||||
attr: Attributes
|
||||
): {
|
||||
key: string;
|
||||
type:
|
||||
| "string"
|
||||
| "number"
|
||||
| "bigint"
|
||||
| "boolean"
|
||||
| "symbol"
|
||||
| "undefined"
|
||||
| "object"
|
||||
| "function";
|
||||
value: AttributeValue | undefined;
|
||||
}[] =>
|
||||
Object.entries(attr).map(([key, value]) => ({
|
||||
key,
|
||||
type: typeof value,
|
||||
@@ -20,13 +50,13 @@ const dumpAttributes = (attr: Attributes) =>
|
||||
export class RageshakeSpanProcessor implements SpanProcessor {
|
||||
private readonly spans: ReadableSpan[] = [];
|
||||
|
||||
async forceFlush(): Promise<void> {}
|
||||
public async forceFlush(): Promise<void> {}
|
||||
|
||||
onStart(span: Span): void {
|
||||
public onStart(span: Span): void {
|
||||
this.spans.push(span);
|
||||
}
|
||||
|
||||
onEnd(): void {}
|
||||
public onEnd(): void {}
|
||||
|
||||
/**
|
||||
* Dumps the spans collected so far as Jaeger-compatible JSON.
|
||||
@@ -110,5 +140,5 @@ export class RageshakeSpanProcessor implements SpanProcessor {
|
||||
});
|
||||
}
|
||||
|
||||
async shutdown(): Promise<void> {}
|
||||
public async shutdown(): Promise<void> {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user