@100mslive/hms-video-store 0.12.3-alpha.2 → 0.12.3-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics/AnalyticsEventFactory.d.ts +1 -1
- package/dist/common/PluginUsageTracker.d.ts +7 -6
- package/dist/index.cjs.js +8 -8
- package/dist/index.cjs.js.map +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +4 -4
- package/dist/plugins/audio/HMSAudioPlugin.d.ts +1 -1
- package/dist/plugins/video/HMSMediaStreamPlugin.d.ts +1 -1
- package/dist/plugins/video/HMSVideoPlugin.d.ts +1 -1
- package/dist/sdk/index.d.ts +1 -0
- package/dist/transport/index.d.ts +3 -1
- package/package.json +2 -2
- package/src/analytics/AnalyticsEventFactory.ts +1 -3
- package/src/common/PluginUsageTracker.ts +40 -36
- package/src/index.ts +1 -1
- package/src/plugins/audio/HMSAudioPlugin.ts +1 -1
- package/src/plugins/audio/HMSAudioPluginsManager.ts +2 -0
- package/src/plugins/video/HMSMediaStreamPlugin.ts +1 -1
- package/src/plugins/video/HMSVideoPlugin.ts +1 -1
- package/src/sdk/index.ts +5 -3
- package/src/transport/index.ts +5 -2
- package/dist/common/index.d.ts +0 -1
- package/src/common/index.ts +0 -1
|
@@ -25,7 +25,7 @@ export interface HMSAudioPlugin {
|
|
|
25
25
|
* variables, loading ML models etc. This can be used by a plugin to ensure it's prepared at the time
|
|
26
26
|
* processAudio is called.
|
|
27
27
|
*/
|
|
28
|
-
init(): Promise<void> | void;
|
|
28
|
+
init(sessionID?: string): Promise<void> | void;
|
|
29
29
|
/**
|
|
30
30
|
* The name is meant to uniquely specify a plugin instance. This will be used to track number of plugins
|
|
31
31
|
* added to the track, and same name won't be allowed twice.
|
|
@@ -25,7 +25,7 @@ export interface HMSVideoPlugin {
|
|
|
25
25
|
* variables, loading ML models etc. This can be used by a plugin to ensure it's prepared at the time
|
|
26
26
|
* processVideoFrame is called.
|
|
27
27
|
*/
|
|
28
|
-
init(): Promise<void>;
|
|
28
|
+
init(sessionID?: string): Promise<void>;
|
|
29
29
|
/**
|
|
30
30
|
* @see HMSVideoPluginType
|
|
31
31
|
*/
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import ITransportObserver from './ITransportObserver';
|
|
|
2
2
|
import { AdditionalAnalyticsProperties } from '../analytics/AdditionalAnalyticsProperties';
|
|
3
3
|
import { AnalyticsEventsService } from '../analytics/AnalyticsEventsService';
|
|
4
4
|
import { AnalyticsTimer } from '../analytics/AnalyticsTimer';
|
|
5
|
+
import { PluginUsageTracker } from '../common/PluginUsageTracker';
|
|
5
6
|
import HMSSubscribeConnection from '../connection/subscribe/subscribeConnection';
|
|
6
7
|
import { DeviceManager } from '../device-manager';
|
|
7
8
|
import { EventBus } from '../events/EventBus';
|
|
@@ -18,6 +19,7 @@ export default class HMSTransport {
|
|
|
18
19
|
private eventBus;
|
|
19
20
|
private analyticsEventsService;
|
|
20
21
|
private analyticsTimer;
|
|
22
|
+
private pluginUsageTracker;
|
|
21
23
|
private state;
|
|
22
24
|
private trackStates;
|
|
23
25
|
private publishConnection;
|
|
@@ -31,7 +33,7 @@ export default class HMSTransport {
|
|
|
31
33
|
private subscribeStatsAnalytics?;
|
|
32
34
|
private maxSubscribeBitrate;
|
|
33
35
|
joinRetryCount: number;
|
|
34
|
-
constructor(observer: ITransportObserver, deviceManager: DeviceManager, store: Store, eventBus: EventBus, analyticsEventsService: AnalyticsEventsService, analyticsTimer: AnalyticsTimer);
|
|
36
|
+
constructor(observer: ITransportObserver, deviceManager: DeviceManager, store: Store, eventBus: EventBus, analyticsEventsService: AnalyticsEventsService, analyticsTimer: AnalyticsTimer, pluginUsageTracker: PluginUsageTracker);
|
|
35
37
|
/**
|
|
36
38
|
* Map of callbacks used to wait for an event to fire.
|
|
37
39
|
* Used here for:
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.12.3-alpha.
|
|
2
|
+
"version": "0.12.3-alpha.4",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"conferencing",
|
|
74
74
|
"100ms"
|
|
75
75
|
],
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "f402d418c294acc6ce73bc81ab286d26431a6f53"
|
|
77
77
|
}
|
|
@@ -3,7 +3,6 @@ import { AdditionalAnalyticsProperties } from './AdditionalAnalyticsProperties';
|
|
|
3
3
|
import AnalyticsEvent from './AnalyticsEvent';
|
|
4
4
|
import { AnalyticsEventLevel } from './AnalyticsEventLevel';
|
|
5
5
|
import { IAnalyticsPropertiesProvider } from './IAnalyticsPropertiesProvider';
|
|
6
|
-
import { pluginUsageTracker } from '../common';
|
|
7
6
|
import { HMSException } from '../error/HMSException';
|
|
8
7
|
import { DeviceMap, SelectedDevices } from '../interfaces';
|
|
9
8
|
import { HMSTrackSettings } from '../media/settings/HMSTrackSettings';
|
|
@@ -236,8 +235,7 @@ export default class AnalyticsEventFactory {
|
|
|
236
235
|
});
|
|
237
236
|
}
|
|
238
237
|
|
|
239
|
-
static getKrispUsage(
|
|
240
|
-
const duration = pluginUsageTracker.getPluginUsage('HMSKrispPlugin', sessionID);
|
|
238
|
+
static getKrispUsage(duration: number) {
|
|
241
239
|
return new AnalyticsEvent({
|
|
242
240
|
name: 'krisp.usage',
|
|
243
241
|
level: AnalyticsEventLevel.INFO,
|
|
@@ -1,53 +1,57 @@
|
|
|
1
1
|
import AnalyticsEvent from '../analytics/AnalyticsEvent';
|
|
2
|
+
import { EventBus } from '../events/EventBus';
|
|
2
3
|
|
|
3
|
-
class PluginUsageTracker {
|
|
4
|
+
export class PluginUsageTracker {
|
|
4
5
|
private pluginUsage: Map<string, number> = new Map<string, number>();
|
|
5
6
|
private pluginLastAddedAt: Map<string, number> = new Map<string, number>();
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
constructor(private eventBus: EventBus) {
|
|
9
|
+
this.eventBus.analytics.subscribe(e => this.updatePluginUsageData(e));
|
|
10
|
+
}
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
getPluginUsage = (name: string) => {
|
|
13
|
+
if (!this.pluginUsage.has(name)) {
|
|
14
|
+
this.pluginUsage.set(name, 0);
|
|
12
15
|
}
|
|
13
|
-
if (this.pluginLastAddedAt.has(
|
|
14
|
-
const lastAddedAt = this.pluginLastAddedAt.get(
|
|
16
|
+
if (this.pluginLastAddedAt.has(name)) {
|
|
17
|
+
const lastAddedAt = this.pluginLastAddedAt.get(name) || 0;
|
|
15
18
|
const extraDuration = lastAddedAt ? Date.now() - lastAddedAt : 0;
|
|
16
|
-
this.pluginUsage.set(
|
|
17
|
-
this.pluginLastAddedAt.delete(
|
|
19
|
+
this.pluginUsage.set(name, (this.pluginUsage.get(name) || 0) + extraDuration);
|
|
20
|
+
this.pluginLastAddedAt.delete(name);
|
|
18
21
|
}
|
|
19
|
-
return this.pluginUsage.get(
|
|
22
|
+
return this.pluginUsage.get(name);
|
|
20
23
|
};
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
// eslint-disable-next-line complexity
|
|
26
|
+
updatePluginUsageData = (event: AnalyticsEvent) => {
|
|
27
|
+
const name = event.properties?.plugin_name || '';
|
|
28
|
+
switch (event.name) {
|
|
29
|
+
// Sent on leave, after krisp usage is sent
|
|
30
|
+
case 'transport.leave': {
|
|
31
|
+
this.cleanup();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
case 'mediaPlugin.toggled.on':
|
|
35
|
+
case 'mediaPlugin.added': {
|
|
36
|
+
const addedAt = event.properties.added_at || Date.now();
|
|
37
|
+
this.pluginLastAddedAt.set(name, addedAt);
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
case 'mediaPlugin.toggled.off':
|
|
41
|
+
case 'mediaPlugin.stats': {
|
|
42
|
+
if (this.pluginLastAddedAt.has(name)) {
|
|
43
|
+
const duration = event.properties.duration || (Date.now() - (this.pluginLastAddedAt.get(name) || 0)) / 1000;
|
|
44
|
+
this.pluginUsage.set(name, (this.pluginUsage.get(name) || 0) + Math.max(duration, 0) * 1000);
|
|
45
|
+
this.pluginLastAddedAt.delete(name);
|
|
46
|
+
}
|
|
47
|
+
break;
|
|
39
48
|
}
|
|
49
|
+
default:
|
|
40
50
|
}
|
|
41
51
|
};
|
|
42
52
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.pluginUsage.delete(key);
|
|
47
|
-
this.pluginLastAddedAt.delete(key);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
53
|
+
cleanup = () => {
|
|
54
|
+
this.pluginLastAddedAt.clear();
|
|
55
|
+
this.pluginUsage.clear();
|
|
50
56
|
};
|
|
51
57
|
}
|
|
52
|
-
|
|
53
|
-
export const pluginUsageTracker = new PluginUsageTracker();
|
package/src/index.ts
CHANGED
|
@@ -53,7 +53,7 @@ export type {
|
|
|
53
53
|
HMSQuizLeaderboardSummary,
|
|
54
54
|
} from './internal';
|
|
55
55
|
|
|
56
|
-
export {
|
|
56
|
+
export { EventBus } from './events/EventBus';
|
|
57
57
|
export { HMSReactiveStore } from './reactive-store/HMSReactiveStore';
|
|
58
58
|
export { HMSPluginUnsupportedTypes, HMSRecordingState, HLSPlaylistType } from './internal';
|
|
59
59
|
export type {
|
|
@@ -29,7 +29,7 @@ export interface HMSAudioPlugin {
|
|
|
29
29
|
* variables, loading ML models etc. This can be used by a plugin to ensure it's prepared at the time
|
|
30
30
|
* processAudio is called.
|
|
31
31
|
*/
|
|
32
|
-
init(): Promise<void> | void;
|
|
32
|
+
init(sessionID?: string): Promise<void> | void;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* The name is meant to uniquely specify a plugin instance. This will be used to track number of plugins
|
|
@@ -29,7 +29,7 @@ export interface HMSVideoPlugin {
|
|
|
29
29
|
* variables, loading ML models etc. This can be used by a plugin to ensure it's prepared at the time
|
|
30
30
|
* processVideoFrame is called.
|
|
31
31
|
*/
|
|
32
|
-
init(): Promise<void>;
|
|
32
|
+
init(sessionID?: string): Promise<void>;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* @see HMSVideoPluginType
|
package/src/sdk/index.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { HMSAnalyticsLevel } from '../analytics/AnalyticsEventLevel';
|
|
|
12
12
|
import { AnalyticsEventsService } from '../analytics/AnalyticsEventsService';
|
|
13
13
|
import { AnalyticsTimer, TimedEvent } from '../analytics/AnalyticsTimer';
|
|
14
14
|
import { AudioSinkManager } from '../audio-sink-manager';
|
|
15
|
-
import {
|
|
15
|
+
import { PluginUsageTracker } from '../common/PluginUsageTracker';
|
|
16
16
|
import { DeviceManager } from '../device-manager';
|
|
17
17
|
import { AudioOutputManager } from '../device-manager/AudioOutputManager';
|
|
18
18
|
import { DeviceStorageManager } from '../device-manager/DeviceStorage';
|
|
@@ -119,6 +119,7 @@ export class HMSSdk implements HMSInterface {
|
|
|
119
119
|
private wakeLockManager!: WakeLockManager;
|
|
120
120
|
private sessionStore!: SessionStore;
|
|
121
121
|
private interactivityCenter!: InteractivityCenter;
|
|
122
|
+
private pluginUsageTracker!: PluginUsageTracker;
|
|
122
123
|
private sdkState = { ...INITIAL_STATE };
|
|
123
124
|
private frameworkInfo?: HMSFrameworkInfo;
|
|
124
125
|
private playlistSettings: HMSPlaylistSettings = {
|
|
@@ -156,6 +157,7 @@ export class HMSSdk implements HMSInterface {
|
|
|
156
157
|
this.sdkState.isInitialised = true;
|
|
157
158
|
this.store = new Store();
|
|
158
159
|
this.eventBus = new EventBus();
|
|
160
|
+
this.pluginUsageTracker = new PluginUsageTracker(this.eventBus);
|
|
159
161
|
this.wakeLockManager = new WakeLockManager();
|
|
160
162
|
this.networkTestManager = new NetworkTestManager(this.eventBus, this.listener);
|
|
161
163
|
this.playlistManager = new PlaylistManager(this, this.eventBus);
|
|
@@ -179,6 +181,7 @@ export class HMSSdk implements HMSInterface {
|
|
|
179
181
|
this.eventBus,
|
|
180
182
|
this.analyticsEventsService,
|
|
181
183
|
this.analyticsTimer,
|
|
184
|
+
this.pluginUsageTracker,
|
|
182
185
|
);
|
|
183
186
|
this.sessionStore = new SessionStore(this.transport);
|
|
184
187
|
this.interactivityCenter = new InteractivityCenter(this.transport, this.store, this.listener);
|
|
@@ -572,8 +575,6 @@ export class HMSSdk implements HMSInterface {
|
|
|
572
575
|
throw error;
|
|
573
576
|
}
|
|
574
577
|
HMSLogger.timeEnd(`join-room-${roomId}`);
|
|
575
|
-
const sessionID = this.store.getRoom()?.sessionId || '';
|
|
576
|
-
this.eventBus.analytics.subscribe(e => pluginUsageTracker.updatePluginUsageData(e, sessionID));
|
|
577
578
|
}
|
|
578
579
|
|
|
579
580
|
private stringifyMetadata(config: HMSConfig) {
|
|
@@ -587,6 +588,7 @@ export class HMSSdk implements HMSInterface {
|
|
|
587
588
|
private cleanup() {
|
|
588
589
|
this.cleanDeviceManagers();
|
|
589
590
|
this.eventBus.analytics.unsubscribe(this.sendAnalyticsEvent);
|
|
591
|
+
this.pluginUsageTracker?.cleanup();
|
|
590
592
|
this.analyticsTimer.cleanup();
|
|
591
593
|
DeviceStorageManager.cleanup();
|
|
592
594
|
this.playlistManager.cleanup();
|
package/src/transport/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { AnalyticsTimer, TimedEvent } from '../analytics/AnalyticsTimer';
|
|
|
11
11
|
import { HTTPAnalyticsTransport } from '../analytics/HTTPAnalyticsTransport';
|
|
12
12
|
import { SignalAnalyticsTransport } from '../analytics/signal-transport/SignalAnalyticsTransport';
|
|
13
13
|
import { PublishStatsAnalytics, SubscribeStatsAnalytics } from '../analytics/stats';
|
|
14
|
+
import { PluginUsageTracker } from '../common/PluginUsageTracker';
|
|
14
15
|
import { HMSConnectionRole, HMSTrickle } from '../connection/model';
|
|
15
16
|
import { IPublishConnectionObserver } from '../connection/publish/IPublishConnectionObserver';
|
|
16
17
|
import HMSPublishConnection from '../connection/publish/publishConnection';
|
|
@@ -86,6 +87,7 @@ export default class HMSTransport {
|
|
|
86
87
|
private eventBus: EventBus,
|
|
87
88
|
private analyticsEventsService: AnalyticsEventsService,
|
|
88
89
|
private analyticsTimer: AnalyticsTimer,
|
|
90
|
+
private pluginUsageTracker: PluginUsageTracker,
|
|
89
91
|
) {
|
|
90
92
|
this.webrtcInternals = new HMSWebrtcInternals(
|
|
91
93
|
this.store,
|
|
@@ -495,8 +497,9 @@ export default class HMSTransport {
|
|
|
495
497
|
this.joinParameters = undefined;
|
|
496
498
|
HMSLogger.d(TAG, 'leaving in transport');
|
|
497
499
|
try {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
+
this.eventBus.analytics.publish(
|
|
501
|
+
AnalyticsEventFactory.getKrispUsage(this.pluginUsageTracker.getPluginUsage('HMSKrispPlugin')!),
|
|
502
|
+
);
|
|
500
503
|
this.eventBus.analytics.publish(AnalyticsEventFactory.transportLeave());
|
|
501
504
|
this.state = TransportState.Leaving;
|
|
502
505
|
this.publishStatsAnalytics?.stop();
|
package/dist/common/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { pluginUsageTracker } from './PluginUsageTracker';
|
package/src/common/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { pluginUsageTracker } from './PluginUsageTracker';
|