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

View File

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

View File

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

View File

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