Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into beta/events-queue-fix…
Browse files Browse the repository at this point in the history
…-opt-1
  • Loading branch information
saikumarrs committed Dec 25, 2024
2 parents 85f3969 + 93818fe commit 4857797
Show file tree
Hide file tree
Showing 95 changed files with 2,312 additions and 1,343 deletions.
173 changes: 88 additions & 85 deletions .github/workflows/deploy.yml

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion .github/workflows/draft-new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ env:
NODE_OPTIONS: '--no-warnings'

jobs:
validate-actor:
# Only allow to draft a new release from develop and hotfix branches
if: github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/hotfix/')
uses: ./.github/workflows/validate-actor.yml
secrets:
PAT: ${{ secrets.PAT }}

draft-new-release:
needs: validate-actor
name: Draft a new release
runs-on: [self-hosted, Linux, X64]
if: github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/hotfix/')
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/rollback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ on:
workflow_dispatch:

jobs:
validate-actor:
# Only allow to be deployed from tags and main branch
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'
uses: ./.github/workflows/validate-actor.yml
secrets:
PAT: ${{ secrets.PAT }}

deploy:
needs: validate-actor
name: Rollback production deployment
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'
uses: ./.github/workflows/deploy.yml
with:
environment: 'production'
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/update-cache-policy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Update cache control policy

on:
workflow_dispatch:
inputs:
policy_type:
type: choice
description: Select the cache control policy type
required: true
options:
- no-store
- max-age=3600

permissions:
id-token: write # allows the JWT to be requested from GitHub's OIDC provider
contents: read # This is required for actions/checkout

jobs:
validate-actor:
# Only allow to be deployed from tags and main branch
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'
uses: ./.github/workflows/validate-actor.yml
secrets:
PAT: ${{ secrets.PAT }}

update-cache-policy:
needs: validate-actor
name: Update cache control policy for SDK artifacts
runs-on: [self-hosted, Linux, X64]

steps:
- name: Install AWS CLI
uses: unfor19/install-aws-cli-action@master

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_PROD_ACCOUNT_ID }}:role/${{ secrets.AWS_PROD_S3_SYNC_ROLE }}
aws-region: us-east-1

- name: Determine the cache control policy
id: determine_policy
run: |
echo "cache_control_policy=${{ github.event.inputs.policy_type || inputs.policy_type }}" >> $GITHUB_ENV
- name: Update cache control policy
run: |
# Get the number of CPU cores in the runner and leave one core free
num_cores=$(nproc --ignore=1 || echo 1) # Default to 1 if nproc is unavailable
# Use a factor to set the parallel jobs (e.g., number of cores or slightly lower)
parallel_jobs=$((num_cores * 2))
echo "Detected $num_cores cores. Using $parallel_jobs parallel jobs."
prefixes=("adobe-analytics-js" "v3" "v1.1")
for prefix in "${prefixes[@]}"; do
echo "Processing prefix: $prefix"
aws s3api list-objects --bucket ${{ secrets.AWS_PROD_S3_BUCKET_NAME }} --prefix "$prefix" --query "Contents[].Key" --output text | tr '\t' '\n' | \
parallel --retries 10 -j "$parallel_jobs" "aws s3api copy-object \
--bucket ${{ secrets.AWS_PROD_S3_BUCKET_NAME }} \
--copy-source ${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/{} \
--key {} \
--metadata-directive REPLACE \
--cache-control '${{ env.cache_control_policy }}'"
done
30 changes: 30 additions & 0 deletions .github/workflows/validate-actor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Validate Actor

on:
workflow_call:
secrets:
PAT:
required: true

jobs:
validate-actor:
runs-on: [self-hosted, Linux, X64]
steps:
- name: Validate if actor is allowed to trigger the workflow
env:
ORG_NAME: rudderlabs
TEAM_NAME: js-sdk
run: |
actor=${{ github.actor || github.triggering_actor }}
response=$(curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/${{ env.ORG_NAME }}/teams/${{ env.TEAM_NAME }}/memberships/$actor)
if echo "$response" | grep -q '"state": "active"'; then
echo "$actor is a member of $TEAM_NAME team"
else
echo "$actor is NOT a member of $TEAM_NAME team"
exit 1
fi
45 changes: 24 additions & 21 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.66.0",
"version": "3.70.0",
"private": true,
"description": "Monorepo for RudderStack Analytics JS SDK",
"workspaces": [
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics-js-common/.size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ module.exports = [
{
name: 'Common - No bundling',
path: 'dist/npm/**/*.js',
limit: '16.5 KiB',
limit: '17.2 KiB',
},
];
14 changes: 14 additions & 0 deletions packages/analytics-js-common/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

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

## [3.14.14](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected]...@rudderstack/[email protected]) (2024-12-17)


### Bug Fixes

* remove circular dependency in packages ([#1973](https://github.com/rudderlabs/rudder-sdk-js/issues/1973)) ([e525496](https://github.com/rudderlabs/rudder-sdk-js/commit/e5254964310c2c73baaf4d0655c3e4025c5e7d2b))

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


### Bug Fixes

* integration constants file type ([#1958](https://github.com/rudderlabs/rudder-sdk-js/issues/1958)) ([e0f6ff2](https://github.com/rudderlabs/rudder-sdk-js/commit/e0f6ff28f3b02d56e862e01d308653e2178eec43))

## [3.14.12](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected]...@rudderstack/[email protected]) (2024-11-22)


Expand Down
4 changes: 2 additions & 2 deletions packages/analytics-js-common/CHANGELOG_LATEST.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## [3.14.12](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected].11...@rudderstack/[email protected].12) (2024-11-22)
## [3.14.14](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected].13...@rudderstack/[email protected].14) (2024-12-17)


### Bug Fixes

* revert temp utility ([2f60cae](https://github.com/rudderlabs/rudder-sdk-js/commit/2f60caeea0dc9944bf9434d5981952c8e85eef38))
* remove circular dependency in packages ([#1973](https://github.com/rudderlabs/rudder-sdk-js/issues/1973)) ([e525496](https://github.com/rudderlabs/rudder-sdk-js/commit/e5254964310c2c73baaf4d0655c3e4025c5e7d2b))

Empty file.
10 changes: 10 additions & 0 deletions packages/analytics-js-common/__mocks__/BufferQueue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class BufferQueue<T> {
items: T[] = [];
enqueue = jest.fn();
dequeue = jest.fn();
isEmpty = jest.fn();
size = jest.fn();
clear = jest.fn();
}

export { BufferQueue };
16 changes: 16 additions & 0 deletions packages/analytics-js-common/__mocks__/ErrorHandler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { IErrorHandler, PreLoadErrorData } from '../src/types/ErrorHandler';
import { BufferQueue } from './BufferQueue';

// Mock all the methods of the ErrorHandler class
class ErrorHandler implements IErrorHandler {
onError = jest.fn();
leaveBreadcrumb = jest.fn();
notifyError = jest.fn();
init = jest.fn();
attachErrorListeners = jest.fn();
errorBuffer = new BufferQueue<PreLoadErrorData>();
}

const defaultErrorHandler = new ErrorHandler();

export { ErrorHandler, defaultErrorHandler };
18 changes: 18 additions & 0 deletions packages/analytics-js-common/__mocks__/Logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { ILogger } from '../src/types/Logger';

class Logger implements ILogger {
warn = jest.fn();
log = jest.fn();
error = jest.fn();
info = jest.fn();
debug = jest.fn();
minLogLevel = 0;
scope = 'test scope';
setMinLogLevel = jest.fn();
setScope = jest.fn();
logProvider = console;
}

const defaultLogger = new Logger();

export { Logger, defaultLogger };
Loading

0 comments on commit 4857797

Please sign in to comment.