Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(segment-wrapper): send client version as a context property #1877

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Member Author

@kikoruiz kikoruiz Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sets package version by manipulating the compiled file that uses the process.env.VERSION, this script is compatible between Linux and macOS platforms.

"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