diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6026df461d..30292a181a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: test-and-build: runs-on: ubuntu-20.04 - timeout-minutes: 20 + timeout-minutes: 30 strategy: matrix: @@ -51,6 +51,8 @@ jobs: run: NODE_ENV=production yarn build - name: Lint + env: + NODE_OPTIONS: '--max-old-space-size=4096' run: yarn lint - name: Validate @@ -65,54 +67,54 @@ jobs: yarn subscriptions size fi - browser-tests-destination: - env: - SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}} - SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}} - - runs-on: ubuntu-20.04 - - timeout-minutes: 20 - - strategy: - matrix: - node-version: [18.x] - - steps: - - uses: actions/checkout@master - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node-version }} - registry-url: 'https://registry.npmjs.org' - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - - uses: actions/cache@v2 - id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - - name: Install Dependencies - run: yarn install --frozen-lockfile - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - - name: Build - run: NODE_ENV=production yarn lerna run build --scope=@segment/browser-destinations --include-dependencies --stream - - - name: Run Saucelabs Tests - working-directory: packages/browser-destinations-integration-tests - shell: bash - run: | - yarn start-destination-server & - yarn test:sauce + # browser-tests-destination: + # # env: # Disable saucelabs - we blew through our quota. + # # SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}} + # # SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}} + + # runs-on: ubuntu-20.04 + + # timeout-minutes: 20 + + # strategy: + # matrix: + # node-version: [18.x] + + # steps: + # - uses: actions/checkout@master + + # - name: Use Node.js ${{ matrix.node-version }} + # uses: actions/setup-node@v2 + # with: + # node-version: ${{ matrix.node-version }} + # registry-url: 'https://registry.npmjs.org' + + # - name: Get yarn cache directory path + # id: yarn-cache-dir-path + # run: echo "::set-output name=dir::$(yarn cache dir)" + + # - uses: actions/cache@v2 + # id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + # with: + # path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + # key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + # restore-keys: | + # ${{ runner.os }}-yarn- + + # - name: Install Dependencies + # run: yarn install --frozen-lockfile + # env: + # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + # - name: Build + # run: NODE_ENV=production yarn build:browser-destinations && yarn browser build-web + + # - name: Run Saucelabs Tests + # working-directory: packages/browser-destinations-integration-tests + # shell: bash + # run: | + # yarn start-destination-server & + # yarn test:sauce browser-tests-core: runs-on: ubuntu-20.04 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1f007fcb5a..715b854940 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -55,4 +55,4 @@ jobs: - name: Publish run: | - yarn lerna publish from-git --yes --allowBranch=main + yarn lerna publish from-git --yes --allowBranch=main --loglevel=verbose --dist-tag latest diff --git a/README.md b/README.md index f68bf1feac..145bd84c09 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ -

+

# Action Destinations - Action Destinations are the new way to build streaming destinations on Segment. Action Destinations were [launched in December 2021](https://segment.com/blog/introducing-destination-actions/) to enable customers with a customizable framework to map Segment event sources to their favorite 3rd party tools like Google Analytics. @@ -28,6 +27,7 @@ For more detailed instruction, see the following READMEs: - [Example Destination](#example-destination) - [Input Fields](#input-fields) - [Default Values](#default-values) +- [Presets](#presets) - [perform function](#the-perform-function) - [Batching Requests](#batching-requests) - [HTTP Requests](#http-requests) @@ -383,6 +383,40 @@ const destination = { } ``` +## Presets + +Presets are pre-built use cases to enable customers to get started quickly with an action destination. They include everything needed to generate a valid subscription. + +There are two types of Presets: `automatic` and `specificEvent`. + +Automatic presets generate subscriptions automatically when an action destination is connected to a _non-Engage_ source. Automatic presets are also available for the customer to choose to generate a subscription at any point in the destination's lifecycle. If you are not sure which type of preset to choose, this is probably the right type. + +[Experimental] SpecificEvent presets are meant to be used with destinations connected to Segment Engage Sources. A subscription will be created from the preset when a _specific action_ is taken by the customer, as specified by the `eventSlug`. If you think your destination should include a specific event preset, please reach out to us. + +```js +const destination = { + // ...other properties + presets: [ + // automatic preset + { + name: 'Track Event', + subscribe: 'type = "track"', + partnerAction: 'track', + mapping: defaultValues(track.fields), + type: 'automatic' + }, + // specific event preset + { + name: 'Associated Entity Added', + partnerAction: 'track', + mapping: defaultValues(track.fields), + type: 'specificEvent' + slug: 'warehouse_entity_added_track' + }, + ], +} +``` + ## The `perform` function The `perform` function defines what the action actually does. All logic and request handling happens here. Every action MUST have a `perform` function defined. @@ -477,6 +511,64 @@ Keep in mind a few important things about how batching works: Additionally, you’ll need to coordinate with Segment’s R&D team for the time being. Please reach out to us in your dedicated Slack channel! +## Audience Support (Pilot) + +In order to support audience destinations, we've introduced a type that extends regular destinations: + +```js +const destination: AudienceDestinationDefinition = { + // ...other properties + audienceFields: { + audienceId: { + label: 'An audience id required by the destination', + description: 'An audience id required by the destination', + type: 'string', + required: true + } + }, + audienceConfig: { + mode: { + type: 'synced', // Indicates that the audience is synced on some schedule + full_audience_sync: true // If true, we send the entire audience. If false, we just send the delta. + } + }, + // These are optional and only needed if you need to create an audience before sending events/users. + // Create an audience on the destination side + async createAudience(request, { settings, audienceSettings, audienceName }) { + const response = await request(YOUR_URL, { + method: 'POST', + json: { + new_audience_name: audienceName, + some_audience_specific_id: audienceSettings.audienceId // As defined in audienceFields + } + }) + const jsonOutput = await response.json() + // Segment will save this externalId for subsequent calls + return { + externalId: jsonOutput['my_audience_id'] + } + }, + // Right now, this serves mostly as a check to ensure the audience still exists in the destination + async getAudience(request, { settings, audienceSettings, externalId }) { + const response = await request(YOUR_URL, { + method: 'POST', + json: { + my_audience_id: externalId + } + }) + const jsonOutput = await response.json() + return { + externalId: jsonOutput['my_audience_id'] + } + } +} +``` + +**Other considerations for audience support:** + +- It is highly recommended to implement a `performBatch` function in your actions implementation. +- You should implement actions specific to audiences such as adding and removing a user + ## HTTP Requests Today, there is only one way to make HTTP requests in a destination: **Manual HTTP Requests**. diff --git a/docs/actions_tester.md b/docs/actions_tester.md index 1b943f814d..96730f600f 100644 --- a/docs/actions_tester.md +++ b/docs/actions_tester.md @@ -50,3 +50,11 @@ Actions tester allows for a simulated test of the action environment. Clicking t Currently the output panel behaves in two 'modes'. The first is `immediate` failures. If your api call could not be completed due to invalid url, credentials, etc, the pane will display whatever debugging information we have in the client. Once you have made a successful api call, we show both the request and response objects that the actions runtime uses internally to track your event. At the time of this writing, these are PERSISTED across individual calls, so if multiple calls appear and this is not desired behavior, you may want to reload the browser instance. + +#### Testing Refresh Token + +For OAuth2 destination, you can test refreshAccessToken handler from the `Test Refresh Token` pane. You can fill in the fields in the section, click on `Test Refresh Token` and results will be displayed in the output panel. + +#### Testing Authentication + +For validating `testAuthentication` handler from actions tester, navigate to the `Settings` pane and fill in all the required settings. You should see `Test Authentication` button below the output panel on the right. On clicking the button, results will be displayed in the output panel. diff --git a/docs/create.md b/docs/create.md index d74d0f09d4..6c3e96a56f 100644 --- a/docs/create.md +++ b/docs/create.md @@ -119,7 +119,7 @@ With this minimal configuration, the destination can connect to the Segment App' ```js import type { Settings } from './generated-types' -import type { BrowserDestinationDefinition } from '../../lib/browser-destinations' +import type { BrowserDestinationDefinition } from '@segment/browser-destination-runtime/types' import { browserDestination } from '../../runtime/shim' // Declare global to access your client diff --git a/docs/testing.md b/docs/testing.md index f08445196e..fe47fd8b3e 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -165,6 +165,43 @@ curl --location --request POST 'http://localhost:3000/authentication' \ }' ``` +### Example request to test createAudience() and getAudience() + +You can test the createAudience and getAudience methods as well. Use the commands below as an example and populate the +settings according to the needs of your destination. + +**createAudience** + +```sh +curl --location 'http://localhost:3000/createAudience' \ +--header 'Content-Type: application/json' \ +--data '{ + "settings": { + "createAudienceUrl": "http://localhost:4242" + }, + "audienceSettings": { + "advertiser_id": "abcxyz123" + }, + "audienceName": "The Super Mario Brothers Super Audience" +}' +``` + +**getAudience** + +```sh +curl --location 'http://localhost:3000/getAudience' \ +--header 'Content-Type: application/json' \ +--data '{ + "settings": { + "getAudienceUrl": "http://localhost:4242/getAudience" + }, + "audienceSettings": { + "advertiser_id": "abcxyz123" + }, + "externalId": 21 +}' +``` + ## Unit Testing When building a destination action, you should write unit and end-to-end tests to ensure your action is working as intended. Tests are automatically run on every commit in Github Actions. Pull requests that do not include relevant tests will not be approved. diff --git a/lerna.json b/lerna.json index ce68bdb8a9..8c3c8d6092 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "packages": ["packages/*"], + "packages": ["packages/*", "packages/browser-destinations/destinations/*"], "npmClient": "yarn", "version": "independent", "useWorkspaces": true, diff --git a/package.json b/package.json index db2633f34c..919d3caead 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "license": "MIT", "workspaces": { "packages": [ - "packages/*" + "packages/*", + "packages/browser-destinations/destinations/*" ] }, "engines": { @@ -17,10 +18,11 @@ "cli-internal": "yarn workspace @segment/actions-cli-internal", "core": "yarn workspace @segment/actions-core", "bootstrap": "lerna bootstrap", - "build": "./bin/run generate:types && lerna run build --stream --ignore @segment/actions-cli-internal", + "build": "./bin/run generate:types && lerna run build --concurrency 1 --stream --ignore @segment/actions-cli-internal && yarn browser build-web", + "build:browser-destinations": "yarn lerna run build --concurrency 1 --scope=@segment/destinations-manifest --include-dependencies --stream && yarn browser build-web", "types": "./bin/run generate:types", "validate": "./bin/run validate", - "lint": "eslint '**/*.ts' --cache", + "lint": "ls -d ./packages/* | xargs -I {} eslint '{}/**/*.ts' --cache", "subscriptions": "yarn workspace @segment/destination-subscriptions", "test": "lerna run test --stream", "test-partners": "lerna run test --stream --ignore @segment/actions-core --ignore @segment/actions-cli --ignore @segment/ajv-human-errors", @@ -56,7 +58,7 @@ "karma-jasmine": "^5.1.0", "karma-webkit-launcher": "^2.0.0", "karma-webpack": "^5.0.0", - "lerna": "^6.0.3", + "lerna": "^6.5.0", "lint-staged": "^10.5.3", "open": "^8.4.0", "os-browserify": "^0.3.0", @@ -68,7 +70,7 @@ "timers-browserify": "^2.0.12", "ts-jest": "^27.0.0", "ts-node": "^9.1.1", - "typescript": "^4.1.3", + "typescript": "4.3.5", "ws": "^8.5.0" }, "resolutions": { diff --git a/packages/actions-shared/package.json b/packages/actions-shared/package.json index c30524f2b5..0b7290b9c7 100644 --- a/packages/actions-shared/package.json +++ b/packages/actions-shared/package.json @@ -1,7 +1,7 @@ { "name": "@segment/actions-shared", "description": "Shared destination action methods and definitions.", - "version": "1.50.0", + "version": "1.65.0", "repository": { "type": "git", "url": "https://github.com/segmentio/action-destinations", @@ -37,7 +37,7 @@ }, "dependencies": { "@amplitude/ua-parser-js": "^0.7.25", - "@segment/actions-core": "^3.68.0", + "@segment/actions-core": "^3.83.0", "cheerio": "^1.0.0-rc.10", "dayjs": "^1.10.7", "escape-goat": "^3", diff --git a/packages/ajv-human-errors/package.json b/packages/ajv-human-errors/package.json index 1ff9e41581..811f31a97a 100644 --- a/packages/ajv-human-errors/package.json +++ b/packages/ajv-human-errors/package.json @@ -1,6 +1,6 @@ { "name": "@segment/ajv-human-errors", - "version": "2.7.0", + "version": "2.11.3", "description": "Human-readable error messages for Ajv (Another JSON Schema Validator).", "repository": { "type": "git", diff --git a/packages/browser-destination-runtime/package.json b/packages/browser-destination-runtime/package.json new file mode 100644 index 0000000000..e02c841693 --- /dev/null +++ b/packages/browser-destination-runtime/package.json @@ -0,0 +1,71 @@ +{ + "name": "@segment/browser-destination-runtime", + "version": "1.14.0", + "license": "MIT", + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org" + }, + "scripts": { + "build": "yarn build:esm && yarn build:cjs", + "build:esm": "tsc --outDir ./dist/esm", + "build:cjs": "tsc --module commonjs --outDir ./dist/cjs" + }, + "exports": { + ".": { + "require": "./dist/cjs/index.js", + "default": "./dist/esm/index.js" + }, + "./load-script": { + "require": "./dist/cjs/load-script.js", + "default": "./dist/esm/load-script.js" + }, + "./plugin": { + "require": "./dist/cjs/plugin.js", + "default": "./dist/esm/plugin.js" + }, + "./resolve-when": { + "require": "./dist/cjs/resolve-when.js", + "default": "./dist/esm/resolve-when.js" + }, + "./shim": { + "require": "./dist/cjs/shim.js", + "default": "./dist/esm/shim.js" + }, + "./types": { + "require": "./dist/cjs/types.js", + "default": "./dist/esm/types.js" + } + }, + "typesVersions": { + "*": { + "*": [ + "dist/esm/index.d.ts" + ], + "load-script": [ + "dist/esm/load-script.d.ts" + ], + "plugin": [ + "dist/esm/plugin.d.ts" + ], + "resolve-when": [ + "dist/esm/resolve-when.d.ts" + ], + "shim": [ + "dist/esm/shim.d.ts" + ], + "types": [ + "dist/esm/types.d.ts" + ] + } + }, + "dependencies": { + "@segment/actions-core": "^3.83.0" + }, + "devDependencies": { + "@segment/analytics-next": "*" + }, + "peerDependencies": { + "@segment/analytics-next": "*" + } +} diff --git a/packages/browser-destinations/src/runtime/__tests__/plugin.test.ts b/packages/browser-destination-runtime/src/__tests__/plugin.test.ts similarity index 95% rename from packages/browser-destinations/src/runtime/__tests__/plugin.test.ts rename to packages/browser-destination-runtime/src/__tests__/plugin.test.ts index d153fc3473..8679002402 100644 --- a/packages/browser-destinations/src/runtime/__tests__/plugin.test.ts +++ b/packages/browser-destination-runtime/src/__tests__/plugin.test.ts @@ -1,4 +1,4 @@ -import { BrowserDestinationDefinition } from 'src/lib/browser-destinations' +import { BrowserDestinationDefinition } from '../types' import { generatePlugins } from '../plugin' describe('generatePlugins', () => { diff --git a/packages/browser-destinations/src/runtime/load-script.ts b/packages/browser-destination-runtime/src/load-script.ts similarity index 100% rename from packages/browser-destinations/src/runtime/load-script.ts rename to packages/browser-destination-runtime/src/load-script.ts diff --git a/packages/browser-destinations/src/runtime/plugin.ts b/packages/browser-destination-runtime/src/plugin.ts similarity index 98% rename from packages/browser-destinations/src/runtime/plugin.ts rename to packages/browser-destination-runtime/src/plugin.ts index 5776c3e456..35c7ad85ed 100644 --- a/packages/browser-destinations/src/runtime/plugin.ts +++ b/packages/browser-destination-runtime/src/plugin.ts @@ -2,7 +2,7 @@ import type { Analytics, Context, Plugin } from '@segment/analytics-next' import type { JSONObject } from '@segment/actions-core' import { transform } from '@segment/actions-core/mapping-kit' import { parseFql, validate } from '@segment/destination-subscriptions' -import { ActionInput, BrowserDestinationDefinition, Subscription } from '../lib/browser-destinations' +import { ActionInput, BrowserDestinationDefinition, Subscription } from './types' import { loadScript } from './load-script' import { resolveWhen } from './resolve-when' diff --git a/packages/browser-destinations/src/runtime/resolve-when.ts b/packages/browser-destination-runtime/src/resolve-when.ts similarity index 100% rename from packages/browser-destinations/src/runtime/resolve-when.ts rename to packages/browser-destination-runtime/src/resolve-when.ts diff --git a/packages/browser-destination-runtime/src/shim.ts b/packages/browser-destination-runtime/src/shim.ts new file mode 100644 index 0000000000..e98004f47b --- /dev/null +++ b/packages/browser-destination-runtime/src/shim.ts @@ -0,0 +1,16 @@ +import type { BrowserDestinationDefinition, PluginFactory, Subscription } from './types' + +export function browserDestination(definition: BrowserDestinationDefinition): PluginFactory { + const factory = (async (settings: S & { subscriptions?: Subscription[] }) => { + const plugin = await import( + /* webpackChunkName: "actions-plugin" */ + /* webpackMode: "lazy-once" */ + './plugin' + ) + return plugin.generatePlugins(definition, settings, settings.subscriptions || []) + }) as unknown as PluginFactory + + factory.pluginName = definition.name + + return factory +} diff --git a/packages/browser-destinations/src/lib/browser-destinations.ts b/packages/browser-destination-runtime/src/types.ts similarity index 93% rename from packages/browser-destinations/src/lib/browser-destinations.ts rename to packages/browser-destination-runtime/src/types.ts index 805fd150b0..37f7d952cd 100644 --- a/packages/browser-destinations/src/lib/browser-destinations.ts +++ b/packages/browser-destination-runtime/src/types.ts @@ -4,7 +4,8 @@ import type { BaseActionDefinition, ExecuteInput, JSONLikeObject, - GlobalSetting + GlobalSetting, + JSONValue } from '@segment/actions-core' export type ActionInput = ExecuteInput & { @@ -61,3 +62,8 @@ export interface Subscription { subscribe: string mapping: JSONLikeObject } + +export interface PluginFactory { + (settings: JSONValue): Plugin[] | Promise + pluginName: string +} diff --git a/packages/browser-destination-runtime/tsconfig.json b/packages/browser-destination-runtime/tsconfig.json new file mode 100644 index 0000000000..b311e107d5 --- /dev/null +++ b/packages/browser-destination-runtime/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "module": "esnext", + "removeComments": false, + "baseUrl": "." + }, + "exclude": ["dist"] +} \ No newline at end of file diff --git a/packages/browser-destinations-integration-tests/src/tests/browser-destinations.test.ts b/packages/browser-destinations-integration-tests/src/tests/browser-destinations.test.ts index 4bb131c5ff..910e93d9bc 100644 --- a/packages/browser-destinations-integration-tests/src/tests/browser-destinations.test.ts +++ b/packages/browser-destinations-integration-tests/src/tests/browser-destinations.test.ts @@ -2,10 +2,10 @@ import page from '../pageobjects/page' import { expect } from 'expect' import { listDestinations } from '../server/utils' -// '688' is actions-core, we don't want to test it as a destination here +// actions-plugins is just a shared chunk, we don't want to test it as a destination here const allDestinations = listDestinations() .map((el) => el.dirPath) - .filter((el) => el !== '688') + .filter((el) => el !== 'actions-plugin') describe('Bundles are capable of being parsed and loaded without errors', () => { for (const destination of allDestinations) { diff --git a/packages/browser-destinations-integration-tests/wdio.conf.local.ts b/packages/browser-destinations-integration-tests/wdio.conf.local.ts index 80b16db396..b8a8d062b6 100644 --- a/packages/browser-destinations-integration-tests/wdio.conf.local.ts +++ b/packages/browser-destinations-integration-tests/wdio.conf.local.ts @@ -1,6 +1,12 @@ import type { Options } from '@wdio/types' +import dns from 'node:dns' export const config: Options.Testrunner = { + beforeSession: () => { + // Fixes: github.com/webdriverio/webdriverio/issues/8279 + // @ts-ignore - this should be in node 18 https://nodejs.org/api/dns.html#dnssetdefaultresultorderorder + dns.setDefaultResultOrder('ipv4first') + }, baseUrl: 'http://localhost:5555', // WebdriverIO allows it to run your tests in arbitrary locations (e.g. locally or // on a remote machine). diff --git a/packages/browser-destinations/README.md b/packages/browser-destinations/README.md index 1057602d31..3c863e17f2 100644 --- a/packages/browser-destinations/README.md +++ b/packages/browser-destinations/README.md @@ -29,7 +29,7 @@ bin/run generate:types You can use our Action Tester environment to test your browser actions: ``` -./bin/run serve --directory ./packages/browser-destinations/src/destinations --browser +./bin/run serve --directory ./packages/browser-destinations/destinations --browser ``` This will give you an option to pick a destination to work on, and then opens the action tester. You can also debug the code from Visual Studio Code. Goto VSCode Debug Tab, and select "Launch Action Tester Web" from the "RUN AND DEBUG" dropdown ( make sure you ran the above command first ). This will launch a new instance of Google Chrome, and allow you to run your code in debug mode. @@ -45,7 +45,7 @@ yarn test Running one file at the time ``` -yarn jest src/destinations/PATH-TO-YOUR-DESTINATION/__tests__/index.test.ts +yarn jest destinations/PATH-TO-YOUR-DESTINATION/src/__tests__/index.test.ts ``` ## Deploying diff --git a/packages/browser-destinations/destinations/adobe-target/package.json b/packages/browser-destinations/destinations/adobe-target/package.json new file mode 100644 index 0000000000..78b0f2144f --- /dev/null +++ b/packages/browser-destinations/destinations/adobe-target/package.json @@ -0,0 +1,24 @@ +{ + "name": "@segment/analytics-browser-actions-adobe-target", + "version": "1.15.0", + "license": "MIT", + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org" + }, + "main": "./dist/cjs", + "module": "./dist/esm", + "scripts": { + "build": "yarn build:esm && yarn build:cjs", + "build-es": "tsc", + "build:cjs": "tsc --module commonjs --outDir ./dist/cjs", + "build:esm": "tsc --outDir ./dist/esm" + }, + "typings": "./dist/esm", + "dependencies": { + "@segment/browser-destination-runtime": "^1.14.0" + }, + "peerDependencies": { + "@segment/analytics-next": ">=1.55.0" + } +} diff --git a/packages/browser-destinations/src/destinations/adobe-target/__tests__/index.test.ts b/packages/browser-destinations/destinations/adobe-target/src/__tests__/index.test.ts similarity index 94% rename from packages/browser-destinations/src/destinations/adobe-target/__tests__/index.test.ts rename to packages/browser-destinations/destinations/adobe-target/src/__tests__/index.test.ts index 46fc7d6691..182cf59624 100644 --- a/packages/browser-destinations/src/destinations/adobe-target/__tests__/index.test.ts +++ b/packages/browser-destinations/destinations/adobe-target/src/__tests__/index.test.ts @@ -1,6 +1,6 @@ import { Analytics, Context } from '@segment/analytics-next' import adobeTarget, { destination } from '../index' -import { Subscription } from '../../../lib/browser-destinations' +import { Subscription } from '@segment/browser-destination-runtime/types' describe('Adobe Target Web', () => { test('can load ATJS', async () => { diff --git a/packages/browser-destinations/src/destinations/adobe-target/__tests__/utils.test.ts b/packages/browser-destinations/destinations/adobe-target/src/__tests__/utils.test.ts similarity index 100% rename from packages/browser-destinations/src/destinations/adobe-target/__tests__/utils.test.ts rename to packages/browser-destinations/destinations/adobe-target/src/__tests__/utils.test.ts diff --git a/packages/browser-destinations/src/destinations/adobe-target/generated-types.ts b/packages/browser-destinations/destinations/adobe-target/src/generated-types.ts similarity index 100% rename from packages/browser-destinations/src/destinations/adobe-target/generated-types.ts rename to packages/browser-destinations/destinations/adobe-target/src/generated-types.ts diff --git a/packages/browser-destinations/src/destinations/adobe-target/index.ts b/packages/browser-destinations/destinations/adobe-target/src/index.ts similarity index 93% rename from packages/browser-destinations/src/destinations/adobe-target/index.ts rename to packages/browser-destinations/destinations/adobe-target/src/index.ts index 1f3d1389f9..711ac38be3 100644 --- a/packages/browser-destinations/src/destinations/adobe-target/index.ts +++ b/packages/browser-destinations/destinations/adobe-target/src/index.ts @@ -1,6 +1,6 @@ import type { Settings } from './generated-types' -import type { BrowserDestinationDefinition } from '../../lib/browser-destinations' -import { browserDestination } from '../../runtime/shim' +import type { BrowserDestinationDefinition } from '@segment/browser-destination-runtime/types' +import { browserDestination } from '@segment/browser-destination-runtime/shim' import { Adobe } from './types' import { initScript } from './init-script' diff --git a/packages/browser-destinations/src/destinations/adobe-target/init-script.ts b/packages/browser-destinations/destinations/adobe-target/src/init-script.ts similarity index 100% rename from packages/browser-destinations/src/destinations/adobe-target/init-script.ts rename to packages/browser-destinations/destinations/adobe-target/src/init-script.ts diff --git a/packages/browser-destinations/src/destinations/adobe-target/trackEvent/__tests__/index.test.ts b/packages/browser-destinations/destinations/adobe-target/src/trackEvent/__tests__/index.test.ts similarity index 96% rename from packages/browser-destinations/src/destinations/adobe-target/trackEvent/__tests__/index.test.ts rename to packages/browser-destinations/destinations/adobe-target/src/trackEvent/__tests__/index.test.ts index 4ed9d54896..d70fcbe7bf 100644 --- a/packages/browser-destinations/src/destinations/adobe-target/trackEvent/__tests__/index.test.ts +++ b/packages/browser-destinations/destinations/adobe-target/src/trackEvent/__tests__/index.test.ts @@ -1,6 +1,6 @@ import { Analytics, Context } from '@segment/analytics-next' import adobeTarget, { destination } from '../../index' -import { Subscription } from '../../../../lib/browser-destinations' +import { Subscription } from '@segment/browser-destination-runtime/types' describe('Adobe Target Web', () => { describe('#track', () => { diff --git a/packages/browser-destinations/src/destinations/adobe-target/trackEvent/generated-types.ts b/packages/browser-destinations/destinations/adobe-target/src/trackEvent/generated-types.ts similarity index 100% rename from packages/browser-destinations/src/destinations/adobe-target/trackEvent/generated-types.ts rename to packages/browser-destinations/destinations/adobe-target/src/trackEvent/generated-types.ts diff --git a/packages/browser-destinations/src/destinations/adobe-target/trackEvent/index.ts b/packages/browser-destinations/destinations/adobe-target/src/trackEvent/index.ts similarity index 96% rename from packages/browser-destinations/src/destinations/adobe-target/trackEvent/index.ts rename to packages/browser-destinations/destinations/adobe-target/src/trackEvent/index.ts index 36e48d7e13..933b24d601 100644 --- a/packages/browser-destinations/src/destinations/adobe-target/trackEvent/index.ts +++ b/packages/browser-destinations/destinations/adobe-target/src/trackEvent/index.ts @@ -1,4 +1,4 @@ -import type { BrowserActionDefinition } from '../../../lib/browser-destinations' +import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types' import type { Settings } from '../generated-types' import type { Payload } from './generated-types' import { Adobe } from '../types' diff --git a/packages/browser-destinations/src/destinations/adobe-target/triggerView/__tests__/index.test.ts b/packages/browser-destinations/destinations/adobe-target/src/triggerView/__tests__/index.test.ts similarity index 96% rename from packages/browser-destinations/src/destinations/adobe-target/triggerView/__tests__/index.test.ts rename to packages/browser-destinations/destinations/adobe-target/src/triggerView/__tests__/index.test.ts index 5a78bb84d1..8f402c57a1 100644 --- a/packages/browser-destinations/src/destinations/adobe-target/triggerView/__tests__/index.test.ts +++ b/packages/browser-destinations/destinations/adobe-target/src/triggerView/__tests__/index.test.ts @@ -1,6 +1,6 @@ import { Analytics, Context } from '@segment/analytics-next' import adobeTarget, { destination } from '../../index' -import { Subscription } from '../../../../lib/browser-destinations' +import { Subscription } from '@segment/browser-destination-runtime/types' describe('Adobe Target Web', () => { describe('#page', () => { diff --git a/packages/browser-destinations/src/destinations/adobe-target/triggerView/generated-types.ts b/packages/browser-destinations/destinations/adobe-target/src/triggerView/generated-types.ts similarity index 100% rename from packages/browser-destinations/src/destinations/adobe-target/triggerView/generated-types.ts rename to packages/browser-destinations/destinations/adobe-target/src/triggerView/generated-types.ts diff --git a/packages/browser-destinations/src/destinations/adobe-target/triggerView/index.ts b/packages/browser-destinations/destinations/adobe-target/src/triggerView/index.ts similarity index 96% rename from packages/browser-destinations/src/destinations/adobe-target/triggerView/index.ts rename to packages/browser-destinations/destinations/adobe-target/src/triggerView/index.ts index b7a0736e89..32822c88e4 100644 --- a/packages/browser-destinations/src/destinations/adobe-target/triggerView/index.ts +++ b/packages/browser-destinations/destinations/adobe-target/src/triggerView/index.ts @@ -1,4 +1,4 @@ -import type { BrowserActionDefinition } from '../../../lib/browser-destinations' +import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types' import type { Settings } from '../generated-types' import type { Payload } from './generated-types' import { Adobe } from '../types' diff --git a/packages/browser-destinations/src/destinations/adobe-target/types.ts b/packages/browser-destinations/destinations/adobe-target/src/types.ts similarity index 100% rename from packages/browser-destinations/src/destinations/adobe-target/types.ts rename to packages/browser-destinations/destinations/adobe-target/src/types.ts diff --git a/packages/browser-destinations/src/destinations/adobe-target/upsertProfile/__tests__/index.test.ts b/packages/browser-destinations/destinations/adobe-target/src/upsertProfile/__tests__/index.test.ts similarity index 97% rename from packages/browser-destinations/src/destinations/adobe-target/upsertProfile/__tests__/index.test.ts rename to packages/browser-destinations/destinations/adobe-target/src/upsertProfile/__tests__/index.test.ts index f01562d546..cae03f0742 100644 --- a/packages/browser-destinations/src/destinations/adobe-target/upsertProfile/__tests__/index.test.ts +++ b/packages/browser-destinations/destinations/adobe-target/src/upsertProfile/__tests__/index.test.ts @@ -1,6 +1,6 @@ import { Analytics, Context } from '@segment/analytics-next' import adobeTarget, { destination } from '../../index' -import { Subscription } from '../../../../lib/browser-destinations' +import { Subscription } from '@segment/browser-destination-runtime/types' describe('Adobe Target Web', () => { describe('#identify', () => { diff --git a/packages/browser-destinations/src/destinations/adobe-target/upsertProfile/generated-types.ts b/packages/browser-destinations/destinations/adobe-target/src/upsertProfile/generated-types.ts similarity index 100% rename from packages/browser-destinations/src/destinations/adobe-target/upsertProfile/generated-types.ts rename to packages/browser-destinations/destinations/adobe-target/src/upsertProfile/generated-types.ts diff --git a/packages/browser-destinations/src/destinations/adobe-target/upsertProfile/index.ts b/packages/browser-destinations/destinations/adobe-target/src/upsertProfile/index.ts similarity index 95% rename from packages/browser-destinations/src/destinations/adobe-target/upsertProfile/index.ts rename to packages/browser-destinations/destinations/adobe-target/src/upsertProfile/index.ts index b51c6fdce4..7a89e792a6 100644 --- a/packages/browser-destinations/src/destinations/adobe-target/upsertProfile/index.ts +++ b/packages/browser-destinations/destinations/adobe-target/src/upsertProfile/index.ts @@ -1,4 +1,4 @@ -import type { BrowserActionDefinition } from '../../../lib/browser-destinations' +import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types' import type { Settings } from '../generated-types' import { Adobe } from '../types' import type { Payload } from './generated-types' diff --git a/packages/browser-destinations/src/destinations/adobe-target/utils.ts b/packages/browser-destinations/destinations/adobe-target/src/utils.ts similarity index 100% rename from packages/browser-destinations/src/destinations/adobe-target/utils.ts rename to packages/browser-destinations/destinations/adobe-target/src/utils.ts diff --git a/packages/browser-destinations/destinations/adobe-target/tsconfig.json b/packages/browser-destinations/destinations/adobe-target/tsconfig.json new file mode 100644 index 0000000000..71c49219d9 --- /dev/null +++ b/packages/browser-destinations/destinations/adobe-target/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.build.json", + "compilerOptions": { + "rootDir": "./src", + "baseUrl": "." + }, + "include": ["src"], + "exclude": ["dist", "**/__tests__"] +} \ No newline at end of file diff --git a/packages/browser-destinations/destinations/amplitude-plugins/package.json b/packages/browser-destinations/destinations/amplitude-plugins/package.json new file mode 100644 index 0000000000..5090f61975 --- /dev/null +++ b/packages/browser-destinations/destinations/amplitude-plugins/package.json @@ -0,0 +1,23 @@ +{ + "name": "@segment/analytics-browser-actions-amplitude-plugins", + "version": "1.15.0", + "license": "MIT", + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org" + }, + "main": "./dist/cjs", + "module": "./dist/esm", + "scripts": { + "build": "yarn build:esm && yarn build:cjs", + "build:cjs": "tsc --module commonjs --outDir ./dist/cjs", + "build:esm": "tsc --outDir ./dist/esm" + }, + "typings": "./dist/esm", + "dependencies": { + "@segment/browser-destination-runtime": "^1.14.0" + }, + "peerDependencies": { + "@segment/analytics-next": ">=1.55.0" + } +} diff --git a/packages/browser-destinations/src/destinations/amplitude-plugins/generated-types.ts b/packages/browser-destinations/destinations/amplitude-plugins/src/generated-types.ts similarity index 100% rename from packages/browser-destinations/src/destinations/amplitude-plugins/generated-types.ts rename to packages/browser-destinations/destinations/amplitude-plugins/src/generated-types.ts diff --git a/packages/browser-destinations/src/destinations/amplitude-plugins/index.ts b/packages/browser-destinations/destinations/amplitude-plugins/src/index.ts similarity index 65% rename from packages/browser-destinations/src/destinations/amplitude-plugins/index.ts rename to packages/browser-destinations/destinations/amplitude-plugins/src/index.ts index d060ea4ae9..9227d87747 100644 --- a/packages/browser-destinations/src/destinations/amplitude-plugins/index.ts +++ b/packages/browser-destinations/destinations/amplitude-plugins/src/index.ts @@ -1,6 +1,6 @@ import type { Settings } from './generated-types' -import type { BrowserDestinationDefinition } from '../../lib/browser-destinations' -import { browserDestination } from '../../runtime/shim' +import type { BrowserDestinationDefinition } from '@segment/browser-destination-runtime/types' +import { browserDestination } from '@segment/browser-destination-runtime/shim' import sessionId from './sessionId' export const destination: BrowserDestinationDefinition = { diff --git a/packages/browser-destinations/src/destinations/amplitude-plugins/sessionId/__tests__/sessionId.test.ts b/packages/browser-destinations/destinations/amplitude-plugins/src/sessionId/__tests__/sessionId.test.ts similarity index 99% rename from packages/browser-destinations/src/destinations/amplitude-plugins/sessionId/__tests__/sessionId.test.ts rename to packages/browser-destinations/destinations/amplitude-plugins/src/sessionId/__tests__/sessionId.test.ts index ef9f0f1ca5..dfd274d3ec 100644 --- a/packages/browser-destinations/src/destinations/amplitude-plugins/sessionId/__tests__/sessionId.test.ts +++ b/packages/browser-destinations/destinations/amplitude-plugins/src/sessionId/__tests__/sessionId.test.ts @@ -1,6 +1,6 @@ import { Analytics, Context, Plugin } from '@segment/analytics-next' import browserPluginsDestination from '../..' -import { Subscription } from '../../../../lib/browser-destinations' +import { Subscription } from '@segment/browser-destination-runtime/types' import jar from 'js-cookie' expect.extend({ diff --git a/packages/browser-destinations/src/destinations/amplitude-plugins/sessionId/generated-types.ts b/packages/browser-destinations/destinations/amplitude-plugins/src/sessionId/generated-types.ts similarity index 100% rename from packages/browser-destinations/src/destinations/amplitude-plugins/sessionId/generated-types.ts rename to packages/browser-destinations/destinations/amplitude-plugins/src/sessionId/generated-types.ts diff --git a/packages/browser-destinations/src/destinations/amplitude-plugins/sessionId/index.ts b/packages/browser-destinations/destinations/amplitude-plugins/src/sessionId/index.ts similarity index 96% rename from packages/browser-destinations/src/destinations/amplitude-plugins/sessionId/index.ts rename to packages/browser-destinations/destinations/amplitude-plugins/src/sessionId/index.ts index 76bdc38280..24aa9d8927 100644 --- a/packages/browser-destinations/src/destinations/amplitude-plugins/sessionId/index.ts +++ b/packages/browser-destinations/destinations/amplitude-plugins/src/sessionId/index.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ import { UniversalStorage } from '@segment/analytics-next' -import type { BrowserActionDefinition } from '../../../lib/browser-destinations' +import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types' import type { Settings } from '../generated-types' import type { Payload } from './generated-types' diff --git a/packages/browser-destinations/destinations/amplitude-plugins/tsconfig.json b/packages/browser-destinations/destinations/amplitude-plugins/tsconfig.json new file mode 100644 index 0000000000..71c49219d9 --- /dev/null +++ b/packages/browser-destinations/destinations/amplitude-plugins/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.build.json", + "compilerOptions": { + "rootDir": "./src", + "baseUrl": "." + }, + "include": ["src"], + "exclude": ["dist", "**/__tests__"] +} \ No newline at end of file diff --git a/packages/browser-destinations/destinations/braze-cloud-plugins/package.json b/packages/browser-destinations/destinations/braze-cloud-plugins/package.json new file mode 100644 index 0000000000..84fd76e262 --- /dev/null +++ b/packages/browser-destinations/destinations/braze-cloud-plugins/package.json @@ -0,0 +1,24 @@ +{ + "name": "@segment/analytics-browser-actions-braze-cloud-plugins", + "version": "1.16.0", + "license": "MIT", + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org" + }, + "main": "./dist/cjs", + "module": "./dist/esm", + "scripts": { + "build": "yarn build:esm && yarn build:cjs", + "build:cjs": "tsc --module commonjs --outDir ./dist/cjs", + "build:esm": "tsc --outDir ./dist/esm" + }, + "typings": "./dist/esm", + "dependencies": { + "@segment/analytics-browser-actions-braze": "^1.16.0", + "@segment/browser-destination-runtime": "^1.14.0" + }, + "peerDependencies": { + "@segment/analytics-next": ">=1.55.0" + } +} diff --git a/packages/browser-destinations/src/destinations/braze-cloud-plugins/debouncePlugin.types.ts b/packages/browser-destinations/destinations/braze-cloud-plugins/src/debouncePlugin.types.ts similarity index 100% rename from packages/browser-destinations/src/destinations/braze-cloud-plugins/debouncePlugin.types.ts rename to packages/browser-destinations/destinations/braze-cloud-plugins/src/debouncePlugin.types.ts diff --git a/packages/browser-destinations/src/destinations/braze-cloud-plugins/generated-types.ts b/packages/browser-destinations/destinations/braze-cloud-plugins/src/generated-types.ts similarity index 100% rename from packages/browser-destinations/src/destinations/braze-cloud-plugins/generated-types.ts rename to packages/browser-destinations/destinations/braze-cloud-plugins/src/generated-types.ts diff --git a/packages/browser-destinations/src/destinations/braze-cloud-plugins/index.ts b/packages/browser-destinations/destinations/braze-cloud-plugins/src/index.ts similarity index 66% rename from packages/browser-destinations/src/destinations/braze-cloud-plugins/index.ts rename to packages/browser-destinations/destinations/braze-cloud-plugins/src/index.ts index 9c6b49bcae..cf21c7db4e 100644 --- a/packages/browser-destinations/src/destinations/braze-cloud-plugins/index.ts +++ b/packages/browser-destinations/destinations/braze-cloud-plugins/src/index.ts @@ -1,7 +1,7 @@ import type { Settings } from './generated-types' -import type { BrowserDestinationDefinition } from '../../lib/browser-destinations' -import { browserDestination } from '../../runtime/shim' -import debouncePlugin from '../braze/debounce' +import type { BrowserDestinationDefinition } from '@segment/browser-destination-runtime/types' +import { browserDestination } from '@segment/browser-destination-runtime/shim' +import debouncePlugin from '@segment/analytics-browser-actions-braze/debounce' export const destination: BrowserDestinationDefinition = { name: 'Braze Cloud Mode (Actions)', diff --git a/packages/browser-destinations/destinations/braze-cloud-plugins/tsconfig.json b/packages/browser-destinations/destinations/braze-cloud-plugins/tsconfig.json new file mode 100644 index 0000000000..71c49219d9 --- /dev/null +++ b/packages/browser-destinations/destinations/braze-cloud-plugins/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.build.json", + "compilerOptions": { + "rootDir": "./src", + "baseUrl": "." + }, + "include": ["src"], + "exclude": ["dist", "**/__tests__"] +} \ No newline at end of file diff --git a/packages/browser-destinations/destinations/braze/package.json b/packages/browser-destinations/destinations/braze/package.json new file mode 100644 index 0000000000..57584cc39a --- /dev/null +++ b/packages/browser-destinations/destinations/braze/package.json @@ -0,0 +1,44 @@ +{ + "name": "@segment/analytics-browser-actions-braze", + "version": "1.16.0", + "license": "MIT", + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org" + }, + "exports": { + ".": { + "require": "./dist/cjs/index.js", + "import": "./dist/esm/index.js" + }, + "./debounce": { + "require": "./dist/cjs/debounce/index.js", + "import": "./dist/esm/debounce/index.js" + } + }, + "scripts": { + "build": "yarn build:esm && yarn build:cjs", + "build:cjs": "tsc --module commonjs --outDir ./dist/cjs", + "build:esm": "tsc --outDir ./dist/esm" + }, + "typesVersions": { + "*": { + "*": [ + "dist/esm/index.d.ts" + ], + "debounce": [ + "dist/esm/debounce/index.d.ts" + ] + } + }, + "typings": "./dist/esm", + "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.83.0", + "@segment/browser-destination-runtime": "^1.14.0" + }, + "peerDependencies": { + "@segment/analytics-next": ">=1.55.0" + } +} diff --git a/packages/browser-destinations/src/destinations/braze/__tests__/__snapshots__/initialization.test.ts.snap b/packages/browser-destinations/destinations/braze/src/__tests__/__snapshots__/initialization.test.ts.snap similarity index 100% rename from packages/browser-destinations/src/destinations/braze/__tests__/__snapshots__/initialization.test.ts.snap rename to packages/browser-destinations/destinations/braze/src/__tests__/__snapshots__/initialization.test.ts.snap diff --git a/packages/browser-destinations/src/destinations/braze/__tests__/__snapshots__/integration.test.ts.snap b/packages/browser-destinations/destinations/braze/src/__tests__/__snapshots__/integration.test.ts.snap similarity index 96% rename from packages/browser-destinations/src/destinations/braze/__tests__/__snapshots__/integration.test.ts.snap rename to packages/browser-destinations/destinations/braze/src/__tests__/__snapshots__/integration.test.ts.snap index 2a6bfa2c26..79a1da3492 100644 --- a/packages/browser-destinations/src/destinations/braze/__tests__/__snapshots__/integration.test.ts.snap +++ b/packages/browser-destinations/destinations/braze/src/__tests__/__snapshots__/integration.test.ts.snap @@ -85,7 +85,7 @@ exports[`loads different versions from CDN undefined version: 1`] = ` NodeList [