Prettier 2.0 (#393)

This commit is contained in:
Steve Faulkner
2021-01-20 09:15:01 -06:00
committed by GitHub
parent c1937ca464
commit 4be53284b5
500 changed files with 41927 additions and 41838 deletions

View File

@@ -12,8 +12,8 @@ describe("getMaxThroughput", () => {
unlimited: 400,
unlimitedmax: 1000000,
unlimitedmin: 400,
shared: 400
}
shared: 400,
},
};
expect(getMaxThroughput(defaults, {} as Explorer)).toEqual(defaults.throughput.unlimited);
@@ -27,12 +27,12 @@ describe("getMaxThroughput", () => {
unlimited: {
collectionThreshold: 3,
lessThanOrEqualToThreshold: 400,
greatThanThreshold: 500
greatThanThreshold: 500,
},
unlimitedmax: 1000000,
unlimitedmin: 400,
shared: 400
}
shared: 400,
},
};
const mockCollection1 = { id: ko.observable("collection1") } as Collection;
@@ -41,7 +41,7 @@ describe("getMaxThroughput", () => {
const mockCollection4 = { id: ko.observable("collection4") } as Collection;
const mockDatabase = {} as Database;
const mockContainer = {
databases: ko.observableArray([mockDatabase])
databases: ko.observableArray([mockDatabase]),
} as Explorer;
it("less than or equal to collection threshold", () => {
@@ -56,7 +56,7 @@ describe("getMaxThroughput", () => {
mockCollection1,
mockCollection2,
mockCollection3,
mockCollection4
mockCollection4,
]);
expect(getMaxThroughput(defaults, mockContainer)).toEqual(defaults.throughput.unlimited.greatThanThreshold);
});

View File

@@ -1,23 +1,23 @@
import { any } from "underscore";
import { CollectionCreationDefaults } from "../Contracts/ViewModels";
import Explorer from "../Explorer/Explorer";
export const getMaxThroughput = (defaults: CollectionCreationDefaults, container: Explorer): number => {
const throughput = defaults.throughput.unlimited;
if (typeof throughput === "number") {
return throughput;
} else {
return _exceedsThreshold(throughput.collectionThreshold, container)
? throughput.greatThanThreshold
: throughput.lessThanOrEqualToThreshold;
}
};
const _exceedsThreshold = (unlimitedThreshold: number, container: Explorer): boolean => {
const databases = (container && container.databases && container.databases()) || [];
return any(
databases,
database =>
database && database.collections && database.collections() && database.collections().length > unlimitedThreshold
);
};
import { any } from "underscore";
import { CollectionCreationDefaults } from "../Contracts/ViewModels";
import Explorer from "../Explorer/Explorer";
export const getMaxThroughput = (defaults: CollectionCreationDefaults, container: Explorer): number => {
const throughput = defaults.throughput.unlimited;
if (typeof throughput === "number") {
return throughput;
} else {
return _exceedsThreshold(throughput.collectionThreshold, container)
? throughput.greatThanThreshold
: throughput.lessThanOrEqualToThreshold;
}
};
const _exceedsThreshold = (unlimitedThreshold: number, container: Explorer): boolean => {
const databases = (container && container.databases && container.databases()) || [];
return any(
databases,
(database) =>
database && database.collections && database.collections() && database.collections().length > unlimitedThreshold
);
};

View File

@@ -1,239 +1,239 @@
import { SubscriptionType } from "../Contracts/SubscriptionType";
export const hoursInAMonth = 730;
export class AutoscalePricing {
public static MonthlyPricing = {
default: {
singleMaster: {
Currency: "USD",
CurrencySign: "$",
Standard: {
StartingPrice: 24,
PricePerRU: 0.09,
PricePerGB: 0.25
}
},
multiMaster: {
Currency: "USD",
CurrencySign: "$",
Standard: {
StartingPrice: 24,
PricePerRU: 0.12,
PricePerGB: 0.25
}
}
},
mooncake: {
singleMaster: {
Currency: "RMB",
CurrencySign: "¥",
Standard: {
StartingPrice: 152,
PricePerRU: 0.57,
PricePerGB: 2.576
}
},
multiMaster: {
Currency: "RMB",
CurrencySign: "¥",
Standard: {
StartingPrice: 152,
PricePerRU: 0.76,
PricePerGB: 2.576
}
}
}
};
public static HourlyPricing = {
default: {
singleMaster: {
Currency: "USD",
CurrencySign: "$",
Standard: {
StartingPrice: 24 / hoursInAMonth,
PricePerRU: 0.00012,
PricePerGB: 0.25 / hoursInAMonth
}
},
multiMaster: {
Currency: "USD",
CurrencySign: "$",
Standard: {
StartingPrice: 24 / hoursInAMonth,
PricePerRU: 0.00016,
PricePerGB: 0.25 / hoursInAMonth
}
}
},
mooncake: {
singleMaster: {
Currency: "RMB",
CurrencySign: "¥",
Standard: {
StartingPrice: AutoscalePricing.MonthlyPricing.mooncake.singleMaster.Standard.StartingPrice / hoursInAMonth, // per hour
PricePerRU: 0.000765,
PricePerGB: AutoscalePricing.MonthlyPricing.mooncake.singleMaster.Standard.PricePerGB / hoursInAMonth
}
},
multiMaster: {
Currency: "RMB",
CurrencySign: "¥",
Standard: {
StartingPrice: AutoscalePricing.MonthlyPricing.mooncake.multiMaster.Standard.StartingPrice / hoursInAMonth, // per hour
PricePerRU: 0.00102,
PricePerGB: AutoscalePricing.MonthlyPricing.mooncake.multiMaster.Standard.PricePerGB / hoursInAMonth
}
}
}
};
}
export class OfferPricing {
public static MonthlyPricing = {
default: {
Currency: "USD",
CurrencySign: "$",
S1Price: 25,
S2Price: 50,
S3Price: 100,
Standard: {
StartingPrice: 24,
PricePerRU: 0.06,
PricePerGB: 0.25
}
},
mooncake: {
Currency: "RMB",
CurrencySign: "¥",
S1Price: 110.3,
S2Price: 220.6,
S3Price: 441.2,
Standard: {
StartingPrice: 152,
PricePerRU: 0.3794,
PricePerGB: 2.576
}
}
};
public static HourlyPricing = {
default: {
Currency: "USD",
CurrencySign: "$",
S1Price: 0.0336,
S2Price: 0.0672,
S3Price: 0.1344,
Standard: {
StartingPrice: 24 / hoursInAMonth, // per hour
PricePerRU: 0.00008,
PricePerGB: 0.25 / hoursInAMonth
}
},
mooncake: {
Currency: "RMB",
CurrencySign: "¥",
S1Price: 0.15,
S2Price: 0.3,
S3Price: 0.6,
Standard: {
StartingPrice: OfferPricing.MonthlyPricing.mooncake.Standard.StartingPrice / hoursInAMonth, // per hour
PricePerRU: 0.00051,
PricePerGB: OfferPricing.MonthlyPricing.mooncake.Standard.PricePerGB / hoursInAMonth
}
}
};
}
export class CollectionCreation {
// TODO generate these values based on Product\Services\Documents\ImageStore\GatewayApplication\Settings.xml
public static readonly MinRUPerPartitionBelow7Partitions: number = 400;
public static readonly MinRU7PartitionsTo25Partitions: number = 2500;
public static readonly MinRUPerPartitionAbove25Partitions: number = 100;
public static readonly MaxRUPerPartition: number = 10000;
public static readonly MinPartitionedCollectionRUs: number = 2500;
public static readonly NumberOfPartitionsInFixedCollection: number = 1;
public static readonly NumberOfPartitionsInUnlimitedCollection: number = 10;
public static storage10Gb: string = "10";
public static storage100Gb: string = "100";
public static readonly DefaultCollectionRUs1000: number = 1000;
public static readonly DefaultCollectionRUs10K: number = 10000;
public static readonly DefaultCollectionRUs400: number = 400;
public static readonly DefaultCollectionRUs2000: number = 2000;
public static readonly DefaultCollectionRUs2500: number = 2500;
public static readonly DefaultCollectionRUs5000: number = 5000;
public static readonly DefaultCollectionRUs15000: number = 15000;
public static readonly DefaultCollectionRUs20000: number = 20000;
public static readonly DefaultCollectionRUs25000: number = 25000;
public static readonly DefaultCollectionRUs100K: number = 100000;
public static readonly DefaultCollectionRUs1Million: number = 1000000;
public static readonly DefaultAddCollectionDefaultFlight: string = "0";
public static readonly DefaultSubscriptionType: SubscriptionType = SubscriptionType.Free;
public static readonly TablesAPIDefaultDatabase: string = "TablesDB";
}
export const CollectionCreationDefaults = {
storage: CollectionCreation.storage100Gb,
throughput: {
fixed: CollectionCreation.DefaultCollectionRUs400,
unlimited: CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: CollectionCreation.DefaultCollectionRUs400,
shared: CollectionCreation.DefaultCollectionRUs400
}
} as const;
export class IndexingPolicies {
public static SharedDatabaseDefault = {
indexingMode: "consistent",
automatic: true,
includedPaths: <any>[],
excludedPaths: [
{
path: "/*"
}
]
};
public static AllPropertiesIndexed = {
indexingMode: "consistent",
automatic: true,
includedPaths: [
{
path: "/*",
indexes: [
{
kind: "Range",
dataType: "Number",
precision: -1
},
{
kind: "Range",
dataType: "String",
precision: -1
}
]
}
],
excludedPaths: <any>[]
};
}
export class SubscriptionUtilMappings {
public static FreeTierSubscriptionIds: string[] = [
"b8f2ff04-0a81-4cf9-95ef-5828d16981d2",
"39b1fdff-e5b2-4f83-adb4-33cb3aabf5ea",
"41f6d14d-ece1-46e4-942c-02c00d67f7d6",
"11dc62e3-77dc-4ef5-a46b-480ec6caa8fe",
"199d0919-60bd-448e-b64d-8461a0fe9747",
"a57b6849-d443-44cf-a3b7-7dd07ead9401"
];
}
export class AutopilotDocumentation {
public static Url: string = "https://aka.ms/cosmos-autoscale-info";
}
import { SubscriptionType } from "../Contracts/SubscriptionType";
export const hoursInAMonth = 730;
export class AutoscalePricing {
public static MonthlyPricing = {
default: {
singleMaster: {
Currency: "USD",
CurrencySign: "$",
Standard: {
StartingPrice: 24,
PricePerRU: 0.09,
PricePerGB: 0.25,
},
},
multiMaster: {
Currency: "USD",
CurrencySign: "$",
Standard: {
StartingPrice: 24,
PricePerRU: 0.12,
PricePerGB: 0.25,
},
},
},
mooncake: {
singleMaster: {
Currency: "RMB",
CurrencySign: "¥",
Standard: {
StartingPrice: 152,
PricePerRU: 0.57,
PricePerGB: 2.576,
},
},
multiMaster: {
Currency: "RMB",
CurrencySign: "¥",
Standard: {
StartingPrice: 152,
PricePerRU: 0.76,
PricePerGB: 2.576,
},
},
},
};
public static HourlyPricing = {
default: {
singleMaster: {
Currency: "USD",
CurrencySign: "$",
Standard: {
StartingPrice: 24 / hoursInAMonth,
PricePerRU: 0.00012,
PricePerGB: 0.25 / hoursInAMonth,
},
},
multiMaster: {
Currency: "USD",
CurrencySign: "$",
Standard: {
StartingPrice: 24 / hoursInAMonth,
PricePerRU: 0.00016,
PricePerGB: 0.25 / hoursInAMonth,
},
},
},
mooncake: {
singleMaster: {
Currency: "RMB",
CurrencySign: "¥",
Standard: {
StartingPrice: AutoscalePricing.MonthlyPricing.mooncake.singleMaster.Standard.StartingPrice / hoursInAMonth, // per hour
PricePerRU: 0.000765,
PricePerGB: AutoscalePricing.MonthlyPricing.mooncake.singleMaster.Standard.PricePerGB / hoursInAMonth,
},
},
multiMaster: {
Currency: "RMB",
CurrencySign: "¥",
Standard: {
StartingPrice: AutoscalePricing.MonthlyPricing.mooncake.multiMaster.Standard.StartingPrice / hoursInAMonth, // per hour
PricePerRU: 0.00102,
PricePerGB: AutoscalePricing.MonthlyPricing.mooncake.multiMaster.Standard.PricePerGB / hoursInAMonth,
},
},
},
};
}
export class OfferPricing {
public static MonthlyPricing = {
default: {
Currency: "USD",
CurrencySign: "$",
S1Price: 25,
S2Price: 50,
S3Price: 100,
Standard: {
StartingPrice: 24,
PricePerRU: 0.06,
PricePerGB: 0.25,
},
},
mooncake: {
Currency: "RMB",
CurrencySign: "¥",
S1Price: 110.3,
S2Price: 220.6,
S3Price: 441.2,
Standard: {
StartingPrice: 152,
PricePerRU: 0.3794,
PricePerGB: 2.576,
},
},
};
public static HourlyPricing = {
default: {
Currency: "USD",
CurrencySign: "$",
S1Price: 0.0336,
S2Price: 0.0672,
S3Price: 0.1344,
Standard: {
StartingPrice: 24 / hoursInAMonth, // per hour
PricePerRU: 0.00008,
PricePerGB: 0.25 / hoursInAMonth,
},
},
mooncake: {
Currency: "RMB",
CurrencySign: "¥",
S1Price: 0.15,
S2Price: 0.3,
S3Price: 0.6,
Standard: {
StartingPrice: OfferPricing.MonthlyPricing.mooncake.Standard.StartingPrice / hoursInAMonth, // per hour
PricePerRU: 0.00051,
PricePerGB: OfferPricing.MonthlyPricing.mooncake.Standard.PricePerGB / hoursInAMonth,
},
},
};
}
export class CollectionCreation {
// TODO generate these values based on Product\Services\Documents\ImageStore\GatewayApplication\Settings.xml
public static readonly MinRUPerPartitionBelow7Partitions: number = 400;
public static readonly MinRU7PartitionsTo25Partitions: number = 2500;
public static readonly MinRUPerPartitionAbove25Partitions: number = 100;
public static readonly MaxRUPerPartition: number = 10000;
public static readonly MinPartitionedCollectionRUs: number = 2500;
public static readonly NumberOfPartitionsInFixedCollection: number = 1;
public static readonly NumberOfPartitionsInUnlimitedCollection: number = 10;
public static storage10Gb: string = "10";
public static storage100Gb: string = "100";
public static readonly DefaultCollectionRUs1000: number = 1000;
public static readonly DefaultCollectionRUs10K: number = 10000;
public static readonly DefaultCollectionRUs400: number = 400;
public static readonly DefaultCollectionRUs2000: number = 2000;
public static readonly DefaultCollectionRUs2500: number = 2500;
public static readonly DefaultCollectionRUs5000: number = 5000;
public static readonly DefaultCollectionRUs15000: number = 15000;
public static readonly DefaultCollectionRUs20000: number = 20000;
public static readonly DefaultCollectionRUs25000: number = 25000;
public static readonly DefaultCollectionRUs100K: number = 100000;
public static readonly DefaultCollectionRUs1Million: number = 1000000;
public static readonly DefaultAddCollectionDefaultFlight: string = "0";
public static readonly DefaultSubscriptionType: SubscriptionType = SubscriptionType.Free;
public static readonly TablesAPIDefaultDatabase: string = "TablesDB";
}
export const CollectionCreationDefaults = {
storage: CollectionCreation.storage100Gb,
throughput: {
fixed: CollectionCreation.DefaultCollectionRUs400,
unlimited: CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: CollectionCreation.DefaultCollectionRUs400,
shared: CollectionCreation.DefaultCollectionRUs400,
},
} as const;
export class IndexingPolicies {
public static SharedDatabaseDefault = {
indexingMode: "consistent",
automatic: true,
includedPaths: <any>[],
excludedPaths: [
{
path: "/*",
},
],
};
public static AllPropertiesIndexed = {
indexingMode: "consistent",
automatic: true,
includedPaths: [
{
path: "/*",
indexes: [
{
kind: "Range",
dataType: "Number",
precision: -1,
},
{
kind: "Range",
dataType: "String",
precision: -1,
},
],
},
],
excludedPaths: <any>[],
};
}
export class SubscriptionUtilMappings {
public static FreeTierSubscriptionIds: string[] = [
"b8f2ff04-0a81-4cf9-95ef-5828d16981d2",
"39b1fdff-e5b2-4f83-adb4-33cb3aabf5ea",
"41f6d14d-ece1-46e4-942c-02c00d67f7d6",
"11dc62e3-77dc-4ef5-a46b-480ec6caa8fe",
"199d0919-60bd-448e-b64d-8461a0fe9747",
"a57b6849-d443-44cf-a3b7-7dd07ead9401",
];
}
export class AutopilotDocumentation {
public static Url: string = "https://aka.ms/cosmos-autoscale-info";
}

View File

@@ -83,7 +83,7 @@ describe("Default Experience Utility", () => {
location: "somewhere",
type: "DocumentDB",
tags: {
defaultExperience: "Gremlin (graph)"
defaultExperience: "Gremlin (graph)",
},
properties: {
documentEndpoint: "",
@@ -93,10 +93,10 @@ describe("Default Experience Utility", () => {
capabilities: [
{
name: Constants.CapabilityNames.EnableGremlin,
description: "something"
}
]
}
description: "something",
},
],
},
};
const databaseAccountWithApiKind: DataModels.DatabaseAccount = {
@@ -114,10 +114,10 @@ describe("Default Experience Utility", () => {
capabilities: [
{
name: Constants.CapabilityNames.EnableGremlin,
description: "something"
}
]
}
description: "something",
},
],
},
};
describe("Disregard tags", () => {

View File

@@ -145,7 +145,7 @@ export class DefaultExperienceUtility {
}
private static _findCapability(capabilities: DataModels.Capability[], capabilityName: string): DataModels.Capability {
return _.find(capabilities, capability => {
return _.find(capabilities, (capability) => {
return capability && capability.name && capability.name.toLowerCase() === capabilityName.toLowerCase();
});
}

View File

@@ -1,43 +1,43 @@
import * as Constants from "./Constants";
export function computeRUUsagePrice(serverId: string, requestUnits: number): string {
if (serverId === "mooncake") {
let ruCharge = requestUnits * Constants.OfferPricing.HourlyPricing.mooncake.Standard.PricePerRU;
return calculateEstimateNumber(ruCharge) + " " + Constants.OfferPricing.HourlyPricing.mooncake.Currency;
}
let ruCharge = requestUnits * Constants.OfferPricing.HourlyPricing.default.Standard.PricePerRU;
return calculateEstimateNumber(ruCharge) + " " + Constants.OfferPricing.HourlyPricing.default.Currency;
}
export function computeStorageUsagePrice(serverId: string, storageUsedRoundUpToGB: number): string {
if (serverId === "mooncake") {
let storageCharge = storageUsedRoundUpToGB * Constants.OfferPricing.HourlyPricing.mooncake.Standard.PricePerGB;
return calculateEstimateNumber(storageCharge) + " " + Constants.OfferPricing.HourlyPricing.mooncake.Currency;
}
let storageCharge = storageUsedRoundUpToGB * Constants.OfferPricing.HourlyPricing.default.Standard.PricePerGB;
return calculateEstimateNumber(storageCharge) + " " + Constants.OfferPricing.HourlyPricing.default.Currency;
}
export function computeDisplayUsageString(usageInKB: number): string {
let usageInMB = usageInKB / 1024,
usageInGB = usageInMB / 1024,
displayUsageString =
usageInGB > 0.1
? usageInGB.toFixed(2) + " GB"
: usageInMB > 0.1
? usageInMB.toFixed(2) + " MB"
: usageInKB.toFixed(2) + " KB";
return displayUsageString;
}
export function usageInGB(usageInKB: number): number {
let usageInMB = usageInKB / 1024,
usageInGB = usageInMB / 1024;
return Math.ceil(usageInGB);
}
function calculateEstimateNumber(n: number): string {
return n >= 1 ? n.toFixed(2) : n.toPrecision(2);
}
import * as Constants from "./Constants";
export function computeRUUsagePrice(serverId: string, requestUnits: number): string {
if (serverId === "mooncake") {
let ruCharge = requestUnits * Constants.OfferPricing.HourlyPricing.mooncake.Standard.PricePerRU;
return calculateEstimateNumber(ruCharge) + " " + Constants.OfferPricing.HourlyPricing.mooncake.Currency;
}
let ruCharge = requestUnits * Constants.OfferPricing.HourlyPricing.default.Standard.PricePerRU;
return calculateEstimateNumber(ruCharge) + " " + Constants.OfferPricing.HourlyPricing.default.Currency;
}
export function computeStorageUsagePrice(serverId: string, storageUsedRoundUpToGB: number): string {
if (serverId === "mooncake") {
let storageCharge = storageUsedRoundUpToGB * Constants.OfferPricing.HourlyPricing.mooncake.Standard.PricePerGB;
return calculateEstimateNumber(storageCharge) + " " + Constants.OfferPricing.HourlyPricing.mooncake.Currency;
}
let storageCharge = storageUsedRoundUpToGB * Constants.OfferPricing.HourlyPricing.default.Standard.PricePerGB;
return calculateEstimateNumber(storageCharge) + " " + Constants.OfferPricing.HourlyPricing.default.Currency;
}
export function computeDisplayUsageString(usageInKB: number): string {
let usageInMB = usageInKB / 1024,
usageInGB = usageInMB / 1024,
displayUsageString =
usageInGB > 0.1
? usageInGB.toFixed(2) + " GB"
: usageInMB > 0.1
? usageInMB.toFixed(2) + " MB"
: usageInKB.toFixed(2) + " KB";
return displayUsageString;
}
export function usageInGB(usageInKB: number): number {
let usageInMB = usageInKB / 1024,
usageInGB = usageInMB / 1024;
return Math.ceil(usageInGB);
}
function calculateEstimateNumber(n: number): string {
return n >= 1 ? n.toFixed(2) : n.toPrecision(2);
}

View File

@@ -79,5 +79,5 @@ export enum StorageKey {
TenantId,
MostRecentActivity,
SetPartitionKeyUndefined,
GalleryCalloutDismissed
GalleryCalloutDismissed,
}

View File

@@ -1,136 +1,136 @@
// Data Explorer specific actions. No need to keep this in sync with the one in Portal.
export enum Action {
CollapseTreeNode,
CreateCollection,
CreateDocument,
CreateStoredProcedure,
CreateTrigger,
CreateUDF,
DeleteCollection,
DeleteDatabase,
DeleteDocument,
ExpandTreeNode,
ExecuteQuery,
HasFeature,
GetVNETServices,
InitializeAccountLocationFromResourceGroup,
InitializeDataExplorer,
LoadDatabaseAccount,
LoadCollections,
LoadDatabases,
LoadOffers,
MongoShell,
ContextualPane,
ScaleThroughput,
ToggleAutoscaleSetting,
SelectItem,
Tab,
UpdateDocument,
UpdateSettings,
UpdateStoredProcedure,
UpdateTrigger,
UpdateUDF,
LoadResourceTree,
CreateDatabase,
ResolveConflict,
DeleteConflict,
SaveQuery,
SetupSavedQueries,
LoadSavedQuery,
DeleteSavedQuery,
ConnectEncryptionToken,
SignInAad,
SignOutAad,
FetchTenants,
FetchSubscriptions,
FetchAccounts,
GetAccountKeys,
LoadingStatus,
AccountSwitch,
SubscriptionSwitch,
TenantSwitch,
DefaultTenantSwitch,
ResetNotebookWorkspace,
CreateNotebookWorkspace,
NotebookErrorNotification,
CreateSparkCluster,
UpdateSparkCluster,
DeleteSparkCluster,
LibraryManage,
ClusterLibraryManage,
ModifyOptionForThroughputWithSharedDatabase,
EnableAzureSynapseLink,
CreateNewNotebook,
OpenSampleNotebook,
ExecuteCell,
ExecuteCellPromptBtn,
ExecuteAllCells,
NotebookEnabled,
NotebooksGitHubConnect,
NotebooksGitHubAuthorize,
NotebooksGitHubManualRepoAdd,
NotebooksGitHubManageRepo,
NotebooksGitHubCommit,
NotebooksGitHubDisconnect,
NotebooksFetched,
NotebooksKernelSpecName,
NotebooksExecuteCellFromMenu,
NotebooksClearOutputsFromMenu,
NotebooksInsertCodeCellAboveFromMenu,
NotebooksInsertCodeCellBelowFromMenu,
NotebooksInsertTextCellAboveFromMenu,
NotebooksInsertTextCellBelowFromMenu,
NotebooksMoveCellUpFromMenu,
NotebooksMoveCellDownFromMenu,
DeleteCellFromMenu,
OpenTerminal,
CreateMongoCollectionWithWildcardIndex,
ClickCommandBarButton,
RefreshResourceTreeMyNotebooks,
ClickResourceTreeNodeContextMenuItem,
DiscardSettings,
SettingsV2Updated,
SettingsV2Discarded,
MongoIndexUpdated
}
export const ActionModifiers = {
Start: "start",
Success: "success",
Failed: "failed",
Mark: "mark",
Open: "open",
IFrameReady: "iframeready",
Close: "close",
Submit: "submit",
IndexAll: "index all properties",
NoIndex: "no indexing",
Cancel: "cancel",
ToggleAutoscaleOn: "autoscale on",
ToggleAutoscaleOff: "autoscale off"
} as const;
export enum SourceBlade {
AddCollection,
AzureFunction,
BrowseCollectionBlade,
CassandraAccountCreateBlade,
CollectionSetting,
DatabaseAccountCreateBlade,
DataExplorer,
DeleteCollection,
DeleteDatabase,
DocumentExplorer,
FirewallVNETBlade,
Metrics,
NonDocumentDBAccountCreateBlade,
OverviewBlade,
QueryExplorer,
Quickstart,
ReaderWarning,
ResourceMenu,
RpcProvider,
ScaleCollection,
ScriptExplorer,
Keys
}
// Data Explorer specific actions. No need to keep this in sync with the one in Portal.
export enum Action {
CollapseTreeNode,
CreateCollection,
CreateDocument,
CreateStoredProcedure,
CreateTrigger,
CreateUDF,
DeleteCollection,
DeleteDatabase,
DeleteDocument,
ExpandTreeNode,
ExecuteQuery,
HasFeature,
GetVNETServices,
InitializeAccountLocationFromResourceGroup,
InitializeDataExplorer,
LoadDatabaseAccount,
LoadCollections,
LoadDatabases,
LoadOffers,
MongoShell,
ContextualPane,
ScaleThroughput,
ToggleAutoscaleSetting,
SelectItem,
Tab,
UpdateDocument,
UpdateSettings,
UpdateStoredProcedure,
UpdateTrigger,
UpdateUDF,
LoadResourceTree,
CreateDatabase,
ResolveConflict,
DeleteConflict,
SaveQuery,
SetupSavedQueries,
LoadSavedQuery,
DeleteSavedQuery,
ConnectEncryptionToken,
SignInAad,
SignOutAad,
FetchTenants,
FetchSubscriptions,
FetchAccounts,
GetAccountKeys,
LoadingStatus,
AccountSwitch,
SubscriptionSwitch,
TenantSwitch,
DefaultTenantSwitch,
ResetNotebookWorkspace,
CreateNotebookWorkspace,
NotebookErrorNotification,
CreateSparkCluster,
UpdateSparkCluster,
DeleteSparkCluster,
LibraryManage,
ClusterLibraryManage,
ModifyOptionForThroughputWithSharedDatabase,
EnableAzureSynapseLink,
CreateNewNotebook,
OpenSampleNotebook,
ExecuteCell,
ExecuteCellPromptBtn,
ExecuteAllCells,
NotebookEnabled,
NotebooksGitHubConnect,
NotebooksGitHubAuthorize,
NotebooksGitHubManualRepoAdd,
NotebooksGitHubManageRepo,
NotebooksGitHubCommit,
NotebooksGitHubDisconnect,
NotebooksFetched,
NotebooksKernelSpecName,
NotebooksExecuteCellFromMenu,
NotebooksClearOutputsFromMenu,
NotebooksInsertCodeCellAboveFromMenu,
NotebooksInsertCodeCellBelowFromMenu,
NotebooksInsertTextCellAboveFromMenu,
NotebooksInsertTextCellBelowFromMenu,
NotebooksMoveCellUpFromMenu,
NotebooksMoveCellDownFromMenu,
DeleteCellFromMenu,
OpenTerminal,
CreateMongoCollectionWithWildcardIndex,
ClickCommandBarButton,
RefreshResourceTreeMyNotebooks,
ClickResourceTreeNodeContextMenuItem,
DiscardSettings,
SettingsV2Updated,
SettingsV2Discarded,
MongoIndexUpdated,
}
export const ActionModifiers = {
Start: "start",
Success: "success",
Failed: "failed",
Mark: "mark",
Open: "open",
IFrameReady: "iframeready",
Close: "close",
Submit: "submit",
IndexAll: "index all properties",
NoIndex: "no indexing",
Cancel: "cancel",
ToggleAutoscaleOn: "autoscale on",
ToggleAutoscaleOff: "autoscale off",
} as const;
export enum SourceBlade {
AddCollection,
AzureFunction,
BrowseCollectionBlade,
CassandraAccountCreateBlade,
CollectionSetting,
DatabaseAccountCreateBlade,
DataExplorer,
DeleteCollection,
DeleteDatabase,
DocumentExplorer,
FirewallVNETBlade,
Metrics,
NonDocumentDBAccountCreateBlade,
OverviewBlade,
QueryExplorer,
Quickstart,
ReaderWarning,
ResourceMenu,
RpcProvider,
ScaleCollection,
ScriptExplorer,
Keys,
}

View File

@@ -18,8 +18,8 @@ export function trace(action: Action, actionModifier: string = ActionModifiers.M
data: {
action: Action[action],
actionModifier: actionModifier,
data: JSON.stringify(data)
}
data: JSON.stringify(data),
},
});
appInsights.trackEvent({ name: Action[action] }, getData(actionModifier, data));
@@ -33,8 +33,8 @@ export function traceStart(action: Action, data?: TelemetryData): number {
action: Action[action],
actionModifier: ActionModifiers.Start,
timestamp: timestamp,
data: JSON.stringify(data)
}
data: JSON.stringify(data),
},
});
appInsights.startTrackEvent(Action[action]);
@@ -48,8 +48,8 @@ export function traceSuccess(action: Action, data?: TelemetryData, timestamp?: n
action: Action[action],
actionModifier: ActionModifiers.Success,
timestamp: timestamp || Date.now(),
data: JSON.stringify(data)
}
data: JSON.stringify(data),
},
});
appInsights.stopTrackEvent(Action[action], getData(ActionModifiers.Success, data));
@@ -62,8 +62,8 @@ export function traceFailure(action: Action, data?: TelemetryData, timestamp?: n
action: Action[action],
actionModifier: ActionModifiers.Failed,
timestamp: timestamp || Date.now(),
data: JSON.stringify(data)
}
data: JSON.stringify(data),
},
});
appInsights.stopTrackEvent(Action[action], getData(ActionModifiers.Failed, data));
@@ -76,8 +76,8 @@ export function traceCancel(action: Action, data?: TelemetryData, timestamp?: nu
action: Action[action],
actionModifier: ActionModifiers.Cancel,
timestamp: timestamp || Date.now(),
data: JSON.stringify(data)
}
data: JSON.stringify(data),
},
});
appInsights.stopTrackEvent(Action[action], getData(ActionModifiers.Cancel, data));
@@ -91,8 +91,8 @@ export function traceOpen(action: Action, data?: TelemetryData, timestamp?: numb
action: Action[action],
actionModifier: ActionModifiers.Open,
timestamp: validTimestamp,
data: JSON.stringify(data)
}
data: JSON.stringify(data),
},
});
appInsights.startTrackEvent(Action[action]);
@@ -107,8 +107,8 @@ export function traceMark(action: Action, data?: TelemetryData, timestamp?: numb
action: Action[action],
actionModifier: ActionModifiers.Mark,
timestamp: validTimestamp,
data: JSON.stringify(data)
}
data: JSON.stringify(data),
},
});
appInsights.startTrackEvent(Action[action]);
@@ -125,6 +125,6 @@ function getData(actionModifier: string, data: TelemetryData = {}): { [key: stri
platform: configContext.platform,
env: process.env.NODE_ENV as string,
actionModifier,
...data
...data,
};
}

View File

@@ -4,8 +4,8 @@ const appInsights = new ApplicationInsights({
config: {
instrumentationKey: "fa645d97-6237-4656-9559-0ee0cb55ee49",
disableFetchTracking: false,
disableCorrelationHeaders: true
}
disableCorrelationHeaders: true,
},
});
appInsights.loadAppInsights();
appInsights.trackPageView(); // Manually call trackPageView to establish the current user/session/pageview