@datadog/vite-plugin 2.4.2 → 2.5.1-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ import { datadogRum, RumInitConfiguration as RumInitConfiguration$1 } from '@datadog/browser-rum';
1
2
  import { UnpluginOptions } from 'unplugin';
2
3
  import * as vite from 'vite';
3
4
 
@@ -11,11 +12,12 @@ declare class TrackedFilesMatcher {
11
12
  private getFilename;
12
13
  }
13
14
 
14
- declare const CONFIG_KEY$1: "rum";
15
+ declare const CONFIG_KEY$2: "errorTracking";
15
16
 
16
17
  type MinifiedPathPrefix = `http://${string}` | `https://${string}` | `/${string}`;
17
- type RumSourcemapsOptions = {
18
+ type SourcemapsOptions = {
18
19
  bailOnError?: boolean;
20
+ disableGit?: boolean;
19
21
  dryRun?: boolean;
20
22
  intakeUrl?: string;
21
23
  maxConcurrency?: number;
@@ -23,10 +25,30 @@ type RumSourcemapsOptions = {
23
25
  releaseVersion: string;
24
26
  service: string;
25
27
  };
28
+ type ErrorTrackingOptions = {
29
+ disabled?: boolean;
30
+ sourcemaps?: SourcemapsOptions;
31
+ };
32
+ interface OptionsWithErrorTracking extends GetPluginsOptions {
33
+ [CONFIG_KEY$2]: ErrorTrackingOptions;
34
+ }
35
+
36
+ type types$2 = {
37
+ ErrorTrackingOptions: ErrorTrackingOptions;
38
+ OptionsWithErrorTracking: OptionsWithErrorTracking;
39
+ };
40
+
41
+ declare const CONFIG_KEY$1: "rum";
42
+
26
43
  type RumOptions = {
27
44
  disabled?: boolean;
28
- sourcemaps?: RumSourcemapsOptions;
45
+ sdk?: SDKOptions;
29
46
  };
47
+ type RumPublicApi = typeof datadogRum;
48
+ type RumInitConfiguration = RumInitConfiguration$1;
49
+ type SDKOptions = Assign<RumInitConfiguration, {
50
+ clientToken?: string;
51
+ }>;
30
52
  interface OptionsWithRum extends GetPluginsOptions {
31
53
  [CONFIG_KEY$1]: RumOptions;
32
54
  }
@@ -34,6 +56,8 @@ interface OptionsWithRum extends GetPluginsOptions {
34
56
  type types$1 = {
35
57
  RumOptions: RumOptions;
36
58
  OptionsWithRum: OptionsWithRum;
59
+ RumPublicApi: RumPublicApi;
60
+ RumInitConfiguration: RumInitConfiguration;
37
61
  };
38
62
 
39
63
  declare const CONFIG_KEY: "telemetry";
@@ -44,9 +68,11 @@ type types = {
44
68
  TelemetryOptions: TelemetryOptions;
45
69
  };
46
70
 
71
+ declare const ALL_ENVS: readonly ["development", "production", "test"];
47
72
  declare const SUPPORTED_BUNDLERS: readonly ["webpack", "vite", "esbuild", "rollup", "rspack"];
48
- declare const FULL_NAME_BUNDLERS: readonly ["webpack4", "webpack5", "vite", "esbuild", "rollup", "rspack"];
73
+ declare const FULL_NAME_BUNDLERS: readonly ["esbuild", "rollup", "rspack", "vite", "webpack4", "webpack5"];
49
74
 
75
+ type Assign<A, B> = Omit<A, keyof B> & B;
50
76
  interface RepositoryData {
51
77
  hash: string;
52
78
  remote: string;
@@ -69,9 +95,11 @@ type Entry = Output & {
69
95
  outputs: Output[];
70
96
  };
71
97
  type BuildReport = {
98
+ bundler: Omit<BundlerReport, 'outDir' | 'rawConfig'>;
72
99
  errors: string[];
73
100
  warnings: string[];
74
101
  logs: {
102
+ bundler: BundlerFullName;
75
103
  pluginName: string;
76
104
  type: LogLevel;
77
105
  message: string;
@@ -95,9 +123,16 @@ type BundlerReport = {
95
123
  variant?: string;
96
124
  version: string;
97
125
  };
126
+ type InjectedValue = string | (() => Promise<string>);
127
+ declare enum InjectPosition {
128
+ BEFORE = 0,
129
+ MIDDLE = 1,
130
+ AFTER = 2
131
+ }
98
132
  type ToInjectItem = {
99
133
  type: 'file' | 'code';
100
- value: string;
134
+ value: InjectedValue;
135
+ position?: InjectPosition;
101
136
  fallback?: ToInjectItem;
102
137
  };
103
138
  type GetLogger = (name: string) => Logger;
@@ -108,21 +143,26 @@ type Logger = {
108
143
  info: (text: any) => void;
109
144
  debug: (text: any) => void;
110
145
  };
146
+ type Env = (typeof ALL_ENVS)[number];
111
147
  type GlobalContext = {
112
148
  auth?: AuthOptions;
113
149
  inject: (item: ToInjectItem) => void;
114
150
  bundler: BundlerReport;
115
151
  build: BuildReport;
116
152
  cwd: string;
153
+ env: Env;
154
+ getLogger: GetLogger;
117
155
  git?: RepositoryData;
118
156
  pluginNames: string[];
157
+ sendLog: (message: string, ctx?: any) => Promise<void>;
119
158
  start: number;
120
159
  version: string;
121
160
  };
122
- type GetCustomPlugins = (options: Options, context: GlobalContext, log: Logger) => UnpluginOptions[];
161
+ type GetCustomPlugins = (options: Options, context: GlobalContext) => UnpluginOptions[];
123
162
  type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
124
163
  type AuthOptions = {
125
164
  apiKey?: string;
165
+ appKey?: string;
126
166
  };
127
167
  interface BaseOptions {
128
168
  auth?: AuthOptions;
@@ -130,6 +170,7 @@ interface BaseOptions {
130
170
  logLevel?: LogLevel;
131
171
  }
132
172
  interface Options extends BaseOptions {
173
+ [CONFIG_KEY$2]?: ErrorTrackingOptions;
133
174
  [CONFIG_KEY$1]?: RumOptions;
134
175
  [CONFIG_KEY]?: TelemetryOptions;
135
176
  customPlugins?: GetCustomPlugins;
@@ -160,9 +201,9 @@ type TelemetryOptions = {
160
201
  timestamp?: number;
161
202
  };
162
203
 
163
- declare const datadogVitePlugin: (options: Options) => vite.Plugin<any>[];
164
204
  type VitePluginOptions = Options;
165
205
 
206
+ declare const datadogVitePlugin: (options: Options) => vite.Plugin<any>[];
166
207
  declare const version: string;
167
208
  declare const helpers: {
168
209
  telemetry: {
@@ -170,5 +211,4 @@ declare const helpers: {
170
211
  };
171
212
  };
172
213
 
173
- export { type types$1 as RumTypes, type types as TelemetryTypes, type VitePluginOptions, datadogVitePlugin, helpers, version };
174
- //# sourceMappingURL=index.d.ts.map
214
+ export { type types$2 as ErrorTrackingTypes, type types$1 as RumTypes, type types as TelemetryTypes, type VitePluginOptions, datadogVitePlugin, helpers, version };