Skip to content

Commit e2ff3f4

Browse files
[Highlighter] - Additional tracking (#5310)
* additional tracking * forgot property * switched tracking to record shown * removed unused logs * Revert "removed unused logs" This reverts commit 661ef41. * added error tracking * track update error * fix tracking property casing --------- Co-authored-by: jankalthoefer <[email protected]>
1 parent 01f3c25 commit e2ff3f4

File tree

9 files changed

+74
-17
lines changed

9 files changed

+74
-17
lines changed

app/components-react/highlighter/ExportModal.tsx

+13-3
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function ExportModal({ close, streamId }: { close: () => void; streamId: string
119119
/>
120120
);
121121
}
122-
return <PlatformSelect onClose={close} videoName={videoName} />;
122+
return <PlatformSelect onClose={close} videoName={videoName} streamId={streamId} />;
123123
}
124124

125125
function ExportProgress() {
@@ -301,7 +301,15 @@ function ExportOptions({
301301
);
302302
}
303303

304-
function PlatformSelect({ onClose, videoName }: { onClose: () => void; videoName: string }) {
304+
function PlatformSelect({
305+
onClose,
306+
videoName,
307+
streamId,
308+
}: {
309+
onClose: () => void;
310+
videoName: string;
311+
streamId: string | undefined;
312+
}) {
305313
const { store, clearUpload, getStreamTitle } = useController(ExportModalCtx);
306314
const { UserService } = Services;
307315
const { isYoutubeLinked } = useVuex(() => ({
@@ -332,7 +340,9 @@ function PlatformSelect({ onClose, videoName }: { onClose: () => void; videoName
332340
nowrap
333341
options={platformOptions}
334342
/>
335-
{platform === 'youtube' && <YoutubeUpload defaultTitle={videoName} close={onClose} />}
343+
{platform === 'youtube' && (
344+
<YoutubeUpload defaultTitle={videoName} close={onClose} streamId={streamId} />
345+
)}
336346
{platform !== 'youtube' && <StorageUpload onClose={onClose} platform={platform} />}
337347
</Form>
338348
);

app/components-react/highlighter/PreviewModal.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function PreviewModal({
3131
streamId: string | undefined;
3232
emitSetShowModal: (modal: TModalClipsView | null) => void;
3333
}) {
34-
const { HighlighterService } = Services;
34+
const { HighlighterService, UsageStatisticsService } = Services;
3535
const clips = HighlighterService.getClips(HighlighterService.views.clips, streamId);
3636
const { intro, outro } = HighlighterService.views.video;
3737
const audioSettings = HighlighterService.views.audio;
@@ -41,6 +41,10 @@ export default function PreviewModal({
4141
const currentClipIndexRef = useRef(initialIndex);
4242
const [showDisabled, setShowDisabled] = useState(true);
4343

44+
useEffect(() => {
45+
UsageStatisticsService.recordShown('ClipsPreview', streamId);
46+
}, []);
47+
4448
function getInitialIndex(introDuration: number | null, sortedClips: TClip[]): number {
4549
if (introDuration) return 0;
4650
const firstEnabledIndex = sortedClips.findIndex(clip => clip.enabled);

app/components-react/highlighter/SettingsView.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export default function SettingsView({
175175
style={{ width: 'fit-content' }}
176176
type="primary"
177177
onClick={() => {
178-
HighlighterService.actions.installAiHighlighter(true);
178+
HighlighterService.actions.installAiHighlighter(true, 'Highlighter-tab');
179179
}}
180180
>
181181
{$t('Install AI Highlighter App')}

app/components-react/highlighter/YoutubeUpload.tsx

+14-6
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ import * as remote from '@electron/remote';
1212
import VideoPreview from './VideoPreview';
1313
import UploadProgress from './UploadProgress';
1414

15-
export default function YoutubeUpload(props: { defaultTitle: string; close: () => void }) {
15+
export default function YoutubeUpload(props: {
16+
defaultTitle: string;
17+
close: () => void;
18+
streamId: string | undefined;
19+
}) {
1620
const [title, setTitle] = useState(props.defaultTitle);
21+
const streamId = props.streamId;
1722
const [description, setDescription] = useState('');
1823
const [privacy, setPrivacy] = useState('private');
1924
const [urlCopied, setUrlCopied] = useState(false);
@@ -107,11 +112,14 @@ export default function YoutubeUpload(props: { defaultTitle: string; close: () =
107112
type="primary"
108113
onClick={() => {
109114
UsageStatisticsService.actions.recordFeatureUsage('HighlighterUpload');
110-
HighlighterService.actions.uploadYoutube({
111-
title,
112-
description,
113-
privacyStatus: privacy as TPrivacyStatus,
114-
});
115+
HighlighterService.actions.uploadYoutube(
116+
{
117+
title,
118+
description,
119+
privacyStatus: privacy as TPrivacyStatus,
120+
},
121+
streamId,
122+
);
115123
}}
116124
>
117125
{$t('Publish')}

app/components-react/pages/Highlighter.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import UpdateModal from 'components-react/highlighter/UpdateModal';
99
import { EAvailableFeatures } from 'services/incremental-rollout';
1010

1111
export default function Highlighter(props: { params?: { view: string } }) {
12-
const { HighlighterService, IncrementalRolloutService } = Services;
12+
const { HighlighterService, IncrementalRolloutService, UsageStatisticsService } = Services;
1313
const aiHighlighterFeatureEnabled = IncrementalRolloutService.views.featureIsEnabled(
1414
EAvailableFeatures.aiHighlighter,
1515
);
@@ -50,6 +50,11 @@ export default function Highlighter(props: { params?: { view: string } }) {
5050
}, []);
5151

5252
const [viewState, setViewState] = useState<IViewState>(initialViewState);
53+
54+
useEffect(() => {
55+
UsageStatisticsService.recordShown('HighlighterTab', viewState.view);
56+
}, [viewState]);
57+
5358
const updaterModal = (
5459
<UpdateModal
5560
version={v.highlighterVersion}

app/components-react/windows/go-live/AiHighlighterToggle.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export default function AiHighlighterToggle({
122122
size="small"
123123
type="primary"
124124
onClick={() => {
125-
HighlighterService.installAiHighlighter();
125+
HighlighterService.installAiHighlighter(false, 'Go-live-flow');
126126
}}
127127
>
128128
Install AI Highlighter

app/services/highlighter/ai-highlighter-updater.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export class AiHighlighterUpdater {
129129
*/
130130
public async isNewVersionAvailable(): Promise<boolean> {
131131
// check if updater checked version in current session already
132-
if (this.versionChecked) {
132+
if (this.versionChecked || Utils.getHighlighterEnvironment() === 'local') {
133133
return false;
134134
}
135135

@@ -235,7 +235,7 @@ export class AiHighlighterUpdater {
235235
const binPath = path.resolve(AiHighlighterUpdater.basepath, 'bin');
236236
const outdateVersionPresent = existsSync(binPath);
237237

238-
// backup the ouotdated version in case something goes bad
238+
// backup the outdated version in case something goes bad
239239
if (outdateVersionPresent) {
240240
console.log('backing up outdated version...');
241241
const backupPath = path.resolve(AiHighlighterUpdater.basepath, 'bin.bkp');

app/services/highlighter/index.ts

+29-2
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,7 @@ export class HighlighterService extends PersistentStatefulService<IHighlighterSt
991991
transitionDuration: this.views.transitionDuration,
992992
transition: this.views.transition,
993993
useAiHighlighter: this.views.useAiHighlighter,
994+
streamId,
994995
},
995996
handleFrame,
996997
setExportInfo,
@@ -1110,7 +1111,15 @@ export class HighlighterService extends PersistentStatefulService<IHighlighterSt
11101111
}
11111112
}
11121113

1113-
async installAiHighlighter(downloadNow: boolean = false) {
1114+
async installAiHighlighter(
1115+
downloadNow: boolean = false,
1116+
location: 'Highlighter-tab' | 'Go-live-flow',
1117+
) {
1118+
this.usageStatisticsService.recordAnalyticsEvent('AIHighlighter', {
1119+
type: 'Installation',
1120+
location,
1121+
});
1122+
11141123
this.setAiHighlighter(true);
11151124
if (downloadNow) {
11161125
await this.aiHighlighterUpdater.isNewVersionAvailable();
@@ -1136,6 +1145,12 @@ export class HighlighterService extends PersistentStatefulService<IHighlighterSt
11361145
this.SET_UPDATER_STATE(true);
11371146
this.SET_HIGHLIGHTER_VERSION(this.aiHighlighterUpdater.version || '');
11381147
await this.aiHighlighterUpdater.update(progress => this.updateProgress(progress));
1148+
} catch (e: unknown) {
1149+
console.error('Error updating AI Highlighter:', e);
1150+
this.usageStatisticsService.recordAnalyticsEvent('Highlighter', {
1151+
type: 'UpdateError',
1152+
newVersion: this.aiHighlighterUpdater.version,
1153+
});
11391154
} finally {
11401155
this.SET_UPDATER_STATE(false);
11411156
}
@@ -1248,14 +1263,25 @@ export class HighlighterService extends PersistentStatefulService<IHighlighterSt
12481263
type: 'Detection',
12491264
clips: highlighterResponse.length,
12501265
game: 'Fortnite', // hardcode for now
1266+
streamId: this.streamMilestones?.streamId,
12511267
});
12521268
console.log('✅ Final HighlighterData', highlighterResponse);
12531269
} catch (error: unknown) {
12541270
if (error instanceof Error && error.message === 'Highlight generation canceled') {
12551271
setStreamInfo.state.type = EAiDetectionState.CANCELED_BY_USER;
1272+
this.usageStatisticsService.recordAnalyticsEvent('AIHighlighter', {
1273+
type: 'DetectionCanceled',
1274+
reason: EAiDetectionState.CANCELED_BY_USER,
1275+
game: 'Fortnite',
1276+
});
12561277
} else {
12571278
console.error('Error in highlight generation:', error);
12581279
setStreamInfo.state.type = EAiDetectionState.ERROR;
1280+
this.usageStatisticsService.recordAnalyticsEvent('AIHighlighter', {
1281+
type: 'DetectionFailed',
1282+
reason: EAiDetectionState.ERROR,
1283+
game: 'Fortnite',
1284+
});
12591285
}
12601286
} finally {
12611287
setStreamInfo.abortController = undefined;
@@ -1343,7 +1369,7 @@ export class HighlighterService extends PersistentStatefulService<IHighlighterSt
13431369
this.CLEAR_UPLOAD();
13441370
}
13451371

1346-
async uploadYoutube(options: IYoutubeVideoUploadOptions) {
1372+
async uploadYoutube(options: IYoutubeVideoUploadOptions, streamId: string | undefined) {
13471373
if (!this.userService.state.auth?.platforms.youtube) {
13481374
throw new Error('Cannot upload without YT linked');
13491375
}
@@ -1407,6 +1433,7 @@ export class HighlighterService extends PersistentStatefulService<IHighlighterSt
14071433
this.views.useAiHighlighter ? 'AIHighlighter' : 'Highlighter',
14081434
{
14091435
type: 'UploadYouTubeSuccess',
1436+
streamId,
14101437
privacy: options.privacyStatus,
14111438
videoLink:
14121439
options.privacyStatus === 'public'

app/services/highlighter/rendering/start-rendering.ts

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface IRenderingConfig {
2828
transitionDuration: number;
2929
transition: ITransitionInfo;
3030
useAiHighlighter: boolean;
31+
streamId: string | undefined;
3132
}
3233
export async function startRendering(
3334
renderingConfig: IRenderingConfig,
@@ -43,6 +44,7 @@ export async function startRendering(
4344
const transitionDuration = renderingConfig.transitionDuration;
4445
const transition = renderingConfig.transition;
4546
const useAiHighlighter = renderingConfig.useAiHighlighter;
47+
const streamId = renderingConfig.streamId;
4648

4749
let fader: AudioCrossfader | null = null;
4850
let mixer: AudioMixer | null = null;
@@ -200,6 +202,7 @@ export async function startRendering(
200202
preset: exportInfo.preset,
201203
duration: totalFramesAfterTransitions / exportOptions.fps,
202204
isPreview,
205+
streamId,
203206
});
204207
break;
205208
}

0 commit comments

Comments
 (0)