Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into hotfix/remove-circula…
Browse files Browse the repository at this point in the history
…r-dependency
  • Loading branch information
saikumarrs committed Dec 17, 2024
2 parents e525496 + a66553b commit 6db8024
Show file tree
Hide file tree
Showing 18 changed files with 253 additions and 116 deletions.
167 changes: 85 additions & 82 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
6 changes: 3 additions & 3 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.68.0",
"version": "3.69.0",
"private": true,
"description": "Monorepo for RudderStack Analytics JS SDK",
"workspaces": [
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.6.19](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected]...@rudderstack/[email protected]) (2024-12-13)

### Dependency Updates

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

### Dependency Updates
Expand Down
6 changes: 3 additions & 3 deletions packages/analytics-js-plugins/CHANGELOG_LATEST.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## [3.6.18](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected].17...@rudderstack/[email protected].18) (2024-12-06)
## [3.6.19](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected].18...@rudderstack/[email protected].19) (2024-12-13)

### Dependency Updates

* `@rudderstack/analytics-js-common` updated to version `3.14.13`
* `@rudderstack/analytics-js` updated to version `3.11.14`
* `@rudderstack/analytics-js` updated to version `3.11.15`
* `@rudderstack/analytics-js-cookies` updated to version `0.4.16`
9 changes: 7 additions & 2 deletions packages/analytics-js-plugins/__tests__/bugsnag/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ describe('Bugsnag utilities', () => {
initBugsnagClient(state, resolve, reject);
});

state.session.sessionInfo.value = { id: 123 };
state.autoTrack.pageLifecycle.visitId.value = 'test-visit-id';

// Advance time and mount the Bugsnag SDK
jest.advanceTimersByTime(1);
mountBugsnagSDK();
Expand Down Expand Up @@ -429,7 +432,7 @@ describe('Bugsnag utilities', () => {
maxBreadcrumbs: 40,
releaseStage: 'development',
user: {
id: 'dummy-source-id',
id: 'dummy-source-id..123..test-visit-id',
},
networkBreadcrumbsEnabled: false,
beforeSend: expect.any(Function),
Expand All @@ -441,6 +444,8 @@ describe('Bugsnag utilities', () => {
// @ts-expect-error source id is not defined for the test case
state.source.value = { id: undefined };
state.lifecycle.writeKey = signal('dummy-write-key');
state.session.sessionInfo.value = { id: 123 };
state.autoTrack.pageLifecycle.visitId.value = 'test-visit-id';

const bsClientPromise: Promise<BugsnagLib.Client> = new Promise((resolve, reject) => {
initBugsnagClient(state, resolve, reject);
Expand Down Expand Up @@ -472,7 +477,7 @@ describe('Bugsnag utilities', () => {
maxBreadcrumbs: 40,
releaseStage: 'development',
user: {
id: 'dummy-write-key',
id: 'dummy-write-key..123..test-visit-id',
},
networkBreadcrumbsEnabled: false,
beforeSend: expect.any(Function),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ describe('Plugin - ErrorReporting', () => {
id: 'test-source-id',
config: {},
}),
session: {
sessionInfo: signal({ id: 'test-session-id' }),
},
autoTrack: {
pageLifecycle: {
visitId: signal('test-visit-id'),
},
},
};

let state: any;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable max-classes-per-file */
import { signal } from '@preact/signals-core';
import type { ErrorEventPayload } from '@rudderstack/analytics-js-common/types/Metrics';
import { mergeDeepRight } from '@rudderstack/analytics-js-common/utilities/object';
import { ErrorFormat } from '../../src/errorReporting/event/event';
import * as errorReportingConstants from '../../src/errorReporting/constants';
import {
Expand Down Expand Up @@ -53,7 +54,6 @@ const DEFAULT_STATE_DATA = {
resolutionStrategy: 'and',
},
context: {
traits: null,
app: {
installType: 'cdn',
name: 'RudderLabs JavaScript SDK',
Expand Down Expand Up @@ -160,13 +160,6 @@ const DEFAULT_STATE_DATA = {
session: {
initialReferrer: '',
initialReferringDomain: '',
sessionInfo: {},
anonymousId: '',
authToken: '',
groupId: '',
groupTraits: {},
userId: '',
userTraits: {},
},
source: {
id: 'dummy-source-id',
Expand All @@ -177,10 +170,6 @@ const DEFAULT_STATE_DATA = {
migrate: false,
trulyAnonymousTracking: false,
},
eventBuffer: {
readyCallbacksArray: [],
toBeProcessedArray: [],
},
};

describe('Error Reporting utilities', () => {
Expand Down Expand Up @@ -319,7 +308,7 @@ describe('Error Reporting utilities', () => {
describe('getAppStateForMetadata', () => {
const origAppStateExcludes = errorReportingConstants.APP_STATE_EXCLUDE_KEYS;

beforeEach(() => {
afterEach(() => {
Object.defineProperty(errorReportingConstants, 'APP_STATE_EXCLUDE_KEYS', {
value: origAppStateExcludes,
writable: true,
Expand Down Expand Up @@ -464,6 +453,9 @@ describe('Error Reporting utilities', () => {

describe('getBugsnagErrorEvent', () => {
it('should return enhanced error event payload', () => {
state.session.sessionInfo.value = { id: 123 };
state.autoTrack.pageLifecycle.visitId.value = 'test-visit-id';

const newError = new Error();
const normalizedError = Object.create(newError, {
message: { value: 'ReferenceError: testUndefinedFn is not defined' },
Expand Down Expand Up @@ -531,13 +523,22 @@ describe('Error Reporting utilities', () => {
name: 'JS',
installType: 'cdn',
},
state: DEFAULT_STATE_DATA,
state: mergeDeepRight(DEFAULT_STATE_DATA, {
autoTrack: {
pageLifecycle: {
visitId: 'test-visit-id',
},
},
session: {
sessionInfo: { id: 123 },
},
}),
source: {
snippetVersion: 'sample_snippet_version',
},
},
user: {
id: 'dummy-source-id',
id: 'dummy-source-id..123..test-visit-id',
},
},
],
Expand Down
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.6.18",
"version": "3.6.19",
"private": true,
"description": "RudderStack JavaScript SDK plugins",
"main": "dist/npm/modern/cjs/index.cjs",
Expand Down
6 changes: 3 additions & 3 deletions packages/analytics-js-plugins/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
"github": {
"executor": "@jscutlery/semver:github",
"options": {
"tag": "@rudderstack/[email protected].18",
"title": "@rudderstack/[email protected].18",
"discussion-category": "@rudderstack/[email protected].18",
"tag": "@rudderstack/[email protected].19",
"title": "@rudderstack/[email protected].19",
"discussion-category": "@rudderstack/[email protected].19",
"notesFile": "./packages/analytics-js-plugins/CHANGELOG_LATEST.md"
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/analytics-js-plugins/src/bugsnag/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ const getNewClient = (state: ApplicationState, logger?: ILogger): BugsnagLib.Cli
maxBreadcrumbs: 40,
releaseStage: getReleaseStage(),
user: {
id: state.source.value?.id || state.lifecycle.writeKey.value,
// Combination of source, session and visit ids
id: `${state.source.value?.id ?? (state.lifecycle.writeKey.value as string)}..${state.session.sessionInfo.value?.id ?? 'NA'}..${state.autoTrack?.pageLifecycle?.visitId?.value ?? 'NA'}`,
},
logger,
networkBreadcrumbsEnabled: false,
Expand Down
3 changes: 2 additions & 1 deletion packages/analytics-js-plugins/src/errorReporting/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ const getBugsnagErrorEvent = (
},
},
user: {
id: state.source.value?.id ?? (state.lifecycle.writeKey.value as string),
// Combination of source, session and visit ids
id: `${state.source.value?.id ?? (state.lifecycle.writeKey.value as string)}..${state.session.sessionInfo.value?.id ?? 'NA'}..${state.autoTrack?.pageLifecycle?.visitId?.value ?? 'NA'}`,
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics-js/.size-limit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default [
name: 'Core - Legacy - NPM (CJS)',
path: 'dist/npm/legacy/cjs/index.cjs',
import: '*',
limit: '49 KiB',
limit: '49.1 KiB',
},
{
name: 'Core - Legacy - NPM (UMD)',
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sonar.qualitygate.wait=false
sonar.projectKey=rudderlabs_rudder-sdk-js
sonar.organization=rudderlabs
sonar.projectName=rudder-sdk-js
sonar.projectVersion=3.68.0
sonar.projectVersion=3.69.0

# Meta-data for the project
sonar.links.scm=https://github.com/rudderlabs/rudder-sdk-js
Expand Down

0 comments on commit 6db8024

Please sign in to comment.