@forge/cli-shared

9.9.0-next.79.9.0-next.8
out/shared/developer-console.js
~out/shared/developer-console.jsModified
+20−2
Index: package/out/shared/developer-console.js
===================================================================
--- package/out/shared/developer-console.js
+++ package/out/shared/developer-console.js
@@ -1,7 +1,7 @@
 "use strict";
 Object.defineProperty(exports, "__esModule", { value: true });
-exports.getDevConsoleUrl = exports.getDevConsoleBaseUrl = void 0;
+exports.withDevConsoleAttribution = exports.getDevConsoleUrl = exports.getDevConsoleBaseUrl = void 0;
 const gateway_1 = require("../graphql/gateway");
 const ari_1 = require("@forge/util/packages/ari");
 const getDevConsoleBaseUrl = () => {
     if (process.env.FORGE_DEV_CONSOLE_URL) {
@@ -32,12 +32,30 @@
 const DEV_CONSOLE_PATHS = {
     appOverview: (appId) => `myapps/${toAppUuid(appId)}/overview`,
     appInstallations: (appId) => `myapps/${toAppUuid(appId)}/monitoring/installations`,
     appDistribution: (appId) => `myapps/${toAppUuid(appId)}/manage/distribution`,
+    appContributors: (appId) => `myapps/${toAppUuid(appId)}/manage/contributors`,
     rolloutLink: (appId, environmentId, rolloutId) => `myapps/${appId}/build/rollouts/${environmentId}/${rolloutId}`,
     developerSpace: (spaceId) => `developer-space/${spaceId}`
 };
 const getDevConsoleUrl = (page, ...args) => {
+    const lastArg = args[args.length - 1];
+    const attribution = typeof lastArg === 'object' ? lastArg : undefined;
+    const pathArgs = typeof lastArg === 'string' ? args : args.slice(0, -1);
     const buildPath = DEV_CONSOLE_PATHS[page];
-    return `${(0, exports.getDevConsoleBaseUrl)()}/console/${buildPath(...args)}`;
+    const url = `${(0, exports.getDevConsoleBaseUrl)()}/console/${buildPath(...pathArgs)}`;
+    return attribution ? (0, exports.withDevConsoleAttribution)(url, attribution) : url;
 };
 exports.getDevConsoleUrl = getDevConsoleUrl;
+const FORGE_CLI_UTM_SOURCE = 'forge-cli';
+const withDevConsoleAttribution = (url, attribution = {}) => {
+    if (attribution.utmSource === undefined && attribution.utmCampaign === undefined) {
+        return url;
+    }
+    const attributedUrl = new URL(url);
+    attributedUrl.searchParams.set('utm_source', attribution.utmSource ?? FORGE_CLI_UTM_SOURCE);
+    if (attribution.utmCampaign !== undefined) {
+        attributedUrl.searchParams.set('utm_campaign', attribution.utmCampaign);
+    }
+    return attributedUrl.toString();
+};
+exports.withDevConsoleAttribution = withDevConsoleAttribution;