@ohos-ports/vite-plugin-radar 0.11.0-beta.0

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.
@@ -0,0 +1,451 @@
1
+ import { HtmlTagDescriptor, Plugin } from 'vite';
2
+
3
+ interface BaiduTongjiDefaults {
4
+ /**
5
+ * `hm.js` script source
6
+ */
7
+ script?: string;
8
+ /**
9
+ * `async` attribute set on the injected script tag
10
+ */
11
+ async?: boolean;
12
+ /**
13
+ * Value pushed to `_hmt` for `_setAutoPageview`
14
+ */
15
+ autoPageview?: boolean;
16
+ }
17
+ interface BaiduTongjiProperty extends BaiduTongjiDefaults {
18
+ id: string;
19
+ }
20
+ type BaiduTongjiOptions = BaiduTongjiProperty | BaiduTongjiProperty[];
21
+
22
+ declare global {
23
+ interface Window {
24
+ _hmt: any[];
25
+ }
26
+ }
27
+
28
+ interface FacebookPixelDefaults {
29
+ /**
30
+ * `fbevents.js` script source
31
+ */
32
+ script?: string;
33
+ /**
34
+ * Tracking endpoint used by the `<noscript>` pixel
35
+ */
36
+ noScript?: string;
37
+ /**
38
+ * Event tracked on load (`fbq('track', <event>)`)
39
+ */
40
+ event?: string;
41
+ }
42
+ interface FacebookPixel extends FacebookPixelDefaults {
43
+ /**
44
+ * Pixel tag
45
+ */
46
+ id: string;
47
+ }
48
+ type FacebookPixelOption = FacebookPixel | FacebookPixel[];
49
+
50
+ declare global {
51
+ interface Window {
52
+ fbq: (event: string, id?: string, params?: Record<string, any>) => void;
53
+ }
54
+ }
55
+
56
+ interface FullStoryDefaults {
57
+ host?: string;
58
+ script?: string;
59
+ namespace?: string;
60
+ /**
61
+ * The FullStory loader snippet (the IIFE that boots the `FS` API).
62
+ * Override only if you need to pin a different snippet version.
63
+ */
64
+ loader?: string;
65
+ }
66
+ interface FullStoryOptions extends FullStoryDefaults {
67
+ org?: string;
68
+ }
69
+
70
+ declare global {
71
+ interface Window {
72
+ _fs_host: any[];
73
+ _fs_script: any[];
74
+ _fs_org: any[];
75
+ _fs_namespace: any[];
76
+ }
77
+ }
78
+
79
+ interface GAConfiguration extends Record<string, any> {
80
+ send_page_view?: boolean;
81
+ allow_google_signals?: boolean;
82
+ allow_ad_personalization_signals?: boolean;
83
+ transport_url?: string;
84
+ cookie_domain?: string;
85
+ cookie_expires?: number;
86
+ cookie_prefix?: string;
87
+ cookie_update?: boolean;
88
+ cookie_flags?: string;
89
+ user_id?: string;
90
+ page_title?: string;
91
+ currency?: string;
92
+ debug_mode?: boolean;
93
+ }
94
+ interface GAConsentDefaults {
95
+ ad_storage?: 'granted' | 'denied';
96
+ analytics_storage?: 'granted' | 'denied';
97
+ wait_for_update?: number;
98
+ }
99
+ interface GoogleAnaliticsDefaults {
100
+ /**
101
+ * Origin serving `gtag.js` (e.g. a self-hosted proxy)
102
+ */
103
+ source?: string;
104
+ /**
105
+ * Path appended to `source` to build the `gtag.js` URL
106
+ */
107
+ basePath?: string;
108
+ /**
109
+ * `async` attribute set on the injected `gtag.js` script tag
110
+ */
111
+ async?: boolean;
112
+ /**
113
+ * Bootstrap snippet that defines `dataLayer` and the `gtag()` function
114
+ */
115
+ loader?: string;
116
+ }
117
+ type GoogleAnaliticsMainProperty = GoogleAnaliticsProperty & GoogleAnaliticsDefaults & {
118
+ consentDefaults?: GAConsentDefaults;
119
+ injectTo?: HtmlTagDescriptor['injectTo'];
120
+ };
121
+ interface GoogleAnaliticsProperty {
122
+ id: string;
123
+ disable?: boolean;
124
+ config?: GAConfiguration;
125
+ persistentValues?: Record<string, string | number | boolean>;
126
+ }
127
+ type GoogleAnaliticsOptions = GoogleAnaliticsMainProperty | [GoogleAnaliticsMainProperty, ...GoogleAnaliticsProperty[]];
128
+
129
+ declare global {
130
+ interface Window {
131
+ dataLayer: any[];
132
+ gtag: (command: string, ...args: any[]) => void;
133
+ }
134
+ }
135
+
136
+ interface GoogleTagManagerMainProperty {
137
+ id: string;
138
+ }
139
+ interface GoogleTagManagerEnvironment {
140
+ auth: string;
141
+ preview: string;
142
+ }
143
+ interface GoogleTagManagerDefaults {
144
+ /**
145
+ * `gtm.js` script source
146
+ */
147
+ gtmBase?: string;
148
+ /**
149
+ * `ns.html` (noscript iframe) source
150
+ */
151
+ nsBase?: string;
152
+ /**
153
+ * `async` attribute set on the injected `gtm.js` script tag
154
+ */
155
+ async?: boolean;
156
+ /**
157
+ * Bootstrap snippet that initialises `dataLayer` and the `gtm.start` event
158
+ */
159
+ loader?: string;
160
+ }
161
+ interface GoogleTagManagerDefaultProperty extends GoogleTagManagerDefaults {
162
+ environment?: GoogleTagManagerEnvironment;
163
+ }
164
+ type GoogleTagManagerProperty = GoogleTagManagerMainProperty & GoogleTagManagerDefaultProperty;
165
+ type GoogleTagManagerOptions = GoogleTagManagerProperty | GoogleTagManagerProperty[];
166
+
167
+ declare global {
168
+ interface Window {
169
+ dataLayer: any[];
170
+ }
171
+ }
172
+
173
+ interface HotjarDefaults {
174
+ /**
175
+ * Hotjar tracking script source prefix
176
+ */
177
+ script?: string;
178
+ /**
179
+ * Hotjar snippet version (`hjsv`)
180
+ */
181
+ version?: number;
182
+ /**
183
+ * `async` value set on the injected script element
184
+ */
185
+ async?: number;
186
+ }
187
+ interface HotjarOptions extends HotjarDefaults {
188
+ id: number;
189
+ }
190
+
191
+ declare global {
192
+ interface Window {
193
+ hj: any[];
194
+ _hjSettings: any[];
195
+ }
196
+ }
197
+
198
+ interface LinkedinInsightDefaults {
199
+ /**
200
+ * `insight.min.js` script source
201
+ */
202
+ script?: string;
203
+ /**
204
+ * Collect endpoint used by the `<noscript>` pixel
205
+ */
206
+ noScript?: string;
207
+ /**
208
+ * `async` attribute set on the injected script tag
209
+ */
210
+ async?: boolean;
211
+ }
212
+ interface LinkedinInsightProperty extends LinkedinInsightDefaults {
213
+ id: string;
214
+ }
215
+ type LinkedinInsightOptions = LinkedinInsightProperty | LinkedinInsightProperty[];
216
+
217
+ declare global {
218
+ interface Window {
219
+ _linkedin_data_partner_ids: any[];
220
+ }
221
+ }
222
+
223
+ interface MicrosoftAdvertisingDefaults {
224
+ /**
225
+ * `bat.js` (UET) script source
226
+ */
227
+ script?: string;
228
+ /**
229
+ * `async` value set on the injected script element
230
+ */
231
+ async?: number;
232
+ }
233
+ interface MicrosoftAdvertisingOptions extends MicrosoftAdvertisingDefaults {
234
+ id: string;
235
+ }
236
+
237
+ declare global {
238
+ interface Window {
239
+ uetq: any[];
240
+ }
241
+ }
242
+
243
+ interface MicrosoftClarityDefaults {
244
+ /**
245
+ * Clarity tag script source (the property id is appended to it)
246
+ */
247
+ script?: string;
248
+ /**
249
+ * `async` value set on the injected script element
250
+ */
251
+ async?: number;
252
+ }
253
+ interface MicrosoftClarityOptions extends MicrosoftClarityDefaults {
254
+ id: string;
255
+ }
256
+
257
+ declare global {
258
+ interface Window {
259
+ clarity: any[];
260
+ }
261
+ }
262
+
263
+ interface PlausibleAnalyticsDefaults {
264
+ /**
265
+ * Tracking script source
266
+ */
267
+ script?: string;
268
+ /**
269
+ * `defer` attribute set on the injected script tag
270
+ */
271
+ defer?: boolean;
272
+ }
273
+ interface PlausibleAnalyticsOptions extends PlausibleAnalyticsDefaults {
274
+ enabled: boolean;
275
+ hostname?: string;
276
+ }
277
+
278
+ interface PostHogAnalyticsDefaults {
279
+ /**
280
+ * The PostHog loader snippet (the `array.js` bootstrap).
281
+ * Override only if you need to pin a different snippet version.
282
+ */
283
+ loader?: string;
284
+ }
285
+ interface PostHogAnalyticsOptions extends PostHogAnalyticsDefaults {
286
+ enabled: boolean;
287
+ token: string;
288
+ api_host: string;
289
+ config?: Record<string, any>;
290
+ }
291
+
292
+ interface SimpleAnalyticsDefaults {
293
+ /**
294
+ * Tracking script source
295
+ */
296
+ script?: string;
297
+ /**
298
+ * `<noscript>` pixel source
299
+ */
300
+ noScript?: string;
301
+ /**
302
+ * `async` attribute set on the injected script tag
303
+ */
304
+ async?: boolean;
305
+ /**
306
+ * `defer` attribute set on the injected script tag
307
+ */
308
+ defer?: boolean;
309
+ }
310
+ interface SimpleAnalyticsOptions extends SimpleAnalyticsDefaults {
311
+ enabled: boolean;
312
+ hostname?: string;
313
+ }
314
+
315
+ interface TikTokPixelDefaults {
316
+ /**
317
+ * TikTok pixel events script source
318
+ */
319
+ script?: string;
320
+ /**
321
+ * Pixel methods registered on the `ttq` stub
322
+ */
323
+ methods?: string[];
324
+ /**
325
+ * Call executed right after the pixel is loaded
326
+ */
327
+ page?: string;
328
+ }
329
+ interface TikTokPixelOptions extends TikTokPixelDefaults {
330
+ id: string;
331
+ }
332
+
333
+ declare global {
334
+ interface Window {
335
+ TiktokAnalyticsObject: 'ttq';
336
+ ttq: Record<string, (...args: any[]) => void>;
337
+ }
338
+ }
339
+
340
+ interface UnbounceDefaults {
341
+ /**
342
+ * Unbounce tracking script source
343
+ */
344
+ script?: string;
345
+ /**
346
+ * Goal pushed to `_ubaq` (raw arguments array as a string)
347
+ */
348
+ goal?: string;
349
+ }
350
+ interface UnbounceOptions extends UnbounceDefaults {
351
+ enabled: boolean;
352
+ }
353
+
354
+ interface VKRetargetingDefaults {
355
+ /**
356
+ * `openapi.js` script source
357
+ */
358
+ script?: string;
359
+ /**
360
+ * Tracking endpoint used by the `<noscript>` pixel
361
+ */
362
+ noScript?: string;
363
+ /**
364
+ * Hit call executed once the script is loaded
365
+ */
366
+ hit?: string;
367
+ }
368
+ interface VKRetargeting extends VKRetargetingDefaults {
369
+ /**
370
+ * Retargeting tag
371
+ */
372
+ id: string;
373
+ }
374
+ type VKRetargetingOption = VKRetargeting | VKRetargeting[];
375
+
376
+ declare global {
377
+ interface Window {
378
+ VK: any;
379
+ }
380
+ }
381
+
382
+ interface MetricaConfiguration {
383
+ defer?: boolean;
384
+ clickmap?: boolean;
385
+ trackLinks?: boolean;
386
+ accurateTrackBounce?: boolean;
387
+ childIframe?: boolean;
388
+ webvisor?: boolean;
389
+ trackHash?: boolean;
390
+ triggerEvent?: boolean;
391
+ ecommerce?: string | boolean | any[];
392
+ trustedDomains?: string[];
393
+ type?: number;
394
+ params?: Record<string, string | number | boolean> | Record<string, string | number | boolean>[];
395
+ userParams?: Record<string, string | number | boolean>;
396
+ }
397
+ interface YandexMetricaDefaults {
398
+ /**
399
+ * `tag.js` script source
400
+ */
401
+ script?: string;
402
+ /**
403
+ * Tracking endpoint used by the `<noscript>` pixel
404
+ */
405
+ noScript?: string;
406
+ }
407
+ interface YandexMetricaProperty extends YandexMetricaDefaults {
408
+ id: string;
409
+ config?: MetricaConfiguration;
410
+ }
411
+ type YandexMetricaOptions = YandexMetricaProperty | YandexMetricaProperty[];
412
+
413
+ declare global {
414
+ interface Window {
415
+ dataLayer: any[];
416
+ ym: (id: string, command: string, ...args: any[]) => void;
417
+ }
418
+ }
419
+
420
+ interface VitePluginRadarOptions {
421
+ enableDev?: boolean;
422
+ analytics?: GoogleAnaliticsOptions;
423
+ gtm?: GoogleTagManagerOptions;
424
+ pixel?: FacebookPixelOption;
425
+ linkedin?: LinkedinInsightOptions;
426
+ tongji?: BaiduTongjiOptions;
427
+ metrica?: YandexMetricaOptions;
428
+ microsoft?: MicrosoftAdvertisingOptions;
429
+ microsoftClarity?: MicrosoftClarityOptions;
430
+ retargeting?: VKRetargetingOption;
431
+ hotjar?: HotjarOptions;
432
+ fullStory?: FullStoryOptions;
433
+ unbounce?: UnbounceOptions | boolean;
434
+ tiktok?: TikTokPixelOptions;
435
+ simpleanalytics?: SimpleAnalyticsOptions;
436
+ posthog?: PostHogAnalyticsOptions;
437
+ plausible?: PlausibleAnalyticsOptions;
438
+ }
439
+ type InjectorKey = Exclude<keyof VitePluginRadarOptions, 'enableDev'>;
440
+ interface InjectorEntry {
441
+ key: InjectorKey;
442
+ enabled?: (value: any) => boolean;
443
+ load: () => Promise<{
444
+ default: (options: any) => HtmlTagDescriptor[];
445
+ }>;
446
+ }
447
+ declare const INJECTORS: InjectorEntry[];
448
+ declare function VitePluginRadar({ enableDev, ...options }: VitePluginRadarOptions): Plugin;
449
+
450
+ export { INJECTORS, VitePluginRadar };
451
+ export type { VitePluginRadarOptions };