diff --git a/change/@microsoft-teams-js-07a56fbc-6d3e-474d-b3d9-6c6fe3a3be50.json b/change/@microsoft-teams-js-07a56fbc-6d3e-474d-b3d9-6c6fe3a3be50.json new file mode 100644 index 0000000000..cffa37ae3c --- /dev/null +++ b/change/@microsoft-teams-js-07a56fbc-6d3e-474d-b3d9-6c6fe3a3be50.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "Added a new parameter to `app.getContext` called `appId` which contains the current application's AppId. This value is used in deeplinks and hosts to identify apps", + "packageName": "@microsoft/teams-js", + "email": "vikramtha@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/packages/teams-js/src/public/app.ts b/packages/teams-js/src/public/app.ts index 8efd2fa1e9..c3623af73f 100644 --- a/packages/teams-js/src/public/app.ts +++ b/packages/teams-js/src/public/app.ts @@ -354,6 +354,11 @@ export namespace app { * ID for the current visible app which is different for across cached sessions. Used for correlating telemetry data. */ appLaunchId?: string; + + /** + * App id that is used by Hosts to distinguish between different apps sideloaded or in store + */ + appId: string; } /** @@ -1007,6 +1012,7 @@ function transformLegacyContextToAppContext(legacyContext: LegacyContext): app.C ringId: legacyContext.ringId, }, appLaunchId: legacyContext.appLaunchId, + appId: legacyContext.appId, }, page: { id: legacyContext.entityId, diff --git a/packages/teams-js/src/public/interfaces.ts b/packages/teams-js/src/public/interfaces.ts index fceeedca9f..7c604e997b 100644 --- a/packages/teams-js/src/public/interfaces.ts +++ b/packages/teams-js/src/public/interfaces.ts @@ -758,6 +758,14 @@ export interface Context { * They help pre-fill the dialog with necessary information (`dialogParameters`) along with other details. */ dialogParameters?: Record; + + /** + * @deprecated + * As of 2.0.0, please use {@link app.AppInfo.appId | app.Context.app.appId} instead + * + * App id that is used by Hosts to distinguish between different apps sideloaded or in store + */ + appId: string; } /** Represents the parameters used to share a deep link. */ diff --git a/packages/teams-js/test/private/privateAPIs.spec.ts b/packages/teams-js/test/private/privateAPIs.spec.ts index 3f70758294..e36b000641 100644 --- a/packages/teams-js/test/private/privateAPIs.spec.ts +++ b/packages/teams-js/test/private/privateAPIs.spec.ts @@ -237,6 +237,7 @@ describe('AppSDK-privateAPIs', () => { channelId: 'someChannelId1', entityId: 'someEntityId1', userObjectId: 'someUserObjectId1', + appId: 'someAppId', }; const expectedContext1: app.Context = { app: { @@ -248,6 +249,7 @@ describe('AppSDK-privateAPIs', () => { clientType: HostClientType.web, sessionId: '', }, + appId: 'someAppId', }, page: { id: 'someEntityId1', @@ -267,6 +269,7 @@ describe('AppSDK-privateAPIs', () => { channelId: 'someChannelId2', entityId: 'someEntityId2', userObjectId: 'someUserObjectId2', + appId: 'someAppId', }; const expectedContext2: app.Context = { app: { @@ -278,6 +281,7 @@ describe('AppSDK-privateAPIs', () => { clientType: HostClientType.web, sessionId: '', }, + appId: 'someAppId', }, page: { id: 'someEntityId2', @@ -297,6 +301,7 @@ describe('AppSDK-privateAPIs', () => { channelId: 'someChannelId3', entityId: 'someEntityId3', userObjectId: 'someUserObjectId3', + appId: 'someAppId', }; const expectedContext3: app.Context = { app: { @@ -308,6 +313,7 @@ describe('AppSDK-privateAPIs', () => { clientType: HostClientType.web, sessionId: '', }, + appId: 'someAppId', }, page: { id: 'someEntityId3', @@ -360,6 +366,7 @@ describe('AppSDK-privateAPIs', () => { userClickTime: 1000, teamTemplateId: 'com.microsoft.teams.ManageAProject', userFileOpenPreference: FileOpenPreference.Web, + appId: 'someappId', }; // Get many responses to the same message diff --git a/packages/teams-js/test/public/app.spec.ts b/packages/teams-js/test/public/app.spec.ts index 27fc99e6dc..81d49d37a7 100644 --- a/packages/teams-js/test/public/app.spec.ts +++ b/packages/teams-js/test/public/app.spec.ts @@ -563,6 +563,7 @@ describe('Testing app capability', () => { appLaunchId: 'appLaunchId', userDisplayName: 'someTestUser', teamSiteId: 'someSiteId', + appId: 'someAppId', }; const expectedContext: app.Context = { @@ -576,6 +577,7 @@ describe('Testing app capability', () => { userClickTime: 2222, userFileOpenPreference: FileOpenPreference.Inline, appLaunchId: 'appLaunchId', + appId: 'someAppId', host: { name: HostName.orange, clientType: HostClientType.web, @@ -1430,6 +1432,7 @@ describe('Testing app capability', () => { appLaunchId: 'appLaunchId', userDisplayName: 'someTestUser', teamSiteId: 'someSiteId', + appId: 'someAppId', }; const expectedContext: app.Context = { @@ -1449,6 +1452,7 @@ describe('Testing app capability', () => { ringId: 'someRingId', }, appLaunchId: 'appLaunchId', + appId: 'someAppId', }, page: { id: 'someEntityId', diff --git a/packages/teams-js/test/public/publicAPIs.spec.ts b/packages/teams-js/test/public/publicAPIs.spec.ts index e9fc3a13e6..ab1906f1ec 100644 --- a/packages/teams-js/test/public/publicAPIs.spec.ts +++ b/packages/teams-js/test/public/publicAPIs.spec.ts @@ -348,6 +348,7 @@ describe('MicrosoftTeams-publicAPIs', () => { appSessionId: 'appSessionId', appLaunchId: 'appLaunchId', meetingId: 'dummyMeetingId', + appId: 'dummyAppId', }; getContext((context) => { Object.keys(expectedContext).forEach((e) => {