diff --git a/.github/workflows/deploy-beta.yml b/.github/workflows/deploy-beta.yml index c2bf34d18..a0b9d5c1a 100644 --- a/.github/workflows/deploy-beta.yml +++ b/.github/workflows/deploy-beta.yml @@ -163,6 +163,7 @@ jobs: trigger_source: ${{ needs.get-deploy-inputs.outputs.trigger_source }} secrets: RS_PROD_BUGSNAG_API_KEY: ${{ secrets.RS_PROD_BUGSNAG_API_KEY }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} SLACK_RELEASE_CHANNEL_ID: ${{ secrets.SLACK_RELEASE_CHANNEL_ID_NON_PROD }} diff --git a/.github/workflows/deploy-npm.yml b/.github/workflows/deploy-npm.yml index bccece34d..0e34bf41c 100644 --- a/.github/workflows/deploy-npm.yml +++ b/.github/workflows/deploy-npm.yml @@ -40,6 +40,8 @@ on: secrets: RS_PROD_BUGSNAG_API_KEY: required: true + NPM_TOKEN: + required: true SLACK_BOT_TOKEN: required: true SLACK_RELEASE_CHANNEL_ID: @@ -156,12 +158,14 @@ jobs: - name: Publish package to NPM env: HUSKY: 0 + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_CONFIG_PROVENANCE: true run: | # Remove unnecessary fields from package.json before publishing ./scripts/make-package-json-publish-ready.sh - npx nx release publish --base=${{ env.last_monorepo_version }} --head=${{ env.current_monorepo_version }} ${{ inputs.environment == 'beta' && '--tag=beta' || '' }} + npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} + npx nx release publish --verbose --base=${{ env.last_monorepo_version }} --head=${{ env.current_monorepo_version }} ${{ inputs.environment == 'beta' && '--tag=beta' || '' }} # Reset the changes made to package.json git reset --hard @@ -202,8 +206,10 @@ jobs: - 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. While your events are still being tracked and delivered, we strongly recommend you to 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/." diff --git a/.github/workflows/publish-new-release.yml b/.github/workflows/publish-new-release.yml index b391387cd..4c17ae7ff 100644 --- a/.github/workflows/publish-new-release.yml +++ b/.github/workflows/publish-new-release.yml @@ -269,6 +269,7 @@ jobs: monorepo_release_version: ${{ needs.get-release-inputs.outputs.release_version }} release_ticket_id: ${{ needs.get-release-inputs.outputs.release_ticket_id }} secrets: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} RS_PROD_BUGSNAG_API_KEY: ${{ secrets.RS_PROD_BUGSNAG_API_KEY }} SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} SLACK_RELEASE_CHANNEL_ID: ${{ secrets.SLACK_RELEASE_CHANNEL_ID }} diff --git a/.github/workflows/rollback.yml b/.github/workflows/rollback.yml index af65fda1b..233d21cad 100644 --- a/.github/workflows/rollback.yml +++ b/.github/workflows/rollback.yml @@ -166,12 +166,14 @@ jobs: - name: Deprecate the rolled back NPM version continue-on-error: true env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_CONFIG_PROVENANCE: true run: | VERSION_TO_DEPRECATE="${{ env.CURRENT_VERSION_VALUE }}" echo "Deprecating NPM version: $VERSION_TO_DEPRECATE" # Deprecate the specified version with a message + npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} npm deprecate "@rudderstack/analytics-js@$VERSION_TO_DEPRECATE" "We've identified issues with this version of the package. Please switch to v${{ env.ROLLBACK_VERSION_VALUE }} or the latest version if available." # Note: The legacy SDK is not deprecated as it is deprecated by default with every release. diff --git a/packages/analytics-js-plugins/__tests__/xhrQueue/index.test.ts b/packages/analytics-js-plugins/__tests__/xhrQueue/index.test.ts index 29472c3b5..4855edd7e 100644 --- a/packages/analytics-js-plugins/__tests__/xhrQueue/index.test.ts +++ b/packages/analytics-js-plugins/__tests__/xhrQueue/index.test.ts @@ -213,6 +213,7 @@ describe('XhrQueue', () => { attemptNumber: 1, lastAttemptedAt: expect.any(Number), firstAttemptedAt: expect.any(Number), + reclaimed: undefined, id: 'sample_uuid', time: 1 + 1000 * 2 ** 1, // this is the delay calculation in RetryQueue type: 'Single', @@ -391,6 +392,7 @@ describe('XhrQueue', () => { event: mergeDeepRight(event, { sentAt: 'sample_timestamp' }), }, attemptNumber: 1, + reclaimed: undefined, lastAttemptedAt: expect.any(Number), firstAttemptedAt: expect.any(Number), id: 'sample_uuid', @@ -498,6 +500,7 @@ describe('XhrQueue', () => { event: mergeDeepRight(event, { sentAt: 'sample_timestamp' }), }, attemptNumber: 1, + reclaimed: undefined, lastAttemptedAt: expect.any(Number), firstAttemptedAt: expect.any(Number), id: 'sample_uuid', diff --git a/packages/analytics-js-plugins/src/xhrQueue/index.ts b/packages/analytics-js-plugins/src/xhrQueue/index.ts index 10dc32ece..e2cc50d1d 100644 --- a/packages/analytics-js-plugins/src/xhrQueue/index.ts +++ b/packages/analytics-js-plugins/src/xhrQueue/index.ts @@ -31,6 +31,7 @@ import { isErrRetryable, isUndefined, LOCAL_STORAGE, + MEMORY_STORAGE, toBase64, validateEventPayloadSize, } from '../shared-chunks/common'; @@ -124,7 +125,8 @@ const XhrQueue = (): ExtensionPlugin => ({ }); }, storeManager, - LOCAL_STORAGE, + // If local storage is available, use it, else use memory storage + state.capabilities.storage.isLocalStorageAvailable.value ? LOCAL_STORAGE : MEMORY_STORAGE, logger, (itemData: XHRQueueItemData[]): number => { const currentTime = getCurrentTimeFormatted();