Skip to content

Commit

Permalink
Merge pull request #1877 from SUI-Components/client-version
Browse files Browse the repository at this point in the history
feat(segment-wrapper): send client version as a context property
  • Loading branch information
kikoruiz authored Nov 26, 2024
2 parents a3caecb + f522f3a commit 31c07c9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 10 additions & 1 deletion packages/sui-segment-wrapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
"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",
"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",
Expand All @@ -22,5 +24,12 @@
"@s-ui/bundler": "9",
"@s-ui/js-compiler": "1",
"@s-ui/test": "8"
},
"config": {
"sui-bundler": {
"env": [
"VERSION"
]
}
}
}
3 changes: 2 additions & 1 deletion packages/sui-segment-wrapper/src/segmentWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ export const decorateContextWithNeededData = async ({event = '', context = {}})
integrations: {
...context.integrations,
...integrations
}
},
clientVersion: `segment-wrapper@${process.env.VERSION ?? '0.0.0'}`
}
}

Expand Down
3 changes: 2 additions & 1 deletion packages/sui-segment-wrapper/test/segmentWrapperSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,8 @@ describe('Segment Wrapper', function () {
gdpr_privacy_advertising: 'declined',
context: {
integrations
}
},
clientVersion: '[email protected]'
}
const {traits} = spy.getCall(0).firstArg.obj.context

Expand Down

0 comments on commit 31c07c9

Please sign in to comment.