diff --git a/change/@microsoft-teams-js-a4e76c3e-7ab3-4dd4-9a24-c0c909040b64.json b/change/@microsoft-teams-js-a4e76c3e-7ab3-4dd4-9a24-c0c909040b64.json new file mode 100644 index 0000000000..1f8dc7023e --- /dev/null +++ b/change/@microsoft-teams-js-a4e76c3e-7ab3-4dd4-9a24-c0c909040b64.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "Add userClickTimeV2 to app `Context` to provide the timestamp when the user clicked the app using the performance timer API.", + "packageName": "@microsoft/teams-js", + "email": "jcardenasr123@gmail.com", + "dependentChangeType": "patch" +} diff --git a/packages/teams-js/src/public/app.ts b/packages/teams-js/src/public/app.ts index a3cc920c2b..236df21ce1 100644 --- a/packages/teams-js/src/public/app.ts +++ b/packages/teams-js/src/public/app.ts @@ -151,10 +151,19 @@ export interface AppInfo { iconPositionVertical?: number; /** - * Time when the user clicked on the tab + * Time when the user clicked on the tab using the date. + * + * For measuring elapsed time between the moment the user click the tab, use {@link app.AppInfo.userClickTimeV2 | app.Context.app.userClickTimeV2} instead as it uses the performance timer API. */ userClickTime?: number; + /** + * Time when the user click on the app by using the performance timer API. Useful for measuring elapsed time accurately. + * + * For displaying the time when the user clicked on the app, please use {@link app.AppInfo.userClickTime | app.Context.app.userClickTime} as it uses the date. + */ + userClickTimeV2?: number; + /** * The ID of the parent message from which this task module was launched. * This is only available in task modules launched from bot cards. @@ -822,6 +831,7 @@ function transformLegacyContextToAppContext(legacyContext: LegacyContext): Conte osLocaleInfo: legacyContext.osLocaleInfo, parentMessageId: legacyContext.parentMessageId, userClickTime: legacyContext.userClickTime, + userClickTimeV2: legacyContext.userClickTimeV2, userFileOpenPreference: legacyContext.userFileOpenPreference, host: { name: legacyContext.hostName ? legacyContext.hostName : HostName.teams, diff --git a/packages/teams-js/src/public/interfaces.ts b/packages/teams-js/src/public/interfaces.ts index 70ba0427c4..9e6ded08a9 100644 --- a/packages/teams-js/src/public/interfaces.ts +++ b/packages/teams-js/src/public/interfaces.ts @@ -707,10 +707,22 @@ export interface Context { * @deprecated * As of TeamsJS v2.0.0, please use {@link app.AppInfo.userClickTime | app.Context.app.userClickTime} instead * - * Time when the user clicked on the tab + * Time when the user clicked on the tab using the date. + * + * For measuring elapsed time between the moment the user click the tab, use {@link app.AppInfo.userClickTimeV2 | app.Context.app.userClickTimeV2} instead as it uses the performance timer API. */ userClickTime?: number; + /** + * @deprecated + * As of TeamsJS v2.0.0, please use {@link app.AppInfo.userClickTimeV2 | app.Context.app.userClickTimeV2} instead + * + * Time when the user click on the app by using the performance timer API. Useful for measuring elapsed time accurately. + * + * For displaying the time when the user clicked on the app, please use {@link app.AppInfo.userClickTime | app.Context.app.userClickTime} as it uses the date. + */ + userClickTimeV2?: number; + /** * @deprecated * As of TeamsJS v2.0.0, please use {@link app.TeamInfo.templateId | app.Context.team.templateId} instead @@ -1008,7 +1020,7 @@ export interface SdkError { errorCode: ErrorCode; /** Optional description for the error. This may contain useful information for web-app developers. - This string will not be localized and is not for end-user consumption. + This string will not be localized and is not for end-user consumption. App should not depend on the string content. The exact value may change. This is only for debugging purposes. */ message?: string; diff --git a/packages/teams-js/test/private/privateAPIs.spec.ts b/packages/teams-js/test/private/privateAPIs.spec.ts index 09faedee6e..6397a1bc71 100644 --- a/packages/teams-js/test/private/privateAPIs.spec.ts +++ b/packages/teams-js/test/private/privateAPIs.spec.ts @@ -358,6 +358,7 @@ describe('AppSDK-privateAPIs', () => { appLaunchId: 'appLaunchId', sourceOrigin: 'someOrigin', userClickTime: 1000, + userClickTimeV2: 1001, teamTemplateId: 'com.microsoft.teams.ManageAProject', userFileOpenPreference: FileOpenPreference.Web, }; diff --git a/packages/teams-js/test/public/app.spec.ts b/packages/teams-js/test/public/app.spec.ts index 41a0c62f9a..dffc643fb9 100644 --- a/packages/teams-js/test/public/app.spec.ts +++ b/packages/teams-js/test/public/app.spec.ts @@ -556,6 +556,7 @@ describe('Testing app capability', () => { sourceOrigin: 'www.origin.com', teamTemplateId: 'someTeamTemplateId', userClickTime: 2222, + userClickTimeV2: 3333, userFileOpenPreference: FileOpenPreference.Inline, isMultiWindow: true, isBackgroundLoad: true, @@ -574,6 +575,7 @@ describe('Testing app capability', () => { sessionId: 'appSessionId', theme: 'someTheme', userClickTime: 2222, + userClickTimeV2: 3333, userFileOpenPreference: FileOpenPreference.Inline, appLaunchId: 'appLaunchId', host: { @@ -1424,6 +1426,7 @@ describe('Testing app capability', () => { sourceOrigin: 'www.origin.com', teamTemplateId: 'someTeamTemplateId', userClickTime: 2222, + userClickTimeV2: 3333, userFileOpenPreference: FileOpenPreference.Inline, isMultiWindow: true, frameContext: context, @@ -1441,6 +1444,7 @@ describe('Testing app capability', () => { osLocaleInfo: undefined, parentMessageId: 'someParentMessageId', userClickTime: 2222, + userClickTimeV2: 3333, userFileOpenPreference: FileOpenPreference.Inline, host: { name: HostName.orange,