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

Report business platform ID instead of partner ID when relevant #5120

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions packages/app/src/cli/models/app/app.test-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -176,6 +177,7 @@ export function testOrganization(): Organization {
return {
id: '1',
businessName: 'org1',
source: OrganizationSource.BusinessPlatform,
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/cli/services/app-context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
Expand Down
15 changes: 11 additions & 4 deletions packages/app/src/cli/services/app-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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,
}))
Expand Down
1 change: 1 addition & 0 deletions packages/cli-kit/src/public/node/monorail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface Schemas {
env_plugin_installed_all?: Optional<string>
}
public: {
business_platform_id?: Optional<number>
partner_id?: Optional<number>
command: string
project_type?: Optional<string>
Expand Down
6 changes: 5 additions & 1 deletion packages/cli-kit/src/public/node/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ export async function fanoutHooks<TPluginMap extends HookReturnsPerPlugin, TEven
return Object.fromEntries(res.successes.map(({result, plugin}) => [plugin.name, result])) as any
}

type AppSpecificMonorailFields = PickByPrefix<MonorailEventPublic, 'app_', 'project_type' | 'api_key' | 'partner_id'> &
type AppSpecificMonorailFields = PickByPrefix<
MonorailEventPublic,
'app_',
'project_type' | 'api_key' | 'partner_id' | 'business_platform_id'
> &
PickByPrefix<MonorailEventPublic, 'cmd_extensions_'> &
PickByPrefix<MonorailEventPublic, 'cmd_scaffold_'>

Expand Down
Loading