@algolia/client-insights 5.2.5 → 5.3.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.
- package/dist/browser.d.ts +170 -98
- package/dist/builds/browser.js +39 -29
- package/dist/builds/browser.js.map +1 -1
- package/dist/builds/browser.min.js +1 -1
- package/dist/builds/browser.min.js.map +1 -1
- package/dist/builds/browser.umd.js +1 -1
- package/dist/builds/node.cjs +39 -29
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +39 -29
- package/dist/builds/node.js.map +1 -1
- package/dist/node.d.cts +170 -98
- package/dist/node.d.ts +170 -98
- package/dist/src/insightsClient.cjs +39 -29
- package/dist/src/insightsClient.cjs.map +1 -1
- package/dist/src/insightsClient.js +39 -29
- package/dist/src/insightsClient.js.map +1 -1
- package/package.json +4 -4
package/dist/node.d.ts
CHANGED
|
@@ -1,5 +1,89 @@
|
|
|
1
1
|
import * as _algolia_client_common from '@algolia/client-common';
|
|
2
|
-
import { ClientOptions } from '@algolia/client-common';
|
|
2
|
+
import { CreateClientOptions, RequestOptions, ClientOptions } from '@algolia/client-common';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Properties for the `customDelete` method.
|
|
6
|
+
*/
|
|
7
|
+
type CustomDeleteProps = {
|
|
8
|
+
/**
|
|
9
|
+
* Path of the endpoint, anything after \"/1\" must be specified.
|
|
10
|
+
*/
|
|
11
|
+
path: string;
|
|
12
|
+
/**
|
|
13
|
+
* Query parameters to apply to the current query.
|
|
14
|
+
*/
|
|
15
|
+
parameters?: Record<string, any>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Properties for the `customGet` method.
|
|
19
|
+
*/
|
|
20
|
+
type CustomGetProps = {
|
|
21
|
+
/**
|
|
22
|
+
* Path of the endpoint, anything after \"/1\" must be specified.
|
|
23
|
+
*/
|
|
24
|
+
path: string;
|
|
25
|
+
/**
|
|
26
|
+
* Query parameters to apply to the current query.
|
|
27
|
+
*/
|
|
28
|
+
parameters?: Record<string, any>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Properties for the `customPost` method.
|
|
32
|
+
*/
|
|
33
|
+
type CustomPostProps = {
|
|
34
|
+
/**
|
|
35
|
+
* Path of the endpoint, anything after \"/1\" must be specified.
|
|
36
|
+
*/
|
|
37
|
+
path: string;
|
|
38
|
+
/**
|
|
39
|
+
* Query parameters to apply to the current query.
|
|
40
|
+
*/
|
|
41
|
+
parameters?: Record<string, any>;
|
|
42
|
+
/**
|
|
43
|
+
* Parameters to send with the custom request.
|
|
44
|
+
*/
|
|
45
|
+
body?: Record<string, unknown>;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Properties for the `customPut` method.
|
|
49
|
+
*/
|
|
50
|
+
type CustomPutProps = {
|
|
51
|
+
/**
|
|
52
|
+
* Path of the endpoint, anything after \"/1\" must be specified.
|
|
53
|
+
*/
|
|
54
|
+
path: string;
|
|
55
|
+
/**
|
|
56
|
+
* Query parameters to apply to the current query.
|
|
57
|
+
*/
|
|
58
|
+
parameters?: Record<string, any>;
|
|
59
|
+
/**
|
|
60
|
+
* Parameters to send with the custom request.
|
|
61
|
+
*/
|
|
62
|
+
body?: Record<string, unknown>;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Properties for the `deleteUserToken` method.
|
|
66
|
+
*/
|
|
67
|
+
type DeleteUserTokenProps = {
|
|
68
|
+
/**
|
|
69
|
+
* User token for which to delete all associated events.
|
|
70
|
+
*/
|
|
71
|
+
userToken: string;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The response of the Insights API.
|
|
76
|
+
*/
|
|
77
|
+
type EventsResponse = {
|
|
78
|
+
/**
|
|
79
|
+
* Details about the response, such as error messages.
|
|
80
|
+
*/
|
|
81
|
+
message?: string;
|
|
82
|
+
/**
|
|
83
|
+
* The HTTP status code of the response.
|
|
84
|
+
*/
|
|
85
|
+
status?: number;
|
|
86
|
+
};
|
|
3
87
|
|
|
4
88
|
type AddToCartEvent = 'addToCart';
|
|
5
89
|
|
|
@@ -325,13 +409,6 @@ type ConvertedObjectIDsAfterSearch = {
|
|
|
325
409
|
timestamp?: number;
|
|
326
410
|
};
|
|
327
411
|
|
|
328
|
-
/**
|
|
329
|
-
* Error.
|
|
330
|
-
*/
|
|
331
|
-
type ErrorBase = Record<string, any> & {
|
|
332
|
-
message?: string;
|
|
333
|
-
};
|
|
334
|
-
|
|
335
412
|
type PurchaseEvent = 'purchase';
|
|
336
413
|
|
|
337
414
|
/**
|
|
@@ -482,20 +559,6 @@ type ViewedObjectIDs = {
|
|
|
482
559
|
|
|
483
560
|
type EventsItems = AddedToCartObjectIDs | AddedToCartObjectIDsAfterSearch | ClickedFilters | ClickedObjectIDs | ClickedObjectIDsAfterSearch | ConvertedFilters | ConvertedObjectIDs | ConvertedObjectIDsAfterSearch | PurchasedObjectIDs | PurchasedObjectIDsAfterSearch | ViewedFilters | ViewedObjectIDs;
|
|
484
561
|
|
|
485
|
-
/**
|
|
486
|
-
* The response of the Insights API.
|
|
487
|
-
*/
|
|
488
|
-
type EventsResponse = {
|
|
489
|
-
/**
|
|
490
|
-
* Details about the response, such as error messages.
|
|
491
|
-
*/
|
|
492
|
-
message?: string;
|
|
493
|
-
/**
|
|
494
|
-
* The HTTP status code of the response.
|
|
495
|
-
*/
|
|
496
|
-
status?: number;
|
|
497
|
-
};
|
|
498
|
-
|
|
499
562
|
type InsightsEvents = {
|
|
500
563
|
/**
|
|
501
564
|
* Click and conversion events. **All** events must be valid, otherwise the API returns an error.
|
|
@@ -503,96 +566,105 @@ type InsightsEvents = {
|
|
|
503
566
|
events: EventsItems[];
|
|
504
567
|
};
|
|
505
568
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
path: string;
|
|
514
|
-
/**
|
|
515
|
-
* Query parameters to apply to the current query.
|
|
516
|
-
*/
|
|
517
|
-
parameters?: Record<string, any>;
|
|
518
|
-
};
|
|
519
|
-
/**
|
|
520
|
-
* Properties for the `customGet` method.
|
|
521
|
-
*/
|
|
522
|
-
type CustomGetProps = {
|
|
523
|
-
/**
|
|
524
|
-
* Path of the endpoint, anything after \"/1\" must be specified.
|
|
525
|
-
*/
|
|
526
|
-
path: string;
|
|
527
|
-
/**
|
|
528
|
-
* Query parameters to apply to the current query.
|
|
529
|
-
*/
|
|
530
|
-
parameters?: Record<string, any>;
|
|
531
|
-
};
|
|
532
|
-
/**
|
|
533
|
-
* Properties for the `customPost` method.
|
|
534
|
-
*/
|
|
535
|
-
type CustomPostProps = {
|
|
536
|
-
/**
|
|
537
|
-
* Path of the endpoint, anything after \"/1\" must be specified.
|
|
538
|
-
*/
|
|
539
|
-
path: string;
|
|
569
|
+
declare const apiClientVersion = "5.3.0";
|
|
570
|
+
declare const REGIONS: readonly ["de", "us"];
|
|
571
|
+
type Region = (typeof REGIONS)[number];
|
|
572
|
+
declare function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & {
|
|
573
|
+
region?: Region;
|
|
574
|
+
}): {
|
|
575
|
+
transporter: _algolia_client_common.Transporter;
|
|
540
576
|
/**
|
|
541
|
-
*
|
|
577
|
+
* The `appId` currently in use.
|
|
542
578
|
*/
|
|
543
|
-
|
|
579
|
+
appId: string;
|
|
544
580
|
/**
|
|
545
|
-
*
|
|
581
|
+
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
546
582
|
*/
|
|
547
|
-
|
|
548
|
-
};
|
|
549
|
-
/**
|
|
550
|
-
* Properties for the `customPut` method.
|
|
551
|
-
*/
|
|
552
|
-
type CustomPutProps = {
|
|
583
|
+
clearCache(): Promise<void>;
|
|
553
584
|
/**
|
|
554
|
-
*
|
|
585
|
+
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
|
|
555
586
|
*/
|
|
556
|
-
|
|
587
|
+
readonly _ua: string;
|
|
557
588
|
/**
|
|
558
|
-
*
|
|
589
|
+
* Adds a `segment` to the `x-algolia-agent` sent with every requests.
|
|
590
|
+
*
|
|
591
|
+
* @param segment - The algolia agent (user-agent) segment to add.
|
|
592
|
+
* @param version - The version of the agent.
|
|
559
593
|
*/
|
|
560
|
-
|
|
594
|
+
addAlgoliaAgent(segment: string, version?: string): void;
|
|
561
595
|
/**
|
|
562
|
-
*
|
|
563
|
-
|
|
564
|
-
|
|
596
|
+
* Helper method to switch the API key used to authenticate the requests.
|
|
597
|
+
*
|
|
598
|
+
* @param params - Method params.
|
|
599
|
+
* @param params.apiKey - The new API Key to use.
|
|
600
|
+
*/
|
|
601
|
+
setClientApiKey({ apiKey }: {
|
|
602
|
+
apiKey: string;
|
|
603
|
+
}): void;
|
|
604
|
+
/**
|
|
605
|
+
* This method allow you to send requests to the Algolia REST API.
|
|
606
|
+
*
|
|
607
|
+
* @param customDelete - The customDelete object.
|
|
608
|
+
* @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
609
|
+
* @param customDelete.parameters - Query parameters to apply to the current query.
|
|
610
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
611
|
+
*/
|
|
612
|
+
customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
|
|
613
|
+
/**
|
|
614
|
+
* This method allow you to send requests to the Algolia REST API.
|
|
615
|
+
*
|
|
616
|
+
* @param customGet - The customGet object.
|
|
617
|
+
* @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
618
|
+
* @param customGet.parameters - Query parameters to apply to the current query.
|
|
619
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
620
|
+
*/
|
|
621
|
+
customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
|
|
622
|
+
/**
|
|
623
|
+
* This method allow you to send requests to the Algolia REST API.
|
|
624
|
+
*
|
|
625
|
+
* @param customPost - The customPost object.
|
|
626
|
+
* @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
627
|
+
* @param customPost.parameters - Query parameters to apply to the current query.
|
|
628
|
+
* @param customPost.body - Parameters to send with the custom request.
|
|
629
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
630
|
+
*/
|
|
631
|
+
customPost({ path, parameters, body }: CustomPostProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
|
|
632
|
+
/**
|
|
633
|
+
* This method allow you to send requests to the Algolia REST API.
|
|
634
|
+
*
|
|
635
|
+
* @param customPut - The customPut object.
|
|
636
|
+
* @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
637
|
+
* @param customPut.parameters - Query parameters to apply to the current query.
|
|
638
|
+
* @param customPut.body - Parameters to send with the custom request.
|
|
639
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
640
|
+
*/
|
|
641
|
+
customPut({ path, parameters, body }: CustomPutProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
|
|
642
|
+
/**
|
|
643
|
+
* Deletes all events related to the specified user token from events metrics and analytics. The deletion is asynchronous, and processed within 48 hours. To delete a personalization user profile, see `Delete a user profile` in the Personalization API.
|
|
644
|
+
*
|
|
645
|
+
* @param deleteUserToken - The deleteUserToken object.
|
|
646
|
+
* @param deleteUserToken.userToken - User token for which to delete all associated events.
|
|
647
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
648
|
+
*/
|
|
649
|
+
deleteUserToken({ userToken }: DeleteUserTokenProps, requestOptions?: RequestOptions): Promise<void>;
|
|
650
|
+
/**
|
|
651
|
+
* Sends a list of events to the Insights API. You can include up to 1,000 events in a single request, but the request body must be smaller than 2 MB.
|
|
652
|
+
*
|
|
653
|
+
* @param insightsEvents - The insightsEvents object.
|
|
654
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
655
|
+
*/
|
|
656
|
+
pushEvents(insightsEvents: InsightsEvents, requestOptions?: RequestOptions): Promise<EventsResponse>;
|
|
565
657
|
};
|
|
658
|
+
|
|
566
659
|
/**
|
|
567
|
-
*
|
|
660
|
+
* Error.
|
|
568
661
|
*/
|
|
569
|
-
type
|
|
570
|
-
|
|
571
|
-
* User token for which to delete all associated events.
|
|
572
|
-
*/
|
|
573
|
-
userToken: string;
|
|
662
|
+
type ErrorBase = Record<string, any> & {
|
|
663
|
+
message?: string;
|
|
574
664
|
};
|
|
575
665
|
|
|
576
|
-
|
|
577
|
-
declare const REGIONS: readonly ["de", "us"];
|
|
578
|
-
type Region = (typeof REGIONS)[number];
|
|
666
|
+
type InsightsClient = ReturnType<typeof createInsightsClient>;
|
|
579
667
|
|
|
580
|
-
|
|
581
|
-
* The client type.
|
|
582
|
-
*/
|
|
583
|
-
type InsightsClient = ReturnType<typeof insightsClient>;
|
|
584
|
-
declare function insightsClient(appId: string, apiKey: string, region?: Region, options?: ClientOptions): {
|
|
585
|
-
transporter: _algolia_client_common.Transporter;
|
|
586
|
-
appId: string;
|
|
587
|
-
clearCache(): Promise<void>;
|
|
588
|
-
_ua: string;
|
|
589
|
-
addAlgoliaAgent(segment: string, version?: string): void;
|
|
590
|
-
customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
|
|
591
|
-
customGet({ path, parameters }: CustomGetProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
|
|
592
|
-
customPost({ path, parameters, body }: CustomPostProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
|
|
593
|
-
customPut({ path, parameters, body }: CustomPutProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
|
|
594
|
-
deleteUserToken({ userToken }: DeleteUserTokenProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<void>;
|
|
595
|
-
pushEvents(insightsEvents: InsightsEvents, requestOptions?: _algolia_client_common.RequestOptions): Promise<EventsResponse>;
|
|
596
|
-
};
|
|
668
|
+
declare function insightsClient(appId: string, apiKey: string, region?: Region, options?: ClientOptions): InsightsClient;
|
|
597
669
|
|
|
598
670
|
export { type AddToCartEvent, type AddedToCartObjectIDs, type AddedToCartObjectIDsAfterSearch, type ClickEvent, type ClickedFilters, type ClickedObjectIDs, type ClickedObjectIDsAfterSearch, type ConversionEvent, type ConvertedFilters, type ConvertedObjectIDs, type ConvertedObjectIDsAfterSearch, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type DeleteUserTokenProps, type Discount, type ErrorBase, type EventsItems, type EventsResponse, type InsightsClient, type InsightsEvents, type ObjectData, type ObjectDataAfterSearch, type Price, type PurchaseEvent, type PurchasedObjectIDs, type PurchasedObjectIDsAfterSearch, type Region, type Value, type ViewEvent, type ViewedFilters, type ViewedObjectIDs, apiClientVersion, insightsClient };
|
|
@@ -26,7 +26,7 @@ __export(insightsClient_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(insightsClient_exports);
|
|
28
28
|
var import_client_common = require("@algolia/client-common");
|
|
29
|
-
var apiClientVersion = "5.
|
|
29
|
+
var apiClientVersion = "5.3.0";
|
|
30
30
|
var REGIONS = ["de", "us"];
|
|
31
31
|
function getDefaultHosts(region) {
|
|
32
32
|
const url = !region ? "insights.algolia.io" : "insights.{region}.algolia.io".replace("{region}", region);
|
|
@@ -41,26 +41,25 @@ function createInsightsClient({
|
|
|
41
41
|
...options
|
|
42
42
|
}) {
|
|
43
43
|
const auth = (0, import_client_common.createAuth)(appIdOption, apiKeyOption, authMode);
|
|
44
|
-
const transporter = (0, import_client_common.createTransporter)({
|
|
45
|
-
hosts: getDefaultHosts(regionOption),
|
|
46
|
-
...options,
|
|
47
|
-
algoliaAgent: (0, import_client_common.getAlgoliaAgent)({
|
|
48
|
-
algoliaAgents,
|
|
49
|
-
client: "Insights",
|
|
50
|
-
version: apiClientVersion
|
|
51
|
-
}),
|
|
52
|
-
baseHeaders: {
|
|
53
|
-
"content-type": "text/plain",
|
|
54
|
-
...auth.headers(),
|
|
55
|
-
...options.baseHeaders
|
|
56
|
-
},
|
|
57
|
-
baseQueryParameters: {
|
|
58
|
-
...auth.queryParameters(),
|
|
59
|
-
...options.baseQueryParameters
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
44
|
return {
|
|
63
|
-
transporter,
|
|
45
|
+
transporter: (0, import_client_common.createTransporter)({
|
|
46
|
+
hosts: getDefaultHosts(regionOption),
|
|
47
|
+
...options,
|
|
48
|
+
algoliaAgent: (0, import_client_common.getAlgoliaAgent)({
|
|
49
|
+
algoliaAgents,
|
|
50
|
+
client: "Insights",
|
|
51
|
+
version: apiClientVersion
|
|
52
|
+
}),
|
|
53
|
+
baseHeaders: {
|
|
54
|
+
"content-type": "text/plain",
|
|
55
|
+
...auth.headers(),
|
|
56
|
+
...options.baseHeaders
|
|
57
|
+
},
|
|
58
|
+
baseQueryParameters: {
|
|
59
|
+
...auth.queryParameters(),
|
|
60
|
+
...options.baseQueryParameters
|
|
61
|
+
}
|
|
62
|
+
}),
|
|
64
63
|
/**
|
|
65
64
|
* The `appId` currently in use.
|
|
66
65
|
*/
|
|
@@ -69,13 +68,15 @@ function createInsightsClient({
|
|
|
69
68
|
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
70
69
|
*/
|
|
71
70
|
clearCache() {
|
|
72
|
-
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(
|
|
71
|
+
return Promise.all([this.transporter.requestsCache.clear(), this.transporter.responsesCache.clear()]).then(
|
|
72
|
+
() => void 0
|
|
73
|
+
);
|
|
73
74
|
},
|
|
74
75
|
/**
|
|
75
76
|
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
|
|
76
77
|
*/
|
|
77
78
|
get _ua() {
|
|
78
|
-
return transporter.algoliaAgent.value;
|
|
79
|
+
return this.transporter.algoliaAgent.value;
|
|
79
80
|
},
|
|
80
81
|
/**
|
|
81
82
|
* Adds a `segment` to the `x-algolia-agent` sent with every requests.
|
|
@@ -84,7 +85,16 @@ function createInsightsClient({
|
|
|
84
85
|
* @param version - The version of the agent.
|
|
85
86
|
*/
|
|
86
87
|
addAlgoliaAgent(segment, version) {
|
|
87
|
-
transporter.algoliaAgent.add({ segment, version });
|
|
88
|
+
this.transporter.algoliaAgent.add({ segment, version });
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* Helper method to switch the API key used to authenticate the requests.
|
|
92
|
+
*
|
|
93
|
+
* @param params - Method params.
|
|
94
|
+
* @param params.apiKey - The new API Key to use.
|
|
95
|
+
*/
|
|
96
|
+
setClientApiKey({ apiKey }) {
|
|
97
|
+
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey;
|
|
88
98
|
},
|
|
89
99
|
/**
|
|
90
100
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -107,7 +117,7 @@ function createInsightsClient({
|
|
|
107
117
|
queryParameters,
|
|
108
118
|
headers
|
|
109
119
|
};
|
|
110
|
-
return transporter.request(request, requestOptions);
|
|
120
|
+
return this.transporter.request(request, requestOptions);
|
|
111
121
|
},
|
|
112
122
|
/**
|
|
113
123
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -130,7 +140,7 @@ function createInsightsClient({
|
|
|
130
140
|
queryParameters,
|
|
131
141
|
headers
|
|
132
142
|
};
|
|
133
|
-
return transporter.request(request, requestOptions);
|
|
143
|
+
return this.transporter.request(request, requestOptions);
|
|
134
144
|
},
|
|
135
145
|
/**
|
|
136
146
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -155,7 +165,7 @@ function createInsightsClient({
|
|
|
155
165
|
headers,
|
|
156
166
|
data: body ? body : {}
|
|
157
167
|
};
|
|
158
|
-
return transporter.request(request, requestOptions);
|
|
168
|
+
return this.transporter.request(request, requestOptions);
|
|
159
169
|
},
|
|
160
170
|
/**
|
|
161
171
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -180,7 +190,7 @@ function createInsightsClient({
|
|
|
180
190
|
headers,
|
|
181
191
|
data: body ? body : {}
|
|
182
192
|
};
|
|
183
|
-
return transporter.request(request, requestOptions);
|
|
193
|
+
return this.transporter.request(request, requestOptions);
|
|
184
194
|
},
|
|
185
195
|
/**
|
|
186
196
|
* Deletes all events related to the specified user token from events metrics and analytics. The deletion is asynchronous, and processed within 48 hours. To delete a personalization user profile, see `Delete a user profile` in the Personalization API.
|
|
@@ -202,7 +212,7 @@ function createInsightsClient({
|
|
|
202
212
|
queryParameters,
|
|
203
213
|
headers
|
|
204
214
|
};
|
|
205
|
-
return transporter.request(request, requestOptions);
|
|
215
|
+
return this.transporter.request(request, requestOptions);
|
|
206
216
|
},
|
|
207
217
|
/**
|
|
208
218
|
* Sends a list of events to the Insights API. You can include up to 1,000 events in a single request, but the request body must be smaller than 2 MB.
|
|
@@ -227,7 +237,7 @@ function createInsightsClient({
|
|
|
227
237
|
headers,
|
|
228
238
|
data: insightsEvents
|
|
229
239
|
};
|
|
230
|
-
return transporter.request(request, requestOptions);
|
|
240
|
+
return this.transporter.request(request, requestOptions);
|
|
231
241
|
}
|
|
232
242
|
};
|
|
233
243
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/insightsClient.ts"],"sourcesContent":["// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.\n\nimport { createAuth, createTransporter, getAlgoliaAgent } from '@algolia/client-common';\nimport type {\n CreateClientOptions,\n Headers,\n Host,\n QueryParameters,\n Request,\n RequestOptions,\n} from '@algolia/client-common';\n\nimport type {\n CustomDeleteProps,\n CustomGetProps,\n CustomPostProps,\n CustomPutProps,\n DeleteUserTokenProps,\n} from '../model/clientMethodProps';\nimport type { EventsResponse } from '../model/eventsResponse';\nimport type { InsightsEvents } from '../model/insightsEvents';\n\nexport const apiClientVersion = '5.2.5';\n\nexport const REGIONS = ['de', 'us'] as const;\nexport type Region = (typeof REGIONS)[number];\n\nfunction getDefaultHosts(region?: Region): Host[] {\n const url = !region ? 'insights.algolia.io' : 'insights.{region}.algolia.io'.replace('{region}', region);\n\n return [{ url, accept: 'readWrite', protocol: 'https' }];\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function createInsightsClient({\n appId: appIdOption,\n apiKey: apiKeyOption,\n authMode,\n algoliaAgents,\n region: regionOption,\n ...options\n}: CreateClientOptions & { region?: Region }) {\n const auth = createAuth(appIdOption, apiKeyOption, authMode);\n const transporter = createTransporter({\n hosts: getDefaultHosts(regionOption),\n ...options,\n algoliaAgent: getAlgoliaAgent({\n algoliaAgents,\n client: 'Insights',\n version: apiClientVersion,\n }),\n baseHeaders: {\n 'content-type': 'text/plain',\n ...auth.headers(),\n ...options.baseHeaders,\n },\n baseQueryParameters: {\n ...auth.queryParameters(),\n ...options.baseQueryParameters,\n },\n });\n\n return {\n transporter,\n\n /**\n * The `appId` currently in use.\n */\n appId: appIdOption,\n\n /**\n * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.\n */\n clearCache(): Promise<void> {\n return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => undefined);\n },\n\n /**\n * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.\n */\n get _ua(): string {\n return transporter.algoliaAgent.value;\n },\n\n /**\n * Adds a `segment` to the `x-algolia-agent` sent with every requests.\n *\n * @param segment - The algolia agent (user-agent) segment to add.\n * @param version - The version of the agent.\n */\n addAlgoliaAgent(segment: string, version?: string): void {\n transporter.algoliaAgent.add({ segment, version });\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n *\n * @param customDelete - The customDelete object.\n * @param customDelete.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customDelete.parameters - Query parameters to apply to the current query.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customDelete(\n { path, parameters }: CustomDeleteProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customDelete`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'DELETE',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n *\n * @param customGet - The customGet object.\n * @param customGet.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customGet.parameters - Query parameters to apply to the current query.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customGet`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'GET',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n *\n * @param customPost - The customPost object.\n * @param customPost.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customPost.parameters - Query parameters to apply to the current query.\n * @param customPost.body - Parameters to send with the custom request.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customPost(\n { path, parameters, body }: CustomPostProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customPost`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'POST',\n path: requestPath,\n queryParameters,\n headers,\n data: body ? body : {},\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n *\n * @param customPut - The customPut object.\n * @param customPut.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customPut.parameters - Query parameters to apply to the current query.\n * @param customPut.body - Parameters to send with the custom request.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customPut(\n { path, parameters, body }: CustomPutProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customPut`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'PUT',\n path: requestPath,\n queryParameters,\n headers,\n data: body ? body : {},\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * Deletes all events related to the specified user token from events metrics and analytics. The deletion is asynchronous, and processed within 48 hours. To delete a personalization user profile, see `Delete a user profile` in the Personalization API.\n *\n * @param deleteUserToken - The deleteUserToken object.\n * @param deleteUserToken.userToken - User token for which to delete all associated events.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n deleteUserToken({ userToken }: DeleteUserTokenProps, requestOptions?: RequestOptions): Promise<void> {\n if (!userToken) {\n throw new Error('Parameter `userToken` is required when calling `deleteUserToken`.');\n }\n\n const requestPath = '/1/usertokens/{userToken}'.replace('{userToken}', encodeURIComponent(userToken));\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'DELETE',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * Sends a list of events to the Insights API. You can include up to 1,000 events in a single request, but the request body must be smaller than 2 MB.\n *\n * @param insightsEvents - The insightsEvents object.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n pushEvents(insightsEvents: InsightsEvents, requestOptions?: RequestOptions): Promise<EventsResponse> {\n if (!insightsEvents) {\n throw new Error('Parameter `insightsEvents` is required when calling `pushEvents`.');\n }\n\n if (!insightsEvents.events) {\n throw new Error('Parameter `insightsEvents.events` is required when calling `pushEvents`.');\n }\n\n const requestPath = '/1/events';\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'POST',\n path: requestPath,\n queryParameters,\n headers,\n data: insightsEvents,\n };\n\n return transporter.request(request, requestOptions);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,2BAA+D;AAoBxD,IAAM,mBAAmB;AAEzB,IAAM,UAAU,CAAC,MAAM,IAAI;AAGlC,SAAS,gBAAgB,QAAyB;AAChD,QAAM,MAAM,CAAC,SAAS,wBAAwB,+BAA+B,QAAQ,YAAY,MAAM;AAEvG,SAAO,CAAC,EAAE,KAAK,QAAQ,aAAa,UAAU,QAAQ,CAAC;AACzD;AAGO,SAAS,qBAAqB;AAAA,EACnC,OAAO;AAAA,EACP,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,GAAG;AACL,GAA8C;AAC5C,QAAM,WAAO,iCAAW,aAAa,cAAc,QAAQ;AAC3D,QAAM,kBAAc,wCAAkB;AAAA,IACpC,OAAO,gBAAgB,YAAY;AAAA,IACnC,GAAG;AAAA,IACH,kBAAc,sCAAgB;AAAA,MAC5B;AAAA,MACA,QAAQ;AAAA,MACR,SAAS;AAAA,IACX,CAAC;AAAA,IACD,aAAa;AAAA,MACX,gBAAgB;AAAA,MAChB,GAAG,KAAK,QAAQ;AAAA,MAChB,GAAG,QAAQ;AAAA,IACb;AAAA,IACA,qBAAqB;AAAA,MACnB,GAAG,KAAK,gBAAgB;AAAA,MACxB,GAAG,QAAQ;AAAA,IACb;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO;AAAA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A,MACF;AAEA,aAAO,YAAY,QAAQ,SAAS,cAAc;AAAA,IACpD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQA,WAAW,gBAAgC,gBAA0D;AACnG,UAAI,CAAC,gBAAgB;AACnB,cAAM,IAAI,MAAM,mEAAmE;AAAA,MACrF;AAEA,UAAI,CAAC,eAAe,QAAQ;AAC1B,cAAM,IAAI,MAAM,0EAA0E;AAAA,MAC5F;AAEA,YAAM,cAAc;AACpB,YAAM,UAAmB,CAAC;AAC1B,YAAM,kBAAmC,CAAC;AAE1C,YAAM,UAAmB;AAAA,QACvB,QAAQ;AAAA,QACR,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA,MAAM;AAAA,MACR;AAEA,aAAO,YAAY,QAAQ,SAAS,cAAc;AAAA,IACpD;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/insightsClient.ts"],"sourcesContent":["// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.\n\nimport { createAuth, createTransporter, getAlgoliaAgent } from '@algolia/client-common';\nimport type {\n CreateClientOptions,\n Headers,\n Host,\n QueryParameters,\n Request,\n RequestOptions,\n} from '@algolia/client-common';\n\nimport type {\n CustomDeleteProps,\n CustomGetProps,\n CustomPostProps,\n CustomPutProps,\n DeleteUserTokenProps,\n} from '../model/clientMethodProps';\nimport type { EventsResponse } from '../model/eventsResponse';\nimport type { InsightsEvents } from '../model/insightsEvents';\n\nexport const apiClientVersion = '5.3.0';\n\nexport const REGIONS = ['de', 'us'] as const;\nexport type Region = (typeof REGIONS)[number];\n\nfunction getDefaultHosts(region?: Region): Host[] {\n const url = !region ? 'insights.algolia.io' : 'insights.{region}.algolia.io'.replace('{region}', region);\n\n return [{ url, accept: 'readWrite', protocol: 'https' }];\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function createInsightsClient({\n appId: appIdOption,\n apiKey: apiKeyOption,\n authMode,\n algoliaAgents,\n region: regionOption,\n ...options\n}: CreateClientOptions & { region?: Region }) {\n const auth = createAuth(appIdOption, apiKeyOption, authMode);\n\n return {\n transporter: createTransporter({\n hosts: getDefaultHosts(regionOption),\n ...options,\n algoliaAgent: getAlgoliaAgent({\n algoliaAgents,\n client: 'Insights',\n version: apiClientVersion,\n }),\n baseHeaders: {\n 'content-type': 'text/plain',\n ...auth.headers(),\n ...options.baseHeaders,\n },\n baseQueryParameters: {\n ...auth.queryParameters(),\n ...options.baseQueryParameters,\n },\n }),\n\n /**\n * The `appId` currently in use.\n */\n appId: appIdOption,\n\n /**\n * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.\n */\n clearCache(): Promise<void> {\n return Promise.all([this.transporter.requestsCache.clear(), this.transporter.responsesCache.clear()]).then(\n () => undefined,\n );\n },\n\n /**\n * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.\n */\n get _ua(): string {\n return this.transporter.algoliaAgent.value;\n },\n\n /**\n * Adds a `segment` to the `x-algolia-agent` sent with every requests.\n *\n * @param segment - The algolia agent (user-agent) segment to add.\n * @param version - The version of the agent.\n */\n addAlgoliaAgent(segment: string, version?: string): void {\n this.transporter.algoliaAgent.add({ segment, version });\n },\n\n /**\n * Helper method to switch the API key used to authenticate the requests.\n *\n * @param params - Method params.\n * @param params.apiKey - The new API Key to use.\n */\n setClientApiKey({ apiKey }: { apiKey: string }): void {\n this.transporter.baseHeaders['x-algolia-api-key'] = apiKey;\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n *\n * @param customDelete - The customDelete object.\n * @param customDelete.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customDelete.parameters - Query parameters to apply to the current query.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customDelete(\n { path, parameters }: CustomDeleteProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customDelete`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'DELETE',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return this.transporter.request(request, requestOptions);\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n *\n * @param customGet - The customGet object.\n * @param customGet.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customGet.parameters - Query parameters to apply to the current query.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customGet`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'GET',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return this.transporter.request(request, requestOptions);\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n *\n * @param customPost - The customPost object.\n * @param customPost.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customPost.parameters - Query parameters to apply to the current query.\n * @param customPost.body - Parameters to send with the custom request.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customPost(\n { path, parameters, body }: CustomPostProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customPost`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'POST',\n path: requestPath,\n queryParameters,\n headers,\n data: body ? body : {},\n };\n\n return this.transporter.request(request, requestOptions);\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n *\n * @param customPut - The customPut object.\n * @param customPut.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customPut.parameters - Query parameters to apply to the current query.\n * @param customPut.body - Parameters to send with the custom request.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customPut(\n { path, parameters, body }: CustomPutProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customPut`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'PUT',\n path: requestPath,\n queryParameters,\n headers,\n data: body ? body : {},\n };\n\n return this.transporter.request(request, requestOptions);\n },\n\n /**\n * Deletes all events related to the specified user token from events metrics and analytics. The deletion is asynchronous, and processed within 48 hours. To delete a personalization user profile, see `Delete a user profile` in the Personalization API.\n *\n * @param deleteUserToken - The deleteUserToken object.\n * @param deleteUserToken.userToken - User token for which to delete all associated events.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n deleteUserToken({ userToken }: DeleteUserTokenProps, requestOptions?: RequestOptions): Promise<void> {\n if (!userToken) {\n throw new Error('Parameter `userToken` is required when calling `deleteUserToken`.');\n }\n\n const requestPath = '/1/usertokens/{userToken}'.replace('{userToken}', encodeURIComponent(userToken));\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'DELETE',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return this.transporter.request(request, requestOptions);\n },\n\n /**\n * Sends a list of events to the Insights API. You can include up to 1,000 events in a single request, but the request body must be smaller than 2 MB.\n *\n * @param insightsEvents - The insightsEvents object.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n pushEvents(insightsEvents: InsightsEvents, requestOptions?: RequestOptions): Promise<EventsResponse> {\n if (!insightsEvents) {\n throw new Error('Parameter `insightsEvents` is required when calling `pushEvents`.');\n }\n\n if (!insightsEvents.events) {\n throw new Error('Parameter `insightsEvents.events` is required when calling `pushEvents`.');\n }\n\n const requestPath = '/1/events';\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'POST',\n path: requestPath,\n queryParameters,\n headers,\n data: insightsEvents,\n };\n\n return this.transporter.request(request, requestOptions);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,2BAA+D;AAoBxD,IAAM,mBAAmB;AAEzB,IAAM,UAAU,CAAC,MAAM,IAAI;AAGlC,SAAS,gBAAgB,QAAyB;AAChD,QAAM,MAAM,CAAC,SAAS,wBAAwB,+BAA+B,QAAQ,YAAY,MAAM;AAEvG,SAAO,CAAC,EAAE,KAAK,QAAQ,aAAa,UAAU,QAAQ,CAAC;AACzD;AAGO,SAAS,qBAAqB;AAAA,EACnC,OAAO;AAAA,EACP,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,GAAG;AACL,GAA8C;AAC5C,QAAM,WAAO,iCAAW,aAAa,cAAc,QAAQ;AAE3D,SAAO;AAAA,IACL,iBAAa,wCAAkB;AAAA,MAC7B,OAAO,gBAAgB,YAAY;AAAA,MACnC,GAAG;AAAA,MACH,kBAAc,sCAAgB;AAAA,QAC5B;AAAA,QACA,QAAQ;AAAA,QACR,SAAS;AAAA,MACX,CAAC;AAAA,MACD,aAAa;AAAA,QACX,gBAAgB;AAAA,QAChB,GAAG,KAAK,QAAQ;AAAA,QAChB,GAAG,QAAQ;AAAA,MACb;AAAA,MACA,qBAAqB;AAAA,QACnB,GAAG,KAAK,gBAAgB;AAAA,QACxB,GAAG,QAAQ;AAAA,MACb;AAAA,IACF,CAAC;AAAA;AAAA;AAAA;AAAA,IAKD,OAAO;AAAA;AAAA;AAAA;AAAA,IAKP,aAA4B;AAC1B,aAAO,QAAQ,IAAI,CAAC,KAAK,YAAY,cAAc,MAAM,GAAG,KAAK,YAAY,eAAe,MAAM,CAAC,CAAC,EAA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AAQ;AAAA,QACR,MAAM;AAAA,QACN;AAAA,QACA;AAAA,MACF;AAEA,aAAO,KAAK,YAAY,QAAQ,SAAS,cAAc;AAAA,IACzD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQA,WAAW,gBAAgC,gBAA0D;AACnG,UAAI,CAAC,gBAAgB;AACnB,cAAM,IAAI,MAAM,mEAAmE;AAAA,MACrF;AAEA,UAAI,CAAC,eAAe,QAAQ;AAC1B,cAAM,IAAI,MAAM,0EAA0E;AAAA,MAC5F;AAEA,YAAM,cAAc;AACpB,YAAM,UAAmB,CAAC;AAC1B,YAAM,kBAAmC,CAAC;AAE1C,YAAM,UAAmB;AAAA,QACvB,QAAQ;AAAA,QACR,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA,MAAM;AAAA,MACR;AAEA,aAAO,KAAK,YAAY,QAAQ,SAAS,cAAc;AAAA,IACzD;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/insightsClient.ts
|
|
2
2
|
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
|
|
3
|
-
var apiClientVersion = "5.
|
|
3
|
+
var apiClientVersion = "5.3.0";
|
|
4
4
|
var REGIONS = ["de", "us"];
|
|
5
5
|
function getDefaultHosts(region) {
|
|
6
6
|
const url = !region ? "insights.algolia.io" : "insights.{region}.algolia.io".replace("{region}", region);
|
|
@@ -15,26 +15,25 @@ function createInsightsClient({
|
|
|
15
15
|
...options
|
|
16
16
|
}) {
|
|
17
17
|
const auth = createAuth(appIdOption, apiKeyOption, authMode);
|
|
18
|
-
const transporter = createTransporter({
|
|
19
|
-
hosts: getDefaultHosts(regionOption),
|
|
20
|
-
...options,
|
|
21
|
-
algoliaAgent: getAlgoliaAgent({
|
|
22
|
-
algoliaAgents,
|
|
23
|
-
client: "Insights",
|
|
24
|
-
version: apiClientVersion
|
|
25
|
-
}),
|
|
26
|
-
baseHeaders: {
|
|
27
|
-
"content-type": "text/plain",
|
|
28
|
-
...auth.headers(),
|
|
29
|
-
...options.baseHeaders
|
|
30
|
-
},
|
|
31
|
-
baseQueryParameters: {
|
|
32
|
-
...auth.queryParameters(),
|
|
33
|
-
...options.baseQueryParameters
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
18
|
return {
|
|
37
|
-
transporter
|
|
19
|
+
transporter: createTransporter({
|
|
20
|
+
hosts: getDefaultHosts(regionOption),
|
|
21
|
+
...options,
|
|
22
|
+
algoliaAgent: getAlgoliaAgent({
|
|
23
|
+
algoliaAgents,
|
|
24
|
+
client: "Insights",
|
|
25
|
+
version: apiClientVersion
|
|
26
|
+
}),
|
|
27
|
+
baseHeaders: {
|
|
28
|
+
"content-type": "text/plain",
|
|
29
|
+
...auth.headers(),
|
|
30
|
+
...options.baseHeaders
|
|
31
|
+
},
|
|
32
|
+
baseQueryParameters: {
|
|
33
|
+
...auth.queryParameters(),
|
|
34
|
+
...options.baseQueryParameters
|
|
35
|
+
}
|
|
36
|
+
}),
|
|
38
37
|
/**
|
|
39
38
|
* The `appId` currently in use.
|
|
40
39
|
*/
|
|
@@ -43,13 +42,15 @@ function createInsightsClient({
|
|
|
43
42
|
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
44
43
|
*/
|
|
45
44
|
clearCache() {
|
|
46
|
-
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(
|
|
45
|
+
return Promise.all([this.transporter.requestsCache.clear(), this.transporter.responsesCache.clear()]).then(
|
|
46
|
+
() => void 0
|
|
47
|
+
);
|
|
47
48
|
},
|
|
48
49
|
/**
|
|
49
50
|
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
|
|
50
51
|
*/
|
|
51
52
|
get _ua() {
|
|
52
|
-
return transporter.algoliaAgent.value;
|
|
53
|
+
return this.transporter.algoliaAgent.value;
|
|
53
54
|
},
|
|
54
55
|
/**
|
|
55
56
|
* Adds a `segment` to the `x-algolia-agent` sent with every requests.
|
|
@@ -58,7 +59,16 @@ function createInsightsClient({
|
|
|
58
59
|
* @param version - The version of the agent.
|
|
59
60
|
*/
|
|
60
61
|
addAlgoliaAgent(segment, version) {
|
|
61
|
-
transporter.algoliaAgent.add({ segment, version });
|
|
62
|
+
this.transporter.algoliaAgent.add({ segment, version });
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* Helper method to switch the API key used to authenticate the requests.
|
|
66
|
+
*
|
|
67
|
+
* @param params - Method params.
|
|
68
|
+
* @param params.apiKey - The new API Key to use.
|
|
69
|
+
*/
|
|
70
|
+
setClientApiKey({ apiKey }) {
|
|
71
|
+
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey;
|
|
62
72
|
},
|
|
63
73
|
/**
|
|
64
74
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -81,7 +91,7 @@ function createInsightsClient({
|
|
|
81
91
|
queryParameters,
|
|
82
92
|
headers
|
|
83
93
|
};
|
|
84
|
-
return transporter.request(request, requestOptions);
|
|
94
|
+
return this.transporter.request(request, requestOptions);
|
|
85
95
|
},
|
|
86
96
|
/**
|
|
87
97
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -104,7 +114,7 @@ function createInsightsClient({
|
|
|
104
114
|
queryParameters,
|
|
105
115
|
headers
|
|
106
116
|
};
|
|
107
|
-
return transporter.request(request, requestOptions);
|
|
117
|
+
return this.transporter.request(request, requestOptions);
|
|
108
118
|
},
|
|
109
119
|
/**
|
|
110
120
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -129,7 +139,7 @@ function createInsightsClient({
|
|
|
129
139
|
headers,
|
|
130
140
|
data: body ? body : {}
|
|
131
141
|
};
|
|
132
|
-
return transporter.request(request, requestOptions);
|
|
142
|
+
return this.transporter.request(request, requestOptions);
|
|
133
143
|
},
|
|
134
144
|
/**
|
|
135
145
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -154,7 +164,7 @@ function createInsightsClient({
|
|
|
154
164
|
headers,
|
|
155
165
|
data: body ? body : {}
|
|
156
166
|
};
|
|
157
|
-
return transporter.request(request, requestOptions);
|
|
167
|
+
return this.transporter.request(request, requestOptions);
|
|
158
168
|
},
|
|
159
169
|
/**
|
|
160
170
|
* Deletes all events related to the specified user token from events metrics and analytics. The deletion is asynchronous, and processed within 48 hours. To delete a personalization user profile, see `Delete a user profile` in the Personalization API.
|
|
@@ -176,7 +186,7 @@ function createInsightsClient({
|
|
|
176
186
|
queryParameters,
|
|
177
187
|
headers
|
|
178
188
|
};
|
|
179
|
-
return transporter.request(request, requestOptions);
|
|
189
|
+
return this.transporter.request(request, requestOptions);
|
|
180
190
|
},
|
|
181
191
|
/**
|
|
182
192
|
* Sends a list of events to the Insights API. You can include up to 1,000 events in a single request, but the request body must be smaller than 2 MB.
|
|
@@ -201,7 +211,7 @@ function createInsightsClient({
|
|
|
201
211
|
headers,
|
|
202
212
|
data: insightsEvents
|
|
203
213
|
};
|
|
204
|
-
return transporter.request(request, requestOptions);
|
|
214
|
+
return this.transporter.request(request, requestOptions);
|
|
205
215
|
}
|
|
206
216
|
};
|
|
207
217
|
}
|