Skip to content

Commit 4b3ad9c

Browse files
bkboothclaude
andcommitted
feat(audience): bump pixel to v1.0.0 and inject version at build time
Read version from package.json in tsup.config.ts and inject it via esbuild define as PIXEL_VERSION_INJECTED. This stamps every event payload with the correct libraryVersion automatically — no manual bumping needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 51a9008 commit 4b3ad9c

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

packages/audience/pixel/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@imtbl/pixel",
33
"description": "Immutable Tracking Pixel — drop-in JavaScript snippet for device fingerprint, page view, and attribution data",
4-
"version": "0.0.0",
4+
"version": "1.0.0",
55
"author": "Immutable",
66
"private": true,
77
"bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/** Injected at build time by tsup `define` — see tsup.config.ts */
2+
declare const PIXEL_VERSION_INJECTED: string;

packages/audience/pixel/src/pixel.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ import {
2424
createConsentManager,
2525
} from '@imtbl/audience-core';
2626

27-
const PIXEL_VERSION = '0.0.0';
27+
// Replaced at build time by tsup `define` (see tsup.config.ts).
28+
// In tests the global isn't defined, so we fall back to 'unknown'.
29+
const PIXEL_VERSION: string = typeof PIXEL_VERSION_INJECTED !== 'undefined'
30+
? PIXEL_VERSION_INJECTED
31+
: 'unknown';
2832

2933
export interface PixelInitOptions {
3034
key: string;

packages/audience/pixel/tsup.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { resolve } from 'path';
2+
import { readFileSync } from 'fs';
23
import { defineConfig } from 'tsup';
34

5+
const pkg = JSON.parse(readFileSync(resolve(__dirname, 'package.json'), 'utf-8'));
6+
47
export default defineConfig({
58
entry: ['src/index.ts'],
69
outDir: 'dist',
@@ -14,6 +17,9 @@ export default defineConfig({
1417
sourcemap: false,
1518
clean: true,
1619
noExternal: ['@imtbl/audience-core', '@imtbl/metrics'],
20+
define: {
21+
PIXEL_VERSION_INJECTED: JSON.stringify(pkg.version),
22+
},
1723
outExtension: () => ({ js: '.js' }),
1824
esbuildOptions(options) {
1925
options.outbase = 'src';

0 commit comments

Comments
 (0)