@surfside/ads-react 0.1.16 → 0.1.18

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 (50) hide show
  1. package/lib/cjs/BuildInfo.js +1 -1
  2. package/lib/cjs/BuildInfo.js.map +1 -1
  3. package/lib/cjs/components/SurfsideBanner.js +46 -0
  4. package/lib/cjs/components/SurfsideBanner.js.map +1 -0
  5. package/lib/cjs/components/SurfsideBannerRenderer.js +45 -0
  6. package/lib/cjs/components/SurfsideBannerRenderer.js.map +1 -0
  7. package/lib/cjs/components/SurfsideBannerVideoRenderer.js +25 -0
  8. package/lib/cjs/components/SurfsideBannerVideoRenderer.js.map +1 -0
  9. package/lib/cjs/components/SurfsideCarousel.js +116 -0
  10. package/lib/cjs/components/SurfsideCarousel.js.map +1 -0
  11. package/lib/cjs/components/SurfsideDynamicZone.js +141 -0
  12. package/lib/cjs/components/SurfsideDynamicZone.js.map +1 -0
  13. package/lib/cjs/components/SurfsideProduct.js +118 -0
  14. package/lib/cjs/components/SurfsideProduct.js.map +1 -0
  15. package/lib/cjs/components/SurfsideVideo.js +84 -0
  16. package/lib/cjs/components/SurfsideVideo.js.map +1 -0
  17. package/lib/cjs/components/SurfsideVideoRenderer.js +42 -0
  18. package/lib/cjs/components/SurfsideVideoRenderer.js.map +1 -0
  19. package/lib/cjs/components/index.js +23 -0
  20. package/lib/cjs/components/index.js.map +1 -0
  21. package/lib/cjs/hooks/index.js +20 -0
  22. package/lib/cjs/hooks/index.js.map +1 -0
  23. package/lib/cjs/hooks/useSurfsideBanner.js +215 -0
  24. package/lib/cjs/hooks/useSurfsideBanner.js.map +1 -0
  25. package/lib/cjs/hooks/useSurfsideDynamicZone.js +283 -0
  26. package/lib/cjs/hooks/useSurfsideDynamicZone.js.map +1 -0
  27. package/lib/cjs/hooks/useSurfsideProducts.js +445 -0
  28. package/lib/cjs/hooks/useSurfsideProducts.js.map +1 -0
  29. package/lib/cjs/hooks/useSurfsideVideo.js +299 -0
  30. package/lib/cjs/hooks/useSurfsideVideo.js.map +1 -0
  31. package/lib/cjs/index.js +71 -0
  32. package/lib/cjs/index.js.map +1 -0
  33. package/lib/cjs/provider/SurfsideContextProvider.js +175 -0
  34. package/lib/cjs/provider/SurfsideContextProvider.js.map +1 -0
  35. package/lib/cjs/provider/index.js +9 -0
  36. package/lib/cjs/provider/index.js.map +1 -0
  37. package/lib/cjs/utils/Analytics.js +181 -0
  38. package/lib/cjs/utils/Analytics.js.map +1 -0
  39. package/lib/cjs/utils/index.js +12 -0
  40. package/lib/cjs/utils/index.js.map +1 -0
  41. package/lib/esm/BuildInfo.js +1 -1
  42. package/lib/esm/BuildInfo.js.map +1 -1
  43. package/lib/esm/components/SurfsideDynamicZone.js +9 -1
  44. package/lib/esm/components/SurfsideDynamicZone.js.map +1 -1
  45. package/lib/esm/hooks/useSurfsideProducts.js +17 -6
  46. package/lib/esm/hooks/useSurfsideProducts.js.map +1 -1
  47. package/lib/esm/provider/SurfsideContextProvider.js +18 -2
  48. package/lib/esm/provider/SurfsideContextProvider.js.map +1 -1
  49. package/lib/types/components/SurfsideDynamicZone.d.ts +1 -1
  50. package/package.json +3 -3
@@ -0,0 +1,445 @@
1
+ "use strict";
2
+ 'use client';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.InvalidProductsStateError = exports.InvalidStrategyError = void 0;
5
+ exports.useSurfsideProducts = useSurfsideProducts;
6
+ exports.useSurfsideProductsResponse = useSurfsideProductsResponse;
7
+ const react_1 = require("react");
8
+ const provider_1 = require("../provider");
9
+ const ads_core_client_1 = require("@surfside/ads-core-client");
10
+ ;
11
+ ;
12
+ ;
13
+ /**
14
+ * Fetches a page of either product data or product IDs. Returns a set of callbacks for fetching more products and
15
+ * callbacks for tracking impression and click events.
16
+ *
17
+ * This hook is useful for implementing carousels or pages of sponsored product listings within search results.
18
+ *
19
+ * This will either return a set of products and their data fields (i.e, name, description, price, etc.) or a set of
20
+ * product IDs, depending on the value of `props.withProductInfo`.
21
+ *
22
+ * @param props The page information and recommender strategy. See {@link UseSurfsideProductsPropsWithProductIDs} and
23
+ * {@link UseSurfsideProductsPropsWithProductData}
24
+
25
+ *
26
+ * @example
27
+ * To retrieve full product data, including all available fields:
28
+ *
29
+ * ```tsx
30
+ * // returns product data
31
+ * const { products } = useSurfsideProducts({
32
+ * zoneId: '123',
33
+ * pageSize: 6,
34
+ * strategy: 'sponsored',
35
+ * withProductInfo: true // or pass nothing - withProductInfo is true by default
36
+ * })
37
+ *
38
+ * console.log(products.map(product => product.data.name))
39
+ * ```
40
+ *
41
+ * *(See {@link IProductInfoData} and {@link IProductInformation} for a list of fields and the full return type)*
42
+ *
43
+ * @example
44
+ * To retrieve *only* product IDs:
45
+ *
46
+ * ```tsx
47
+ * // returns product IDs
48
+ * const { products } = useSurfsideProducts({
49
+ * zoneId: '123',
50
+ * pageSize: 6,
51
+ * strategy: 'sponsored',
52
+ * withProductInfo: false
53
+ * })
54
+ *
55
+ * console.log(products.map(product => product.id))
56
+ * ```
57
+ *
58
+ * *(See {@link IProductIDData} for the full return type)*
59
+ *
60
+ * @example
61
+ * Both return types will return an object with a `type` field:
62
+ *
63
+ * ```ts
64
+ * {
65
+ * type: 'sponsored' | 'recommended'
66
+ * // either product ID or product data goes here...
67
+ * }
68
+ * ```
69
+ *
70
+ * This is so you can mark Sponsored products as sponsored. In the United States,
71
+ * [
72
+ * the FTC requires all advertisements be conspicuously labeled as such
73
+ * ](https://www.ftc.gov/business-guidance/resources/ftcs-endorsement-guides-what-people-are-asking#\
74
+ * :~:text=The%20FTC%20Act%20applies%20to,have%20you%20mention%20that%20product).
75
+ *
76
+ * When rendering a product card, you might use this field thusly:
77
+ *
78
+ * ```tsx
79
+ * products.map(product => <div>
80
+ * {product.data.name}
81
+ * {product.type === 'sponsored'
82
+ * ? <span>Sponsored</span>
83
+ * : <></>
84
+ * }
85
+ * </div>);
86
+ * ```
87
+ *
88
+ * @example
89
+ * A very simple carousel implementation might look like:
90
+ *
91
+ * ```tsx
92
+ * const myCarousel = ({ zoneId }: MyCarouselProps) => {
93
+ * const { products, hasMore, fetchNextPage, analytics } = useSurfsideProducts({
94
+ * zoneId,
95
+ * strategy: 'sponsored',
96
+ * pageSize: 6
97
+ * });
98
+ *
99
+ * return <div>
100
+ * <div class="products">
101
+ * {products.map(product => <div>
102
+ * { \/* Product Image is a URL string *\/ }
103
+ * <img src={product.data.image} />
104
+ * { \/* Product name *\/ }
105
+ * <h2>{product.data.name}</h2>
106
+ * { \/* Details is a short description of the product *\/ }
107
+ * <p>{product.data.details}</p>
108
+ * { \/* product.type is either 'sponsored' or 'recommended' *\/ }
109
+ * {product.type === 'sponsored'
110
+ * ? <span>Sponsored</span>
111
+ * : <></>
112
+ * }
113
+ * </div>)}
114
+ * </div>
115
+ * <div class="controls">
116
+ * { \/* hasMore indicates that there are more products available to be fetched *\/ }
117
+ * {hasMore
118
+ * ? <button class="nextButton" onClick={fetchNextPage}>➡️</button>
119
+ * : <></>
120
+ * }
121
+ * </div>
122
+ * </div>
123
+ * }
124
+ * ```
125
+ */
126
+ function useSurfsideProducts(props) {
127
+ const stableCategory = (0, react_1.useMemo)(() => props.category, [props.category?.join(',') ?? '']);
128
+ const internalProps = (0, react_1.useMemo)(() => ({
129
+ carousel: undefined,
130
+ ...props,
131
+ category: stableCategory,
132
+ }), [
133
+ props.zoneId,
134
+ props.pageSize,
135
+ props.maxProducts,
136
+ props.enabled,
137
+ stableCategory,
138
+ props.withProductInfo,
139
+ props.strategy,
140
+ props.recommenderType,
141
+ ]);
142
+ const internalState = useSurfsideProductsResponse(internalProps);
143
+ (0, react_1.useEffect)(() => {
144
+ internalState.refetch?.();
145
+ }, [internalState.refetch]);
146
+ return internalState;
147
+ }
148
+ ;
149
+ /** There are three workflows for fetching products:
150
+ * 1. Internal carousel is provided, and sets the dataSource, and triggers a fetchProducts call
151
+ * 2. Refetch
152
+ * - this builds the carousel and and sets the internal carousel
153
+ * - this triggers a useEffect and sets the dataSource
154
+ * - this triggers a rebuild of fetchProducts callback and triggers a fetchProducts call
155
+ * 3. Fetch next page
156
+ * - this triggers a call to fetchProducts with isRefetch set to false
157
+ * - and loads in the next page size of products
158
+ */
159
+ /**
160
+ * Good things to know:
161
+ * category, zoneId, and other props changing only matter in refetch because its safe to assume that
162
+ if they come from dynamic zone, the carousel will be provided from the dynamic zone
163
+ * if they come from useSurfsideProducts, we need to call refetch to rebuild the carousel
164
+ */
165
+ function useSurfsideProductsResponse(props) {
166
+ const { defaultNative, startRequest, buildHybridCarousel, buildSponsoredCarousel, buildRecommendedCarousel, isReady: apiIsReady, hasError: apiHasError, error: apiError, logger } = (0, provider_1.useSurfsideContext)();
167
+ const log = (0, ads_core_client_1.Ctx)(logger)?.with('useSurfsideProductsResponse');
168
+ log?.info('Using surfside products response!');
169
+ const [internalCarousel, setInternalCarousel] = (0, react_1.useState)(props?.carousel);
170
+ const [loading, setLoading] = (0, react_1.useState)(true);
171
+ const [products, setProducts] = (0, react_1.useState)([]);
172
+ const [dataSource, setDataSource] = (0, react_1.useState)();
173
+ const [productsError, setProductsError] = (0, react_1.useState)();
174
+ const [hasMore, setHasMore] = (0, react_1.useState)(false);
175
+ log?.debug('Props', props, products);
176
+ /* If the API has an error, set an error */
177
+ (0, react_1.useEffect)(() => {
178
+ if (apiError !== undefined) {
179
+ log?.error(apiError);
180
+ setErrorState(apiError);
181
+ }
182
+ }, [apiHasError, apiError]);
183
+ /* If the API is still loading, set the loading state */
184
+ (0, react_1.useEffect)(() => {
185
+ if (!apiIsReady) {
186
+ log?.debug('Loading...');
187
+ setLoadingState();
188
+ }
189
+ else {
190
+ log?.debug('Ready!');
191
+ setReady();
192
+ }
193
+ }, [apiIsReady]);
194
+ /* If the datasource was just set, fetch a page of products */
195
+ /* This is only called if a new internal carousel is set */
196
+ (0, react_1.useEffect)(() => {
197
+ log?.debug('Checking data source...');
198
+ if (dataSource !== undefined) {
199
+ log?.debug('DataSource set, fetching!');
200
+ fetchProducts();
201
+ }
202
+ }, [dataSource]);
203
+ /* If the internalCarousel was just set, set the datasource from that internal carousel
204
+ * This can either be passed in to the arguments (i.e, dynamic zones) or it can be set by calling
205
+ * refetch, which also works as an initial fetch request */
206
+ (0, react_1.useEffect)(() => {
207
+ log?.debug('Checking internal carousel response...');
208
+ if (internalCarousel?.ok === true) {
209
+ log?.debug('Found internal carousel!');
210
+ setDataSource(internalCarousel.value.getProduct());
211
+ }
212
+ else if (internalCarousel?.ok === false) {
213
+ log?.debug('Did not find internal carousel!');
214
+ setErrorState(internalCarousel);
215
+ }
216
+ }, [internalCarousel]);
217
+ (0, react_1.useEffect)(() => {
218
+ log?.info('Setting loading state...');
219
+ if (props === undefined) {
220
+ setLoadingState();
221
+ }
222
+ else {
223
+ setInternalCarousel(props.carousel);
224
+ }
225
+ }, [props]);
226
+ const setSuccessState = (newProduct, hasMore, isFetchMore = true) => {
227
+ log?.debug('Success!', newProduct, products, isFetchMore);
228
+ setLoading(false);
229
+ setProductsError(undefined);
230
+ setHasMore(hasMore);
231
+ setProducts((currentProducts) => {
232
+ return isFetchMore ? [...currentProducts, ...newProduct] : newProduct;
233
+ });
234
+ };
235
+ const setErrorState = (error) => {
236
+ log?.error('Setting error state', error);
237
+ setLoading(false);
238
+ setProductsError(error);
239
+ setHasMore(false);
240
+ };
241
+ const setLoadingState = () => {
242
+ log?.debug('Setting loading state');
243
+ setLoading(true);
244
+ setProductsError(undefined);
245
+ };
246
+ const setReady = () => {
247
+ log?.debug('Setting ready state');
248
+ setLoading(false);
249
+ setProductsError(undefined);
250
+ };
251
+ /* This is used for re-requesting the carousel, and is also called by useSurfsideProducts to initialize the data */
252
+ const refetch = (0, react_1.useCallback)(() => {
253
+ log?.debug('Refetching!');
254
+ if (props === undefined || !apiIsReady || props.enabled === false) {
255
+ if (apiHasError) {
256
+ setErrorState(apiError);
257
+ }
258
+ return;
259
+ }
260
+ setLoadingState();
261
+ const request = startRequest(props.zoneId)
262
+ .withNative(defaultNative()
263
+ .withMetaProduct(80, false)
264
+ .withMetaBrand(80, false)
265
+ .build())
266
+ .withSurfCategory(props?.category ?? [])
267
+ .build();
268
+ const recommenderType = props.recommenderType ?? 'top-products';
269
+ const carousel = (0, ads_core_client_1.TryDo)(() => {
270
+ switch (props.strategy) {
271
+ case 'hybrid':
272
+ return (0, ads_core_client_1.GetValueOrThrow)(buildHybridCarousel({
273
+ type: recommenderType
274
+ }, request));
275
+ case 'sponsored':
276
+ return (0, ads_core_client_1.GetValueOrThrow)(buildSponsoredCarousel(request));
277
+ case 'recommended':
278
+ return (0, ads_core_client_1.GetValueOrThrow)(buildRecommendedCarousel({ type: recommenderType }));
279
+ default:
280
+ throw new InvalidStrategyError(props.strategy);
281
+ }
282
+ });
283
+ setInternalCarousel(carousel);
284
+ }, [
285
+ apiIsReady,
286
+ apiError,
287
+ startRequest,
288
+ defaultNative,
289
+ buildHybridCarousel,
290
+ buildSponsoredCarousel,
291
+ buildRecommendedCarousel,
292
+ props?.enabled,
293
+ props?.category?.join(',') ?? '',
294
+ props?.strategy,
295
+ props?.recommenderType,
296
+ props?.zoneId,
297
+ props?.pageSize,
298
+ props?.maxProducts,
299
+ props?.withProductInfo,
300
+ props?.recommenderType,
301
+ ]);
302
+ /*
303
+ * This can be called in two different ways, either by the dataSource (internal carousel)
304
+ or by the fetchNextPage callback
305
+ * It is crucial to break these into two different calls with isFetchMore
306
+ because the fetchNextPage callback is called and the dataSource is called when the internal carousel is set
307
+ * if the dataSource is called, we need to set isFetchMore to false which replaces the old dataSource's products
308
+ */
309
+ const fetchProducts = (0, react_1.useCallback)((isFetchMore = false) => {
310
+ log?.debug('Fetching', products);
311
+ if (props === undefined) {
312
+ return;
313
+ }
314
+ if (dataSource !== undefined) {
315
+ const actualPageSize = props.maxProducts !== undefined
316
+ ? Math.min(props.maxProducts - products.length, props.pageSize)
317
+ : props.pageSize;
318
+ (0, ads_core_client_1.ConsumeNAsync)(dataSource, actualPageSize)
319
+ .then(([data, finished]) => {
320
+ setSuccessState(data, !finished, isFetchMore);
321
+ });
322
+ }
323
+ }, [dataSource, props, products]);
324
+ const mappedProducts = (0, react_1.useMemo)(() => {
325
+ // safe assumption that product feed and recommender returns products with ids
326
+ const validProducts = products.filter((p) => typeof p.product.id === 'string' && p.product.id.trim() !== '');
327
+ return props?.withProductInfo === true
328
+ ? validProducts.map(mapProductToData)
329
+ : validProducts.map(mapProductToIds);
330
+ }, [props?.withProductInfo, products]);
331
+ log?.debug('Final State', loading, productsError, products, apiError);
332
+ if (!loading && productsError === undefined) { /* Handle Success State */
333
+ return {
334
+ loading,
335
+ error: undefined,
336
+ products: mappedProducts,
337
+ hasMore,
338
+ refetch,
339
+ fetchNextPage: () => fetchProducts(true),
340
+ analytics: {
341
+ trackWin: product => {
342
+ const winTrackers = product.productCardResponse.trackers?.namedTrackers.win ?? [];
343
+ if (winTrackers.length === 0) {
344
+ log?.warn('Missing win trackers from namedTrackers in bid response');
345
+ }
346
+ for (const tracker of winTrackers) {
347
+ if (tracker.type === 'pixel') {
348
+ fetch(tracker.url);
349
+ ;
350
+ }
351
+ }
352
+ },
353
+ trackImpression: product => {
354
+ const impTrackers = product.productCardResponse.trackers?.namedTrackers.impression ?? [];
355
+ if (impTrackers.length === 0) {
356
+ log?.warn('Missing win trackers from namedTrackers in bid response');
357
+ }
358
+ for (const tracker of impTrackers) {
359
+ if (tracker.type === 'pixel') {
360
+ fetch(tracker.url);
361
+ }
362
+ }
363
+ },
364
+ trackClick: product => {
365
+ const clickUrl = product.productCardResponse.clickthrough;
366
+ const parsedClickUrl = new URL(clickUrl);
367
+ // Remove the 'url' query parameter if it exists
368
+ parsedClickUrl.searchParams.delete('url');
369
+ fetch(parsedClickUrl.toString());
370
+ }
371
+ }
372
+ };
373
+ }
374
+ else if (!loading && productsError !== undefined) { /* Handle Error State */
375
+ return {
376
+ loading,
377
+ error: productsError,
378
+ products: mappedProducts,
379
+ hasMore: false,
380
+ refetch,
381
+ fetchNextPage: undefined,
382
+ analytics: undefined
383
+ };
384
+ }
385
+ else if (loading && productsError === undefined) { /* Handle Loading State */
386
+ return {
387
+ loading,
388
+ error: undefined,
389
+ products: mappedProducts,
390
+ hasMore,
391
+ refetch,
392
+ fetchNextPage: undefined,
393
+ analytics: undefined
394
+ };
395
+ }
396
+ else { /* Handle invalid states */
397
+ return {
398
+ loading: false,
399
+ error: (0, ads_core_client_1.Err)(new InvalidProductsStateError(products, productsError, loading)),
400
+ products: mappedProducts,
401
+ hasMore,
402
+ refetch,
403
+ fetchNextPage: undefined,
404
+ analytics: undefined
405
+ };
406
+ }
407
+ }
408
+ ;
409
+ const mapProductToData = (product) => ({
410
+ data: {
411
+ ...product.product,
412
+ id: product.product.id !== undefined ? product.product.id : ''
413
+ },
414
+ type: product.sponsored ? 'sponsored' : 'recommended',
415
+ productCardResponse: product,
416
+ });
417
+ const mapProductToIds = (product) => ({
418
+ data: {
419
+ id: product.product.id
420
+ },
421
+ type: product.sponsored ? 'sponsored' : 'recommended',
422
+ productCardResponse: product
423
+ });
424
+ class InvalidStrategyError extends Error {
425
+ strategy;
426
+ constructor(strategy) {
427
+ super('Invalid strategy withing useSurfsideProducts');
428
+ this.strategy = strategy;
429
+ }
430
+ }
431
+ exports.InvalidStrategyError = InvalidStrategyError;
432
+ class InvalidProductsStateError extends Error {
433
+ products;
434
+ error;
435
+ loading;
436
+ constructor(products, error, loading) {
437
+ super('useSurfsideProducts resulted in an invalid state');
438
+ this.products = products;
439
+ this.error = error;
440
+ this.loading = loading;
441
+ }
442
+ }
443
+ exports.InvalidProductsStateError = InvalidProductsStateError;
444
+ ;
445
+ //# sourceMappingURL=useSurfsideProducts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSurfsideProducts.js","sourceRoot":"src/","sources":["hooks/useSurfsideProducts.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AAqXb,kDA4BC;AAgCD,kEAiRC;AAhsBD,iCAAkE;AAClE,0CAAiD;AACjD,+DAYmC;AAwClC,CAAC;AAkED,CAA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