Skip to content

Add BotDetection functions#301

Open
mosherBT wants to merge 3 commits into
masterfrom
bot-detection-add
Open

Add BotDetection functions#301
mosherBT wants to merge 3 commits into
masterfrom
bot-detection-add

Conversation

@mosherBT

@mosherBT mosherBT commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Why

Moving this from custom solutioned template to the web-sdk.

What Changed

Only adding this. Will use it via solutions templates going forward.

How to Test

  • Tested
  • Docs / README updated (if public API changed)

Notes

  • Breaking change
  • Requires release

@mosherBT mosherBT self-assigned this Jul 14, 2026
@mosherBT mosherBT force-pushed the bot-detection-add branch from ecfeefe to 426e48f Compare July 14, 2026 19:04
Comment thread lib/addons/botDetection.ts Outdated
Comment thread lib/addons/botDetection.ts
Comment thread lib/addons/botDetection.ts Outdated
Comment on lines +42 to +48
export function enableBotDetection(): boolean {
if (isBot()) {
sessionStorage.setItem(TARGETING_DONE_KEY, "1");
return true;
}
return false;
}

@etiennelatendresse-optable etiennelatendresse-optable Jul 14, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we can rely on storage because in a sandboxed iframe where most bot would be, touching sessionStorage would actually throw a security error. Might consider adding a try catch

export function enableBotDetection(): boolean {
  if (isBot()) {
    try {
      sessionStorage.setItem(TARGETING_DONE_KEY, "1");
    } catch {
      // storage unavailable (sandboxed iframe, cookies blocked), detection still stands
    }
    return true;
  }
  return false;
}

@jplaroche jplaroche left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants