From 12fff8171522a770485d6e5e9e75309046371c62 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Date: Mon, 25 Nov 2024 16:11:48 +0100 Subject: [PATCH 1/3] feat(packages/sui-segment-wrapper): send client version as context property --- packages/sui-segment-wrapper/package.json | 9 ++++++++- packages/sui-segment-wrapper/src/segmentWrapper.js | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/sui-segment-wrapper/package.json b/packages/sui-segment-wrapper/package.json index a285355a4..82b21a06f 100644 --- a/packages/sui-segment-wrapper/package.json +++ b/packages/sui-segment-wrapper/package.json @@ -10,7 +10,7 @@ "test:client": "sui-test browser --src-pattern=src/index.js -H", "test": "npm run test:client", "test:umd": "npm run umd && npx servor ./umd", - "umd": "sui-bundler lib src-umd/index.js -o umd/ -p --root" + "umd": "VERSION=$npm_package_version sui-bundler lib src-umd/index.js -o umd/ -p --root" }, "author": "", "license": "ISC", @@ -22,5 +22,12 @@ "@s-ui/bundler": "9", "@s-ui/js-compiler": "1", "@s-ui/test": "8" + }, + "config": { + "sui-bundler": { + "env": [ + "VERSION" + ] + } } } diff --git a/packages/sui-segment-wrapper/src/segmentWrapper.js b/packages/sui-segment-wrapper/src/segmentWrapper.js index ed2c98b8c..70d3cfceb 100644 --- a/packages/sui-segment-wrapper/src/segmentWrapper.js +++ b/packages/sui-segment-wrapper/src/segmentWrapper.js @@ -127,6 +127,7 @@ export const decorateContextWithNeededData = async ({event = '', context = {}}) getTrackIntegrations({gdprPrivacyValue, event}), getXandrId({gdprPrivacyValueAdvertising}) ]) + const version = process.env.VERSION if (!isGdprAccepted) { context.integrations = { @@ -146,7 +147,8 @@ export const decorateContextWithNeededData = async ({event = '', context = {}}) integrations: { ...context.integrations, ...integrations - } + }, + clientVersion: `segment-wrapper${version ? `@${version}` : ''}` } } From 8caf104d91fdebfd83df18effe95c3eee18ab907 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Date: Mon, 25 Nov 2024 16:16:19 +0100 Subject: [PATCH 2/3] feat(packages/sui-segment-wrapper): send version always --- packages/sui-segment-wrapper/src/segmentWrapper.js | 3 +-- packages/sui-segment-wrapper/test/segmentWrapperSpec.js | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/sui-segment-wrapper/src/segmentWrapper.js b/packages/sui-segment-wrapper/src/segmentWrapper.js index 70d3cfceb..f990e39fe 100644 --- a/packages/sui-segment-wrapper/src/segmentWrapper.js +++ b/packages/sui-segment-wrapper/src/segmentWrapper.js @@ -127,7 +127,6 @@ export const decorateContextWithNeededData = async ({event = '', context = {}}) getTrackIntegrations({gdprPrivacyValue, event}), getXandrId({gdprPrivacyValueAdvertising}) ]) - const version = process.env.VERSION if (!isGdprAccepted) { context.integrations = { @@ -148,7 +147,7 @@ export const decorateContextWithNeededData = async ({event = '', context = {}}) ...context.integrations, ...integrations }, - clientVersion: `segment-wrapper${version ? `@${version}` : ''}` + clientVersion: `segment-wrapper@${process.env.VERSION ?? '0.0.0'}` } } diff --git a/packages/sui-segment-wrapper/test/segmentWrapperSpec.js b/packages/sui-segment-wrapper/test/segmentWrapperSpec.js index e3dd00276..3bf1cb7c4 100644 --- a/packages/sui-segment-wrapper/test/segmentWrapperSpec.js +++ b/packages/sui-segment-wrapper/test/segmentWrapperSpec.js @@ -755,7 +755,8 @@ describe('Segment Wrapper', function () { gdpr_privacy_advertising: 'declined', context: { integrations - } + }, + clientVersion: 'segment-wrapper@0.0.0' } const {traits} = spy.getCall(0).firstArg.obj.context From f522f3aaa8bf4d0e161f3ccb4ce3e487fb635542 Mon Sep 17 00:00:00 2001 From: Kiko Ruiz Date: Mon, 25 Nov 2024 17:31:56 +0100 Subject: [PATCH 3/3] feat(packages/sui-segment-wrapper): set version on lib compilation --- packages/sui-segment-wrapper/package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/sui-segment-wrapper/package.json b/packages/sui-segment-wrapper/package.json index 82b21a06f..94a78547c 100644 --- a/packages/sui-segment-wrapper/package.json +++ b/packages/sui-segment-wrapper/package.json @@ -5,7 +5,9 @@ "main": "lib/index.js", "scripts": { "lib": "sui-js-compiler", + "postlib": "npm run set:version", "prepublishOnly": "npm run umd && npm run lib", + "set:version": "sed -i.bak \"s/process\\.env\\.VERSION/\\\"$npm_package_version\\\"/g\" lib/segmentWrapper.js && rm lib/segmentWrapper.js.bak", "test:client:watch": "npm run test:client -- --watch", "test:client": "sui-test browser --src-pattern=src/index.js -H", "test": "npm run test:client",