Remove the dependency on buffer

It's not generally available in browser environments / certain Yarn modes and can easily be replaced by TextEncoder.
This commit is contained in:
Robin
2025-03-14 02:09:48 -04:00
parent 46e7e8e9cd
commit fee9841183

View File

@@ -12,7 +12,6 @@ import posthog, {
} from "posthog-js";
import { logger } from "matrix-js-sdk/src/logger";
import { type MatrixClient } from "matrix-js-sdk/src/matrix";
import { Buffer } from "buffer";
import { widget } from "../widget";
import {
@@ -297,7 +296,7 @@ export class PosthogAnalytics {
const posthogIdMaterial = "ec" + accountAnalyticsId + client.getUserId();
const bufferForPosthogId = await crypto.subtle.digest(
"sha-256",
Buffer.from(posthogIdMaterial, "utf-8"),
new TextEncoder().encode(posthogIdMaterial),
);
const view = new Int32Array(bufferForPosthogId);
return Array.from(view)