Telemetry updates (#429)

This commit is contained in:
Tanuj Mittal 2021-02-06 00:26:20 +05:30 committed by GitHub
parent 3e5a876ef2
commit afaa844d28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 6 deletions

View File

@ -30,7 +30,7 @@ import { CodeOfConductComponent } from "./CodeOfConductComponent";
import { InfoComponent } from "./InfoComponent/InfoComponent";
import { handleError } from "../../../Common/ErrorHandlingUtils";
import { trace } from "../../../Shared/Telemetry/TelemetryProcessor";
import { Action } from "../../../Shared/Telemetry/TelemetryConstants";
import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants";
export interface GalleryViewerComponentProps {
container?: Explorer;
@ -459,6 +459,10 @@ export class GalleryViewerComponent extends React.Component<GalleryViewerCompone
}
this.sampleNotebooks = response.data;
trace(Action.NotebooksGalleryOfficialSamplesCount, ActionModifiers.Mark, {
count: this.sampleNotebooks?.length,
});
} catch (error) {
handleError(error, "GalleryViewerComponent/loadSampleNotebooks", "Failed to load sample notebooks");
}
@ -485,6 +489,8 @@ export class GalleryViewerComponent extends React.Component<GalleryViewerCompone
if (response.status !== HttpStatusCodes.OK && response.status !== HttpStatusCodes.NoContent) {
throw new Error(`Received HTTP ${response.status} when loading public notebooks`);
}
trace(Action.NotebooksGalleryPublicGalleryCount, ActionModifiers.Mark, { count: this.publicNotebooks?.length });
} catch (error) {
handleError(error, "GalleryViewerComponent/loadPublicNotebooks", "Failed to load public notebooks");
}
@ -505,6 +511,8 @@ export class GalleryViewerComponent extends React.Component<GalleryViewerCompone
}
this.favoriteNotebooks = response.data;
trace(Action.NotebooksGalleryFavoritesCount, ActionModifiers.Mark, { count: this.favoriteNotebooks?.length });
} catch (error) {
handleError(error, "GalleryViewerComponent/loadFavoriteNotebooks", "Failed to load favorite notebooks");
}
@ -531,6 +539,14 @@ export class GalleryViewerComponent extends React.Component<GalleryViewerCompone
}
this.publishedNotebooks = response.data;
const { published, underReview, removed } = GalleryUtils.filterPublishedNotebooks(this.publishedNotebooks);
trace(Action.NotebooksGalleryPublishedCount, ActionModifiers.Mark, {
count: this.publishedNotebooks?.length,
publishedCount: published.length,
underReviewCount: underReview.length,
removedCount: removed.length,
});
} catch (error) {
handleError(error, "GalleryViewerComponent/loadPublishedNotebooks", "Failed to load published notebooks");
}

View File

@ -82,6 +82,7 @@ export class NotebookViewerComponent
const startKey = traceStart(Action.NotebooksGalleryViewNotebook, {
notebookUrl: this.props.notebookUrl,
notebookId: this.props.galleryItem?.id,
isSample: this.props.galleryItem?.isSample,
});
try {
@ -93,7 +94,11 @@ export class NotebookViewerComponent
traceSuccess(
Action.NotebooksGalleryViewNotebook,
{ notebookUrl: this.props.notebookUrl, notebookId: this.props.galleryItem?.id },
{
notebookUrl: this.props.notebookUrl,
notebookId: this.props.galleryItem?.id,
isSample: this.props.galleryItem?.isSample,
},
startKey
);
@ -116,6 +121,7 @@ export class NotebookViewerComponent
{
notebookUrl: this.props.notebookUrl,
notebookId: this.props.galleryItem?.id,
isSample: this.props.galleryItem?.isSample,
error: getErrorMessage(error),
errorStack: getErrorStack(error),
},

View File

@ -110,6 +110,10 @@ export enum Action {
NotebooksGalleryViewFavorites,
NotebooksGalleryViewPublishedNotebooks,
NotebooksGalleryClickPublishToGallery,
NotebooksGalleryOfficialSamplesCount,
NotebooksGalleryPublicGalleryCount,
NotebooksGalleryFavoritesCount,
NotebooksGalleryPublishedCount,
}
export const ActionModifiers = {

View File

@ -135,7 +135,7 @@ export function reportAbuse(
true
);
const startKey = traceStart(Action.NotebooksGalleryReportAbuse, { notebookId: data.id });
const startKey = traceStart(Action.NotebooksGalleryReportAbuse, { notebookId: data.id, abuseCategory });
try {
const response = await junoClient.reportAbuse(notebookId, abuseCategory, additionalDetails);
@ -161,6 +161,7 @@ export function reportAbuse(
Action.NotebooksGalleryReportAbuse,
{
notebookId: data.id,
abuseCategory,
error: getErrorMessage(error),
errorStack: getErrorStack(error),
},
@ -233,6 +234,7 @@ export function downloadItem(
const startKey = traceStart(Action.NotebooksGalleryDownload, {
notebookId: data.id,
downloadCount: data.downloads,
isSample: data.isSample,
});
try {
@ -251,7 +253,7 @@ export function downloadItem(
if (increaseDownloadResponse.data) {
traceSuccess(
Action.NotebooksGalleryDownload,
{ notebookId: data.id, downloadCount: increaseDownloadResponse.data.downloads },
{ notebookId: data.id, downloadCount: increaseDownloadResponse.data.downloads, isSample: data.isSample },
startKey
);
onComplete(increaseDownloadResponse.data);
@ -262,6 +264,7 @@ export function downloadItem(
{
notebookId: data.id,
downloadCount: data.downloads,
isSample: data.isSample,
error: getErrorMessage(error),
errorStack: getErrorStack(error),
},
@ -287,6 +290,7 @@ export async function favoriteItem(
if (container) {
const startKey = traceStart(Action.NotebooksGalleryFavorite, {
notebookId: data.id,
isSample: data.isSample,
favoriteCount: data.favorites,
});
@ -298,7 +302,7 @@ export async function favoriteItem(
traceSuccess(
Action.NotebooksGalleryFavorite,
{ notebookId: data.id, favoriteCount: response.data.favorites },
{ notebookId: data.id, isSample: data.isSample, favoriteCount: response.data.favorites },
startKey
);
@ -308,6 +312,7 @@ export async function favoriteItem(
Action.NotebooksGalleryFavorite,
{
notebookId: data.id,
isSample: data.isSample,
favoriteCount: data.favorites,
error: getErrorMessage(error),
errorStack: getErrorStack(error),
@ -329,6 +334,7 @@ export async function unfavoriteItem(
if (container) {
const startKey = traceStart(Action.NotebooksGalleryUnfavorite, {
notebookId: data.id,
isSample: data.isSample,
favoriteCount: data.favorites,
});
@ -340,7 +346,7 @@ export async function unfavoriteItem(
traceSuccess(
Action.NotebooksGalleryUnfavorite,
{ notebookId: data.id, favoriteCount: response.data.favorites },
{ notebookId: data.id, isSample: data.isSample, favoriteCount: response.data.favorites },
startKey
);
@ -350,6 +356,7 @@ export async function unfavoriteItem(
Action.NotebooksGalleryUnfavorite,
{
notebookId: data.id,
isSample: data.isSample,
favoriteCount: data.favorites,
error: getErrorMessage(error),
errorStack: getErrorStack(error),