Skip to content

Commit 7accad2

Browse files
aalkhodirysileskyneelkanth-kaushikchenxzhanggithub-actions[bot]
authored
sync (#1)
* Small repo chores (segmentio#1289) * Migrate consent integration tests to Playwright (segmentio#1292) Co-authored-by: Neelkanth Kaushik <[email protected]> * Fix jira automation (segmentio#1301) * Update Node.js version to ^20 across the repository (segmentio#1307) * Expose BaseUserTraits (segmentio#1306) * change to minor release (segmentio#1310) * Version Packages (segmentio#1309) * Update to use new signals specification (segmentio#1311) * Move signals packages out of repo (segmentio#1315) * Add architecture documentation (segmentio#1319) * Update dependencies for snyk issues (segmentio#1321) * Remove github signals docs folder (segmentio#1322) * Fix filtering of non-consented device mode integrations (segmentio#1328) * Version Packages (segmentio#1329) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update RELEASING.md on how to rotate npm tokens (segmentio#1330) --------- Co-authored-by: Seth Silesky <[email protected]> Co-authored-by: Neelkanth Kaushik <[email protected]> Co-authored-by: Chenxiang Zhang <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 958cdc8 commit 7accad2

File tree

280 files changed

+2220
-22284
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

280 files changed

+2220
-22284
lines changed

.buildkite/pipeline.yml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,29 +149,21 @@ steps:
149149
plugins:
150150
- ssh://[email protected]/segmentio/cache-buildkite-plugin#v2.0.0:
151151
key: "v1.1-cache-dev-{{ checksum 'yarn.lock' }}"
152-
153-
- label: '[Signals] Lint + Test'
152+
153+
- label: '[Consent] Integration Tests'
154154
agents:
155155
queue: v1
156156
commands:
157157
- npm config set "//registry.npmjs.org/:_authToken" $${NPM_TOKEN}
158158
- echo "--- Install dependencies"
159159
- HUSKY=0 yarn install --immutable
160-
- echo "--- Build bundles"
161-
- yarn turbo run --filter='./packages/signals/*' build
162-
- echo "+++ Assert Generated Files Up-to-Date"
163-
- yarn turbo run --filter='./packages/signals/*' assert-generated
164-
- echo "+++ Run Lint"
165-
- yarn turbo run --filter='./packages/signals/*' lint
166-
- echo "+++ Run Tests"
167-
- yarn turbo run --filter='./packages/signals/*' test
168-
- echo "+++ Run Integration Tests"
169-
- yarn turbo run --filter='./packages/signals/*' test:int
160+
- echo "--- Build + Test"
161+
- yarn turbo run --filter='./packages/consent/consent-tools-integration-tests' test:int
162+
170163
plugins:
171164
- ssh://[email protected]/segmentio/cache-buildkite-plugin#v2.0.0:
172165
key: "v1.1-cache-dev-{{ checksum 'yarn.lock' }}"
173-
paths: ['.yarn/cache/']
174-
166+
175167
- label: ':thisisfine: [Browser] Destinations QA / E2E'
176168
key: destinations
177169
agents:

.eslintrc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/** @type { import('eslint').Linter.Config } */
22
module.exports = {
33
root: true,
4-
ignorePatterns: ['node_modules', 'dist'],
4+
ignorePatterns: require('eslint-gitignore').readGitignoreFiles({
5+
cwd: __dirname,
6+
}),
57
parserOptions: {
68
ecmaVersion: 2020,
79
},

.github/workflows/ci.yml

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
node-version: [18]
13+
node-version: [20]
1414
steps:
1515
- uses: actions/checkout@v3
1616
- uses: actions/setup-node@v3
@@ -39,7 +39,7 @@ jobs:
3939
runs-on: ubuntu-latest
4040
strategy:
4141
matrix:
42-
node-version: [18]
42+
node-version: [20]
4343
steps:
4444
- uses: actions/checkout@v3
4545
- uses: actions/setup-node@v3
@@ -55,23 +55,3 @@ jobs:
5555
restore-keys: |
5656
${{ runner.os }}-turbo-
5757
- run: yarn turbo run --filter='./packages/node-integration-tests' test:cloudflare-workers
58-
consent-intg-tests:
59-
name: Consent Integration Tests
60-
runs-on: ubuntu-latest
61-
steps:
62-
- uses: actions/checkout@v3
63-
64-
- uses: browser-actions/setup-chrome@v1
65-
- uses: actions/setup-node@v3
66-
with:
67-
node-version: 16 # UPDATE TO NODE 20!!!
68-
cache: 'yarn'
69-
- run: yarn install --immutable
70-
- name: Turbo cache
71-
uses: actions/cache@v3
72-
with:
73-
path: node_modules/.cache/turbo
74-
key: ${{ runner.os }}-turbo-${{ github.sha }}
75-
restore-keys: |
76-
${{ runner.os }}-turbo-
77-
- run: yarn turbo run --filter='./packages/consent/consent-tools-integration-tests' test:int

.github/workflows/create-jira.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,18 @@ jobs:
1919
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
2020
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
2121
JIRA_API_TOKEN: ${{ secrets.JIRA_TOKEN }}
22-
2322
- name: Create
2423
id: create
2524
uses: atlassian/gajira-create@master
2625
with:
27-
project: LIBRARIES
26+
project: ${{ secrets.JIRA_PROJECT }}
2827
issuetype: Bug
2928
summary: |
3029
[${{ github.event.repository.name }}] (${{ github.event.issue.number }}): ${{ github.event.issue.title }}
3130
description: |
3231
Github Link: ${{ github.event.issue.html_url }}
3332
${{ github.event.issue.body }}
34-
# Parent and Epic Link fields (set to same)
35-
fields: '{
36-
"parent": {"key": "LIBRARIES-1963"},
37-
"customfield_10002": "LIBRARIES-1963"
38-
}'
39-
33+
fields: '{"parent": {"key": "${{ secrets.JIRA_EPIC_KEY }}"}}'
34+
4035
- name: Log created issue
4136
run: echo "Issue ${{ steps.create.outputs.issue }} was created"

.vscode/launch.json

Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,76 +4,64 @@
44
{
55
"type": "node",
66
"request": "launch",
7-
"name": "Jest Current File",
8-
"program": "${workspaceFolder}/node_modules/.bin/jest",
9-
"args": ["--testTimeout=100000", "--findRelatedTests", "${relativeFile}"],
10-
"console": "integratedTerminal",
11-
"internalConsoleOptions": "neverOpen",
12-
"skipFiles": ["<node_internals>/**"]
13-
},
14-
{
15-
"type": "node",
16-
"request": "launch",
17-
"name": "Jest Watch Current File",
7+
"name": "Jest - run only related tests for current file",
188
"program": "${workspaceFolder}/node_modules/.bin/jest",
199
"args": [
2010
"--testTimeout=100000",
21-
"--watch",
2211
"--findRelatedTests",
23-
"${relativeFile}"
12+
"--runInBand",
13+
"--verbose",
14+
"${relativeFile}",
15+
"${input:additionalJestArgs}"
2416
],
2517
"console": "integratedTerminal",
2618
"internalConsoleOptions": "neverOpen",
2719
"skipFiles": ["<node_internals>/**"]
2820
},
2921
{
30-
"name": "Run Jest Tests for Current Package",
22+
"name": "Jest - run _all_ tests for current file's package",
3123
"type": "node",
3224
"request": "launch",
3325
"program": "${workspaceFolder}/node_modules/.bin/jest",
34-
"args": ["--testTimeout=100000"],
35-
"console": "integratedTerminal",
36-
"internalConsoleOptions": "neverOpen",
37-
"cwd": "${fileDirname}"
38-
},
39-
{
40-
"type": "node",
41-
"name": "Jest All",
42-
"request": "launch",
43-
"args": [
44-
"--testTimeout=100000",
45-
"-c",
46-
"${workspaceFolder}/jest.config.js"
47-
],
48-
"cwd": "${workspaceFolder}",
49-
"console": "integratedTerminal",
50-
"internalConsoleOptions": "neverOpen",
51-
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
52-
"skipFiles": ["<node_internals>/**"]
53-
},
54-
{
55-
"type": "node",
56-
"name": "Jest All: Browser",
57-
"request": "launch",
5826
"args": [
5927
"--testTimeout=100000",
60-
"-c",
61-
"${workspaceFolder}/packages/browser/jest.config.js"
28+
"--runInBand",
29+
"${input:additionalJestArgs}"
6230
],
63-
"cwd": "${workspaceFolder}",
6431
"console": "integratedTerminal",
6532
"internalConsoleOptions": "neverOpen",
66-
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
67-
"skipFiles": ["<node_internals>/**"]
33+
"skipFiles": ["<node_internals>/**"],
34+
"cwd": "${fileDirname}"
6835
},
6936
{
70-
"name": "ts-node Current File",
37+
"name": "ts-node - execute current .ts file/script",
7138
"type": "node",
7239
"request": "launch",
7340
"args": ["${relativeFile}"],
7441
"runtimeArgs": ["-r", "ts-node/register"],
7542
"cwd": "${workspaceRoot}",
7643
"internalConsoleOptions": "openOnSessionStart"
7744
}
45+
],
46+
"inputs": [
47+
{
48+
"id": "additionalJestArgs",
49+
"type": "pickString",
50+
"description": "(Optional) Select additional Jest arguments",
51+
"options": [
52+
{ "label": "none", "value": "" },
53+
{ "label": "", "value": "--watch" },
54+
{ "label": "", "value": "--updateSnapshot" },
55+
{ "label": "", "value": "--coverage" },
56+
{ "label": "", "value": "--runInBand" }
57+
],
58+
"default": ""
59+
},
60+
{
61+
"id": "packageName",
62+
"type": "pickString",
63+
"description": "Select a package to debug",
64+
"options": ["@segment/analytics-", "package-b", "package-c"]
65+
}
7866
]
7967
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ This library is one of Segment’s most popular Flagship libraries. It is active
3535

3636
- Contribution guidelines: [CONTRIBUTING.md](CONTRIBUTING.md)
3737
- Development instructions: [DEVELOPMENT.md](DEVELOPMENT.md)
38+
- Releasing (to npm): [RELEASING.md](RELEASING.md)

RELEASING.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,42 @@ yarn release
8080
Feature branches are automatically released under:
8181

8282
- `http://cdn.segment.com/analytics-next/br/<branch>/<latest|sha>/standalone.js.gz`
83+
84+
## NPM Token Management
85+
86+
### How to Rotate/Update NPM Tokens
87+
88+
The repository uses an NPM token stored in GitHub Actions secrets (`NPM_TOKEN`) to publish packages automatically. Due to npm's security updates, tokens now have a maximum 90-day lifetime and classic tokens will be revoked. You should use **Granular Access Tokens** for better security.
89+
90+
#### Creating a New NPM Token
91+
92+
1. **Generate a new token at npm**:
93+
- Go to https://www.npmjs.com/settings/YOUR_USERNAME/tokens
94+
- Click "Generate New Token" → "Granular Access Token"
95+
- Configure the token:
96+
- **Token Name**: Something descriptive like "analytics-next-ci"
97+
- **Expiration**: 90 days (maximum)
98+
- **Permissions**: Select "Read and write"
99+
- **Packages and scopes**: Select packages in `@segment` organization
100+
- Copy the token (starts with `npm_`)
101+
102+
2. **Test the token locally**:
103+
```bash
104+
# Add token to your ~/.npmrc
105+
echo "//registry.npmjs.org/:_authToken=YOUR_NEW_TOKEN" > ~/.npmrc
106+
107+
# Verify authentication
108+
npm whoami
109+
110+
# Build packages
111+
yarn build
112+
113+
# Test dry-run publish (doesn't actually publish)
114+
cd packages/core && npm publish --dry-run
115+
cd ../browser && npm publish --dry-run
116+
cd ../node && npm publish --dry-run
117+
```
118+
119+
3. **Update GitHub Actions Secret**:
120+
- Go to: https://github.com/segmentio/analytics-next/settings/secrets/actions
121+
- Update secret for `NPM_TOKEN`

jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ module.exports = () =>
1717
'<rootDir>/packages/consent/consent-tools',
1818
'<rootDir>/packages/consent/consent-wrapper-onetrust',
1919
'<rootDir>/scripts',
20-
'<rootDir>/packages/signals/signals',
2120
'<rootDir>/packages/test-helpers',
2221
],
2322
})

meta-tests/check-dts.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { exec } from 'child_process'
22
import { promisify } from 'util'
33
import path from 'path'
44
import fs from 'fs'
5+
import getPackages from 'get-monorepo-packages'
56

67
/**
78
* This script is for extra typechecking of the built .d.ts files in {package_name}/dist/types/*.
@@ -11,13 +12,18 @@ import fs from 'fs'
1112
*/
1213
const execa = promisify(exec)
1314

14-
const allPublicPackageDirNames = [
15-
'browser',
16-
'core',
17-
'node',
18-
'signals/signals',
19-
'signals/signals-runtime',
20-
] as const
15+
// Get public packages programmatically
16+
const packages = getPackages(path.join(__dirname, '..'))
17+
const publicPackageNames = [
18+
'@segment/analytics-next',
19+
'@segment/analytics-core',
20+
'@segment/analytics-node',
21+
]
22+
23+
const allPublicPackageDirNames = packages
24+
.filter((pkg) => publicPackageNames.includes(pkg.package.name))
25+
.map((pkg) => path.relative('packages', pkg.location))
26+
.sort() as readonly string[]
2127

2228
type PackageDirName = typeof allPublicPackageDirNames[number]
2329

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
"playgrounds/*",
77
"packages/*",
88
"packages/consent/*",
9-
"packages/signals/*",
109
"scripts"
1110
],
1211
"engines": {
13-
"node": "^20"
12+
"node": ">=20"
1413
},
1514
"scripts": {
1615
"test": "jest",
1716
"test:check-dts": "yarn build && yarn ts-node meta-tests/check-dts.ts",
1817
"test:node-int": "turbo run --filter=node-integration-tests test",
1918
"lint": "yarn constraints && turbo run lint --continue",
19+
"typecheck": "turbo run tsc --filter='./packages/**'",
2020
"build": "turbo run build --filter='./packages/**'",
2121
"watch": "turbo run watch --filter='./packages/**'",
2222
"dev": "yarn workspace @playground/next-playground run dev",
23-
"prepush": "turbo run lint --filter='...[master...HEAD]'",
23+
"prepush": "turbo run tsc --affected",
2424
"postinstall": "husky install",
2525
"changeset": "changeset",
2626
"update-versions-and-changelogs": "changeset version && yarn version-run-all && bash scripts/update-lockfile.sh",
@@ -49,6 +49,7 @@
4949
"concurrently": "^7.6.0",
5050
"eslint": "^8.14.0",
5151
"eslint-config-prettier": "^8.5.0",
52+
"eslint-gitignore": "^0.1.0",
5253
"eslint-plugin-import": "^2.27.5",
5354
"eslint-plugin-jest": "^27.2.2",
5455
"eslint-plugin-prettier": "^4.0.0",

0 commit comments

Comments
 (0)