@ogcio/analytics-sdk 0.0.1-beta.4 → 0.1.0-beta.11

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.
Files changed (47) hide show
  1. package/dist/base/base-client.d.ts +11 -15
  2. package/dist/base/base-client.d.ts.map +1 -1
  3. package/dist/base/base-client.js +35 -34
  4. package/dist/base/base-client.js.map +1 -1
  5. package/dist/base/client-utils.d.ts +37 -0
  6. package/dist/base/client-utils.d.ts.map +1 -0
  7. package/dist/base/client-utils.js +80 -0
  8. package/dist/base/client-utils.js.map +1 -0
  9. package/dist/browser-types.d.ts +16 -8
  10. package/dist/index.d.ts +685 -379
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +333 -139
  13. package/dist/index.js.map +1 -1
  14. package/dist/matomo/helpers.d.ts +14 -11
  15. package/dist/matomo/helpers.d.ts.map +1 -1
  16. package/dist/matomo/helpers.js +102 -34
  17. package/dist/matomo/helpers.js.map +1 -1
  18. package/dist/schema.d.ts +594 -224
  19. package/dist/schema.d.ts.map +1 -1
  20. package/dist/support-files/auth/index.d.ts.map +1 -1
  21. package/dist/support-files/auth/index.js +3 -0
  22. package/dist/support-files/auth/index.js.map +1 -1
  23. package/dist/support-files/building-blocks-sdk.d.ts +2 -3
  24. package/dist/support-files/building-blocks-sdk.d.ts.map +1 -1
  25. package/dist/support-files/building-blocks-sdk.js +2 -0
  26. package/dist/support-files/building-blocks-sdk.js.map +1 -1
  27. package/dist/tests/testUtils/analytics.mock.d.ts +12 -0
  28. package/dist/tests/testUtils/analytics.mock.d.ts.map +1 -0
  29. package/dist/tests/testUtils/analytics.mock.js +21 -0
  30. package/dist/tests/testUtils/analytics.mock.js.map +1 -0
  31. package/dist/tests/testUtils/api.mock.handlers.d.ts +7 -0
  32. package/dist/tests/testUtils/api.mock.handlers.d.ts.map +1 -0
  33. package/dist/tests/testUtils/api.mock.handlers.js +77 -0
  34. package/dist/tests/testUtils/api.mock.handlers.js.map +1 -0
  35. package/dist/tests/testUtils/setup.mock.d.ts +3 -0
  36. package/dist/tests/testUtils/setup.mock.d.ts.map +1 -0
  37. package/dist/tests/testUtils/setup.mock.js +43 -0
  38. package/dist/tests/testUtils/setup.mock.js.map +1 -0
  39. package/dist/tests/testUtils/wait-request.d.ts +2 -0
  40. package/dist/tests/testUtils/wait-request.d.ts.map +1 -0
  41. package/dist/tests/testUtils/wait-request.js +2 -0
  42. package/dist/tests/testUtils/wait-request.js.map +1 -0
  43. package/dist/utils/index.d.ts +1 -0
  44. package/dist/utils/index.d.ts.map +1 -1
  45. package/dist/utils/index.js +10 -0
  46. package/dist/utils/index.js.map +1 -1
  47. package/package.json +23 -31
package/dist/index.d.ts CHANGED
@@ -1,18 +1,20 @@
1
1
  import type createClient from "openapi-fetch";
2
2
  import type { paths } from "./schema.js";
3
3
  export * from "./support-files/auth/index.js";
4
- import BaseClient, { type BaseApiClientParams } from "./base/base-client.js";
4
+ import { BaseClient, type BaseClientParams } from "./base/base-client.js";
5
+ import { type DataResponseValue } from "./base/client-utils.js";
5
6
  declare const DIMENSION_PREFIX = "dimension";
6
7
  export type CustomDimension = {
7
- [x: `${typeof DIMENSION_PREFIX}${number}`]: string;
8
+ [x: `${typeof DIMENSION_PREFIX}${number}`]: string | null;
8
9
  };
9
10
  export type TrackEndpoints = {
10
11
  [K in keyof paths]: K extends `/api/v1/websites/{id}/track-${string}` ? K : never;
11
12
  }[keyof paths];
12
- type WebsiteTrackingContextOverride = NonNullable<paths["/api/v1/websites/{id}/track-event"]["post"]["requestBody"]["content"]["application/json"]["contextOverride"]>;
13
+ type BaseTrackingRequest = paths["/api/v1/websites/{id}/track-event"]["post"];
14
+ type WebsiteTrackingContextOverride = NonNullable<BaseTrackingRequest["requestBody"]["content"]["application/json"]["contextOverride"]>;
13
15
  export type WebsiteTrackingContext = Omit<WebsiteTrackingContextOverride, "customDimensions"> & {
14
16
  /**
15
- * @description Custom dimensions example: { 'dimension1': 'value1', 'dimension2': 'value2' }
17
+ * Custom dimensions in format: { 'dimension1': 'value1', 'dimension2': 'value2' }
16
18
  * @example {
17
19
  * "dimension1": "value1",
18
20
  * "dimension2": "value2"
@@ -20,16 +22,20 @@ export type WebsiteTrackingContext = Omit<WebsiteTrackingContextOverride, "custo
20
22
  */
21
23
  customDimensions?: CustomDimension;
22
24
  };
23
- export type WebsiteTrackingMetadata = paths["/api/v1/websites/{id}/track-event"]["post"]["requestBody"]["content"]["application/json"]["metadata"];
24
- export type AnalyticsOptions = BaseApiClientParams & {
25
+ export type WebsiteTrackingMetadata = BaseTrackingRequest["requestBody"]["content"]["application/json"]["metadataOverride"];
26
+ export type WebsiteTrackBackendActionResponse = {
27
+ data?: BaseTrackingRequest["responses"]["200" | "201"]["content"]["application/json"]["data"];
28
+ error?: BaseTrackingRequest["responses"]["4XX"]["content"]["application/json"];
29
+ };
30
+ export type AnalyticsOptions = BaseClientParams & {
25
31
  trackingWebsiteId?: string;
26
32
  organizationId?: string;
27
33
  matomoToken?: string;
28
- trackingContext?: WebsiteTrackingContext;
29
- trackingMetadata?: WebsiteTrackingMetadata;
34
+ dryRun?: boolean;
35
+ optOut?: boolean;
30
36
  };
31
37
  export type WebsiteConfiguration = paths["/api/v1/websites/{id}"]["get"]["responses"]["200"]["content"]["application/json"]["data"];
32
- export type WebsiteTrackingCode = paths["/api/v1/websites/{id}/tracking-code"]["get"]["parameters"]["query"];
38
+ export type WebsiteTrackingCode = NonNullable<paths["/api/v1/websites/{id}/tracking-code"]["post"]["requestBody"]>["content"]["application/json"];
33
39
  export declare class Analytics extends BaseClient<paths> {
34
40
  protected client: ReturnType<typeof createClient<paths>>;
35
41
  protected serviceName: "analytics";
@@ -42,17 +48,45 @@ export declare class Analytics extends BaseClient<paths> {
42
48
  private organizationId?;
43
49
  private websiteConfiguration?;
44
50
  private websiteConfigurationPromise?;
45
- constructor({ trackingWebsiteId, organizationId, matomoToken, trackingContext, trackingMetadata, ...baseApiClientOptions }: AnalyticsOptions);
51
+ constructor({ trackingWebsiteId, organizationId, matomoToken, dryRun, optOut, ...baseApiClientOptions }: AnalyticsOptions);
46
52
  private retrieveWebsiteConfiguration;
47
53
  private matomoOnRequestMiddleware;
48
54
  private clientRequest;
49
55
  private ensureWebsiteConfiguration;
50
56
  private trackPush;
51
57
  private trackBackendAction;
58
+ /**
59
+ * Updates the Matomo authentication token.
60
+ * The token is optional, and is used to validate some params, during the backend requests.
61
+ * If you don't set the token, the validation will be skipped.
62
+ *
63
+ * @note The token is not used in browser environments.
64
+ */
52
65
  setMatomoToken(matomoToken: string): void;
66
+ /**
67
+ * Configures the website ID for tracking purposes
68
+ *
69
+ * When used client-side, this method triggers a background request to fetch the website configuration.
70
+ * The retrieved configuration is then used to initialize the Matomo tracker via the `initClientTracker` method.
71
+ *
72
+ * When used server-side, this method only sets the website ID without making any requests,
73
+ * since configuration retrieval is handled separately on the backend.
74
+ */
53
75
  setTrackingWebsiteId(websiteId: string): void;
76
+ /**
77
+ * Retrieves the currently configured tracking website ID.
78
+ */
54
79
  getTrackingWebsiteId(): string | undefined;
80
+ /**
81
+ * Sets metadata that will be included with all subsequent tracking requests.
82
+ * Setting a new value clears and overrides all previous metadata.
83
+ *
84
+ * @note Metadata is only used for backend tracking requests, as the metadata in browser environments are automatically retrieved.
85
+ */
55
86
  setTrackingMetadata(metadata: WebsiteTrackingMetadata): void;
87
+ /**
88
+ * Retrieves the current tracking metadata configuration.
89
+ */
56
90
  getTrackingMetadata(): {
57
91
  url?: string;
58
92
  userAgent?: string;
@@ -60,400 +94,672 @@ export declare class Analytics extends BaseClient<paths> {
60
94
  language?: string;
61
95
  screenResolution?: string;
62
96
  } | undefined;
63
- setTrackingContext(context: WebsiteTrackingContext): void;
97
+ /**
98
+ * Removes all configured tracking metadata.
99
+ */
100
+ clearTrackingMetadata(): void;
101
+ /**
102
+ * Sets the tracking context for all subsequent tracking operations.
103
+ * Setting a new value will clear and override all previously configured context data.
104
+ *
105
+ * @note When used in a browser environment, this will update the Matomo tracker with the provided user ID and custom dimensions.
106
+ */
107
+ setTrackingContext(context: WebsiteTrackingContext): Promise<void>;
108
+ /**
109
+ * Clears all tracking context data, including user ID and custom dimensions,
110
+ * from both the internal state and the Matomo tracker.
111
+ *
112
+ * @note When running in a browser environment, this method also clears
113
+ * the user ID and custom dimensions from the Matomo tracker instance.
114
+ */
64
115
  clearTrackingContext(): void;
116
+ /**
117
+ * Retrieves the current tracking context configuration.
118
+ */
65
119
  getTrackingContext(): WebsiteTrackingContext | undefined;
120
+ /**
121
+ * Enables or disables dry run mode. When enabled, no request will be sent
122
+ * to the API service, useful for testing and debugging.
123
+ */
66
124
  setDryRun(dryRun: boolean): void;
125
+ /**
126
+ * Enables or disables tracking opt-out. When enabled, the inizialization of the script will be done, but no tracking data will be sent
127
+ * to the analytics service respecting user privacy preferences.
128
+ */
67
129
  setOptOut(optOut: boolean): void;
130
+ /**
131
+ * Returns the current analytics configuration state.
132
+ */
68
133
  getAnalyticsConfig(): {
69
134
  dryRun: boolean;
70
135
  optOut: boolean;
71
136
  };
137
+ /**
138
+ * Updates the analytics configuration state.
139
+ */
72
140
  setAnalyticsConfig(config: {
73
141
  dryRun: boolean;
74
142
  optOut: boolean;
75
143
  }): void;
76
- initClientTracker(overrideConfig?: Partial<WebsiteTrackingCode>): Promise<void>;
144
+ /**
145
+ * Initializes the Matomo tracker by injecting the tracking script
146
+ * and configuring it with the website configuration of the currently set trackingWebsiteId.
147
+ * In order to set the user ID and custom dimensions, please use the `setTrackingContext` method.
148
+ *
149
+ * @note This method is only available in a browser environment, since it injects the tracking script directly into the HEAD of the document.
150
+ * The method also preserves any tracking commands issued before the tracker script loads. These commands are pushed to the Matomo tracker once the script is loaded.
151
+ */
152
+ initClientTracker(overrideConfig?: Partial<Omit<WebsiteTrackingCode, "customDimensions" | "userId">>): Promise<void>;
77
153
  administration: {
78
- getWebsites: () => Promise<{
79
- data: {
80
- data: {
81
- tracker_url: string;
82
- cookieless: boolean;
83
- bypass_adblockers: boolean;
84
- track_page_view: boolean;
85
- link_tracking: boolean;
86
- heart_beat_timer: number;
87
- browser_feature_detection: boolean;
88
- track_bots: boolean;
89
- custom_dimensions: {
90
- [key: string]: string;
91
- } & {
92
- [key: string]: string;
154
+ /**
155
+ * Retrieves a list of all configured websites.
156
+ */
157
+ getWebsites: () => Promise<DataResponseValue<{
158
+ parameters: {
159
+ query?: never;
160
+ header?: never;
161
+ path?: never;
162
+ cookie?: never;
163
+ };
164
+ requestBody?: never;
165
+ responses: {
166
+ 200: {
167
+ headers: {
168
+ [name: string]: unknown;
169
+ };
170
+ content: {
171
+ "application/json": {
172
+ data: {
173
+ siteIds: number[] & number[];
174
+ trackerUrl: string;
175
+ cookieless: boolean;
176
+ bypassAdblockers: boolean;
177
+ trackPageView: boolean;
178
+ linkTracking: boolean;
179
+ heartBeatTimer: number;
180
+ browserFeatureDetection: boolean;
181
+ trackBots: boolean;
182
+ id: string;
183
+ name: string;
184
+ domain: string;
185
+ organizationId: string;
186
+ createdAt: string;
187
+ updatedAt: string;
188
+ customDimensions: {
189
+ [key: string]: string;
190
+ };
191
+ }[];
192
+ };
193
+ };
194
+ };
195
+ "4XX": {
196
+ headers: {
197
+ [name: string]: unknown;
198
+ };
199
+ content: {
200
+ "application/json": {
201
+ code: string;
202
+ detail: string;
203
+ name: string;
204
+ };
205
+ };
206
+ };
207
+ "5XX": {
208
+ headers: {
209
+ [name: string]: unknown;
210
+ };
211
+ content: {
212
+ "application/json": {
213
+ code: string;
214
+ detail: string;
215
+ name: string;
216
+ };
217
+ };
218
+ };
219
+ };
220
+ }, import("openapi-fetch").FetchOptions<{
221
+ parameters: {
222
+ query?: never;
223
+ header?: never;
224
+ path?: never;
225
+ cookie?: never;
226
+ };
227
+ requestBody?: never;
228
+ responses: {
229
+ 200: {
230
+ headers: {
231
+ [name: string]: unknown;
232
+ };
233
+ content: {
234
+ "application/json": {
235
+ data: {
236
+ siteIds: number[] & number[];
237
+ trackerUrl: string;
238
+ cookieless: boolean;
239
+ bypassAdblockers: boolean;
240
+ trackPageView: boolean;
241
+ linkTracking: boolean;
242
+ heartBeatTimer: number;
243
+ browserFeatureDetection: boolean;
244
+ trackBots: boolean;
245
+ id: string;
246
+ name: string;
247
+ domain: string;
248
+ organizationId: string;
249
+ createdAt: string;
250
+ updatedAt: string;
251
+ customDimensions: {
252
+ [key: string]: string;
253
+ };
254
+ }[];
255
+ };
93
256
  };
257
+ };
258
+ "4XX": {
259
+ headers: {
260
+ [name: string]: unknown;
261
+ };
262
+ content: {
263
+ "application/json": {
264
+ code: string;
265
+ detail: string;
266
+ name: string;
267
+ };
268
+ };
269
+ };
270
+ "5XX": {
271
+ headers: {
272
+ [name: string]: unknown;
273
+ };
274
+ content: {
275
+ "application/json": {
276
+ code: string;
277
+ detail: string;
278
+ name: string;
279
+ };
280
+ };
281
+ };
282
+ };
283
+ }> | undefined>>;
284
+ /**
285
+ * Retrieves detailed configuration for a specific website.
286
+ */
287
+ getWebsiteById: (id: paths["/api/v1/websites/{id}"]["get"]["parameters"]["path"]["id"], query?: paths["/api/v1/websites/{id}"]["get"]["parameters"]["query"]) => Promise<DataResponseValue<{
288
+ parameters: {
289
+ query?: {
290
+ orgId?: string;
291
+ };
292
+ header?: never;
293
+ path: {
94
294
  id: string;
95
- name: string;
96
- domain: string;
97
- site_ids: number[];
98
- organization_id: string;
99
- created_at: string;
100
- updated_at: string;
101
- }[];
102
- } | undefined;
103
- error: undefined;
104
- } | {
105
- error: unknown;
106
- data: undefined;
107
- }>;
108
- getWebsiteById: (id: paths["/api/v1/websites/{id}"]["get"]["parameters"]["path"]["id"], query?: paths["/api/v1/websites/{id}"]["get"]["parameters"]["query"]) => Promise<{
109
- data: {
110
- data: {
111
- tracker_url: string;
112
- cookieless: boolean;
113
- bypass_adblockers: boolean;
114
- track_page_view: boolean;
115
- link_tracking: boolean;
116
- heart_beat_timer: number;
117
- browser_feature_detection: boolean;
118
- track_bots: boolean;
119
- custom_dimensions: {
120
- [key: string]: string;
121
- } & {
122
- [key: string]: string;
295
+ };
296
+ cookie?: never;
297
+ };
298
+ requestBody?: never;
299
+ responses: {
300
+ 200: {
301
+ headers: {
302
+ [name: string]: unknown;
303
+ };
304
+ content: {
305
+ "application/json": {
306
+ data: {
307
+ siteIds: number[] & number[];
308
+ trackerUrl: string;
309
+ cookieless: boolean;
310
+ bypassAdblockers: boolean;
311
+ trackPageView: boolean;
312
+ linkTracking: boolean;
313
+ heartBeatTimer: number;
314
+ browserFeatureDetection: boolean;
315
+ trackBots: boolean;
316
+ id: string;
317
+ name: string;
318
+ domain: string;
319
+ organizationId: string;
320
+ createdAt: string;
321
+ updatedAt: string;
322
+ customDimensions: {
323
+ [key: string]: string;
324
+ };
325
+ };
326
+ };
123
327
  };
328
+ };
329
+ "4XX": {
330
+ headers: {
331
+ [name: string]: unknown;
332
+ };
333
+ content: {
334
+ "application/json": {
335
+ code: string;
336
+ detail: string;
337
+ name: string;
338
+ };
339
+ };
340
+ };
341
+ "5XX": {
342
+ headers: {
343
+ [name: string]: unknown;
344
+ };
345
+ content: {
346
+ "application/json": {
347
+ code: string;
348
+ detail: string;
349
+ name: string;
350
+ };
351
+ };
352
+ };
353
+ };
354
+ }, {
355
+ params: {
356
+ path: {
124
357
  id: string;
125
- name: string;
126
- domain: string;
127
- site_ids: number[];
128
- organization_id: string;
129
- created_at: string;
130
- updated_at: string;
131
- };
132
- } | undefined;
133
- error: undefined;
134
- } | {
135
- error: unknown;
136
- data: undefined;
137
- }>;
138
- createWebsite: (data: paths["/api/v1/websites/"]["post"]["requestBody"]["content"]["application/json"]) => Promise<{
139
- data: {
140
- data: {
141
- tracker_url: string;
142
- cookieless: boolean;
143
- bypass_adblockers: boolean;
144
- track_page_view: boolean;
145
- link_tracking: boolean;
146
- heart_beat_timer: number;
147
- browser_feature_detection: boolean;
148
- track_bots: boolean;
149
- custom_dimensions: {
150
- [key: string]: string;
151
- } & {
152
- [key: string]: string;
358
+ };
359
+ query: {
360
+ orgId?: string;
361
+ } | undefined;
362
+ };
363
+ }>>;
364
+ /**
365
+ * Creates a new website configuration
366
+ */
367
+ createWebsite: (data: paths["/api/v1/websites/"]["post"]["requestBody"]["content"]["application/json"]) => Promise<DataResponseValue<{
368
+ parameters: {
369
+ query?: never;
370
+ header?: {
371
+ "x-matomo-token"?: string;
372
+ };
373
+ path?: never;
374
+ cookie?: never;
375
+ };
376
+ requestBody: {
377
+ content: {
378
+ "application/json": {
379
+ siteIds: number[] & (number[] & number[]);
380
+ trackerUrl: string;
381
+ cookieless: boolean;
382
+ bypassAdblockers: boolean;
383
+ trackPageView: boolean;
384
+ linkTracking: boolean;
385
+ heartBeatTimer: number;
386
+ browserFeatureDetection: boolean;
387
+ trackBots: boolean;
388
+ name: string;
389
+ domain: string;
390
+ customDimensions: {
391
+ [key: string]: string;
392
+ };
393
+ id?: string;
394
+ organizationId?: string;
153
395
  };
396
+ };
397
+ };
398
+ responses: {
399
+ 201: {
400
+ headers: {
401
+ [name: string]: unknown;
402
+ };
403
+ content: {
404
+ "application/json": {
405
+ data: {
406
+ siteIds: number[] & number[];
407
+ trackerUrl: string;
408
+ cookieless: boolean;
409
+ bypassAdblockers: boolean;
410
+ trackPageView: boolean;
411
+ linkTracking: boolean;
412
+ heartBeatTimer: number;
413
+ browserFeatureDetection: boolean;
414
+ trackBots: boolean;
415
+ id: string;
416
+ name: string;
417
+ domain: string;
418
+ organizationId: string;
419
+ createdAt: string;
420
+ updatedAt: string;
421
+ customDimensions: {
422
+ [key: string]: string;
423
+ };
424
+ };
425
+ };
426
+ };
427
+ };
428
+ "4XX": {
429
+ headers: {
430
+ [name: string]: unknown;
431
+ };
432
+ content: {
433
+ "application/json": {
434
+ code: string;
435
+ detail: string;
436
+ name: string;
437
+ };
438
+ };
439
+ };
440
+ "5XX": {
441
+ headers: {
442
+ [name: string]: unknown;
443
+ };
444
+ content: {
445
+ "application/json": {
446
+ code: string;
447
+ detail: string;
448
+ name: string;
449
+ };
450
+ };
451
+ };
452
+ };
453
+ }, {
454
+ body: {
455
+ siteIds: number[] & (number[] & number[]);
456
+ trackerUrl: string;
457
+ cookieless: boolean;
458
+ bypassAdblockers: boolean;
459
+ trackPageView: boolean;
460
+ linkTracking: boolean;
461
+ heartBeatTimer: number;
462
+ browserFeatureDetection: boolean;
463
+ trackBots: boolean;
464
+ name: string;
465
+ domain: string;
466
+ customDimensions: {
467
+ [key: string]: string;
468
+ };
469
+ id?: string;
470
+ organizationId?: string;
471
+ };
472
+ }>>;
473
+ /**
474
+ * Updates an existing website configuration.
475
+ */
476
+ updateWebsite: (id: paths["/api/v1/websites/{id}"]["patch"]["parameters"]["path"]["id"], data: NonNullable<paths["/api/v1/websites/{id}"]["patch"]["requestBody"]>["content"]["application/json"]) => Promise<DataResponseValue<{
477
+ parameters: {
478
+ query?: never;
479
+ header?: {
480
+ "x-matomo-token"?: string;
481
+ };
482
+ path: {
154
483
  id: string;
155
- name: string;
156
- domain: string;
157
- site_ids: number[];
158
- organization_id: string;
159
- created_at: string;
160
- updated_at: string;
161
- };
162
- } | undefined;
163
- error: undefined;
164
- } | {
165
- error: unknown;
166
- data: undefined;
167
- }>;
168
- updateWebsite: (id: paths["/api/v1/websites/{id}"]["patch"]["parameters"]["path"]["id"], data: NonNullable<paths["/api/v1/websites/{id}"]["patch"]["requestBody"]>["content"]["application/json"]) => Promise<{
169
- data: {
170
- data: {
171
- tracker_url: string;
172
- cookieless: boolean;
173
- bypass_adblockers: boolean;
174
- track_page_view: boolean;
175
- link_tracking: boolean;
176
- heart_beat_timer: number;
177
- browser_feature_detection: boolean;
178
- track_bots: boolean;
179
- custom_dimensions?: {
180
- [key: string]: string;
484
+ };
485
+ cookie?: never;
486
+ };
487
+ requestBody?: {
488
+ content: {
489
+ "application/json": {
490
+ siteIds?: number[] & (number[] & number[]);
491
+ trackerUrl?: string;
492
+ cookieless?: boolean;
493
+ bypassAdblockers?: boolean;
494
+ trackPageView?: boolean;
495
+ linkTracking?: boolean;
496
+ heartBeatTimer?: number;
497
+ browserFeatureDetection?: boolean;
498
+ trackBots?: boolean;
499
+ name?: string;
500
+ domain?: string;
501
+ customDimensions?: {
502
+ [key: string]: string;
503
+ };
504
+ organizationId?: string;
505
+ };
506
+ };
507
+ };
508
+ responses: {
509
+ 200: {
510
+ headers: {
511
+ [name: string]: unknown;
512
+ };
513
+ content: {
514
+ "application/json": {
515
+ data: {
516
+ siteIds: number[] & number[];
517
+ trackerUrl: string;
518
+ cookieless: boolean;
519
+ bypassAdblockers: boolean;
520
+ trackPageView: boolean;
521
+ linkTracking: boolean;
522
+ heartBeatTimer: number;
523
+ browserFeatureDetection: boolean;
524
+ trackBots: boolean;
525
+ id: string;
526
+ name: string;
527
+ domain: string;
528
+ organizationId: string;
529
+ createdAt: string;
530
+ updatedAt: string;
531
+ customDimensions: {
532
+ [key: string]: string;
533
+ };
534
+ };
535
+ };
181
536
  };
537
+ };
538
+ "4XX": {
539
+ headers: {
540
+ [name: string]: unknown;
541
+ };
542
+ content: {
543
+ "application/json": {
544
+ code: string;
545
+ detail: string;
546
+ name: string;
547
+ };
548
+ };
549
+ };
550
+ "5XX": {
551
+ headers: {
552
+ [name: string]: unknown;
553
+ };
554
+ content: {
555
+ "application/json": {
556
+ code: string;
557
+ detail: string;
558
+ name: string;
559
+ };
560
+ };
561
+ };
562
+ };
563
+ }, {
564
+ params: {
565
+ path: {
182
566
  id: string;
183
- name: string;
184
- domain: string;
185
- site_ids: number[];
186
- organization_id: string;
187
- created_at: string;
188
- updated_at: string;
189
- };
190
- } | undefined;
191
- error: undefined;
192
- } | {
193
- error: unknown;
194
- data: undefined;
195
- }>;
567
+ };
568
+ };
569
+ body: {
570
+ siteIds?: number[] & (number[] & number[]);
571
+ trackerUrl?: string;
572
+ cookieless?: boolean;
573
+ bypassAdblockers?: boolean;
574
+ trackPageView?: boolean;
575
+ linkTracking?: boolean;
576
+ heartBeatTimer?: number;
577
+ browserFeatureDetection?: boolean;
578
+ trackBots?: boolean;
579
+ name?: string;
580
+ domain?: string;
581
+ customDimensions?: {
582
+ [key: string]: string;
583
+ };
584
+ organizationId?: string;
585
+ };
586
+ }>>;
196
587
  };
197
588
  generate: {
198
- initTrackingJsCode: (query: WebsiteTrackingCode) => Promise<{
199
- data: {
200
- data: {
201
- script: string;
202
- };
203
- } | undefined;
204
- error: undefined;
205
- } | {
206
- error: unknown;
207
- data: undefined;
208
- }>;
209
- trackEventJsCode: (data: paths["/api/v1/websites/{id}/track-event"]["post"]["requestBody"]["content"]["application/json"]) => Promise<{
210
- data: {
211
- data: unknown;
212
- } | {
213
- data: unknown;
214
- } | {
215
- data: unknown;
216
- } | {
217
- data: unknown;
218
- } | {
219
- data: unknown;
220
- } | {
221
- data: unknown;
222
- } | undefined;
223
- error: undefined;
224
- } | {
225
- error: unknown;
226
- data: undefined;
227
- }>;
228
- trackPageViewJsCode: (data: paths["/api/v1/websites/{id}/track-page-view"]["post"]["requestBody"]["content"]["application/json"]) => Promise<{
229
- data: {
230
- data: unknown;
231
- } | {
232
- data: unknown;
233
- } | {
234
- data: unknown;
235
- } | {
236
- data: unknown;
237
- } | {
238
- data: unknown;
239
- } | {
240
- data: unknown;
241
- } | undefined;
242
- error: undefined;
243
- } | {
244
- error: unknown;
245
- data: undefined;
246
- }>;
247
- trackSiteSearchJsCode: (data: paths["/api/v1/websites/{id}/track-search"]["post"]["requestBody"]["content"]["application/json"]) => Promise<{
248
- data: {
249
- data: unknown;
250
- } | {
251
- data: unknown;
252
- } | {
253
- data: unknown;
254
- } | {
255
- data: unknown;
256
- } | {
257
- data: unknown;
258
- } | {
259
- data: unknown;
260
- } | undefined;
261
- error: undefined;
262
- } | {
263
- error: unknown;
264
- data: undefined;
265
- }>;
266
- trackLinkJsCode: (data: paths["/api/v1/websites/{id}/track-link"]["post"]["requestBody"]["content"]["application/json"]) => Promise<{
267
- data: {
268
- data: unknown;
269
- } | {
270
- data: unknown;
271
- } | {
272
- data: unknown;
273
- } | {
274
- data: unknown;
275
- } | {
276
- data: unknown;
277
- } | {
278
- data: unknown;
279
- } | undefined;
280
- error: undefined;
281
- } | {
282
- error: unknown;
283
- data: undefined;
284
- }>;
285
- trackContentImpressionJsCode: (data: paths["/api/v1/websites/{id}/track-content-impression"]["post"]["requestBody"]["content"]["application/json"]) => Promise<{
286
- data: {
287
- data: unknown;
288
- } | {
289
- data: unknown;
290
- } | {
291
- data: unknown;
292
- } | {
293
- data: unknown;
294
- } | {
295
- data: unknown;
296
- } | {
297
- data: unknown;
298
- } | undefined;
299
- error: undefined;
300
- } | {
301
- error: unknown;
302
- data: undefined;
303
- }>;
304
- trackContentInteractionJsCode: (data: paths["/api/v1/websites/{id}/track-content-interaction"]["post"]["requestBody"]["content"]["application/json"]) => Promise<{
305
- data: {
306
- data: unknown;
307
- } | {
308
- data: unknown;
309
- } | {
310
- data: unknown;
311
- } | {
312
- data: unknown;
313
- } | {
314
- data: unknown;
315
- } | {
316
- data: unknown;
317
- } | undefined;
318
- error: undefined;
319
- } | {
320
- error: unknown;
321
- data: undefined;
322
- }>;
589
+ /**
590
+ * Generates the JavaScript tracking code for initializing analytics on a website.
591
+ *
592
+ * @note This method is available only on the backend-side
593
+ */
594
+ initTrackingJsCode: (body?: WebsiteTrackingCode) => Promise<DataResponseValue<{
595
+ parameters: {
596
+ query?: never;
597
+ header?: never;
598
+ path: {
599
+ id: string;
600
+ };
601
+ cookie?: never;
602
+ };
603
+ requestBody?: {
604
+ content: {
605
+ "application/json": {
606
+ siteIds?: number[];
607
+ trackerUrl?: string;
608
+ cookieless?: boolean;
609
+ bypassAdblockers?: boolean;
610
+ trackPageView?: boolean;
611
+ linkTracking?: boolean;
612
+ heartBeatTimer?: number;
613
+ browserFeatureDetection?: boolean;
614
+ trackBots?: boolean;
615
+ customDimensions?: {
616
+ [key: string]: string;
617
+ };
618
+ userId?: string;
619
+ };
620
+ };
621
+ };
622
+ responses: {
623
+ 200: {
624
+ headers: {
625
+ [name: string]: unknown;
626
+ };
627
+ content: {
628
+ "application/json": {
629
+ data: {
630
+ script: string;
631
+ };
632
+ };
633
+ };
634
+ };
635
+ "4XX": {
636
+ headers: {
637
+ [name: string]: unknown;
638
+ };
639
+ content: {
640
+ "application/json": {
641
+ code: string;
642
+ detail: string;
643
+ name: string;
644
+ };
645
+ };
646
+ };
647
+ "5XX": {
648
+ headers: {
649
+ [name: string]: unknown;
650
+ };
651
+ content: {
652
+ "application/json": {
653
+ code: string;
654
+ detail: string;
655
+ name: string;
656
+ };
657
+ };
658
+ };
659
+ };
660
+ }, {
661
+ params: {
662
+ path: {
663
+ id: string;
664
+ };
665
+ body: {
666
+ siteIds?: number[];
667
+ trackerUrl?: string;
668
+ cookieless?: boolean;
669
+ bypassAdblockers?: boolean;
670
+ trackPageView?: boolean;
671
+ linkTracking?: boolean;
672
+ heartBeatTimer?: number;
673
+ browserFeatureDetection?: boolean;
674
+ trackBots?: boolean;
675
+ customDimensions?: {
676
+ [key: string]: string;
677
+ };
678
+ userId?: string;
679
+ } | undefined;
680
+ };
681
+ }>>;
682
+ /**
683
+ * Generates JavaScript code for tracking custom events.
684
+ *
685
+ * @note This method is available only on the backend-side
686
+ *
687
+ */
688
+ trackEventJsCode: (data: paths["/api/v1/websites/{id}/track-event"]["post"]["requestBody"]["content"]["application/json"]) => Promise<WebsiteTrackBackendActionResponse>;
689
+ /**
690
+ * Generates JavaScript code for tracking page views.
691
+ *
692
+ * @note This method is available only on the backend-side
693
+ *
694
+ */
695
+ trackPageViewJsCode: (data: paths["/api/v1/websites/{id}/track-page-view"]["post"]["requestBody"]["content"]["application/json"]) => Promise<WebsiteTrackBackendActionResponse>;
696
+ /**
697
+ * Generates JavaScript code for tracking site searches.
698
+ *
699
+ * @note This method is available only on the backend-side
700
+ *
701
+ */
702
+ trackSiteSearchJsCode: (data: paths["/api/v1/websites/{id}/track-search"]["post"]["requestBody"]["content"]["application/json"]) => Promise<WebsiteTrackBackendActionResponse>;
703
+ /**
704
+ * Generates JavaScript code for tracking link clicks.
705
+ *
706
+ * @note This method is available only on the backend-side
707
+ *
708
+ */
709
+ trackLinkJsCode: (data: paths["/api/v1/websites/{id}/track-link"]["post"]["requestBody"]["content"]["application/json"]) => Promise<WebsiteTrackBackendActionResponse>;
710
+ /**
711
+ * Generates JavaScript code for tracking content impressions.
712
+ *
713
+ * @note This method is available only on the backend-side
714
+ *
715
+ */
716
+ trackContentImpressionJsCode: (data: paths["/api/v1/websites/{id}/track-content-impression"]["post"]["requestBody"]["content"]["application/json"]) => Promise<WebsiteTrackBackendActionResponse>;
717
+ /**
718
+ * Generates JavaScript code for tracking content interactions.
719
+ *
720
+ * @note This method is available only on the backend-side
721
+ *
722
+ */
723
+ trackContentInteractionJsCode: (data: paths["/api/v1/websites/{id}/track-content-interaction"]["post"]["requestBody"]["content"]["application/json"]) => Promise<WebsiteTrackBackendActionResponse>;
323
724
  };
324
725
  track: {
325
- event: (data: paths["/api/v1/websites/{id}/track-event"]["post"]["requestBody"]["content"]["application/json"]) => Promise<number | {
326
- data: string;
327
- error?: undefined;
328
- } | {
329
- error: unknown;
330
- data?: undefined;
331
- } | {
332
- data: {
333
- data: unknown;
334
- } | {
335
- data: unknown;
336
- } | {
337
- data: unknown;
338
- } | {
339
- data: unknown;
340
- } | {
341
- data: unknown;
342
- } | {
343
- data: unknown;
344
- } | undefined;
345
- error: undefined;
346
- } | undefined>;
347
- pageView: (data: paths["/api/v1/websites/{id}/track-page-view"]["post"]["requestBody"]["content"]["application/json"]) => Promise<number | {
348
- data: string;
349
- error?: undefined;
350
- } | {
351
- error: unknown;
352
- data?: undefined;
353
- } | {
354
- data: {
355
- data: unknown;
356
- } | {
357
- data: unknown;
358
- } | {
359
- data: unknown;
360
- } | {
361
- data: unknown;
362
- } | {
363
- data: unknown;
364
- } | {
365
- data: unknown;
366
- } | undefined;
367
- error: undefined;
368
- } | undefined>;
369
- siteSearch: (data: paths["/api/v1/websites/{id}/track-search"]["post"]["requestBody"]["content"]["application/json"]) => Promise<number | {
370
- data: string;
371
- error?: undefined;
372
- } | {
373
- error: unknown;
374
- data?: undefined;
375
- } | {
376
- data: {
377
- data: unknown;
378
- } | {
379
- data: unknown;
380
- } | {
381
- data: unknown;
382
- } | {
383
- data: unknown;
384
- } | {
385
- data: unknown;
386
- } | {
387
- data: unknown;
388
- } | undefined;
389
- error: undefined;
390
- } | undefined>;
391
- link: (data: paths["/api/v1/websites/{id}/track-link"]["post"]["requestBody"]["content"]["application/json"]) => Promise<number | {
392
- data: string;
393
- error?: undefined;
394
- } | {
395
- error: unknown;
396
- data?: undefined;
397
- } | {
398
- data: {
399
- data: unknown;
400
- } | {
401
- data: unknown;
402
- } | {
403
- data: unknown;
404
- } | {
405
- data: unknown;
406
- } | {
407
- data: unknown;
408
- } | {
409
- data: unknown;
410
- } | undefined;
411
- error: undefined;
412
- } | undefined>;
413
- contentImpression: (data: paths["/api/v1/websites/{id}/track-content-impression"]["post"]["requestBody"]["content"]["application/json"]) => Promise<number | {
414
- data: string;
415
- error?: undefined;
416
- } | {
417
- error: unknown;
418
- data?: undefined;
419
- } | {
420
- data: {
421
- data: unknown;
422
- } | {
423
- data: unknown;
424
- } | {
425
- data: unknown;
426
- } | {
427
- data: unknown;
428
- } | {
429
- data: unknown;
430
- } | {
431
- data: unknown;
432
- } | undefined;
433
- error: undefined;
434
- } | undefined>;
435
- contentInteraction: (data: paths["/api/v1/websites/{id}/track-content-interaction"]["post"]["requestBody"]["content"]["application/json"]) => Promise<number | {
436
- data: string;
437
- error?: undefined;
438
- } | {
439
- error: unknown;
440
- data?: undefined;
441
- } | {
442
- data: {
443
- data: unknown;
444
- } | {
445
- data: unknown;
446
- } | {
447
- data: unknown;
448
- } | {
449
- data: unknown;
450
- } | {
451
- data: unknown;
452
- } | {
453
- data: unknown;
454
- } | undefined;
455
- error: undefined;
456
- } | undefined>;
726
+ /**
727
+ * Tracks custom event
728
+ * @note The contextOverride parameter allows overriding specific custom dimensions for this event only, while preserving other global tracking context values. Set a dimension to null to remove it for this event.
729
+ */
730
+ event: (data: paths["/api/v1/websites/{id}/track-event"]["post"]["requestBody"]["content"]["application/json"]) => Promise<WebsiteTrackBackendActionResponse>;
731
+ /**
732
+ * Tracks page views
733
+ * @note The contextOverride parameter allows overriding specific custom dimensions for this event only, while preserving other global tracking context values. Set a dimension to null to remove it for this event.
734
+
735
+ */
736
+ pageView: (data: paths["/api/v1/websites/{id}/track-page-view"]["post"]["requestBody"]["content"]["application/json"]) => Promise<WebsiteTrackBackendActionResponse>;
737
+ /**
738
+ * Tracks site search
739
+ * @note The contextOverride parameter allows overriding specific custom dimensions for this event only, while preserving other global tracking context values. Set a dimension to null to remove it for this event.
740
+
741
+ */
742
+ siteSearch: (data: paths["/api/v1/websites/{id}/track-search"]["post"]["requestBody"]["content"]["application/json"]) => Promise<WebsiteTrackBackendActionResponse>;
743
+ /**
744
+ * Tracks link click
745
+ *
746
+ * if linkType is 'link' the link is an outgoing link, if 'download' the link is a download
747
+ * @note The contextOverride parameter allows overriding specific custom dimensions for this event only, while preserving other global tracking context values. Set a dimension to null to remove it for this event.
748
+
749
+ */
750
+ link: (data: paths["/api/v1/websites/{id}/track-link"]["post"]["requestBody"]["content"]["application/json"]) => Promise<WebsiteTrackBackendActionResponse>;
751
+ /**
752
+ * Tracks content impression
753
+ * @note The contextOverride parameter allows overriding specific custom dimensions for this event only, while preserving other global tracking context values. Set a dimension to null to remove it for this event.
754
+
755
+ */
756
+ contentImpression: (data: paths["/api/v1/websites/{id}/track-content-impression"]["post"]["requestBody"]["content"]["application/json"]) => Promise<WebsiteTrackBackendActionResponse>;
757
+ /**
758
+ * Tracks content interaction
759
+ * @note The contextOverride parameter allows overriding specific custom dimensions for this event only, while preserving other global tracking context values. Set a dimension to null to remove it for this event.
760
+
761
+ */
762
+ contentInteraction: (data: paths["/api/v1/websites/{id}/track-content-interaction"]["post"]["requestBody"]["content"]["application/json"]) => Promise<WebsiteTrackBackendActionResponse>;
457
763
  };
458
764
  }
459
765
  //# sourceMappingURL=index.d.ts.map