@surfside/ads-core 2.0.22 → 2.0.23
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/README.md +15 -15
- package/lib/cjs/BuildInfo.js +1 -1
- package/lib/cjs/BuildInfo.js.map +1 -1
- package/lib/cjs/Init.js +474 -0
- package/lib/cjs/Init.js.map +1 -0
- package/lib/cjs/helpers/TelemetryCollector.js +72 -0
- package/lib/cjs/helpers/TelemetryCollector.js.map +1 -0
- package/lib/cjs/helpers/Types.js +3 -0
- package/lib/cjs/helpers/Types.js.map +1 -0
- package/lib/cjs/helpers/response/Html.js +37 -0
- package/lib/cjs/helpers/response/Html.js.map +1 -0
- package/lib/cjs/helpers/response/Products.js +174 -0
- package/lib/cjs/helpers/response/Products.js.map +1 -0
- package/lib/cjs/services/Product.js.map +1 -1
- package/lib/esm/BuildInfo.js +1 -1
- package/lib/esm/BuildInfo.js.map +1 -1
- package/lib/esm/Init.js +455 -0
- package/lib/esm/Init.js.map +1 -0
- package/lib/esm/helpers/TelemetryCollector.js +67 -0
- package/lib/esm/helpers/TelemetryCollector.js.map +1 -0
- package/lib/esm/helpers/Types.js +2 -0
- package/lib/esm/helpers/Types.js.map +1 -0
- package/lib/esm/helpers/response/Html.js +33 -0
- package/lib/esm/helpers/response/Html.js.map +1 -0
- package/lib/esm/helpers/response/Products.js +169 -0
- package/lib/esm/helpers/response/Products.js.map +1 -0
- package/lib/esm/services/Product.js.map +1 -1
- package/lib/types/Init.d.ts +147 -0
- package/lib/types/helpers/TelemetryCollector.d.ts +25 -0
- package/lib/types/helpers/Types.d.ts +1 -0
- package/lib/types/helpers/response/Html.d.ts +2 -0
- package/lib/types/helpers/response/Products.d.ts +8 -0
- package/package.json +47 -47
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { EventTrackingMethods, EventTypes, NativeAssetId } from '../../models';
|
|
2
|
+
import { Ctx, Err, Ok } from '../../services';
|
|
3
|
+
import { TryGet } from '../TryGet';
|
|
4
|
+
import { MissingAdmError } from './BuiltResponse';
|
|
5
|
+
import { MalformedNativeResponseError, MissingProductIdError, MissingWinUrlError, } from './ProductCard';
|
|
6
|
+
export const fetchProductsFromBid = async (logger, getAllSponsoredProducts, getAllSponsoredBrandProducts, config, bid) => {
|
|
7
|
+
try {
|
|
8
|
+
const log = Ctx(logger)?.with('fetchProductsFromBid');
|
|
9
|
+
log?.info('Fetching products from IBid');
|
|
10
|
+
if (bid.adm === undefined) {
|
|
11
|
+
log?.warn('Bid is missing ADM', bid);
|
|
12
|
+
return Err(new MissingAdmError(bid));
|
|
13
|
+
}
|
|
14
|
+
const adm = bid.adm; // save it here to make it effectively final;
|
|
15
|
+
const nativeRes = TryGet(() => JSON.parse(adm));
|
|
16
|
+
if (!nativeRes.ok) {
|
|
17
|
+
log?.error('Bid adm failed to deserialize', bid, adm);
|
|
18
|
+
return Err(new MalformedNativeResponseError(bid));
|
|
19
|
+
}
|
|
20
|
+
const native = nativeRes.value;
|
|
21
|
+
const metaProductId = getField(native)(NativeAssetId.SurfMetaProduct);
|
|
22
|
+
const metaBrandId = getField(native)(NativeAssetId.SurfMetaBrand);
|
|
23
|
+
if (metaProductId === undefined && metaBrandId === undefined) {
|
|
24
|
+
return Err(new MissingProductIdError(bid, native));
|
|
25
|
+
}
|
|
26
|
+
const attempts = [metaProductId, metaBrandId].filter(id => id !== undefined);
|
|
27
|
+
const products = [];
|
|
28
|
+
const errors = [];
|
|
29
|
+
/* If publisher category filtering is enabled, or advertiser category filtering is enabled,
|
|
30
|
+
* filter by requested publisher categories
|
|
31
|
+
*/
|
|
32
|
+
log?.debug('🤖 config.settings.strictCategoryMatching', config.settings.strictCategoryMatching);
|
|
33
|
+
log?.debug('🤖 bid.ext?.filteringEnabled', bid.ext?.filteringEnabled);
|
|
34
|
+
const categories = ((config.settings.strictCategoryMatching === true) || (bid.ext?.filteringEnabled === true))
|
|
35
|
+
? bid.ext?.originalCategories
|
|
36
|
+
: undefined;
|
|
37
|
+
log?.debug('🤖 categories', bid.ext?.originalCategories, categories);
|
|
38
|
+
if (metaProductId !== undefined) {
|
|
39
|
+
const stopProductsFetch = Ctx(logger)?.with('BuildProductCards').time?.('fetch products from bid');
|
|
40
|
+
const productRes = await getAllSponsoredProducts(metaProductId, categories);
|
|
41
|
+
if (!productRes.ok) {
|
|
42
|
+
errors.push(productRes);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
stopProductsFetch?.();
|
|
46
|
+
products.push(...productRes.value);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (metaBrandId !== undefined) {
|
|
50
|
+
const stopProductsFetch = Ctx(logger)?.with('BuildProductCards').time?.('fetch brand products from bid');
|
|
51
|
+
const brandRes = await getAllSponsoredBrandProducts(metaBrandId, categories);
|
|
52
|
+
if (!brandRes.ok) {
|
|
53
|
+
errors.push(brandRes);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
stopProductsFetch?.();
|
|
57
|
+
products.push(...brandRes.value);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (errors.length === attempts.length) {
|
|
61
|
+
return errors[0];
|
|
62
|
+
}
|
|
63
|
+
else if (errors.length !== 0) {
|
|
64
|
+
log?.warn(errors[0]);
|
|
65
|
+
}
|
|
66
|
+
return Ok({
|
|
67
|
+
products,
|
|
68
|
+
native
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
return Err(err);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const getField = (native) => (id) => native.native.assets
|
|
76
|
+
?.find(asset => asset.id === id)
|
|
77
|
+
?.data
|
|
78
|
+
?.value;
|
|
79
|
+
const addProductIdsToUrl = (logger, href, productIdStr) => href
|
|
80
|
+
.replace('{surf_products}', productIdStr)
|
|
81
|
+
.replace('%7Bsurf_products%7D', productIdStr)
|
|
82
|
+
.replace('\\{surf_products\\}', productIdStr);
|
|
83
|
+
export const getTrackers = (logger, bid, native, productIds) => {
|
|
84
|
+
const log = Ctx(logger)?.with('getTrackers');
|
|
85
|
+
log?.info('Getting trackers');
|
|
86
|
+
const win = bid.nurl;
|
|
87
|
+
if (win === undefined) {
|
|
88
|
+
return Err(new MissingWinUrlError(bid));
|
|
89
|
+
}
|
|
90
|
+
/*
|
|
91
|
+
This is a weird way to initialize this, but it's just meant to
|
|
92
|
+
prevent empty strings from joining an empty array
|
|
93
|
+
|
|
94
|
+
([]).join(',') === ""
|
|
95
|
+
*/
|
|
96
|
+
const productIdsStr = (productIds?.length !== 0)
|
|
97
|
+
? productIds?.join(',')
|
|
98
|
+
: undefined;
|
|
99
|
+
const imp = native.native.eventtrackers
|
|
100
|
+
?.filter(tracker => tracker.event === EventTypes.Imp && tracker.method === EventTrackingMethods.Img)
|
|
101
|
+
.map(tracker => tracker.url)
|
|
102
|
+
.filter(url => url !== undefined)
|
|
103
|
+
.map(url => productIdsStr === undefined
|
|
104
|
+
? url
|
|
105
|
+
: addProductIdsToUrl(logger, url, productIdsStr)) ?? [];
|
|
106
|
+
const others = native.native.eventtrackers
|
|
107
|
+
?.filter(tracker => tracker.url !== undefined)
|
|
108
|
+
.map(tracker => ({
|
|
109
|
+
type: tracker.method,
|
|
110
|
+
url: tracker.url
|
|
111
|
+
}))
|
|
112
|
+
.map(productIdsStr === undefined
|
|
113
|
+
? tracker => tracker
|
|
114
|
+
: tracker => ({
|
|
115
|
+
...tracker,
|
|
116
|
+
url: addProductIdsToUrl(logger, tracker.url, productIdsStr)
|
|
117
|
+
})) ?? [];
|
|
118
|
+
const eventNames = Object.entries(EventTypes).reduce((acc, [key, value]) => {
|
|
119
|
+
acc[value] = key[0].toLowerCase() + key.substring(1); // camelCase
|
|
120
|
+
return acc;
|
|
121
|
+
}, {});
|
|
122
|
+
const winNamedTracker = {
|
|
123
|
+
impression: [],
|
|
124
|
+
win: [{
|
|
125
|
+
type: 'pixel',
|
|
126
|
+
url: productIdsStr === undefined
|
|
127
|
+
? win
|
|
128
|
+
: addProductIdsToUrl(logger, win, productIdsStr)
|
|
129
|
+
}]
|
|
130
|
+
};
|
|
131
|
+
const namedTrackers = native.native.eventtrackers
|
|
132
|
+
?.reduce((acc, tracker) => {
|
|
133
|
+
const { method: type, url } = tracker;
|
|
134
|
+
if (url === undefined) {
|
|
135
|
+
return acc;
|
|
136
|
+
}
|
|
137
|
+
const eventName = eventNames[tracker.event];
|
|
138
|
+
// imp => impression
|
|
139
|
+
// viewableMRC50 => viewable
|
|
140
|
+
// {other} => {other}
|
|
141
|
+
// undefined => event_{raw ID}
|
|
142
|
+
const key = (eventName === 'imp')
|
|
143
|
+
? 'impression'
|
|
144
|
+
: (eventName === 'viewableMRC50')
|
|
145
|
+
? 'viewable'
|
|
146
|
+
: (eventName ?? `event_${tracker.event}`);
|
|
147
|
+
acc[key] = acc[key] ?? [];
|
|
148
|
+
switch (type) {
|
|
149
|
+
case EventTrackingMethods.Img: {
|
|
150
|
+
acc[key].push({
|
|
151
|
+
type: 'pixel',
|
|
152
|
+
url: productIdsStr === undefined
|
|
153
|
+
? url
|
|
154
|
+
: addProductIdsToUrl(logger, url, productIdsStr)
|
|
155
|
+
});
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
case EventTrackingMethods.JS: {
|
|
159
|
+
acc[key].push({
|
|
160
|
+
type: 'script',
|
|
161
|
+
src: url
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return acc;
|
|
166
|
+
}, winNamedTracker) ?? winNamedTracker;
|
|
167
|
+
return Ok({ win, imp, others, namedTrackers });
|
|
168
|
+
};
|
|
169
|
+
//# sourceMappingURL=Products.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Products.js","sourceRoot":"/","sources":["helpers/response/Products.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,oBAAoB,EACpB,UAAU,EAKV,aAAa,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAEH,GAAG,EACH,GAAG,EAI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ISurfsideApi } from './Api';
|
|
2
|
+
import Handlebars from 'handlebars/runtime';
|
|
3
|
+
import { type BuildAllSponsoredProductCardResponsesFn, type GenerateSponsoredProductCardResponseFn, type HandlebarsHelpers, type RequestBuilderFn } from './helpers';
|
|
4
|
+
import { type IDevice, type ICompiledPublisherConfiguration, type IGeoContext, type INativeTemplateDelegateWindow } from './models';
|
|
5
|
+
import { type RequestBidsFn, type GetAllSponsoredProductFromNativeIdFn, type GetRecommendedProductFromProductIdFn, type NonPersonalRecommenderFn, type PersonalRecommenderFn, type GetDynamicZoneFn, type EvaluateProductCardTemplateFn, type EvaluateClickthroughTemplateFn, type IProductTrackerService, type ILogger, type ITelemetryCollector, type IScreen, type INavigator, type Result, type AsyncResult, type LoadConfigurationFileFn, type LoadGlobalCategoryConfigurationFn } from './services';
|
|
6
|
+
import { type MapCategoriesFn } from './services/Category';
|
|
7
|
+
export type OverrideFactory<T, U = ISurfAdsCoreConfiguration> = (config: U, original: T) => Result<T>;
|
|
8
|
+
export type AsyncOverrideFactory<T, U = ISurfAdsCoreConfiguration> = (config: U, original: T) => AsyncResult<T>;
|
|
9
|
+
export declare const MemoizeOverride: <TArgs extends unknown[], TReturn, U = ISurfAdsCoreConfiguration>(time?: Partial<{
|
|
10
|
+
minutes: number;
|
|
11
|
+
hours: number;
|
|
12
|
+
seconds: number;
|
|
13
|
+
milliseconds: number;
|
|
14
|
+
}>) => OverrideFactory<(...args: TArgs) => TReturn, U>;
|
|
15
|
+
export declare const MemoizeOverrideAsync: <TArgs extends unknown[], TReturn, U = ISurfAdsCoreConfiguration>(time?: Partial<{
|
|
16
|
+
minutes: number;
|
|
17
|
+
hours: number;
|
|
18
|
+
seconds: number;
|
|
19
|
+
milliseconds: number;
|
|
20
|
+
}>) => AsyncOverrideFactory<(...args: TArgs) => Promise<TReturn>, U>;
|
|
21
|
+
export declare const CacheOverride: <TArgs extends unknown[], TReturn, U = ISurfAdsCoreConfiguration>(timeout?: Partial<{
|
|
22
|
+
minutes: number;
|
|
23
|
+
hours: number;
|
|
24
|
+
seconds: number;
|
|
25
|
+
milliseconds: number;
|
|
26
|
+
}>) => OverrideFactory<(...args: TArgs) => TReturn, U>;
|
|
27
|
+
export declare const AsyncCacheOverride: <TArgs extends unknown[], TReturn, U = ISurfAdsCoreConfiguration>(timeout?: Partial<{
|
|
28
|
+
minutes: number;
|
|
29
|
+
hours: number;
|
|
30
|
+
seconds: number;
|
|
31
|
+
milliseconds: number;
|
|
32
|
+
}>) => OverrideFactory<(...args: TArgs) => Promise<TReturn>, U>;
|
|
33
|
+
export interface ISurfAdsCoreConfigurationOverrides {
|
|
34
|
+
mapCategories: OverrideFactory<(categories: string[]) => string[]>;
|
|
35
|
+
generateCategories: OverrideFactory<MapCategoriesFn>;
|
|
36
|
+
requestBids: OverrideFactory<RequestBidsFn>;
|
|
37
|
+
getAllSponsoredProducts: OverrideFactory<GetAllSponsoredProductFromNativeIdFn>;
|
|
38
|
+
getAllSponsoredBrandProducts: OverrideFactory<GetAllSponsoredProductFromNativeIdFn>;
|
|
39
|
+
getRecommendedProduct: OverrideFactory<GetRecommendedProductFromProductIdFn>;
|
|
40
|
+
generateTopProducts: OverrideFactory<NonPersonalRecommenderFn>;
|
|
41
|
+
generateForYou: OverrideFactory<PersonalRecommenderFn>;
|
|
42
|
+
generatePreviousPurchases: OverrideFactory<PersonalRecommenderFn>;
|
|
43
|
+
getDynamicZone: OverrideFactory<GetDynamicZoneFn>;
|
|
44
|
+
buildAllSponsoredProductCardResponses: OverrideFactory<BuildAllSponsoredProductCardResponsesFn>;
|
|
45
|
+
generateSponsoredProductCardResponse: OverrideFactory<GenerateSponsoredProductCardResponseFn>;
|
|
46
|
+
evaluateProductCardTemplate: OverrideFactory<EvaluateProductCardTemplateFn>;
|
|
47
|
+
evaluateClickthroughTemplate: OverrideFactory<EvaluateClickthroughTemplateFn>;
|
|
48
|
+
startRequest: (config: ISurfAdsCoreConfiguration, startRequest: RequestBuilderFn) => Result<RequestBuilderFn>;
|
|
49
|
+
trackerService: OverrideFactory<IProductTrackerService>;
|
|
50
|
+
createTelemetryCollector: OverrideFactory<ITelemetryCollector | undefined, Omit<ISurfAdsCoreConfiguration, 'geo' | 'handlebars' | 'configuration' | 'logger'>>;
|
|
51
|
+
loadConfigurationFile: OverrideFactory<LoadConfigurationFileFn, ILoadSurfAdsCoreConfigurationDependenciesConfig>;
|
|
52
|
+
loadGlobalCategoryConfiguration: OverrideFactory<LoadGlobalCategoryConfigurationFn, ILoadSurfAdsCoreConfigurationDependenciesConfig>;
|
|
53
|
+
}
|
|
54
|
+
export interface ISurfAdsCoreConfiguration extends ISurfAdsCoreDependencies {
|
|
55
|
+
windowInfo: INativeTemplateDelegateWindow;
|
|
56
|
+
screen: IScreen;
|
|
57
|
+
navigator: INavigator;
|
|
58
|
+
mobile: boolean;
|
|
59
|
+
ip: string | undefined;
|
|
60
|
+
accountId: string;
|
|
61
|
+
siteId: string;
|
|
62
|
+
channelId: string;
|
|
63
|
+
locationId: string;
|
|
64
|
+
userId: string | undefined;
|
|
65
|
+
overrides?: {
|
|
66
|
+
services?: Partial<ISurfAdsCoreConfigurationOverrides>;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export declare function CreateSurfAdsCore(config: ISurfAdsCoreConfiguration): Result<ISurfsideApi>;
|
|
70
|
+
export interface ILoadSurfAdsCoreConfiguration {
|
|
71
|
+
logger?: ILogger;
|
|
72
|
+
windowInfo: INativeTemplateDelegateWindow;
|
|
73
|
+
screen: IScreen;
|
|
74
|
+
navigator: INavigator;
|
|
75
|
+
mobile: boolean;
|
|
76
|
+
ip: string | undefined;
|
|
77
|
+
accountId: string;
|
|
78
|
+
siteId: string;
|
|
79
|
+
channelId: string;
|
|
80
|
+
locationId: string;
|
|
81
|
+
userId: string | undefined;
|
|
82
|
+
telemetry?: boolean;
|
|
83
|
+
overrides?: {
|
|
84
|
+
services?: Partial<ISurfAdsCoreConfigurationOverrides>;
|
|
85
|
+
dependencies?: Partial<ISurfAdsCoreDependencies>;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export interface ISurfAdsCoreDependencies {
|
|
89
|
+
handlebars: typeof Handlebars;
|
|
90
|
+
configuration: ICompiledPublisherConfiguration;
|
|
91
|
+
geo: IGeoContext | undefined;
|
|
92
|
+
device: IDevice | undefined;
|
|
93
|
+
logger: ILogger | undefined;
|
|
94
|
+
}
|
|
95
|
+
export declare const LoadSurfAdsCoreHandlebarsDependencies: (logger: ILogger | undefined, windowInfo: INativeTemplateDelegateWindow) => [typeof Handlebars, HandlebarsHelpers];
|
|
96
|
+
export interface ILoadSurfAdsCoreConfigurationDependenciesConfig {
|
|
97
|
+
logger: ILogger | undefined;
|
|
98
|
+
accountId: string;
|
|
99
|
+
siteId: string;
|
|
100
|
+
handlebars: typeof Handlebars;
|
|
101
|
+
handlebarsHelpers: HandlebarsHelpers;
|
|
102
|
+
overrides?: {
|
|
103
|
+
services?: Partial<{
|
|
104
|
+
loadConfigurationFile: OverrideFactory<LoadConfigurationFileFn, ILoadSurfAdsCoreConfigurationDependenciesConfig>;
|
|
105
|
+
loadGlobalCategoryConfiguration: OverrideFactory<LoadGlobalCategoryConfigurationFn, ILoadSurfAdsCoreConfigurationDependenciesConfig>;
|
|
106
|
+
}>;
|
|
107
|
+
dependencies?: Partial<ISurfAdsCoreDependencies>;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export declare const LoadSurfAdsCoreConfigurationDependencies: (config: ILoadSurfAdsCoreConfigurationDependenciesConfig) => AsyncResult<ICompiledPublisherConfiguration>;
|
|
111
|
+
export interface ILoadSurfAdsCoreGeoDependenciesConfig {
|
|
112
|
+
logger: ILogger | undefined;
|
|
113
|
+
overrides?: {
|
|
114
|
+
dependencies?: Partial<ISurfAdsCoreDependencies>;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
export declare const LoadSurfAdsCoreGeoDependencies: (config: ILoadSurfAdsCoreGeoDependenciesConfig) => AsyncResult<IGeoContext>;
|
|
118
|
+
export interface ILoadSurfAdsCoreDeviceDependenciesConfig {
|
|
119
|
+
logger: ILogger | undefined;
|
|
120
|
+
screen: IScreen;
|
|
121
|
+
navigator: INavigator;
|
|
122
|
+
mobile: boolean;
|
|
123
|
+
overrides?: {
|
|
124
|
+
dependencies?: Partial<ISurfAdsCoreDependencies>;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
export declare const LoadSurfAdsCoreDeviceDependencies: (config: ILoadSurfAdsCoreDeviceDependenciesConfig) => IDevice | undefined;
|
|
128
|
+
export declare const LoadSurfAdsCoreDependencies: (config: ILoadSurfAdsCoreConfiguration) => AsyncResult<ISurfAdsCoreDependencies>;
|
|
129
|
+
export declare const LoadSurfAdsCore: (config: ILoadSurfAdsCoreConfiguration) => AsyncResult<ISurfsideApi>;
|
|
130
|
+
export declare const LoadAdsCoreBrowser: (accountId: string, channelId: string, siteId: string, locationId: string, userId?: string, logger?: ILogger) => AsyncResult<ISurfsideApi>;
|
|
131
|
+
export type LoadsSurfAdsCoreHeadlessConfig = {
|
|
132
|
+
accountId: string;
|
|
133
|
+
siteId: string;
|
|
134
|
+
channelId: string;
|
|
135
|
+
locationId: string;
|
|
136
|
+
userId?: string;
|
|
137
|
+
ip: string;
|
|
138
|
+
telemetry?: boolean;
|
|
139
|
+
logging?: boolean;
|
|
140
|
+
userAgent: string;
|
|
141
|
+
url: string;
|
|
142
|
+
overrides?: {
|
|
143
|
+
services?: Partial<ISurfAdsCoreConfigurationOverrides>;
|
|
144
|
+
dependencies?: Partial<ISurfAdsCoreDependencies>;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
export declare const LoadSurfAdsCoreHeadless: (config: LoadsSurfAdsCoreHeadlessConfig) => AsyncResult<ISurfsideApi>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type IDevice } from '../models';
|
|
2
|
+
import { ITelemetryCollector, type ITelemetryDevice, type ITelemetryEntry } from '../services/Logger';
|
|
3
|
+
export interface ISSRTelemetryCollectorOptions {
|
|
4
|
+
accountId: string;
|
|
5
|
+
siteId: string;
|
|
6
|
+
channelId: string;
|
|
7
|
+
locationId: string;
|
|
8
|
+
endpoint: string;
|
|
9
|
+
tags?: Record<string, string>;
|
|
10
|
+
batchIntervalMs?: number;
|
|
11
|
+
url: string;
|
|
12
|
+
device?: ITelemetryDevice;
|
|
13
|
+
}
|
|
14
|
+
export declare const DeviceToTelemetryDevice: (device: IDevice | undefined) => ITelemetryDevice | undefined;
|
|
15
|
+
export declare class SSRTelemetryCollector extends ITelemetryCollector {
|
|
16
|
+
private readonly _endpoint;
|
|
17
|
+
private readonly _tags;
|
|
18
|
+
private readonly _batchIntervalMs;
|
|
19
|
+
private readonly _pageUrl;
|
|
20
|
+
private queue;
|
|
21
|
+
private flushTimer;
|
|
22
|
+
constructor(options: ISSRTelemetryCollectorOptions);
|
|
23
|
+
record(entry: ITelemetryEntry): void;
|
|
24
|
+
flush(): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Debouncer = ReturnType<typeof globalThis.setTimeout>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type IBid, type ICompiledPublisherConfiguration, type INativeResponse, type IProductInformation } from '../../models';
|
|
2
|
+
import { type AsyncResult, type GetAllSponsoredProductFromNativeIdFn, type ILogger, type Result } from '../../services';
|
|
3
|
+
import { type ITrackerObject } from './ProductCard';
|
|
4
|
+
export declare const fetchProductsFromBid: (logger: ILogger | undefined, getAllSponsoredProducts: GetAllSponsoredProductFromNativeIdFn, getAllSponsoredBrandProducts: GetAllSponsoredProductFromNativeIdFn, config: ICompiledPublisherConfiguration, bid: IBid) => AsyncResult<{
|
|
5
|
+
products: IProductInformation[];
|
|
6
|
+
native: INativeResponse;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const getTrackers: (logger: ILogger | undefined, bid: IBid, native: INativeResponse, productIds?: string[]) => Result<ITrackerObject>;
|
package/package.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@surfside/ads-core",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"module": "./lib/esm/index.js",
|
|
5
|
-
"main": "./lib/cjs/index.js",
|
|
6
|
-
"types": "./lib/types/index.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"import": "./lib/esm/index.js",
|
|
10
|
-
"require": "./lib/cjs/index.js",
|
|
11
|
-
"types": "./lib/types/index.d.ts"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"license": "UNLICENSED",
|
|
15
|
-
"type": "module",
|
|
16
|
-
"files": [
|
|
17
|
-
"lib/",
|
|
18
|
-
"README.md"
|
|
19
|
-
],
|
|
20
|
-
"devDependencies": {
|
|
21
|
-
"@eslint/js": "^9.25.1",
|
|
22
|
-
"@types/bun": "latest",
|
|
23
|
-
"@types/handlebars": "^4.1.0",
|
|
24
|
-
"@types/jest": "^29.5.14",
|
|
25
|
-
"eslint": "^9.25.1",
|
|
26
|
-
"jest": "^29.7.0",
|
|
27
|
-
"npm-run-all": "^4.1.5",
|
|
28
|
-
"ts-jest": "^29.3.2",
|
|
29
|
-
"typedoc": "^0.28.5",
|
|
30
|
-
"typescript-eslint": "^8.41.0"
|
|
31
|
-
},
|
|
32
|
-
"peerDependencies": {
|
|
33
|
-
"typescript": "^5.8.3"
|
|
34
|
-
},
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"handlebars": "^4.7.8"
|
|
37
|
-
},
|
|
38
|
-
"scripts": {
|
|
39
|
-
"clean": "rm -rf ./lib",
|
|
40
|
-
"prebuild": "echo \"export const SurfsideAdsCoreVersionInfo = { buildBranch: '$(git rev-parse --abbrev-ref HEAD)', buildHash: '$(git rev-parse --short HEAD)', buildVer: '$(bun -e 'console.log(require(\"./package.json\").version)')'};\" > src/BuildInfo.ts",
|
|
41
|
-
"build": "
|
|
42
|
-
"types": "tsc -p ./tsconfig.types.json",
|
|
43
|
-
"esm": "tsc -p ./tsconfig.esm.json",
|
|
44
|
-
"cjs": "tsc -p tsconfig.cjs.json",
|
|
45
|
-
"lint": "npx eslint"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@surfside/ads-core",
|
|
3
|
+
"version": "2.0.23",
|
|
4
|
+
"module": "./lib/esm/index.js",
|
|
5
|
+
"main": "./lib/cjs/index.js",
|
|
6
|
+
"types": "./lib/types/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./lib/esm/index.js",
|
|
10
|
+
"require": "./lib/cjs/index.js",
|
|
11
|
+
"types": "./lib/types/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"license": "UNLICENSED",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"files": [
|
|
17
|
+
"lib/",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@eslint/js": "^9.25.1",
|
|
22
|
+
"@types/bun": "latest",
|
|
23
|
+
"@types/handlebars": "^4.1.0",
|
|
24
|
+
"@types/jest": "^29.5.14",
|
|
25
|
+
"eslint": "^9.25.1",
|
|
26
|
+
"jest": "^29.7.0",
|
|
27
|
+
"npm-run-all": "^4.1.5",
|
|
28
|
+
"ts-jest": "^29.3.2",
|
|
29
|
+
"typedoc": "^0.28.5",
|
|
30
|
+
"typescript-eslint": "^8.41.0"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"typescript": "^5.8.3"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"handlebars": "^4.7.8"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"clean": "rm -rf ./lib",
|
|
40
|
+
"prebuild": "echo \"export const SurfsideAdsCoreVersionInfo = { buildBranch: '$(git rev-parse --abbrev-ref HEAD)', buildHash: '$(git rev-parse --short HEAD)', buildVer: '$(bun -e 'console.log(require(\"./package.json\").version)')'};\" > src/BuildInfo.ts",
|
|
41
|
+
"build": "bun x npm-run-all --parallel \"types\" \"esm\" \"cjs\"",
|
|
42
|
+
"types": "tsc -p ./tsconfig.types.json",
|
|
43
|
+
"esm": "tsc -p ./tsconfig.esm.json",
|
|
44
|
+
"cjs": "tsc -p tsconfig.cjs.json",
|
|
45
|
+
"lint": "npx eslint"
|
|
46
|
+
}
|
|
47
|
+
}
|