Skip to content

Commit ee8d14b

Browse files
authored
Python Lab: log to statsig on resize (code-dot-org#63940)
* add resize logging * change to statsig * log layout and bar name
1 parent 1cf901d commit ee8d14b

File tree

5 files changed

+38
-0
lines changed

5 files changed

+38
-0
lines changed

apps/src/codebridge/Workspace/Output.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
66
import {useResizable} from 'react-resizable-layout';
77

88
import Console from '@cdo/apps/codebridge/Console/Console';
9+
import {logOnResize} from '@cdo/apps/lab2/utils/logOnResize';
910
import ResizeBar from '@cdo/apps/lab2/views/components/ResizeBar';
11+
import {useAppSelector} from '@cdo/apps/util/reduxHooks';
1012

1113
import CodebridgeRegistry from '../CodebridgeRegistry';
1214
import {MiniApps} from '../constants';
@@ -40,6 +42,7 @@ const Output: React.FunctionComponent<OutputProps> = ({
4042
// In vertical mode, consoleSize is the height of the console.
4143
// In horizontal mode, consoleSize is the width of the console.
4244
const [consoleSize, setConsoleSize] = useState<number | undefined>(undefined);
45+
const appName = useAppSelector(state => state.lab.levelProperties?.appName);
4346

4447
const {
4548
position: miniAppSize,
@@ -51,6 +54,11 @@ const Output: React.FunctionComponent<OutputProps> = ({
5154
min: MIN_MINI_APP_SIZE,
5255
max: MAX_MINI_APP_SIZE,
5356
containerRef: resizeContainerRef,
57+
onResizeStart: () =>
58+
logOnResize(appName, {
59+
layout: config.activeLayout || '',
60+
resizeBar: 'neighborhood',
61+
}),
5462
});
5563

5664
const [adjustedMiniAppSize, setAdjustedMiniAppSize] =

apps/src/lab2/utils/logOnResize.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {EVENTS, PLATFORMS} from '@cdo/apps/metrics/AnalyticsConstants';
2+
import analyticsReporter from '@cdo/apps/metrics/AnalyticsReporter';
3+
4+
export const logOnResize = (
5+
labType?: string,
6+
payload?: Record<string, string>
7+
) => {
8+
const fullPayload = payload ? {labType, ...payload} : {labType};
9+
analyticsReporter.sendEvent(
10+
EVENTS.LAB2_RESIZE_DRAG_START,
11+
fullPayload,
12+
PLATFORMS.STATSIG
13+
);
14+
};

apps/src/metrics/AnalyticsConstants.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,9 @@ const EVENTS = {
531531

532532
// Sign in callout on CSF and CSC levels
533533
LEVEL_SIGN_IN_CALLOUT_SHOWN: 'Level Sign In Callout Shown',
534+
535+
// Lab2
536+
LAB2_RESIZE_DRAG_START: 'Resize bar dragged in lab2',
534537
};
535538

536539
const EVENT_GROUP_NAMES = {

apps/src/pythonlab/layout/HorizontalLayout.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {throttle} from 'lodash';
55
import React, {useCallback, useEffect, useMemo} from 'react';
66
import {useResizable} from 'react-resizable-layout';
77

8+
import {logOnResize} from '@cdo/apps/lab2/utils/logOnResize';
89
import ResizeBar, {
910
RESIZE_BAR_SIZE_PX,
1011
} from '@cdo/apps/lab2/views/components/ResizeBar';
@@ -41,6 +42,11 @@ const HorizontalLayout: React.FunctionComponent = () => {
4142
axis: 'x',
4243
initial: INITIAL_INFO_PANEL_WIDTH,
4344
min: MIN_LEFT_PANEL_WIDTH,
45+
onResizeStart: () =>
46+
logOnResize('pythonlab', {
47+
layout: 'horizontal',
48+
resizeBar: 'instructions',
49+
}),
4450
});
4551
const {
4652
position: rawOutputHeight,
@@ -51,6 +57,8 @@ const HorizontalLayout: React.FunctionComponent = () => {
5157
initial: INITIAL_OUTPUT_HEIGHT,
5258
min: MIN_OUTPUT_HEIGHT,
5359
reverse: true,
60+
onResizeStart: () =>
61+
logOnResize('pythonlab', {layout: 'horizontal', resizeBar: 'console'}),
5462
});
5563

5664
const adjustRightPanelWidth = useCallback(() => {

apps/src/pythonlab/layout/VerticalLayout.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Output from '@codebridge/Workspace/Output';
44
import React, {useCallback, useEffect} from 'react';
55
import {useResizable} from 'react-resizable-layout';
66

7+
import {logOnResize} from '@cdo/apps/lab2/utils/logOnResize';
78
import ResizeBar, {
89
RESIZE_BAR_SIZE_PX,
910
} from '@cdo/apps/lab2/views/components/ResizeBar';
@@ -32,6 +33,8 @@ const VerticalLayout: React.FunctionComponent = () => {
3233
axis: 'x',
3334
initial: INITIAL_INFO_PANEL_WIDTH,
3435
min: MIN_INFO_PANEL_WIDTH,
36+
onResizeStart: () =>
37+
logOnResize('pythonlab', {layout: 'vertical', resizeBar: 'instructions'}),
3538
});
3639
const {
3740
position: rawOutputWidth,
@@ -42,6 +45,8 @@ const VerticalLayout: React.FunctionComponent = () => {
4245
initial: INITIAL_OUTPUT_WIDTH,
4346
min: MIN_OUTPUT_WIDTH,
4447
reverse: true,
48+
onResizeStart: () =>
49+
logOnResize('pythonlab', {layout: 'vertical', resizeBar: 'console'}),
4550
});
4651

4752
const adjustWidths = useCallback(() => {

0 commit comments

Comments
 (0)