Skip to content

Commit

Permalink
Merge branch 'segmentio:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
illumin04 authored Oct 3, 2024
2 parents ef7615a + ab536b3 commit 718402c
Show file tree
Hide file tree
Showing 267 changed files with 11,707 additions and 1,075 deletions.
2 changes: 2 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ any of the tasks you completed below during your testing._

- [ ] Added [unit tests](https://github.com/segmentio/action-destinations/blob/main/docs/testing.md#local-end-to-end-testing) for new functionality
- [ ] Tested end-to-end using the [local server](https://github.com/segmentio/action-destinations/blob/main/docs/testing.md#local-end-to-end-testing)
- [ ] [If destination is already live] Tested for backward compatibility of destination. **Note:** New required fields are a breaking change.
- [ ] [Segmenters] Tested in the staging environment
- [ ] [Segmenters] [If applicable for this change] Tested for regression with Hadron.
12 changes: 12 additions & 0 deletions .github/REQUIRED_FIELD_WARNING_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!--REQUIRED_FIELD_DIFF-->

# New required fields detected

> [!WARNING]
> Your PR adds new required fields to an existing destination. Adding new required settings/mappings for a destination already in production requires updating existing customer destination configuration. Ignore this warning if this PR is for a new destination with no active customers in production.
The following required fields were added in this PR:

{{FIELDS_ADDED}}

Add these new fields as optional instead and assume default values in `perform` or `performBatch` block.
136 changes: 136 additions & 0 deletions .github/workflows/required-field-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: Required Field Check

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
required-field-check:
runs-on: ubuntu-20.04

timeout-minutes: 5

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
cache: yarn

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Get files changed in the PR
id: get_files
uses: actions/github-script@v7
with:
script: |
const response = await github.request('GET /repos/{owner}/{repo}/pulls/{pull_number}/files', {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
})
const files = response.data.map(file => file.filename)
core.setOutput('files', files.join(' '))
if (files.length === 0) {
core.setOutput('no_files_changed', true)
}
- name: Find required fields on current branch
id: required-fields-curr-branch
if: steps.get_files.outputs.no_files_changed != 'true'
run: |
REQUIRED_FIELDS_CURR_BRANCH=$(./bin/run list-required-fields -p ${{ steps.get_files.outputs.files }} | jq -c .)
echo "REQUIRED_FIELDS_CURR_BRANCH=$REQUIRED_FIELDS_CURR_BRANCH" >> $GITHUB_ENV
- name: Check for required fields on main branch
id: required-fields-main-branch
if: steps.get_files.outputs.no_files_changed != 'true'
run: |
git checkout main
REQUIRED_FIELDS_MAIN_BRANCH=$(./bin/run list-required-fields -p ${{ steps.get_files.outputs.files }} | jq -c .)
echo "REQUIRED_FIELDS_MAIN_BRANCH=$REQUIRED_FIELDS_MAIN_BRANCH" >> $GITHUB_ENV
- name: Add comment on PR if there is diff in required fields
if: steps.get_files.outputs.no_files_changed != 'true'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs')
const path = require('path')
const fieldsAdded = []
if(process.env.REQUIRED_FIELDS_CURR_BRANCH && process.env.REQUIRED_FIELDS_MAIN_BRANCH) {
const requiredFieldsOnBranch = JSON.parse(process.env.REQUIRED_FIELDS_CURR_BRANCH)
const requiredFieldsOnMain = JSON.parse(process.env.REQUIRED_FIELDS_MAIN_BRANCH)
Object.keys(requiredFieldsOnBranch).forEach(key => {
// Check if key is present in requiredFieldsOnMain
if(requiredFieldsOnMain[key]) {
const getActionKeys = Object.keys(requiredFieldsOnBranch[key])
for(const actionKey of getActionKeys) {
const branchRequiredFields = requiredFieldsOnBranch[key][actionKey]
const mainRequiredFields = requiredFieldsOnMain[key][actionKey]
const diff = branchRequiredFields.filter(field => !mainRequiredFields?.includes(field))
if(diff.length > 0) {
const actionOrSettings = actionKey === 'settings' ? '**Setting**' : `**${actionOrSettings}**:${actionKey},`
fieldsAdded.push(`- **Destination**: ${key}, ${actionOrSettings} **Field(s)**:${diff.join(',')}`)
}
}
} else {
// If key is not present in requiredFieldsOnMain, then all fields are added recently
const getActionKeys = Object.keys(requiredFieldsOnBranch[key])
for(const actionKey of getActionKeys) {
const branchRequiredFields = requiredFieldsOnBranch[key][actionKey]
const actionOrSettings = actionKey === 'settings' ? 'Settings' : 'Action'
fieldsAdded.push(`- **Destination**: ${key}, **${actionOrSettings}**:${actionKey}, **Fields**:${branchRequiredFields.join(',')}`)
}
}
})
}
// Get the comments of the current PR
const comments = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
})
const diffComment = comments.data.find(comment => comment.body.includes('<!--REQUIRED_FIELD_DIFF-->'))
const comment = fs.readFileSync("./.github/REQUIRED_FIELD_WARNING_TEMPLATE.md", "utf8")
const commentBody = comment.replace('{{FIELDS_ADDED}}', fieldsAdded.join('\n'))
if (fieldsAdded.length > 0) {
// Check if the comment is already added
if (!diffComment) {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
})
} else {
await github.rest.issues.updateComment({
comment_id: diffComment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
})
}
} else {
if (diffComment) {
await github.rest.issues.deleteComment({
comment_id: diffComment.id,
owner: context.repo.owner,
repo: context.repo.repo
})
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ The `perform` method accepts two arguments, (1) the request client instance (ext
- `dataFeedCache` - DataFeedCache can only be used by internal Twilio/Segment employees. DataFeedCache cannot be used for Partner builds.
- `transactionContext` - An object, containing transaction variables and a method to update transaction variables which are required for few segment developed actions. Transaction Context cannot be used for Partner builds.
- `stateContext` - An object, containing context variables and a method to get and set context variables which are required for few segment developed actions. State Context cannot be used for Partner builds.
- `subscriptionMetadata` - an object, containing variables which identify the instance of a Destination and Action as well as other metadata. Subscription Metadata cannot be used for Partner builds.
A basic example:
Expand Down
4 changes: 2 additions & 2 deletions packages/actions-shared/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@segment/actions-shared",
"description": "Shared destination action methods and definitions.",
"version": "1.113.0",
"version": "1.116.0",
"repository": {
"type": "git",
"url": "https://github.com/segmentio/action-destinations",
Expand Down Expand Up @@ -37,7 +37,7 @@
},
"dependencies": {
"@amplitude/ua-parser-js": "^0.7.25",
"@segment/actions-core": "^3.132.0",
"@segment/actions-core": "^3.135.0",
"cheerio": "^1.0.0-rc.10",
"dayjs": "^1.10.7",
"escape-goat": "^3",
Expand Down
4 changes: 2 additions & 2 deletions packages/browser-destination-runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@segment/browser-destination-runtime",
"version": "1.61.0",
"version": "1.64.0",
"license": "MIT",
"publishConfig": {
"access": "public",
Expand Down Expand Up @@ -62,7 +62,7 @@
}
},
"dependencies": {
"@segment/actions-core": "^3.132.0"
"@segment/actions-core": "^3.135.0"
},
"devDependencies": {
"@segment/analytics-next": "*"
Expand Down
4 changes: 2 additions & 2 deletions packages/browser-destinations/destinations/1flow/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@segment/analytics-browser-actions-1flow",
"version": "1.44.0",
"version": "1.47.0",
"license": "MIT",
"publishConfig": {
"access": "public",
Expand All @@ -15,7 +15,7 @@
},
"typings": "./dist/esm",
"dependencies": {
"@segment/browser-destination-runtime": "^1.61.0"
"@segment/browser-destination-runtime": "^1.64.0"
},
"peerDependencies": {
"@segment/analytics-next": ">=1.55.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@segment/analytics-browser-actions-adobe-target",
"version": "1.62.0",
"version": "1.65.0",
"license": "MIT",
"publishConfig": {
"access": "public",
Expand All @@ -16,7 +16,7 @@
},
"typings": "./dist/esm",
"dependencies": {
"@segment/browser-destination-runtime": "^1.61.0"
"@segment/browser-destination-runtime": "^1.64.0"
},
"peerDependencies": {
"@segment/analytics-next": ">=1.55.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@segment/analytics-browser-actions-algolia-plugins",
"version": "1.39.0",
"version": "1.42.0",
"license": "MIT",
"publishConfig": {
"access": "public",
Expand All @@ -15,7 +15,7 @@
},
"typings": "./dist/esm",
"dependencies": {
"@segment/browser-destination-runtime": "^1.61.0"
"@segment/browser-destination-runtime": "^1.64.0"
},
"peerDependencies": {
"@segment/analytics-next": ">=1.55.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@segment/analytics-browser-actions-amplitude-plugins",
"version": "1.62.0",
"version": "1.65.0",
"license": "MIT",
"publishConfig": {
"access": "public",
Expand All @@ -15,7 +15,7 @@
},
"typings": "./dist/esm",
"dependencies": {
"@segment/browser-destination-runtime": "^1.61.0"
"@segment/browser-destination-runtime": "^1.64.0"
},
"peerDependencies": {
"@segment/analytics-next": ">=1.55.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@segment/analytics-browser-actions-braze-cloud-plugins",
"version": "1.67.0",
"version": "1.70.0",
"license": "MIT",
"publishConfig": {
"access": "public",
Expand All @@ -15,8 +15,8 @@
},
"typings": "./dist/esm",
"dependencies": {
"@segment/analytics-browser-actions-braze": "^1.67.0",
"@segment/browser-destination-runtime": "^1.61.0"
"@segment/analytics-browser-actions-braze": "^1.70.0",
"@segment/browser-destination-runtime": "^1.64.0"
},
"peerDependencies": {
"@segment/analytics-next": ">=1.55.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/browser-destinations/destinations/braze/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@segment/analytics-browser-actions-braze",
"version": "1.67.0",
"version": "1.70.0",
"license": "MIT",
"publishConfig": {
"access": "public",
Expand Down Expand Up @@ -35,8 +35,8 @@
"dependencies": {
"@braze/web-sdk": "npm:@braze/web-sdk@^4.1.0",
"@braze/web-sdk-v3": "npm:@braze/web-sdk@^3.5.1",
"@segment/actions-core": "^3.132.0",
"@segment/browser-destination-runtime": "^1.61.0"
"@segment/actions-core": "^3.135.0",
"@segment/browser-destination-runtime": "^1.64.0"
},
"peerDependencies": {
"@segment/analytics-next": ">=1.55.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@segment/analytics-browser-actions-bucket",
"version": "1.42.0",
"version": "1.45.0",
"license": "MIT",
"publishConfig": {
"access": "public",
Expand All @@ -16,8 +16,8 @@
"typings": "./dist/esm",
"dependencies": {
"@bucketco/tracking-sdk": "^2.0.0",
"@segment/actions-core": "^3.132.0",
"@segment/browser-destination-runtime": "^1.61.0"
"@segment/actions-core": "^3.135.0",
"@segment/browser-destination-runtime": "^1.64.0"
},
"peerDependencies": {
"@segment/analytics-next": ">=1.55.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@segment/analytics-browser-actions-cdpresolution",
"version": "1.49.0",
"version": "1.52.0",
"license": "MIT",
"publishConfig": {
"access": "public",
Expand All @@ -15,7 +15,7 @@
},
"typings": "./dist/esm",
"dependencies": {
"@segment/browser-destination-runtime": "^1.61.0"
"@segment/browser-destination-runtime": "^1.64.0"
},
"peerDependencies": {
"@segment/analytics-next": ">=1.55.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@segment/analytics-browser-actions-commandbar",
"version": "1.62.0",
"version": "1.65.0",
"license": "MIT",
"publishConfig": {
"access": "public",
Expand All @@ -15,8 +15,8 @@
},
"typings": "./dist/esm",
"dependencies": {
"@segment/actions-core": "^3.132.0",
"@segment/browser-destination-runtime": "^1.61.0"
"@segment/actions-core": "^3.135.0",
"@segment/browser-destination-runtime": "^1.64.0"
},
"peerDependencies": {
"@segment/analytics-next": ">=1.55.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@segment/analytics-browser-actions-contentstack-web",
"version": "1.5.0",
"version": "1.8.0",
"license": "MIT",
"publishConfig": {
"access": "public",
Expand All @@ -15,7 +15,7 @@
},
"typings": "./dist/esm",
"dependencies": {
"@segment/browser-destination-runtime": "^1.61.0"
"@segment/browser-destination-runtime": "^1.64.0"
},
"peerDependencies": {
"@segment/analytics-next": ">=1.55.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@segment/analytics-browser-actions-devrev",
"version": "1.49.0",
"version": "1.52.0",
"license": "MIT",
"publishConfig": {
"access": "public",
Expand All @@ -15,7 +15,7 @@
},
"typings": "./dist/esm",
"dependencies": {
"@segment/browser-destination-runtime": "^1.61.0"
"@segment/browser-destination-runtime": "^1.64.0"
},
"peerDependencies": {
"@segment/analytics-next": ">=1.55.0"
Expand Down
Loading

0 comments on commit 718402c

Please sign in to comment.