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

send eligibility data to host to log telemetry #2650

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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 apps/teams-test-app/src/components/AppAPIs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const GetContext = (): ReactElement =>
onClick: {
withPromise: async () => {
const context = await app.getContext();
console.log('This is the context: ' + context);
return JSON.stringify(context);
},
withCallback: (setResult) => {
Expand Down
13 changes: 12 additions & 1 deletion packages/teams-js/src/internal/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FrameContexts } from '../public/constants';
import { HostToAppPerformanceMetrics, LoadContext, ResumeContext } from '../public/interfaces';
import * as pages from '../public/pages/pages';
import { runtime } from '../public/runtime';
import { Communication, sendMessageEventToChild, sendMessageToParent } from './communication';
import { callFunctionInHost, Communication, sendMessageEventToChild, sendMessageToParent } from './communication';
import { ensureInitialized } from './internalAPIs';
import { getLogger } from './telemetry';
import { isNullOrUndefined } from './typeCheckUtilities';
Expand Down Expand Up @@ -198,9 +198,20 @@ export function registerHostToAppPerformanceMetricsHandler(
* Limited to Microsoft-internal use
*/
export function handleHostToAppPerformanceMetrics(metrics: HostToAppPerformanceMetrics): void {
console.log('NOW IT WILL CHEKCK WHETHER THE HANDLER IS REGISTERED OR NOT');
// post the metrics to the parent window without using async/await. That will make sure the metric is posted asynchronously,
// and does not stop the response to go to the calling app.
// IF we don't want to post back everything, we can add a check here to see if the API name is copilot.eligibility
callFunctionInHost(
'reportTelemetryEvent',
[metrics.actionName, metrics.messageDelay, metrics.requestStartedAt],
'v3_reportTelemetryEvent',
);
if (!HandlersPrivate.hostToAppPerformanceMetricsHandler) {
console.log('not registered');
return;
}
console.log('registered');
HandlersPrivate.hostToAppPerformanceMetricsHandler(metrics);
}

Expand Down
3 changes: 3 additions & 0 deletions packages/teams-js/src/internal/hostToAppTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ export default class HostToAppMessageDelayTelemetry {
);
return;
}
console.log('callbackInformation', callbackInformation);
console.log('message', message);
//the api call should always reach here regardless the handler is registered or not
handleHostToAppPerformanceMetrics({
actionName: callbackInformation.name,
messageDelay: endTime - message.monotonicTimestamp,
Expand Down
Loading