Skip to content

Commit 14aa241

Browse files
stanchclaude
andcommitted
Address PR review feedback for browser-plugin-bot-detection
- Change rush change type from "none" to "minor" for new package - Add author field to package.json - Add README.md and LICENSE files - Improve error log message to be more descriptive - Fix test mock detect() to return Promise.reject instead of throwing - Revert unrelated rush-prettier lockfile upgrade - Remove unrelated transitive version bumps from pnpm-lock.yaml Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7c34543 commit 14aa241

File tree

8 files changed

+302
-183
lines changed

8 files changed

+302
-183
lines changed

common/autoinstallers/rush-prettier/pnpm-lock.yaml

Lines changed: 204 additions & 171 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/changes/@snowplow/browser-plugin-bot-detection/bot-detection-plugin_2026-03-17-17-11.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"changes": [
33
{
44
"comment": "Add browser-plugin-bot-detection plugin wrapping FingerprintJS BotD for client-side bot detection",
5-
"type": "none",
5+
"type": "minor",
66
"packageName": "@snowplow/browser-plugin-bot-detection"
77
}
88
],

common/config/rush/pnpm-lock.yaml

Lines changed: 5 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2022 Snowplow Analytics Ltd, 2010 Anthon Pang
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Snowplow Bot Detection
2+
3+
[![npm version][npm-image]][npm-url]
4+
[![License][license-image]](LICENSE)
5+
6+
Browser Plugin to be used with `@snowplow/browser-tracker`.
7+
8+
Detects bots client-side using [FingerprintJS BotD](https://github.com/nicedoc/fingerprintjs-botd) and attaches the result as a `client_side_bot_detection` context entity to all tracked events.
9+
10+
## Maintainer quick start
11+
12+
Part of the Snowplow JavaScript Tracker monorepo.
13+
Build with [Node.js](https://nodejs.org/en/) (18 - 20) and [Rush](https://rushjs.io/).
14+
15+
### Setup repository
16+
17+
```bash
18+
npm install -g @microsoft/rush
19+
git clone https://github.com/snowplow/snowplow-javascript-tracker.git
20+
rush update
21+
```
22+
23+
## Package Installation
24+
25+
With npm:
26+
27+
```bash
28+
npm install @snowplow/browser-plugin-bot-detection
29+
```
30+
31+
## Usage
32+
33+
Initialize your tracker with the BotDetectionPlugin:
34+
35+
```js
36+
import { newTracker } from '@snowplow/browser-tracker';
37+
import { BotDetectionPlugin } from '@snowplow/browser-plugin-bot-detection';
38+
39+
newTracker('sp1', '{{collector}}', { plugins: [ BotDetectionPlugin() ] });
40+
```
41+
42+
Once detection completes, a `client_side_bot_detection` context entity will be attached to all subsequent events with the following fields:
43+
44+
- `bot` (boolean): Whether a bot was detected.
45+
- `kind` (string | null): The type of bot detected (e.g. `"selenium"`, `"phantomjs"`), or `null` if no bot was found.
46+
47+
## Copyright and license
48+
49+
Licensed and distributed under the [BSD 3-Clause License](LICENSE) ([An OSI Approved License][osi]).
50+
51+
Copyright (c) 2022 Snowplow Analytics Ltd, 2010 Anthon Pang.
52+
53+
All rights reserved.
54+
55+
[npm-url]: https://www.npmjs.com/package/@snowplow/browser-plugin-bot-detection
56+
[npm-image]: https://img.shields.io/npm/v/@snowplow/browser-plugin-bot-detection
57+
[docs]: https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/javascript-tracker/
58+
[osi]: https://opensource.org/licenses/BSD-3-Clause
59+
[license-image]: https://img.shields.io/npm/l/@snowplow/browser-plugin-bot-detection

plugins/browser-plugin-bot-detection/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"url": "https://github.com/snowplow/snowplow-javascript-tracker.git"
1010
},
1111
"license": "BSD-3-Clause",
12+
"author": "Snowplow Analytics Ltd (https://snowplow.io/)",
1213
"sideEffects": false,
1314
"main": "./dist/index.umd.js",
1415
"module": "./dist/index.module.js",

plugins/browser-plugin-bot-detection/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function BotDetectionPlugin(): BrowserPlugin {
1919
.then((result) => {
2020
contextData = result.bot ? { bot: true, kind: result.botKind } : { bot: false, kind: null };
2121
})
22-
.catch((err) => LOG.error('BotDetectionPlugin', err));
22+
.catch((err) => LOG.error('BotDetectionPlugin: BotD load/detect failed', err));
2323
}
2424
},
2525
contexts: () => {

plugins/browser-plugin-bot-detection/test/bot-detection.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jest.mock('@fingerprintjs/botd', () => ({
1616
return Promise.resolve({
1717
detect: () => {
1818
if (mockDetectReject) {
19-
throw mockDetectReject;
19+
return Promise.reject(mockDetectReject);
2020
}
21-
return mockDetectResult;
21+
return Promise.resolve(mockDetectResult);
2222
},
2323
});
2424
},

0 commit comments

Comments
 (0)