Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[analytics] group rendered events by session #5220

Merged
merged 1 commit into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@types/react-dom": "^17.0.3",
"@types/react-router": "^5.1.13",
"@types/react-router-dom": "^5.1.7",
"@types/uuid": "^3.4.5",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/parser": "^4.21.0",
"autoprefixer": "^9.8.6",
Expand Down
25 changes: 20 additions & 5 deletions components/dashboard/src/start/StartWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import PendingChangesDropdown from "../components/PendingChangesDropdown";
import { getGitpodService, gitpodHostUrl } from "../service/service";
import { StartPage, StartPhase, StartWorkspaceError } from "./StartPage";
import { watchHeadlessLogs } from "../components/PrebuildLogs";
import { v4 } from 'uuid';
const sessionId = v4();

const WorkspaceLogs = React.lazy(() => import('../components/WorkspaceLogs'));

Expand All @@ -37,6 +39,7 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
private readonly toDispose = new DisposableCollection();
componentWillMount() {
if (this.runsInIFrame()) {
window.parent.postMessage({ type: '$setSessionId', sessionId }, '*');
const setStateEventListener = (event: MessageEvent) => {
if (event.data.type === 'setState' && 'state' in event.data && typeof event.data['state'] === 'object') {
if (event.data.state.ideFrontendFailureCause) {
Expand Down Expand Up @@ -71,14 +74,26 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
if (newPhase !== oldPhase) {
getGitpodService().server.trackEvent({
event: "status_rendered",
properties: { workspaceId: this.state?.workspaceInstance?.workspaceId, "phase": newPhase },
properties: {
sessionId,
instanceId: this.state.workspaceInstance?.id,
workspaceId: this.state?.workspace?.id,
type: this.state.workspace?.type,
phase: newPhase
},
});
}

if (!!this.state.error && this.state.error !== prevState.error) {
getGitpodService().server.trackEvent({
event: "error_rendered",
properties: { workspaceId: this.state?.workspaceInstance?.workspaceId, "error": this.state.error },
properties: {
sessionId,
instanceId: this.state.workspaceInstance?.id,
workspaceId: this.state?.workspace?.id,
type: this.state.workspace?.type,
error: this.state.error
},
});
}
}
Expand Down Expand Up @@ -196,9 +211,9 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,

redirectTo(url: string) {
if (this.runsInIFrame()) {
window.parent.postMessage({ type: 'relocate', url }, '*');
window.parent.postMessage({ type: 'relocate', url }, '*');
} else {
window.location.href = url;
window.location.href = url;
}
}

Expand Down Expand Up @@ -370,7 +385,7 @@ function HeadlessWorkspaceView(props: { instanceId: string }) {

return <StartPage title="Prebuild in Progress">
<Suspense fallback={<div />}>
<WorkspaceLogs logsEmitter={logsEmitter}/>
<WorkspaceLogs logsEmitter={logsEmitter} />
</Suspense>
</StartPage>;
}
6 changes: 5 additions & 1 deletion components/supervisor/frontend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const loadingIDE = new Promise(resolve => window.addEventListener('DOMContentLoa
LoadingFrame.load({ gitpodService: window.gitpod.service }),
pendingGitpodServiceClient
]);
const sessionId = await loading.sessionId;

if (gitpodServiceClient.info.workspace.type !== 'regular') {
return;
Expand Down Expand Up @@ -141,7 +142,10 @@ const loadingIDE = new Promise(resolve => window.addEventListener('DOMContentLoa
window.gitpod.service.server.trackEvent({
event: "status_rendered",
properties: {
workspaceId: gitpodServiceClient.info.latestInstance?.workspaceId,
sessionId,
instanceId: gitpodServiceClient.info.latestInstance?.id,
workspaceId: gitpodServiceClient.info.workspace.id,
type: gitpodServiceClient.info.workspace.type,
phase: `ide-${ideService.state}`,
error: ideService.failureCause?.message,
},
Expand Down
13 changes: 12 additions & 1 deletion components/supervisor/frontend/src/shared/loading-frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,21 @@ const relocateListener = (event: MessageEvent) => {
};
window.addEventListener('message', relocateListener, false);

let resolveSessionId: (sessionId: string) => void;
const sessionId = new Promise<string>(resolve => resolveSessionId = resolve);
const setSessinoIdListener = (event: MessageEvent) => {
if (event.origin === serverOrigin && event.data.type == '$setSessionId' && event.data.sessionId) {
window.removeEventListener('message', setSessinoIdListener);
resolveSessionId(event.data.sessionId);
}
};
window.addEventListener('message', setSessinoIdListener, false);

export function load({ gitpodService }: {
gitpodService: ReturnType<typeof createGitpodService>
}): Promise<{
frame: HTMLIFrameElement
sessionId: Promise<string>
setState: (state: object) => void
}> {
return new Promise(resolve => {
Expand All @@ -45,7 +56,7 @@ export function load({ gitpodService }: {
const setState = (state: object) => {
frameWindow.postMessage({ type: 'setState', state }, serverOrigin);
}
resolve({ frame, setState });
resolve({ frame, sessionId, setState });
};
});
}
30 changes: 5 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4661,7 +4661,7 @@
"@types/history" "*"
"@types/react" "*"

"@types/react@*", "@types/react@17.0.0", "@types/react@^17.0.0":
"@types/react@*", "@types/react@^17.0.0":
version "17.0.0"
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.0.tgz#5af3eb7fad2807092f0046a1302b7823e27919b8"
integrity sha512-aj/L7RIMsRlWML3YB6KZiXB3fV2t41+5RBGYF8z+tAKU43Px8C3cYUZsDvf1/+Bm4FK21QWBrDutu8ZJ/70qOw==
Expand Down Expand Up @@ -14875,7 +14875,7 @@ mz@^2.4.0:
object-assign "^4.0.1"
thenify-all "^1.0.0"

nan@2.14.1, nan@^2.12.1, nan@^2.13.2, nan@^2.14.0, nan@^2.9.2:
nan@^2.12.1, nan@^2.13.2, nan@^2.9.2:
version "2.14.1"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.1.tgz#d7be34dfa3105b91494c3147089315eff8874b01"
integrity sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==
Expand Down Expand Up @@ -15447,13 +15447,6 @@ onetime@^5.1.2:
dependencies:
mimic-fn "^2.1.0"

[email protected]:
version "7.2.1"
resolved "https://registry.yarnpkg.com/oniguruma/-/oniguruma-7.2.1.tgz#51775834f7819b6e31aa878706aa7f65ad16b07f"
integrity sha512-WPS/e1uzhswPtJSe+Zls/kAj27+lEqZjCmRSjnYk/Z4L2Mu+lJC2JWtkZhPJe4kZeTQfz7ClcLyXlI4J68MG2w==
dependencies:
nan "^2.14.0"

open@^7.0.2:
version "7.4.2"
resolved "https://registry.yarnpkg.com/open/-/open-7.4.2.tgz#b8147e26dcf3e426316c730089fd71edd29c2321"
Expand Down Expand Up @@ -17592,7 +17585,7 @@ react-dev-utils@^11.0.3:
strip-ansi "6.0.0"
text-table "0.2.0"

react-dom@17.0.1, react-dom@^17.0.1:
react-dom@^17.0.1:
version "17.0.1"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.1.tgz#1de2560474ec9f0e334285662ede52dbc5426fc6"
integrity sha512-6eV150oJZ9U2t9svnsspTMrWNyHc6chX0KzDeAOXftRa8bNeOKTTfCJ7KorIwenkHd2xqVTBTCZd79yk/lx/Ug==
Expand Down Expand Up @@ -17721,7 +17714,7 @@ react-scripts@^4.0.3:
optionalDependencies:
fsevents "^2.1.3"

react@17.0.1, react@^17.0.1:
react@^17.0.1:
version "17.0.1"
resolved "https://registry.yarnpkg.com/react/-/react-17.0.1.tgz#6e0600416bd57574e3f86d92edba3d9008726127"
integrity sha512-lG9c9UuMHdcAexXtigOZLX8exLWkW0Ku29qPRU8uhF2R9BN96dLCt0psvzPLlHc5OWkgymP3qwTRgbnw5BKx3w==
Expand Down Expand Up @@ -20999,24 +20992,11 @@ vm-browserify@^1.0.1:
resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.0.tgz#bd76d6a23323e2ca8ffa12028dc04559c75f9019"
integrity sha512-iq+S7vZJE60yejDYM0ek6zg308+UZsdtPExWP9VZoCFCz1zkJoXFnAX7aZfd/ZwrkidzdUZL0C/ryW+JwAiIGw==

vscode-jsonrpc@^5.0.0, vscode-jsonrpc@^5.0.1:
vscode-jsonrpc@^5.0.0:
version "5.0.1"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-5.0.1.tgz#9bab9c330d89f43fc8c1e8702b5c36e058a01794"
integrity sha512-JvONPptw3GAQGXlVV2utDcHx0BiY34FupW/kI6mZ5x06ER5DdPG/tXWMVHjTNULF5uKPOUUD0SaXg5QaubJL0A==

[email protected]:
version "3.15.3"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.15.3.tgz#3fa9a0702d742cf7883cb6182a6212fcd0a1d8bb"
integrity sha512-zrMuwHOAQRhjDSnflWdJG+O2ztMWss8GqUUB8dXLR/FPenwkiBNkMIJJYfSN6sgskvsF0rHAoBowNQfbyZnnvw==
dependencies:
vscode-jsonrpc "^5.0.1"
vscode-languageserver-types "3.15.1"

[email protected]:
version "3.15.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.15.1.tgz#17be71d78d2f6236d414f0001ce1ef4d23e6b6de"
integrity sha512-+a9MPUQrNGRrGU630OGbYVQ+11iOIovjCkqxajPa9w57Sd5ruK8WQNsslzpa0x/QJqC8kRc2DUxWjIFwoNm4ZQ==

vscode-uri@^1.0.1:
version "1.0.8"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-1.0.8.tgz#9769aaececae4026fb6e22359cb38946580ded59"
Expand Down