@seekora-ai/search-sdk 0.2.6 → 0.2.8
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/cdn/seekora-sdk.js +30 -19
- package/cdn/seekora-sdk.min.js +12 -12
- package/dist/client.d.ts +130 -0
- package/dist/client.js +199 -5
- package/dist/generated/api.d.ts +33029 -8906
- package/dist/generated/api.js +46824 -1681
- package/dist/index.d.ts +1 -0
- package/dist/index.js +14 -1
- package/dist/ui-components.d.ts +74 -0
- package/dist/ui-components.js +165 -0
- package/package.json +1 -1
- package/dist/src/cdn.d.ts +0 -16
- package/dist/src/cdn.js +0 -26
- package/dist/src/client.d.ts +0 -709
- package/dist/src/client.js +0 -1548
- package/dist/src/config-loader.d.ts +0 -43
- package/dist/src/config-loader.js +0 -147
- package/dist/src/config.d.ts +0 -22
- package/dist/src/config.js +0 -58
- package/dist/src/context-collector.d.ts +0 -273
- package/dist/src/context-collector.js +0 -868
- package/dist/src/event-queue.d.ts +0 -195
- package/dist/src/event-queue.js +0 -424
- package/dist/src/index.d.ts +0 -14
- package/dist/src/index.js +0 -48
- package/dist/src/logger.d.ts +0 -61
- package/dist/src/logger.js +0 -172
- package/dist/src/utils.d.ts +0 -20
- package/dist/src/utils.js +0 -73
package/dist/index.d.ts
CHANGED
|
@@ -13,4 +13,5 @@ export { EventQueue, createEventQueue, getDefaultEventQueue, type QueuedEvent, t
|
|
|
13
13
|
export * from './generated';
|
|
14
14
|
export { AnalyticsV3Api, createAnalyticsV3Api, type AnalyticsV3ApiConfig, type GenericResponse, } from './analytics-v3-api';
|
|
15
15
|
export type { AnalyticsV3BaseRequest, TimeSeriesPoint, SearchMetricsRequest, SearchMetrics, TopQueriesRequest, QueryMetric, ZeroResultQueriesRequest, ZeroResultQuery, ClickMetricsRequest, ClickMetrics, CTRByPositionRequest, PositionCTR, ConversionMetricsRequest, ConversionMetrics, RevenueAttributionRequest, RevenueAttribution, RecommendationMetricsRequest, RecommendationMetrics, RecommendationCTRRequest, RecommendationCTR, FunnelRequest, FunnelStepResult, FunnelData, JourneyEvent, AnalyticsV3EventPayload, } from './analytics-v3-types';
|
|
16
|
+
export { SeekoraActionButtons, createActionButtons, type ActionButtonConfig, type ShareButtonConfig, type ActionButtonResult } from './ui-components';
|
|
16
17
|
export { SeekoraClient as default } from './client';
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
19
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.default = exports.createAnalyticsV3Api = exports.AnalyticsV3Api = exports.getDefaultEventQueue = exports.createEventQueue = exports.EventQueue = exports.getDefaultContextCollector = exports.collectBrowserContext = exports.ContextCollector = exports.loadConfigFromEnv = exports.loadConfigFromFile = exports.loadConfig = exports.getLogLevelFromEnv = exports.createLogger = exports.Logger = exports.getEnvironment = exports.getBaseUrl = exports.ENVIRONMENTS = exports.SeekoraClient = void 0;
|
|
22
|
+
exports.default = exports.createActionButtons = exports.SeekoraActionButtons = exports.createAnalyticsV3Api = exports.AnalyticsV3Api = exports.getDefaultEventQueue = exports.createEventQueue = exports.EventQueue = exports.getDefaultContextCollector = exports.collectBrowserContext = exports.ContextCollector = exports.loadConfigFromEnv = exports.loadConfigFromFile = exports.loadConfig = exports.getLogLevelFromEnv = exports.createLogger = exports.Logger = exports.getEnvironment = exports.getBaseUrl = exports.ENVIRONMENTS = exports.SeekoraClient = void 0;
|
|
23
23
|
var client_1 = require("./client");
|
|
24
24
|
Object.defineProperty(exports, "SeekoraClient", { enumerable: true, get: function () { return client_1.SeekoraClient; } });
|
|
25
25
|
var config_1 = require("./config");
|
|
@@ -47,6 +47,19 @@ __exportStar(require("./generated"), exports);
|
|
|
47
47
|
var analytics_v3_api_1 = require("./analytics-v3-api");
|
|
48
48
|
Object.defineProperty(exports, "AnalyticsV3Api", { enumerable: true, get: function () { return analytics_v3_api_1.AnalyticsV3Api; } });
|
|
49
49
|
Object.defineProperty(exports, "createAnalyticsV3Api", { enumerable: true, get: function () { return analytics_v3_api_1.createAnalyticsV3Api; } });
|
|
50
|
+
// UI Components and Action Buttons
|
|
51
|
+
var ui_components_1 = require("./ui-components");
|
|
52
|
+
Object.defineProperty(exports, "SeekoraActionButtons", { enumerable: true, get: function () { return ui_components_1.SeekoraActionButtons; } });
|
|
53
|
+
Object.defineProperty(exports, "createActionButtons", { enumerable: true, get: function () { return ui_components_1.createActionButtons; } });
|
|
54
|
+
// React Components (optional, requires React as peer dependency)
|
|
55
|
+
// React components (optional - requires React as peer dependency)
|
|
56
|
+
// Uncomment when React is available:
|
|
57
|
+
// export {
|
|
58
|
+
// SeekoraActionButtons as SeekoraActionButtonsReact,
|
|
59
|
+
// AddToCartButton,
|
|
60
|
+
// AddToWishlistButton,
|
|
61
|
+
// ShareButton
|
|
62
|
+
// } from './react/ActionButtons';
|
|
50
63
|
// Default export
|
|
51
64
|
var client_2 = require("./client");
|
|
52
65
|
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return client_2.SeekoraClient; } });
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI Component Utilities for Seekora Search SDK
|
|
3
|
+
*
|
|
4
|
+
* Provides helper functions for creating action buttons that automatically track analytics
|
|
5
|
+
*/
|
|
6
|
+
import { SeekoraClient } from './client';
|
|
7
|
+
import type { SearchContext } from './client';
|
|
8
|
+
export interface ActionButtonConfig {
|
|
9
|
+
itemId: string;
|
|
10
|
+
position?: number;
|
|
11
|
+
searchContext?: SearchContext;
|
|
12
|
+
quantity?: number;
|
|
13
|
+
value?: number;
|
|
14
|
+
currency?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ShareButtonConfig extends ActionButtonConfig {
|
|
17
|
+
shareMethod?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ActionButtonResult {
|
|
20
|
+
success: boolean;
|
|
21
|
+
error?: any;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Create action button handlers that automatically track analytics
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const actionButtons = createActionButtons(seekoraClient);
|
|
29
|
+
*
|
|
30
|
+
* const addToCartHandler = actionButtons.createAddToCartHandler({
|
|
31
|
+
* itemId: 'product-123',
|
|
32
|
+
* quantity: 1,
|
|
33
|
+
* value: 29.99,
|
|
34
|
+
* searchContext: searchResponse.context
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* button.addEventListener('click', addToCartHandler);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare class SeekoraActionButtons {
|
|
41
|
+
private client;
|
|
42
|
+
constructor(client: SeekoraClient);
|
|
43
|
+
/**
|
|
44
|
+
* Create an Add to Cart button handler
|
|
45
|
+
* Tracks 'add_to_cart' conversion event
|
|
46
|
+
*/
|
|
47
|
+
createAddToCartHandler(config: ActionButtonConfig): (event?: Event) => Promise<ActionButtonResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Create an Add to Wishlist button handler
|
|
50
|
+
* Tracks 'wishlist' conversion event
|
|
51
|
+
*/
|
|
52
|
+
createAddToWishlistHandler(config: ActionButtonConfig): (event?: Event) => Promise<ActionButtonResult>;
|
|
53
|
+
/**
|
|
54
|
+
* Create a Share button handler
|
|
55
|
+
* Tracks custom 'share' event
|
|
56
|
+
*/
|
|
57
|
+
createShareHandler(config: ShareButtonConfig): (event?: Event) => Promise<ActionButtonResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Attach action button handlers to DOM elements
|
|
60
|
+
* Automatically finds elements with data-seekora-action attribute
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```html
|
|
64
|
+
* <button data-seekora-action="add_to_cart" data-seekora-item="product-123">
|
|
65
|
+
* Add to Cart
|
|
66
|
+
* </button>
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
attachToDOM(searchContext?: SearchContext): void;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Factory function to create SeekoraActionButtons instance
|
|
73
|
+
*/
|
|
74
|
+
export declare function createActionButtons(client: SeekoraClient): SeekoraActionButtons;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* UI Component Utilities for Seekora Search SDK
|
|
4
|
+
*
|
|
5
|
+
* Provides helper functions for creating action buttons that automatically track analytics
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.SeekoraActionButtons = void 0;
|
|
9
|
+
exports.createActionButtons = createActionButtons;
|
|
10
|
+
/**
|
|
11
|
+
* Create action button handlers that automatically track analytics
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const actionButtons = createActionButtons(seekoraClient);
|
|
16
|
+
*
|
|
17
|
+
* const addToCartHandler = actionButtons.createAddToCartHandler({
|
|
18
|
+
* itemId: 'product-123',
|
|
19
|
+
* quantity: 1,
|
|
20
|
+
* value: 29.99,
|
|
21
|
+
* searchContext: searchResponse.context
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* button.addEventListener('click', addToCartHandler);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
class SeekoraActionButtons {
|
|
28
|
+
constructor(client) {
|
|
29
|
+
this.client = client;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create an Add to Cart button handler
|
|
33
|
+
* Tracks 'add_to_cart' conversion event
|
|
34
|
+
*/
|
|
35
|
+
createAddToCartHandler(config) {
|
|
36
|
+
return async (event) => {
|
|
37
|
+
event?.preventDefault();
|
|
38
|
+
try {
|
|
39
|
+
await this.client.trackAddToCart({
|
|
40
|
+
itemId: config.itemId,
|
|
41
|
+
quantity: config.quantity,
|
|
42
|
+
value: config.value,
|
|
43
|
+
currency: config.currency,
|
|
44
|
+
position: config.position,
|
|
45
|
+
searchContext: config.searchContext
|
|
46
|
+
});
|
|
47
|
+
return { success: true };
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.error('Failed to track add to cart', error);
|
|
51
|
+
return { success: false, error };
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Create an Add to Wishlist button handler
|
|
57
|
+
* Tracks 'wishlist' conversion event
|
|
58
|
+
*/
|
|
59
|
+
createAddToWishlistHandler(config) {
|
|
60
|
+
return async (event) => {
|
|
61
|
+
event?.preventDefault();
|
|
62
|
+
try {
|
|
63
|
+
await this.client.trackAddToWishlist({
|
|
64
|
+
itemId: config.itemId,
|
|
65
|
+
position: config.position,
|
|
66
|
+
searchContext: config.searchContext
|
|
67
|
+
});
|
|
68
|
+
return { success: true };
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
console.error('Failed to track add to wishlist', error);
|
|
72
|
+
return { success: false, error };
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create a Share button handler
|
|
78
|
+
* Tracks custom 'share' event
|
|
79
|
+
*/
|
|
80
|
+
createShareHandler(config) {
|
|
81
|
+
return async (event) => {
|
|
82
|
+
event?.preventDefault();
|
|
83
|
+
try {
|
|
84
|
+
await this.client.trackShare({
|
|
85
|
+
itemId: config.itemId,
|
|
86
|
+
shareMethod: config.shareMethod,
|
|
87
|
+
position: config.position,
|
|
88
|
+
searchContext: config.searchContext
|
|
89
|
+
});
|
|
90
|
+
return { success: true };
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
console.error('Failed to track share', error);
|
|
94
|
+
return { success: false, error };
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Attach action button handlers to DOM elements
|
|
100
|
+
* Automatically finds elements with data-seekora-action attribute
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```html
|
|
104
|
+
* <button data-seekora-action="add_to_cart" data-seekora-item="product-123">
|
|
105
|
+
* Add to Cart
|
|
106
|
+
* </button>
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
attachToDOM(searchContext) {
|
|
110
|
+
const buttons = document.querySelectorAll('[data-seekora-action]');
|
|
111
|
+
buttons.forEach((button) => {
|
|
112
|
+
const action = button.getAttribute('data-seekora-action');
|
|
113
|
+
const itemId = button.getAttribute('data-seekora-item');
|
|
114
|
+
const position = parseInt(button.getAttribute('data-seekora-position') || '0', 10);
|
|
115
|
+
const quantity = parseInt(button.getAttribute('data-seekora-quantity') || '1', 10);
|
|
116
|
+
const value = parseFloat(button.getAttribute('data-seekora-value') || '0');
|
|
117
|
+
const currency = button.getAttribute('data-seekora-currency') || 'USD';
|
|
118
|
+
const shareMethod = button.getAttribute('data-seekora-share-method') || 'unknown';
|
|
119
|
+
if (!itemId) {
|
|
120
|
+
console.warn('Seekora action button missing data-seekora-item attribute', button);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
let handler = null;
|
|
124
|
+
switch (action) {
|
|
125
|
+
case 'add_to_cart':
|
|
126
|
+
handler = this.createAddToCartHandler({
|
|
127
|
+
itemId,
|
|
128
|
+
position: position || undefined,
|
|
129
|
+
quantity,
|
|
130
|
+
value,
|
|
131
|
+
currency,
|
|
132
|
+
searchContext
|
|
133
|
+
});
|
|
134
|
+
break;
|
|
135
|
+
case 'add_to_wishlist':
|
|
136
|
+
handler = this.createAddToWishlistHandler({
|
|
137
|
+
itemId,
|
|
138
|
+
position: position || undefined,
|
|
139
|
+
searchContext
|
|
140
|
+
});
|
|
141
|
+
break;
|
|
142
|
+
case 'share':
|
|
143
|
+
handler = this.createShareHandler({
|
|
144
|
+
itemId,
|
|
145
|
+
position: position || undefined,
|
|
146
|
+
shareMethod,
|
|
147
|
+
searchContext
|
|
148
|
+
});
|
|
149
|
+
break;
|
|
150
|
+
default:
|
|
151
|
+
console.warn('Unknown Seekora action:', action);
|
|
152
|
+
}
|
|
153
|
+
if (handler) {
|
|
154
|
+
button.addEventListener('click', handler);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.SeekoraActionButtons = SeekoraActionButtons;
|
|
160
|
+
/**
|
|
161
|
+
* Factory function to create SeekoraActionButtons instance
|
|
162
|
+
*/
|
|
163
|
+
function createActionButtons(client) {
|
|
164
|
+
return new SeekoraActionButtons(client);
|
|
165
|
+
}
|
package/package.json
CHANGED
package/dist/src/cdn.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CDN Entry Point for Seekora Search SDK
|
|
3
|
-
*
|
|
4
|
-
* This file is used to create a browser-compatible bundle that can be
|
|
5
|
-
* loaded via a <script> tag and accessed via a global variable.
|
|
6
|
-
*/
|
|
7
|
-
import { SeekoraClient } from './client';
|
|
8
|
-
import { ENVIRONMENTS, getBaseUrl, getEnvironment } from './config';
|
|
9
|
-
import { Logger, createLogger, getLogLevelFromEnv } from './logger';
|
|
10
|
-
import { loadConfig, loadConfigFromFile, loadConfigFromEnv } from './config-loader';
|
|
11
|
-
export type { SeekoraClientConfig, SearchOptions, SearchResponse, SearchContext, ExtendedEventPayload } from './client';
|
|
12
|
-
export type { SeekoraEnvironment, EnvironmentConfig } from './config';
|
|
13
|
-
export type { LogLevel, LoggerConfig } from './logger';
|
|
14
|
-
export type { FileConfig } from './config-loader';
|
|
15
|
-
export { SeekoraClient, ENVIRONMENTS, getBaseUrl, getEnvironment, Logger, createLogger, getLogLevelFromEnv, loadConfig, loadConfigFromFile, loadConfigFromEnv, };
|
|
16
|
-
export default SeekoraClient;
|
package/dist/src/cdn.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* CDN Entry Point for Seekora Search SDK
|
|
4
|
-
*
|
|
5
|
-
* This file is used to create a browser-compatible bundle that can be
|
|
6
|
-
* loaded via a <script> tag and accessed via a global variable.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.loadConfigFromEnv = exports.loadConfigFromFile = exports.loadConfig = exports.getLogLevelFromEnv = exports.createLogger = exports.Logger = exports.getEnvironment = exports.getBaseUrl = exports.ENVIRONMENTS = exports.SeekoraClient = void 0;
|
|
10
|
-
// Import all exports
|
|
11
|
-
const client_1 = require("./client");
|
|
12
|
-
Object.defineProperty(exports, "SeekoraClient", { enumerable: true, get: function () { return client_1.SeekoraClient; } });
|
|
13
|
-
const config_1 = require("./config");
|
|
14
|
-
Object.defineProperty(exports, "ENVIRONMENTS", { enumerable: true, get: function () { return config_1.ENVIRONMENTS; } });
|
|
15
|
-
Object.defineProperty(exports, "getBaseUrl", { enumerable: true, get: function () { return config_1.getBaseUrl; } });
|
|
16
|
-
Object.defineProperty(exports, "getEnvironment", { enumerable: true, get: function () { return config_1.getEnvironment; } });
|
|
17
|
-
const logger_1 = require("./logger");
|
|
18
|
-
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
|
|
19
|
-
Object.defineProperty(exports, "createLogger", { enumerable: true, get: function () { return logger_1.createLogger; } });
|
|
20
|
-
Object.defineProperty(exports, "getLogLevelFromEnv", { enumerable: true, get: function () { return logger_1.getLogLevelFromEnv; } });
|
|
21
|
-
const config_loader_1 = require("./config-loader");
|
|
22
|
-
Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return config_loader_1.loadConfig; } });
|
|
23
|
-
Object.defineProperty(exports, "loadConfigFromFile", { enumerable: true, get: function () { return config_loader_1.loadConfigFromFile; } });
|
|
24
|
-
Object.defineProperty(exports, "loadConfigFromEnv", { enumerable: true, get: function () { return config_loader_1.loadConfigFromEnv; } });
|
|
25
|
-
// Default export
|
|
26
|
-
exports.default = client_1.SeekoraClient;
|