Skip to content

Commit bafe1bf

Browse files
Add plugin to send requests with user ID to a Kantar FocalMeter endpoint (close #1133)
PR #1134
1 parent 9ba6cf2 commit bafe1bf

File tree

14 files changed

+592
-1
lines changed

14 files changed

+592
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@snowplow/browser-plugin-focalmeter",
5+
"comment": "Add plugin to send requests with user ID to a Kantar FocalMeter endpoint (#1133)",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@snowplow/browser-plugin-focalmeter"
10+
}

common/config/rush/browser-approved-packages.json

+4
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@
130130
"name": "@snowplow/browser-plugin-youtube-tracking",
131131
"allowedCategories": [ "trackers" ]
132132
},
133+
{
134+
"name": "@snowplow/browser-plugin-focalmeter",
135+
"allowedCategories": [ "trackers" ]
136+
},
133137
{
134138
"name": "@snowplow/browser-tracker",
135139
"allowedCategories": [ "plugins", "trackers" ]

common/config/rush/pnpm-lock.yaml

+49
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/config/rush/repo-state.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
22
{
3-
"pnpmShrinkwrapHash": "a89befd25d9043396ee1a3dda2def22a80582f46",
3+
"pnpmShrinkwrapHash": "f6c3c1da60e38fc2db1587dd57a4b39e2ff21caf",
44
"preferredVersionsHash": "bf21a9e8fbc5a3846fb05b4fa0859e0917b2202f"
55
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "@snowplow/browser-plugin-focalmeter",
3+
"entries": [
4+
]
5+
}
+29
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.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Snowplow FocalMeter Integration
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+
Adds integration with the Kantar FocalMeter to your Snowplow tracking.
9+
The plugin sends requests with the domain user ID to a Kantar endpoint used with the FocalMeter system.
10+
A request is made when the first event with a new user ID is tracked.
11+
12+
## Maintainer quick start
13+
14+
Part of the Snowplow JavaScript Tracker monorepo.
15+
Build with [Node.js](https://nodejs.org/en/) (14 or 16) and [Rush](https://rushjs.io/).
16+
17+
### Setup repository
18+
19+
```bash
20+
npm install -g @microsoft/rush
21+
git clone https://github.com/snowplow/snowplow-javascript-tracker.git
22+
rush update
23+
```
24+
25+
## Package Installation
26+
27+
With npm:
28+
29+
```bash
30+
npm install @snowplow/browser-plugin-focalmeter
31+
```
32+
33+
## Usage
34+
35+
Initialize your tracker with the FocalMeterPlugin:
36+
37+
```js
38+
import { newTracker } from '@snowplow/browser-tracker';
39+
import { FocalMeterPlugin } from '@snowplow/browser-plugin-focalmeter';
40+
41+
newTracker('sp1', '{{collector}}', { plugins: [ FocalMeterPlugin() ] }); // Also stores reference at module level
42+
```
43+
44+
## Copyright and license
45+
46+
Licensed and distributed under the [BSD 3-Clause License](LICENSE) ([An OSI Approved License][osi]).
47+
48+
Copyright (c) 2022 Snowplow Analytics Ltd, 2010 Anthon Pang.
49+
50+
All rights reserved.
51+
52+
[npm-url]: https://www.npmjs.com/package/@snowplow/browser-plugin-focalmeter
53+
[npm-image]: https://img.shields.io/npm/v/@snowplow/browser-plugin-focalmeter
54+
[docs]: https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/javascript-tracker/
55+
[osi]: https://opensource.org/licenses/BSD-3-Clause
56+
[license-image]: https://img.shields.io/npm/l/@snowplow/browser-plugin-focalmeter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
reporters: ['jest-standard-reporter'],
4+
testEnvironment: 'jest-environment-jsdom-global',
5+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"name": "@snowplow/browser-plugin-focalmeter",
3+
"version": "3.8.0",
4+
"description": "Kantar FocalMeter integration for Snowplow",
5+
"homepage": "http://bit.ly/sp-js",
6+
"bugs": "https://github.com/snowplow/snowplow-javascript-tracker/issues",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/snowplow/snowplow-javascript-tracker.git"
10+
},
11+
"license": "BSD-3-Clause",
12+
"author": "Matus Tomlein",
13+
"sideEffects": false,
14+
"main": "./dist/index.umd.js",
15+
"module": "./dist/index.module.js",
16+
"types": "./dist/index.module.d.ts",
17+
"files": [
18+
"dist"
19+
],
20+
"scripts": {
21+
"build": "rollup -c --silent --failAfterWarnings",
22+
"test": "jest"
23+
},
24+
"dependencies": {
25+
"@snowplow/browser-tracker-core": "workspace:*",
26+
"@snowplow/tracker-core": "workspace:*",
27+
"tslib": "^2.3.1"
28+
},
29+
"devDependencies": {
30+
"@ampproject/rollup-plugin-closure-compiler": "~0.27.0",
31+
"@rollup/plugin-commonjs": "~21.0.2",
32+
"@rollup/plugin-node-resolve": "~13.1.3",
33+
"@types/jest": "~27.4.1",
34+
"@types/jsdom": "~16.2.14",
35+
"@typescript-eslint/eslint-plugin": "~5.15.0",
36+
"@typescript-eslint/parser": "~5.15.0",
37+
"eslint": "~8.11.0",
38+
"jest": "~27.5.1",
39+
"jest-environment-jsdom": "~27.5.1",
40+
"jest-environment-jsdom-global": "~3.0.0",
41+
"jest-standard-reporter": "~2.0.0",
42+
"rollup": "~2.70.1",
43+
"rollup-plugin-cleanup": "~3.2.1",
44+
"rollup-plugin-license": "~2.6.1",
45+
"rollup-plugin-terser": "~7.0.2",
46+
"rollup-plugin-ts": "~2.0.5",
47+
"ts-jest": "~27.1.3",
48+
"typescript": "~4.6.2"
49+
},
50+
"peerDependencies": {
51+
"@snowplow/browser-tracker": "~3.8.0"
52+
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright (c) 2022 Snowplow Analytics Ltd, 2010 Anthon Pang
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright notice, this
9+
* list of conditions and the following disclaimer.
10+
*
11+
* 2. Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following disclaimer in the documentation
13+
* and/or other materials provided with the distribution.
14+
*
15+
* 3. Neither the name of the copyright holder nor the names of its
16+
* contributors may be used to endorse or promote products derived from
17+
* this software without specific prior written permission.
18+
*
19+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
import { nodeResolve } from '@rollup/plugin-node-resolve';
32+
import commonjs from '@rollup/plugin-commonjs';
33+
import ts from 'rollup-plugin-ts'; // Prefered over @rollup/plugin-typescript as it bundles .d.ts files
34+
import { banner } from '../../banner';
35+
import compiler from '@ampproject/rollup-plugin-closure-compiler';
36+
import { terser } from 'rollup-plugin-terser';
37+
import cleanup from 'rollup-plugin-cleanup';
38+
import pkg from './package.json';
39+
import { builtinModules } from 'module';
40+
41+
const umdPlugins = [nodeResolve({ browser: true }), commonjs(), ts()];
42+
const umdName = 'snowplowFocalMeter';
43+
44+
export default [
45+
// CommonJS (for Node) and ES module (for bundlers) build.
46+
{
47+
input: './src/index.ts',
48+
plugins: [...umdPlugins, banner()],
49+
treeshake: { moduleSideEffects: ['sha1'] },
50+
output: [{ file: pkg.main, format: 'umd', sourcemap: true, name: umdName }],
51+
},
52+
{
53+
input: './src/index.ts',
54+
plugins: [...umdPlugins, compiler(), terser(), cleanup({ comments: 'none' }), banner()],
55+
treeshake: { moduleSideEffects: ['sha1'] },
56+
output: [{ file: pkg.main.replace('.js', '.min.js'), format: 'umd', sourcemap: true, name: umdName }],
57+
},
58+
{
59+
input: './src/index.ts',
60+
external: [...builtinModules, ...Object.keys(pkg.dependencies), ...Object.keys(pkg.devDependencies)],
61+
plugins: [
62+
ts(), // so Rollup can convert TypeScript to JavaScript
63+
banner(),
64+
],
65+
output: [{ file: pkg.module, format: 'es', sourcemap: true }],
66+
},
67+
];

0 commit comments

Comments
 (0)