Skip to content

Commit 0eb1f6c

Browse files
authored
Instrument session with analytics events (#9)
* rename to analytics and limit scope * instrument session events * change default analytics poll interval * opt out analytics in a loop
1 parent 78455c7 commit 0eb1f6c

File tree

8 files changed

+565
-371
lines changed

8 files changed

+565
-371
lines changed

peer/generate.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ set -e
33

44
protoc --ts_out=src --experimental_allow_proto3_optional --ts_opt=client_generic --proto_path proto/v1 ./proto/v1/signaling.proto
55
node ./scripts/patch.cjs
6-
sed -i '1s;^;// @ts-nocheck\n;' ./src/google/protobuf/timestamp.ts
6+
# sed -i '1s;^;// @ts-nocheck\n;' ./src/google/protobuf/timestamp.ts

peer/proto

peer/src/quality.ts renamed to peer/src/analytics.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { AnalyticsMetrics, AnalyticsTags, EventType } from "./signaling.ts";
2+
13
interface RTCStats {
24
id: string;
35
timestamp: number;
@@ -50,24 +52,24 @@ interface RTCRemoteInboundRtpStreamStats extends RTCStats {
5052
interface RTCIceCandidatePairStats extends RTCStats {
5153
type: "candidate-pair";
5254
state?:
53-
| "failed"
54-
| "frozen"
55-
| "in-progress"
56-
| "succeeded"
57-
| "waiting";
55+
| "failed"
56+
| "frozen"
57+
| "in-progress"
58+
| "succeeded"
59+
| "waiting";
5860
currentRoundTripTime?: number;
5961
}
6062

6163
interface RTCPeerConnectionStats extends RTCStats {
6264
type: "peer-connection";
6365
iceConnectionState?:
64-
| "new"
65-
| "checking"
66-
| "connected"
67-
| "completed"
68-
| "failed"
69-
| "disconnected"
70-
| "closed";
66+
| "new"
67+
| "checking"
68+
| "connected"
69+
| "completed"
70+
| "failed"
71+
| "disconnected"
72+
| "closed";
7173
iceGatheringState?: "new" | "gathering" | "complete";
7274
}
7375

@@ -175,3 +177,7 @@ export function calculateQualityScore(
175177

176178
return quality;
177179
}
180+
181+
export function now(): bigint {
182+
return BigInt(Date.now() * 1000);
183+
}

peer/src/google/protobuf/timestamp.ts

Lines changed: 0 additions & 294 deletions
This file was deleted.

0 commit comments

Comments
 (0)