@campfire-interactive/shell-header 0.13.0 → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -134,8 +134,8 @@ interface AboutInfo {
134
134
  interface BugReportContext {
135
135
  /** Reporting app slug, e.g. "omsf". */
136
136
  appId: string;
137
- /** Environment label, e.g. "dev". Hosts should omit the whole `bugReport`
138
- * prop in prod until the prod-visibility story exists. */
137
+ /** Environment label, e.g. "dev" / "prod". Reports land in the same
138
+ * environment's DMS and surface on its /issues page. */
139
139
  environment: string;
140
140
  /** Defaults to window.location.href at submit time. */
141
141
  url?: string;
@@ -356,13 +356,30 @@ declare function LocaleSwitcher({ currentLocale, supportedLocales, onLocaleChang
356
356
  declare function installBugReportCapture(): void;
357
357
 
358
358
  declare const appCatalog: AppDefinition[];
359
+ /**
360
+ * Read the environment segment out of a deployed suite hostname.
361
+ *
362
+ * The environment is always the label adjacent to the base domain, deduced
363
+ * from the host rather than matched against a fixed list so a new environment
364
+ * needs no code change here:
365
+ * - `<app>.campfiresuite.com` → '' (prod)
366
+ * - `<app>.<env>.campfiresuite.com` → `<env>` (dev / uat / qa / …)
367
+ * - `pr-<n>.<app>.<env>.campfiresuite.com` → `<env>` (PR previews run against
368
+ * a shared env; the `pr-<n>` / app labels ahead of it don't change that)
369
+ *
370
+ * Anything that isn't a `*.campfiresuite.com` host is treated as prod (empty
371
+ * segment) — the same conservative default as before.
372
+ */
373
+ declare function getEnvSegment(host: string): string;
359
374
  /**
360
375
  * Derive the app URL from the current hostname, optionally appending the
361
- * catalog entry's preferred landing path.
376
+ * catalog entry's preferred landing path. Keeps whatever environment the
377
+ * current host is on (see {@link getEnvSegment}) and just swaps in the target
378
+ * app id:
362
379
  * - localhost → localhost:<localPort>[<path>]
363
- * - *.dev.campfiresuite.com → <id>.dev.campfiresuite.com[<path>]
364
- * - *.campfiresuite.com → <id>.campfiresuite.com[<path>]
380
+ * - <app>.campfiresuite.com → <id>.campfiresuite.com[<path>] (prod)
381
+ * - <app>.<env>.campfiresuite.com → <id>.<env>.campfiresuite.com[<path>]
365
382
  */
366
383
  declare function getAppUrl(app: AppDefinition): string;
367
384
 
368
- export { type AboutInfo, type AppDefinition, type BugReportConfig, type BugReportContext, type BugReportPayload, type CurrencyOption, type LocaleOption, LocaleSwitcher, type NotificationItem, ShellHeader, type ShellHeaderProps, type ShellUser, type VersionInfo, appCatalog, getAppUrl, installBugReportCapture };
385
+ export { type AboutInfo, type AppDefinition, type BugReportConfig, type BugReportContext, type BugReportPayload, type CurrencyOption, type LocaleOption, LocaleSwitcher, type NotificationItem, ShellHeader, type ShellHeaderProps, type ShellUser, type VersionInfo, appCatalog, getAppUrl, getEnvSegment, installBugReportCapture };
package/dist/index.js CHANGED
@@ -120,6 +120,13 @@ var appCatalog = [
120
120
  path: "/admin/users"
121
121
  }
122
122
  ];
123
+ var BASE_DOMAIN = "campfiresuite.com";
124
+ function getEnvSegment(host) {
125
+ const suffix = `.${BASE_DOMAIN}`;
126
+ if (!host.endsWith(suffix)) return "";
127
+ const labels = host.slice(0, -suffix.length).split(".");
128
+ return labels.length > 1 ? labels[labels.length - 1] : "";
129
+ }
123
130
  function getAppUrl(app) {
124
131
  const host = typeof window !== "undefined" ? window.location.hostname : "";
125
132
  const protocol = typeof window !== "undefined" ? window.location.protocol : "https:";
@@ -127,10 +134,9 @@ function getAppUrl(app) {
127
134
  if (host === "localhost" || host === "127.0.0.1") {
128
135
  return app.localPort ? `http://localhost:${app.localPort}${path}` : "#";
129
136
  }
130
- if (host.includes(".dev.")) {
131
- return `${protocol}//${app.id}.dev.campfiresuite.com${path}`;
132
- }
133
- return `${protocol}//${app.id}.campfiresuite.com${path}`;
137
+ const env = getEnvSegment(host);
138
+ const infix = env ? `.${env}` : "";
139
+ return `${protocol}//${app.id}${infix}.${BASE_DOMAIN}${path}`;
134
140
  }
135
141
 
136
142
  // src/AppSwitcher.tsx
@@ -1114,7 +1120,7 @@ function BugReportModal({ config, initialScreenshot, onClose }) {
1114
1120
  onFocus: (e) => e.stopPropagation(),
1115
1121
  children: /* @__PURE__ */ jsxs6("div", { className: `cfi-sh-bug-card${view === "editor" ? " cfi-sh-bug-card-wide" : ""}`, children: [
1116
1122
  /* @__PURE__ */ jsxs6("div", { className: "cfi-sh-bug-header", children: [
1117
- /* @__PURE__ */ jsx6("span", { className: "cfi-sh-bug-title", children: "Report an issue" }),
1123
+ /* @__PURE__ */ jsx6("span", { className: "cfi-sh-bug-title", children: view === "editor" ? "New Issue - Attach Screenshot (Optional)" : "Report an issue" }),
1118
1124
  /* @__PURE__ */ jsx6("span", { className: "cfi-sh-bug-env", children: config.context.environment }),
1119
1125
  /* @__PURE__ */ jsx6("button", { className: "cfi-sh-bug-close", type: "button", onClick: closeUnlessBusy, "aria-label": "Close", children: "\xD7" })
1120
1126
  ] }),
@@ -1142,6 +1148,7 @@ function BugReportModal({ config, initialScreenshot, onClose }) {
1142
1148
  ] }),
1143
1149
  /* @__PURE__ */ jsx6("span", { className: "cfi-sh-bug-hint", children: mode === "crop" ? "Drag to crop to a region" : "Drag to black out sensitive data" }),
1144
1150
  /* @__PURE__ */ jsxs6("div", { className: "cfi-sh-bug-modes", children: [
1151
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "cfi-sh-bug-btn", onClick: () => setView("form"), children: "Skip" }),
1145
1152
  /* @__PURE__ */ jsx6("button", { type: "button", className: "cfi-sh-bug-btn", onClick: handleEditorReset, children: "Reset" }),
1146
1153
  /* @__PURE__ */ jsx6("button", { type: "button", className: "cfi-sh-bug-btn cfi-sh-bug-btn-primary", onClick: handleEditorDone, children: "Done" })
1147
1154
  ] })
@@ -1505,5 +1512,6 @@ export {
1505
1512
  ShellHeader,
1506
1513
  appCatalog,
1507
1514
  getAppUrl,
1515
+ getEnvSegment,
1508
1516
  installBugReportCapture
1509
1517
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campfire-interactive/shell-header",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
4
4
  "description": "Shared shell header with app switcher for Campfire Suite",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",