Skip to content
Draft
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ packages/plugins/analytics @yoannmoin

# Custom Hooks
packages/plugins/custom-hooks @yoannmoinet

# Synthetics
packages/plugins/synthetics @yoannmoinet @etnbrd
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to invite etienne I think:

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.
I'll wait for his review, see if I should instead maybe use a team (cc @etnbrd)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should definitely use the @DataDog/synthetics-ct team, indeed.

24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ To interact with Datadog directly from your builds.
- [`customPlugins`](#customplugins)
- [Features](#features)
- [Error Tracking](#error-tracking-----)
- [Synthetics](#synthetics-----)
- [Telemetry](#telemetry-----)
- [Contributing](#contributing)
- [License](#license)
Expand Down Expand Up @@ -103,6 +104,9 @@ Follow the specific documentation for each bundler:
service: string;
};
};
synthetics?: {
disabled?: boolean;
};
telemetry?: {
disabled?: boolean;
enableTracing?: boolean;
Expand Down Expand Up @@ -246,6 +250,26 @@ datadogWebpackPlugin({

</details>

### Synthetics <img src="packages/assets/src/esbuild.svg" alt="ESBuild" width="17" /> <img src="packages/assets/src/rollup.svg" alt="Rollup" width="17" /> <img src="packages/assets/src/rspack.svg" alt="Rspack" width="17" /> <img src="packages/assets/src/vite.svg" alt="Vite" width="17" /> <img src="packages/assets/src/webpack.svg" alt="Webpack" width="17" />

> Interact with Synthetics at build time.

#### [📝 Full documentation ➡️](/packages/plugins/synthetics#readme)

<details>

<summary>Configuration</summary>

```typescript
datadogWebpackPlugin({
synthetics?: {
disabled?: boolean,
}
});
```

</details>

### Telemetry <img src="packages/assets/src/esbuild.svg" alt="ESBuild" width="17" /> <img src="packages/assets/src/rollup.svg" alt="Rollup" width="17" /> <img src="packages/assets/src/rspack.svg" alt="Rspack" width="17" /> <img src="packages/assets/src/vite.svg" alt="Vite" width="17" /> <img src="packages/assets/src/webpack.svg" alt="Webpack" width="17" />

> Display and send telemetry data as metrics to Datadog.
Expand Down
10 changes: 10 additions & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ declare global {
* For instance, we only submit logs to Datadog when the environment is `production`.
*/
BUILD_PLUGINS_ENV?: Env;
/**
* The port of the dev server of our synthetics plugin.
*
* This is only used by datadog-ci, in its build'n test workflow,
* using the customer's build command, if it includes our plugin,
* will launch a dev-server over the outdir of the build so datadog-ci
* can trigger a tunnel and a test batch over the branch's code.
*
*/
BUILD_PLUGINS_S8S_PORT?: string;
/**
* Defined in github actions when running in CI.
*/
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import type { ErrorTrackingOptions } from '@dd/error-tracking-plugin/types';
import type * as errorTracking from '@dd/error-tracking-plugin';
import type { RumOptions } from '@dd/rum-plugin/types';
import type * as rum from '@dd/rum-plugin';
import type { SyntheticsOptions } from '@dd/synthetics-plugin/types';
import type * as synthetics from '@dd/synthetics-plugin';
import type { TelemetryOptions } from '@dd/telemetry-plugin/types';
import type * as telemetry from '@dd/telemetry-plugin';
// #imports-injection-marker
Expand All @@ -22,8 +24,11 @@ import type { UnpluginOptions } from 'unplugin';

import type { ALL_ENVS, FULL_NAME_BUNDLERS, SUPPORTED_BUNDLERS } from './constants';

// Re-assign B into A.
export type Assign<A, B> = Omit<A, keyof B> & B;
export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
// Type object with specified keys required.
export type Ensure<T, K extends keyof T> = Assign<T, Required<Pick<T, K>>>;
// Target one item from an iterable.
export type IterableElement<IterableType extends Iterable<unknown>> =
IterableType extends Iterable<infer ElementType> ? ElementType : never;

Expand Down Expand Up @@ -197,6 +202,7 @@ export interface Options extends BaseOptions {
// #types-injection-marker
[errorTracking.CONFIG_KEY]?: ErrorTrackingOptions;
[rum.CONFIG_KEY]?: RumOptions;
[synthetics.CONFIG_KEY]?: SyntheticsOptions;
[telemetry.CONFIG_KEY]?: TelemetryOptions;
// #types-injection-marker
customPlugins?: GetCustomPlugins;
Expand Down
1 change: 1 addition & 0 deletions packages/factory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@dd/internal-git-plugin": "workspace:*",
"@dd/internal-injection-plugin": "workspace:*",
"@dd/rum-plugin": "workspace:*",
"@dd/synthetics-plugin": "workspace:*",
"@dd/telemetry-plugin": "workspace:*",
"chalk": "2.3.1",
"unplugin": "1.16.0"
Expand Down
3 changes: 3 additions & 0 deletions packages/factory/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { getContext, validateOptions } from './helpers';
// #imports-injection-marker
import * as errorTracking from '@dd/error-tracking-plugin';
import * as rum from '@dd/rum-plugin';
import * as synthetics from '@dd/synthetics-plugin';
import * as telemetry from '@dd/telemetry-plugin';
import { getAnalyticsPlugins } from '@dd/internal-analytics-plugin';
import { getBuildReportPlugins } from '@dd/internal-build-report-plugin';
Expand All @@ -39,6 +40,7 @@ import { getInjectionPlugins } from '@dd/internal-injection-plugin';
// #types-export-injection-marker
export type { types as ErrorTrackingTypes } from '@dd/error-tracking-plugin';
export type { types as RumTypes } from '@dd/rum-plugin';
export type { types as SyntheticsTypes } from '@dd/synthetics-plugin';
export type { types as TelemetryTypes } from '@dd/telemetry-plugin';
// #types-export-injection-marker

Expand Down Expand Up @@ -102,6 +104,7 @@ export const buildPluginFactory = ({
// #configs-injection-marker
errorTracking,
rum,
synthetics,
telemetry,
// #configs-injection-marker
];
Expand Down
21 changes: 21 additions & 0 deletions packages/plugins/synthetics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Synthetics Plugin <!-- #omit in toc -->

Interact with Synthetics at build time.

<!-- The title and the following line will both be added to the root README.md -->

## Table of content <!-- #omit in toc -->

<!-- This is auto generated with yarn cli integrity -->

<!-- #toc -->
- [Configuration](#configuration)
<!-- #toc -->

## Configuration

```ts
synthetics?: {
disabled?: boolean;
}
```
26 changes: 26 additions & 0 deletions packages/plugins/synthetics/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@dd/synthetics-plugin",
"packageManager": "yarn@4.0.2",
"license": "MIT",
"private": true,
"author": "Datadog",
"description": "Interact with Synthetics at build time.",
"homepage": "https://github.com/DataDog/build-plugins/tree/main/packages/plugins/synthetics#readme",
"repository": {
"type": "git",
"url": "https://github.com/DataDog/build-plugins",
"directory": "packages/plugins/synthetics"
},
"exports": {
".": "./src/index.ts",
"./*": "./src/*.ts"
},
"scripts": {
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@dd/core": "workspace:*",
"@dd/error-tracking-plugin": "workspace:*",
"chalk": "2.3.1"
}
}
11 changes: 11 additions & 0 deletions packages/plugins/synthetics/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the MIT License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.

import type { PluginName } from '@dd/core/types';

export const CONFIG_KEY = 'synthetics' as const;
export const PLUGIN_NAME: PluginName = 'datadog-synthetics-plugin' as const;

export const API_PREFIX = '_datadog-ci_' as const;
export const DEFAULT_PORT = 1234 as const;
Loading