Skip to content

Commit

Permalink
Skip empty UTM parameters (#10)
Browse files Browse the repository at this point in the history
Empty UTM parameters are no longer captured
  • Loading branch information
JeroenBakker authored Aug 25, 2023
1 parent 3c7d4fa commit 8dd6cd7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.4.3] - 2023-08-25

### Changed

- Empty UTM parameters are no longer captured.

## [0.4.2] - 2023-08-25

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jeroen.bakker/just-attribute",
"version": "0.4.2",
"version": "0.4.3",
"description": "Realtime privacy-conscious marketing attribution for the web",
"author": "Jeroen Bakker",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/InteractionLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default class InteractionLogger {

url.searchParams.forEach((value, key) => {
const mappedKey = InteractionLogger.queryMapping[key];
if (mappedKey) {
if (mappedKey && value.length) {
interaction[mappedKey] = value;
} else {
// Empty parameters can be considered missing as they don't tell us anything
Expand Down
8 changes: 8 additions & 0 deletions tests/InteractionLogger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,3 +384,11 @@ test('the last interaction storage key can be set', async () => {

expect(storage.getItem('foo')).toBe('1');
});

test('empty UTM parameters are skipped', async () => {
const logger = new InteractionLogger();

const interaction = logger.determineInteraction(new URL('https://www.example.com?utm_source=foo&utm_medium=bar&utm_campaign='));

expect(interaction).toEqual({source: 'foo', medium: 'bar', timestamp: expect.any(Number)});
});

0 comments on commit 8dd6cd7

Please sign in to comment.