Skip to content

Commit

Permalink
Merge branch 'main' into users/nityagi/GeoExpansionSupport
Browse files Browse the repository at this point in the history
  • Loading branch information
tyaginidhi authored Jan 17, 2024
2 parents 43e68fb + ebd090a commit 287872a
Show file tree
Hide file tree
Showing 8 changed files with 312 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/PullRequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ jobs:
- name: Run integration tests
uses: coactions/setup-xvfb@v1
with:
run: npm run test-integration
run: |
npm run test-integration
npm run test-web-integration
49 changes: 49 additions & 0 deletions src/common/OneDSLoggerTelemetry/EventContants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

export enum SeverityLevel {
Low = 'Low',
Medium = 'Medium',
High = 'High',
Critical = 'Critical',
}

export enum CustomEventModifier {
Complete = 'Complete',
Failure = 'Failure',
Progress = 'Progress',
Start = 'Start',
}

export enum EventType {
Info = 'Information',
Warning = 'Warning',
Error = 'Error',
}

export enum CustomEventSubType {
Load = 'Load',
Create = 'Create',
Update = 'Update',
Delete = 'Delete',
}

export enum CustomType {
/**
* Defines a user action to track.
*/
Action = 'Action',

/**
* Defines a custom event to track.
*/
Custom = 'Custom',

/**
* Defines a scenario to track, that has a start, an end and duration.
*/
Scenario = 'Scenario',

}
37 changes: 37 additions & 0 deletions src/common/OneDSLoggerTelemetry/IEventTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import {CustomEventModifier, CustomEventSubType, CustomType, EventType, SeverityLevel} from './EventContants';
import {IWebExtensionTelemetryData} from '../../web/client/telemetry/webExtensionTelemetryInterface';
import {IProDevCopilotTelemetryData} from '../copilot/telemetry/ITelemetry';

export interface IUserInfo {
oid: string;
tid: string;
}

export interface IEvent {
eventName: string;
eventType: EventType | string;
eventMessage?: object;
customDimension?: IWebExtensionTelemetryData| IProDevCopilotTelemetryData| object; // TODO: Use IPortalTelemetryData
customMeasurements?: IWebExtensionTelemetryData| object; // TODO: Use IPortalTelemetryData
eventSeverity?: SeverityLevel;
correlationId?: string;
}

export interface ICustomEvent {
customEventType: CustomType;
customEventId?: string;
customEventSubType? : CustomEventSubType;
customEventModifier? : CustomEventModifier;
}
export interface IException {
exceptionName?: string;
exceptionStack?: string;
exceptionSource?: string;
exceptionCauseCode?: string | number;
exceptionDetails?: string;
}
54 changes: 49 additions & 5 deletions src/common/OneDSLoggerTelemetry/oneDSLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ import { PostChannel, type IChannelConfiguration, type IXHROverride } from "@mic
import { ITelemetryLogger } from "./ITelemetryLogger";
import { EventType } from "./telemetryConstants";

interface IInstrumentationSettings {
endpointURL: string;
instrumentationKey: string;
}

export class OneDSLogger implements ITelemetryLogger{

private readonly appInsightsCore = new AppInsightsCore();
private readonly postChannel: PostChannel = new PostChannel();



private readonly fetchHttpXHROverride: IXHROverride = {
sendPOST: (payload, oncomplete) => {
const telemetryRequestData =
Expand Down Expand Up @@ -58,25 +63,26 @@ export class OneDSLogger implements ITelemetryLogger{
},
};

public constructor() {
public constructor(geo?:string ) {

const channelConfig: IChannelConfiguration = {
alwaysUseXhrOverride: true,
httpXHROverride: this.fetchHttpXHROverride,
};

const instrumentationKey = '';

const instrumentationSetting : IInstrumentationSettings= OneDSLogger.getInstrumentationSettings(geo); // Need to replace with actual data
// Configure App insights core to send to collector
const coreConfig: IExtendedConfiguration = {
instrumentationKey,
instrumentationKey: instrumentationSetting.instrumentationKey,
loggingLevelConsole: 0, // Do not log to console
disableDbgExt: true, // Small perf optimization
extensions: [
// Passing no channels here when the user opts out of telemetry would be ideal, completely ensuring telemetry
// could not be sent out at all.
this.postChannel,
],
endpointUrl: instrumentationSetting.endpointURL,
extensionConfig: {
[this.postChannel.identifier]: channelConfig,
},
Expand All @@ -87,6 +93,44 @@ export class OneDSLogger implements ITelemetryLogger{
}
}

private static getInstrumentationSettings(geo?:string): IInstrumentationSettings {
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
const region:string = "test"; // TODO: Remove it from here and replace it with value getting from build. Check gulp.mjs (setTelemetryTarget)
const instrumentationSettings:IInstrumentationSettings = {
endpointURL: 'https://self.pipe.aria.int.microsoft.com/OneCollector/1.0/',
instrumentationKey: 'bd47fc8d971f4283a6686ec46fd48782-bdef6c1c-75ab-417c-a1f7-8bbe21e12da6-7708'
};
switch (region) {
case 'tie':
case 'test':
case 'preprod':
break;
case 'prod':
case 'preview':
switch (geo) {
case 'eu':
instrumentationSettings.endpointURL = '' //prod endpoint;
instrumentationSettings.instrumentationKey = '' //prod key;
break;
default:
instrumentationSettings.endpointURL = '' //prod endpoint;
instrumentationSettings.instrumentationKey = '' //prod key;
}
break;
case 'gov':
case 'high':
case 'dod':
case 'mooncake':
instrumentationSettings.endpointURL = '' //prod endpoint;
instrumentationSettings.instrumentationKey = '' //prod key;
break;
case 'ex':
case 'rx':
default:
break;
}
return instrumentationSettings;
}

/// Trace info log
public traceInfo(eventName:string, customDimension?:Record<string, string>, customMeasurement?: Record<string, number>, message?:string) {
Expand Down
59 changes: 59 additions & 0 deletions src/common/OneDSLoggerTelemetry/oneDSLoggerWrapper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { OneDSLogger } from "./oneDSLogger";

//// Wrapper class of oneDSLogger for below purposes
//// 1. Abstracting code from manual trace log APIs.
//// 2. Constrolling instantiation of 1ds SDK framework code in oneDSLogger.ts

export class oneDSLoggerWrapper {
private static instance: oneDSLoggerWrapper;
private static oneDSLoggerIntance : OneDSLogger;

private constructor(geo?: string) {
oneDSLoggerWrapper.oneDSLoggerIntance = new OneDSLogger(geo);
}


static getLogger(){
return this.instance;
}

static instantiate(geo?:string){
if(!oneDSLoggerWrapper.instance) {
oneDSLoggerWrapper.instance = new oneDSLoggerWrapper(geo);
}
return this.instance;
}

/// Trace info log
public traceInfo(eventName:string, customDimension?:Record<string, string>, customMeasurement?: Record<string, number>, message?:string) {
try{
oneDSLoggerWrapper.oneDSLoggerIntance.traceInfo(eventName, customDimension, customMeasurement, message);
}catch (exception) {
console.warn(exception);
}
}

/// Trace warning log
public traceWarning(eventName:string, customDimension?:Record<string, string>, customMeasurement?: Record<string, number>, message?:string) {
try{
oneDSLoggerWrapper.oneDSLoggerIntance.traceWarning(eventName, customDimension, customMeasurement, message);
}catch (exception) {
console.warn(exception);
}
}

/// Trace exception log
public traceError(eventName:string, customDimension?:Record<string, string>, customMeasurement?: Record<string, number>, message?:string) {
try{
oneDSLoggerWrapper.oneDSLoggerIntance.traceError(eventName, customDimension, customMeasurement, message);
}catch (exception) {
console.warn(exception);
}
}

}
14 changes: 12 additions & 2 deletions src/common/copilot/assets/walkthrough/Copilot-In-PowerPages.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ![Copilot Screen](./images/M365.svg) Copilot in Power Pages

Copilot in Visual Studio Code helps you code using natural language chat interaction. In Power Pages, you work with site code that includes HTML, JS, or CSS code to make site customizations that are not currently supported in Power Pages low-code design studio. This Copilot chat experience assists Power Pages developers like you to write code by simply describing your expected code behavior using natural language. You can then refine the generated code and use it when customizing your site.
Copilot in Visual Studio Code helps you code using natural language chat interaction. In Power Pages, you work with site code that includes HTML, JS, or CSS code to make site customizations that are not currently supported in Power Pages low-code design studio. This Copilot chat experience assists Power Pages developers like you to write code by simply describing your expected code behavior using natural language. You can also delve deeper into existing code and learn what it means by using the Explain feature. You can then refine the generated code and use it when customizing your site.

![Copilot Screen](./images/copilotimage.svg)

Expand All @@ -20,7 +20,7 @@ Review the [terms](https://go.microsoft.com/fwlink/?linkid=2189520) and [Respons
Copilot in Visual Studio Code is tuned to generate code for Power Pages sites, so its functionalities are limited to Power Pages site supported languages like HTML, JS, and CSS. The generated code from Copilot makes use of supported frameworks like bootstrap and jQuery.

1. In the Copilot chat, describe the code behavior you want using natural language. For example, code for form validation or Ajax calls using the Power Pages Web API.
1. Continue to repharse your questions in the Copilot chat and iterate them till you’ve got what you need.
1. Continue to rephrase your questions in the Copilot chat and iterate them till you’ve got what you need.
1. Once you are happy with the generated code, you can easily copy and paste the code snippet or insert the code to Power Pages site and modify the code further.
1. Use the **up/down** arrow key to navigate between recently entered prompts.

Expand All @@ -38,6 +38,16 @@ Note

To know more, see [Copilot in Power Pages documentation](https://go.microsoft.com/fwlink/?linkid=2206366).

## How to use Explain in Copilot to understand code

Copilot's Explain feature is useful for developers who are working on existing code and want to understand it. To use Explain, follow these steps:

Select the lines of code you want to understand from the code editor, right-click to access the in-context menu and then select **Copilot in Power Pages > Explain**. Copilot will record the selected lines of code in the chat panel and provide a response explaining the code to you.

Alternatively, select the lines of code and type ```Explain selected code``` in the Copilot chat panel. You can also directly ask Copilot by adding the code in the prompt. For example, you can ask ```Explain the following code {% include 'Page Copy'%}```.

![Explain Screen](./images/explain.svg)

## Help us in improving this feature

In every response of the Copilot chat, click the feedback options, 👍if you like the response or 👎if you didn’t like it. Your feedback will greatly help improve the capabilities of this feature.
Expand Down
Loading

0 comments on commit 287872a

Please sign in to comment.