Skip to content

Commit

Permalink
chore(release): pull main into develop post release v3.15.0 (#1764)
Browse files Browse the repository at this point in the history
  • Loading branch information
saikumarrs authored Jun 25, 2024
2 parents 7a8ea30 + 74dc02f commit de01ffc
Show file tree
Hide file tree
Showing 26 changed files with 186 additions and 69 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/deploy-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ jobs:
run: |
current_version_v1=$(jq -r .version packages/analytics-v1.1/package.json)
current_version_sw=$(jq -r .version packages/analytics-js-service-worker/package.json)
current_version_cookie_utils=$(jq -r .version packages/analytics-js-cookies/package.json)
current_version=$(jq -r .version packages/analytics-js/package.json)
echo "CURRENT_VERSION_V1_VALUE=$current_version_v1" >> $GITHUB_ENV
echo "CURRENT_VERSION_SW_VALUE=$current_version_sw" >> $GITHUB_ENV
echo "CURRENT_VERSION_COOKIE_UTILS_VALUE=$current_version_cookie_utils" >> $GITHUB_ENV
echo "CURRENT_VERSION_VALUE=$current_version" >> $GITHUB_ENV
- name: Get versions in NPM
Expand All @@ -59,6 +61,9 @@ jobs:
current_npm_version_sw=$(npm show @rudderstack/analytics-js-service-worker version 2>/dev/null || echo "not found")
echo "CURRENT_NPM_VERSION_SW=$current_npm_version_sw" >> $GITHUB_ENV
current_npm_version_cookie_utils=$(npm show @rudderstack/analytics-js-cookies version 2>/dev/null || echo "not found")
echo "CURRENT_NPM_VERSION_COOKIE_UTILS=$current_npm_version_cookie_utils" >> $GITHUB_ENV
- name: Setup Node
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -92,20 +97,28 @@ jobs:
- name: Get versions in NPM after publish
run: |
npm cache clean --force
new_npm_version=$(npm show @rudderstack/analytics-js version 2>/dev/null || echo "not found")
echo "NEW_NPM_VERSION=$new_npm_version" >> $GITHUB_ENV
new_npm_version_sw=$(npm show @rudderstack/analytics-js-service-worker version 2>/dev/null || echo "not found")
echo "NEW_NPM_VERSION_SW=$new_npm_version_sw" >> $GITHUB_ENV
new_npm_version_cookie_utils=$(npm show @rudderstack/analytics-js-cookies version 2>/dev/null || echo "not found")
echo "NEW_NPM_VERSION_COOKIE_UTILS=$new_npm_version_cookie_utils" >> $GITHUB_ENV
- name: Debug environment variables
continue-on-error: true
run: |
echo "CURRENT_NPM_VERSION=${{ env.CURRENT_NPM_VERSION }}"
echo "NEW_NPM_VERSION=${{ env.NEW_NPM_VERSION }}"
echo "CURRENT_NPM_VERSION_SW=${{ env.CURRENT_NPM_VERSION_SW }}"
echo "NEW_NPM_VERSION_SW=${{ env.NEW_NPM_VERSION_SW }}"
echo "CURRENT_NPM_VERSION_COOKIE_UTILS=${{ env.CURRENT_NPM_VERSION_COOKIE_UTILS }}"
echo "NEW_NPM_VERSION_COOKIE_UTILS=${{ env.NEW_NPM_VERSION_COOKIE_UTILS }}"
- name: Send message to Slack channel
if: env.CURRENT_NPM_VERSION != env.NEW_NPM_VERSION && env.NEW_NPM_VERSION != 'not found'
id: slack
Expand Down Expand Up @@ -205,3 +218,53 @@ jobs:
}
]
}
- name: Send message to Slack channel for cookie utilities
if: env.CURRENT_NPM_VERSION_COOKIE_UTILS != env.CURRENT_NPM_VERSION_COOKIE_UTILS && env.CURRENT_NPM_VERSION_COOKIE_UTILS != 'not found'
id: slack-cookie-utils
continue-on-error: true
uses: slackapi/[email protected]
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
PROJECT_NAME: 'JS SDK Cookies Utilities'
NPM_PACKAGE_URL: 'https://www.npmjs.com/package/@rudderstack/analytics-js-cookies'
RELEASES_URL: 'https://github.com/rudderlabs/rudder-sdk-js/releases/tag/@rudderstack/analytics-js-cookies@'
with:
channel-id: ${{ secrets.SLACK_RELEASE_CHANNEL_ID }}
payload: |
{
"text": "*New Release: ${{ env.PROJECT_NAME }} - <${{ env.NPM_PACKAGE_URL }}|${{ env.CURRENT_VERSION_COOKIE_UTILS_VALUE }}>*\n${{ env.DATE }}\nCC: <!subteam^S0555JBV36D>",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "New Release: ${{ env.PROJECT_NAME }}"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*<${{ env.NPM_PACKAGE_URL }}|v${{ env.CURRENT_VERSION_COOKIE_UTILS_VALUE }}>*\n${{ env.DATE }}\nCC: <!subteam^S0555JBV36D>"
},
"accessory": {
"type": "image",
"image_url": "https://img.icons8.com/color/452/npm.png",
"alt_text": "NPM Icon"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "For more details, check the full release notes <${{ env.RELEASES_URL }}${{ env.CURRENT_VERSION_COOKIE_UTILS_VALUE }}|here>."
}
]
}
]
}
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rudderstack/analytics-js-monorepo",
"version": "3.14.0",
"version": "3.15.0",
"private": true,
"description": "Monorepo for RudderStack Analytics JS SDK",
"workspaces": [
Expand Down
7 changes: 7 additions & 0 deletions packages/analytics-js-cookies/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [0.2.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected]...@rudderstack/[email protected]) (2024-06-25)


### Features

* add getDecryptedValue utility ([#1762](https://github.com/rudderlabs/rudder-sdk-js/issues/1762)) ([04cf7e9](https://github.com/rudderlabs/rudder-sdk-js/commit/04cf7e996a6dd09e6c83fff8606135c3941d34c8))

## 0.1.0 (2024-06-25)

### Dependency Updates
Expand Down
10 changes: 2 additions & 8 deletions packages/analytics-js-cookies/CHANGELOG_LATEST.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
## 0.1.0 (2024-06-25)
## [0.2.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-cookies@0.1.0...@rudderstack/[email protected]) (2024-06-25)

### Dependency Updates

* `@rudderstack/analytics-js-common` updated to version `0.1.0`

### Features

* create new package for cookie utilities ([#1759](https://github.com/rudderlabs/rudder-sdk-js/issues/1759)) ([92826a4](https://github.com/rudderlabs/rudder-sdk-js/commit/92826a4f2e87dd2d0d755016592e36e4708f34d4))

# Changelog
* add getDecryptedValue utility ([#1762](https://github.com/rudderlabs/rudder-sdk-js/issues/1762)) ([04cf7e9](https://github.com/rudderlabs/rudder-sdk-js/commit/04cf7e996a6dd09e6c83fff8606135c3941d34c8))

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
21 changes: 18 additions & 3 deletions packages/analytics-js-cookies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@ RudderStack JavaScript SDK utility for cookies.

## APIs

### `getDecryptedValue`

This function decrypts the provided encrypted RudderStack JavaScript cookie value using the RudderStack JavaScript SDK encryption version "v3".

> The encrypted value should be a string starting with `RS_ENC_v3_`.
> If the provided value is not properly encrypted, the function will throw an exception.
```javascript
import { decrypt } from '@rudderstack/analytics-js-cookies';

const encryptedCookieValue = 'RS_ENC_v3_InRlc3QtZGF0YSI=';
const decryptedCookieValue = decrypt(encryptedCookieValue);
console.log('Decrypted Cookie Value: ', decryptedCookieValue);
// Output: Decrypted Cookie Value: test-data
```

### `getDecryptedCookie`

This function decrypts and returns the RudderStack JavaScript SDK cookie values.
Expand All @@ -39,11 +56,10 @@ It returns `null` in either of the following scenarios:
- If the decrypted cookie value is not a valid JSON string.
- If the provided cookie name is not a valid RudderStack JavaScript SDK cookie name.

> If unencrypted, the cookie value will be returned as is.
> Any errors during decryption are swallowed by the function, returning `null`.
The following are the available cookie key exports:

- `userIdKey`: The key for the user ID cookie.
- `userTraitsKey`: The key for the user traits cookie.
- `anonymousUserIdKey`: The key for the anonymous user ID cookie.
Expand All @@ -54,7 +70,6 @@ The following are the available cookie key exports:
- `sessionInfoKey`: The key for the session ID cookie.
- `authTokenKey`: The key for the auth token cookie.


```javascript
import {
getDecryptedCookie,
Expand Down
24 changes: 23 additions & 1 deletion packages/analytics-js-cookies/__tests__/cookieUtilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
userIdKey,
userTraitsKey,
} from '../src';
import { encrypt, decrypt, getDecryptedCookie } from '../src/cookiesUtilities';
import { encrypt, decrypt, getDecryptedCookie, getDecryptedValue } from '../src/cookiesUtilities';

describe('Cookie Utilities', () => {
describe('encrypt', () => {
Expand Down Expand Up @@ -119,4 +119,26 @@ describe('Cookie Utilities', () => {
document.cookie = 'rl_auth_token=; expires=Thu, 01 Jan 1970 00:00:00 UTC';
});
});

describe('getDecryptedValue', () => {
it('should return the decrypted value', () => {
expect(getDecryptedValue('RS_ENC_v3_InRlc3QtZGF0YSI=')).toBe('test-data');
});

it('should return null if it is not encrypted', () => {
expect(getDecryptedValue('test-data')).toBeNull();
});

it('should return null if the value is not properly encrypted', () => {
expect(getDecryptedValue('RS_ENC_v3_InRlc3QtZGF0YSI-some-random-data')).toBeNull();
});

it('should return null if the input is null', () => {
expect(getDecryptedValue(null)).toBeNull();
});

it('should return null if the input is undefined', () => {
expect(getDecryptedValue(undefined)).toBeNull();
});
});
});
6 changes: 3 additions & 3 deletions packages/analytics-js-cookies/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@rudderstack/analytics-js-cookies",
"version": "0.1.0",
"description": "RudderStack JavaScript SDK Cookies Module",
"version": "0.2.0",
"description": "RudderStack JavaScript SDK Cookies Utilities",
"main": "dist/npm/modern/cjs/index.js",
"module": "dist/npm/modern/esm/index.js",
"exports": {
Expand Down Expand Up @@ -56,7 +56,7 @@
"build:browser": "exit 0",
"build:npm": "rollup -c --environment VERSION:$npm_package_version,ENV:prod,MODULE_TYPE:npm",
"build:npm:modern": "BROWSERSLIST_ENV=modern npm run build:npm",
"build:package": "npm run build:npm:modern",
"build:package": "npm run build:npm:modern && npm run build:npm",
"test": "nx test --maxWorkers=50%",
"test:ci": "nx test --parallel=false --configuration=ci --runInBand --maxWorkers=1 --forceExit",
"check:lint": "nx lint",
Expand Down
6 changes: 3 additions & 3 deletions packages/analytics-js-cookies/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@
"github": {
"executor": "@jscutlery/semver:github",
"options": {
"tag": "@rudderstack/analytics-js-cookies@0.1.0",
"title": "@rudderstack/analytics-js-cookies@0.1.0",
"discussion-category": "@rudderstack/analytics-js-cookies@0.1.0",
"tag": "@rudderstack/analytics-js-cookies@0.2.0",
"title": "@rudderstack/analytics-js-cookies@0.2.0",
"discussion-category": "@rudderstack/analytics-js-cookies@0.2.0",
"notesFile": "./packages/analytics-js-cookies/CHANGELOG_LATEST.md"
}
}
Expand Down
24 changes: 14 additions & 10 deletions packages/analytics-js-cookies/src/cookiesUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,26 @@ const decrypt = (value: string | undefined): string | undefined => {
return value;
};

const getDecryptedCookie = (cookieKey: string): Nullable<string | ApiObject> => {
const getDecryptedValue = (value: string): Nullable<string | ApiObject> => {
const fallbackValue = null;
try {
if (Object.values(COOKIE_KEYS).includes(cookieKey)) {
const decryptedVal = decrypt(cookie(cookieKey));

if (isNullOrUndefined(decryptedVal)) {
return fallbackValue;
}
const decryptedVal = decrypt(value);

return JSON.parse(decryptedVal as string);
if (isNullOrUndefined(decryptedVal)) {
return fallbackValue;
}
return fallbackValue;

return JSON.parse(decryptedVal as string);
} catch (err) {
return fallbackValue;
}
};

export { getDecryptedCookie, encrypt, decrypt };
const getDecryptedCookie = (cookieKey: string): Nullable<string | ApiObject> => {
if (Object.values(COOKIE_KEYS).includes(cookieKey)) {
return getDecryptedValue(cookie(cookieKey));
}
return null;
};

export { getDecryptedCookie, encrypt, decrypt, getDecryptedValue };
2 changes: 1 addition & 1 deletion packages/analytics-js-cookies/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { getDecryptedCookie } from './cookiesUtilities';
export { getDecryptedCookie, getDecryptedValue } from './cookiesUtilities';

export {
userIdKey,
Expand Down
6 changes: 6 additions & 0 deletions packages/analytics-js-plugins/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [3.2.1](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected]...@rudderstack/[email protected]) (2024-06-25)

### Dependency Updates

* `@rudderstack/analytics-js` updated to version `3.2.0`
* `@rudderstack/analytics-js-cookies` updated to version `3.2.0`
## [3.2.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected]...@rudderstack/[email protected]) (2024-06-25)

### Dependency Updates
Expand Down
11 changes: 3 additions & 8 deletions packages/analytics-js-plugins/CHANGELOG_LATEST.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
## [3.2.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.1.1...@rudderstack/[email protected].0) (2024-06-25)
## [3.2.1](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-plugins@3.2.0...@rudderstack/[email protected].1) (2024-06-25)

### Dependency Updates

* `@rudderstack/analytics-js` updated to version `3.1.1`
* `@rudderstack/analytics-js-cookies` updated to version `3.1.1`

### Features

* create new package for cookie utilities ([#1759](https://github.com/rudderlabs/rudder-sdk-js/issues/1759)) ([92826a4](https://github.com/rudderlabs/rudder-sdk-js/commit/92826a4f2e87dd2d0d755016592e36e4708f34d4))

* `@rudderstack/analytics-js` updated to version `3.2.0`
* `@rudderstack/analytics-js-cookies` updated to version `3.2.0`
2 changes: 1 addition & 1 deletion packages/analytics-js-plugins/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rudderstack/analytics-js-plugins",
"version": "3.2.0",
"version": "3.2.1",
"private": true,
"description": "RudderStack JavaScript SDK plugins",
"main": "dist/npm/modern/cjs/index.js",
Expand Down
Loading

0 comments on commit de01ffc

Please sign in to comment.