@botim/mp-debug-sdk 0.7.0 → 0.7.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.cts CHANGED
@@ -228,7 +228,7 @@ interface AppInfo {
228
228
  interface RemoteDebugOptions {
229
229
  /** When false, returns a no-op handle and installs nothing. */
230
230
  enabled?: boolean;
231
- /** Relay base URL, e.g. "https://debug.botim.dev". */
231
+ /** Relay base URL — your debug-relay deployment (e.g. "https://relay.example.com"). */
232
232
  endpoint: string;
233
233
  /**
234
234
  * Optional override for the app identity reported in events. When omitted
package/dist/index.d.ts CHANGED
@@ -228,7 +228,7 @@ interface AppInfo {
228
228
  interface RemoteDebugOptions {
229
229
  /** When false, returns a no-op handle and installs nothing. */
230
230
  enabled?: boolean;
231
- /** Relay base URL, e.g. "https://debug.botim.dev". */
231
+ /** Relay base URL — your debug-relay deployment (e.g. "https://relay.example.com"). */
232
232
  endpoint: string;
233
233
  /**
234
234
  * Optional override for the app identity reported in events. When omitted
package/dist/index.js CHANGED
@@ -1614,19 +1614,24 @@ function assertConfig(config) {
1614
1614
  async function enableRemoteDebug(options) {
1615
1615
  if (options.enabled === false) return NOOP_HANDLE;
1616
1616
  assertConfig(options.config);
1617
- if (options.consent?.promptUser) {
1617
+ const consentInput = options.consent ?? {};
1618
+ const hasExplicitConsent = consentInput.userOptIn === true || typeof consentInput.hostToken === "string" && consentInput.hostToken.length > 0;
1619
+ const promptDisabled = consentInput.promptUser === false;
1620
+ const canPrompt = typeof document !== "undefined" && typeof window !== "undefined";
1621
+ const shouldPrompt = !hasExplicitConsent && !promptDisabled && canPrompt;
1622
+ if (shouldPrompt) {
1618
1623
  const cached = readConsentDecision(options.config.miniProgramId);
1619
1624
  let decision = cached;
1620
1625
  if (decision === null) {
1621
1626
  decision = await promptForConsent(
1622
1627
  options.config.miniProgramId,
1623
- options.consent.promptCopy
1628
+ consentInput.promptCopy
1624
1629
  );
1625
1630
  }
1626
1631
  if (decision === "denied") return NOOP_HANDLE;
1627
1632
  options = {
1628
1633
  ...options,
1629
- consent: { ...options.consent, userOptIn: true }
1634
+ consent: { ...consentInput, userOptIn: true }
1630
1635
  };
1631
1636
  }
1632
1637
  assertConsent(options.config, options.consent);