Skip to content

Commit

Permalink
feat: add legacy sdk deprecation notices (#2026)
Browse files Browse the repository at this point in the history
* feat: add legacy sdk deprecation notices

* chore: fix postinstall script logic

* fix: use migration guide url

* chore: fix readme
  • Loading branch information
saikumarrs authored Jan 29, 2025
1 parent 2612935 commit 2a01152
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/deploy-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ jobs:
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: Deprecate the legacy SDK NPM package
continue-on-error: true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
run: |
npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
npm deprecate rudder-sdk-js "This package is deprecated and no longer maintained. Please migrate to the latest package, @rudderstack/analytics-js (https://www.npmjs.com/package/@rudderstack/analytics-js), for the latest features, security updates, and improved performance. For more details, visit the migration guide: https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-javascript-sdk/migration-guide/."
- 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
4 changes: 2 additions & 2 deletions packages/analytics-v1.1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

---

| :warning: This package is deprecated. Please switch to the latest [@rudderstack/analytics-js](https://www.npmjs.com/package/@rudderstack/analytics-js) package for improved features and support. <br>For more details, visit [link](https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-javascript-sdk/). |
| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| :warning: **This package is deprecated and no longer maintained.** Please migrate to the latest [@rudderstack/analytics-js](https://www.npmjs.com/package/@rudderstack/analytics-js) package for enhanced features, security updates, and ongoing support. <br/><br/>For more details, visit the [migration guide](https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-javascript-sdk/migration-guide/). |
| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

# RudderStack JavaScript SDK

Expand Down
11 changes: 11 additions & 0 deletions packages/analytics-v1.1/src/core/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,17 @@ const startSession = instance.startSession.bind(instance);
const endSession = instance.endSession.bind(instance);
const setAuthToken = instance.setAuthToken.bind(instance);

// eslint-disable-next-line no-constant-condition
if ('__MODULE_TYPE__' === 'npm') {
logger.error(
'This package is deprecated and no longer maintained. Please migrate to the latest [@rudderstack/analytics-js](https://www.npmjs.com/package/@rudderstack/analytics-js) package for enhanced features, security updates, and ongoing support. For more details, visit the migration guide: https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-javascript-sdk/migration-guide/.',
);
} else {
logger.error(
'This version of the RudderStack JavaScript SDK is deprecated and no longer maintained. Please migrate to the latest version (v3) for enhanced features, security updates, and ongoing support. For more details, visit the migration guide: https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-javascript-sdk/migration-guide/.',
);
}

export {
initialized,
ready,
Expand Down
7 changes: 7 additions & 0 deletions scripts/make-package-json-publish-ready.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@ for package in "$PACKAGES_DIR"/*; do
fi
done

# Add postinstall script to the legacy SDK package.json
legacy_sdk_package="$PACKAGES_DIR/analytics-v1.1"
package_json="$legacy_sdk_package/package.json"

echo "Adding postinstall script to $package_json..."
jq '.scripts = (.scripts // {}) | .scripts.postinstall = "echo '\''This package is deprecated and no longer maintained. Please migrate to the latest @rudderstack/analytics-js (https://www.npmjs.com/package/@rudderstack/analytics-js) package for enhanced features, security updates, and ongoing support. For more details, visit the migration guide: https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-javascript-sdk/migration-guide/'\''"' "$package_json" > "$legacy_sdk_package/package_cleaned.json" && mv "$legacy_sdk_package/package_cleaned.json" "$package_json"

echo "Cleaning completed for all packages."

0 comments on commit 2a01152

Please sign in to comment.