diff --git a/packages/app/src/cli/models/app/app.test-data.ts b/packages/app/src/cli/models/app/app.test-data.ts index 2ea50a349d..7f46adf12f 100644 --- a/packages/app/src/cli/models/app/app.test-data.ts +++ b/packages/app/src/cli/models/app/app.test-data.ts @@ -18,6 +18,7 @@ import { OrganizationApp, MinimalOrganizationApp, AppApiKeyAndOrgId, + OrganizationSource, } from '../organization.js' import {RemoteSpecification} from '../../api/graphql/extension_specifications.js' import {ExtensionInstance} from '../extensions/extension-instance.js' @@ -176,6 +177,7 @@ export function testOrganization(): Organization { return { id: '1', businessName: 'org1', + source: OrganizationSource.BusinessPlatform, } } diff --git a/packages/app/src/cli/services/app-context.test.ts b/packages/app/src/cli/services/app-context.test.ts index c6bc55bbcd..f96d12127f 100644 --- a/packages/app/src/cli/services/app-context.test.ts +++ b/packages/app/src/cli/services/app-context.test.ts @@ -232,7 +232,7 @@ describe('linkedAppContext', () => { const meta = metadata.getAllPublicMetadata() expect(meta).toEqual( expect.objectContaining({ - partner_id: tryParseInt(mockRemoteApp.organizationId), + business_platform_id: tryParseInt(mockOrganization.id), api_key: mockRemoteApp.apiKey, cmd_app_reset_used: false, }), diff --git a/packages/app/src/cli/services/app-context.ts b/packages/app/src/cli/services/app-context.ts index db2888d3f5..85f23b0507 100644 --- a/packages/app/src/cli/services/app-context.ts +++ b/packages/app/src/cli/services/app-context.ts @@ -3,7 +3,7 @@ import {getCachedAppInfo, setCachedAppInfo} from './local-storage.js' import {fetchSpecifications} from './generate/fetch-extension-specifications.js' import link from './app/config/link.js' import {fetchOrgFromId} from './dev/fetch.js' -import {Organization, OrganizationApp} from '../models/organization.js' +import {Organization, OrganizationApp, OrganizationSource} from '../models/organization.js' import {DeveloperPlatformClient, selectDeveloperPlatformClient} from '../utilities/developer-platform-client.js' import {getAppConfigurationState, loadAppUsingConfigurationState} from '../models/app/loader.js' import {RemoteAwareExtensionSpecification} from '../models/extensions/specification.js' @@ -97,14 +97,21 @@ export async function linkedAppContext({ setCachedAppInfo({appId: remoteApp.apiKey, title: remoteApp.title, directory, orgId: remoteApp.organizationId}) } - await logMetadata(remoteApp, forceRelink) + await logMetadata(remoteApp, organization, forceRelink) return {app: localApp, remoteApp, developerPlatformClient, specifications, organization} } -async function logMetadata(app: {organizationId: string; apiKey: string}, resetUsed: boolean) { +async function logMetadata(app: {apiKey: string}, organization: Organization, resetUsed: boolean) { + let organizationInfo: {partner_id?: number; business_platform_id?: number} + if (organization.source === OrganizationSource.BusinessPlatform) { + organizationInfo = {business_platform_id: tryParseInt(organization.id)} + } else { + organizationInfo = {partner_id: tryParseInt(organization.id)} + } + await metadata.addPublicMetadata(() => ({ - partner_id: tryParseInt(app.organizationId), + ...organizationInfo, api_key: app.apiKey, cmd_app_reset_used: resetUsed, })) diff --git a/packages/cli-kit/src/public/node/monorail.ts b/packages/cli-kit/src/public/node/monorail.ts index 45c1ae7db9..fb10c45bc3 100644 --- a/packages/cli-kit/src/public/node/monorail.ts +++ b/packages/cli-kit/src/public/node/monorail.ts @@ -29,6 +29,7 @@ export interface Schemas { env_plugin_installed_all?: Optional } public: { + business_platform_id?: Optional partner_id?: Optional command: string project_type?: Optional diff --git a/packages/cli-kit/src/public/node/plugins.ts b/packages/cli-kit/src/public/node/plugins.ts index 1e9eb99c3d..83031057d6 100644 --- a/packages/cli-kit/src/public/node/plugins.ts +++ b/packages/cli-kit/src/public/node/plugins.ts @@ -28,7 +28,7 @@ export async function fanoutHooks [plugin.name, result])) as any } -type AppSpecificMonorailFields = PickByPrefix & +type AppSpecificMonorailFields = PickByPrefix & PickByPrefix & PickByPrefix