@surfside/ads-react 0.1.15 → 0.1.17

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 (46) hide show
  1. package/lib/cjs/BuildInfo.js +1 -1
  2. package/lib/cjs/BuildInfo.js.map +1 -1
  3. package/lib/cjs/components/SurfsideDynamicZone.js +9 -1
  4. package/lib/cjs/components/SurfsideDynamicZone.js.map +1 -1
  5. package/lib/esm/BuildInfo.js +1 -1
  6. package/lib/esm/BuildInfo.js.map +1 -1
  7. package/lib/types/components/SurfsideDynamicZone.d.ts +1 -1
  8. package/package.json +3 -3
  9. package/lib/esm/components/SurfsideBanner.js +0 -43
  10. package/lib/esm/components/SurfsideBanner.js.map +0 -1
  11. package/lib/esm/components/SurfsideBannerRenderer.js +0 -41
  12. package/lib/esm/components/SurfsideBannerRenderer.js.map +0 -1
  13. package/lib/esm/components/SurfsideBannerVideoRenderer.js +0 -21
  14. package/lib/esm/components/SurfsideBannerVideoRenderer.js.map +0 -1
  15. package/lib/esm/components/SurfsideCarousel.js +0 -112
  16. package/lib/esm/components/SurfsideCarousel.js.map +0 -1
  17. package/lib/esm/components/SurfsideDynamicZone.js +0 -128
  18. package/lib/esm/components/SurfsideDynamicZone.js.map +0 -1
  19. package/lib/esm/components/SurfsideProduct.js +0 -113
  20. package/lib/esm/components/SurfsideProduct.js.map +0 -1
  21. package/lib/esm/components/SurfsideVideo.js +0 -81
  22. package/lib/esm/components/SurfsideVideo.js.map +0 -1
  23. package/lib/esm/components/SurfsideVideoRenderer.js +0 -38
  24. package/lib/esm/components/SurfsideVideoRenderer.js.map +0 -1
  25. package/lib/esm/components/index.js +0 -9
  26. package/lib/esm/components/index.js.map +0 -1
  27. package/lib/esm/hooks/index.js +0 -5
  28. package/lib/esm/hooks/index.js.map +0 -1
  29. package/lib/esm/hooks/useSurfsideBanner.js +0 -209
  30. package/lib/esm/hooks/useSurfsideBanner.js.map +0 -1
  31. package/lib/esm/hooks/useSurfsideDynamicZone.js +0 -278
  32. package/lib/esm/hooks/useSurfsideDynamicZone.js.map +0 -1
  33. package/lib/esm/hooks/useSurfsideProducts.js +0 -427
  34. package/lib/esm/hooks/useSurfsideProducts.js.map +0 -1
  35. package/lib/esm/hooks/useSurfsideVideo.js +0 -293
  36. package/lib/esm/hooks/useSurfsideVideo.js.map +0 -1
  37. package/lib/esm/index.js +0 -20
  38. package/lib/esm/index.js.map +0 -1
  39. package/lib/esm/provider/SurfsideContextProvider.js +0 -152
  40. package/lib/esm/provider/SurfsideContextProvider.js.map +0 -1
  41. package/lib/esm/provider/index.js +0 -2
  42. package/lib/esm/provider/index.js.map +0 -1
  43. package/lib/esm/utils/Analytics.js +0 -171
  44. package/lib/esm/utils/Analytics.js.map +0 -1
  45. package/lib/esm/utils/index.js +0 -2
  46. package/lib/esm/utils/index.js.map +0 -1
@@ -1,293 +0,0 @@
1
- 'use client';
2
- import { useState, useEffect, useCallback, useMemo, useRef } from 'react';
3
- import { useSurfsideContext } from '../provider';
4
- import { AsyncPipe, Err, WrapValue, Ctx, } from '@surfside/ads-core-client';
5
- /**
6
- * Requests and returns a video creative. Accepts size, duration, and MIME type arguments and returns an object wrapping
7
- * the creative, exporting both a deserialized object representing the VAST 3.0 XML markup as well as the raw XML
8
- * itself, which can be passed into video players supporting the VAST 3.0 XML specification. The return type also
9
- * contains an `analytics` object which is a set of callback functions to be called for specific video playback events,
10
- * such as completing each quartile of the video playback, recording impressions, and starting/finishing the video.
11
- *
12
- * @remarks
13
- * Video players are more complicated to implement than static banner creatives because of their inherently interactive
14
- * nature. Modern browsers will disallow videos from autoplaying unmuted, [except under specific circumstances](
15
- * https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Autoplay#autoplay_availability). For this reason, it is
16
- * recommended that you mark your `<video>` tag as `autoPlay muted`. e.g:
17
- *
18
- * ```html
19
- * <video autoPlay muted>
20
- * <!-- ... <source> tags go here -->
21
- * </video>
22
- * ```
23
- *
24
- * It is *possible* to autoplay a video unmuted under other circumstances, such as if the user has interacted with the
25
- * page already. That implementation is left up to the developer.
26
- *
27
- * Surfside's bidder will always return with a single video creative per video bid request. This means that the
28
- * `video.vast.ads` field will always have exactly one {@link IAd} object, and all VAST creative types will be a single
29
- * `linear` video creative. This means that it will always be safe to do this:
30
- *
31
- * ```ts
32
- * if (video !== undefined) {
33
- * // URL of the video and its MIME type
34
- * const { url, type } = video.ads[0].inline.creatives[0].mediaFiles[0];
35
- * }
36
- * ```
37
- *
38
- * Since this is somewhat verbose, these values are available to you through the `video.url` and `video.mime` fields
39
- * within the {@link IVideo} object.
40
- *
41
- * @example
42
- * A very simple video player for a video response might look like this
43
- *
44
- * ```tsx
45
- * const { video, loading, error, analytics } = useSurfsideVideo({
46
- * zoneId: 'my-zone',
47
- * size: [4, 3], // 4x3 video ad
48
- * maxDuration: 30 // 30 seconds max
49
- * });
50
- *
51
- * // Call impression and win handlers if they exist
52
- * useEffect(() => {
53
- * analytics?.impression();
54
- * analytics?.win();
55
- * }, [analytics]);
56
- *
57
- * if (loading) {
58
- * return <div>loading...</div>;
59
- * }
60
- *
61
- * if (error) {
62
- * throw error.error; // error.error is the Javascript Error type and can be safely thrown
63
- * }
64
- *
65
- * return (
66
- * <video autoplay muted>
67
- * <source src={video.url} type={video.mime} />
68
- * </video>
69
- * );
70
- * ```
71
- *
72
- * Note that this implementation ONLY implements the `win` and `impression` events. In order to implement playback-based
73
- * events, you must write handlers for the [`play`, `ended`, and `timeupdate` events](
74
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/video#events). For quartile playback events, you
75
- * will need to check the current time of the video during the `timeupdate` events to determine if the proper quartile
76
- * has been passed (e.g, `firstQuartile` must be fired **a single time, only after the video has surpassed 25% of its
77
- * duration**).
78
- *
79
- * @param {IUseSurfsideVideoOptions} props
80
- *
81
- * @expandType IUseSurfsideVideoOptions
82
- * @expandType UseSurfsideVideoReturn
83
- */
84
- export const useSurfsideVideo = ({ zoneId, size, minDuration = 0, maxDuration, mimes = ['video/mp4'], enabled = true, category }) => {
85
- const resolvedMimes = useMemo(() => mimes, [mimes.join(',')]);
86
- const stableCategory = useMemo(() => category, [category?.join(',') ?? '']);
87
- const respProps = useMemo(() => ({
88
- video: undefined,
89
- zoneId,
90
- size,
91
- minDuration,
92
- maxDuration,
93
- mimes: resolvedMimes,
94
- enabled,
95
- category: stableCategory
96
- }), [zoneId, size?.[0], size?.[1], minDuration, maxDuration, resolvedMimes, enabled, stableCategory]);
97
- const internalState = useSurfsideVideoResponse(respProps);
98
- useEffect(() => {
99
- internalState.refetch?.();
100
- }, [internalState.refetch]);
101
- return internalState;
102
- };
103
- export const useSurfsideVideoResponse = (props) => {
104
- const { startRequest, requestBids, buildVideoResponse, logger, error: apiError, hasError: apiHasError, isReady: apiIsReady } = useSurfsideContext();
105
- const [internalVideo, setInternalVideo] = useState(props?.video);
106
- const [video, setVideo] = useState();
107
- const [loading, setLoading] = useState(true);
108
- const [videoError, setVideoError] = useState();
109
- const trackingEvents = useRef();
110
- useEffect(() => {
111
- if (internalVideo?.ok === true) {
112
- const value = internalVideo.value;
113
- const ad = value.video.ads[0];
114
- const creative = ad?.inline.creatives[0];
115
- const mediaFile = creative?.mediaFiles[0];
116
- const adm = internalVideo.value.bid.adm;
117
- if (ad !== undefined && creative !== undefined && mediaFile !== undefined && adm !== undefined) {
118
- setSuccessState({
119
- ...internalVideo.value,
120
- id: internalVideo.value.bid.id,
121
- title: ad.inline.adTitle,
122
- duration: creative.duration,
123
- mime: mediaFile.type,
124
- adm: adm,
125
- videoUrl: mediaFile.url,
126
- }, creative.trackingEvents);
127
- }
128
- }
129
- else if (internalVideo?.ok === false) {
130
- setErrorState(internalVideo);
131
- }
132
- }, [internalVideo]);
133
- useEffect(() => {
134
- if (props?.video === undefined) {
135
- // setLoadingState();
136
- // } else if (internalVideo?.ok === false) {
137
- // setErrorState(internalVideo);
138
- }
139
- else {
140
- setInternalVideo(props?.video);
141
- }
142
- }, [props?.video]);
143
- const setErrorState = (err) => {
144
- setVideoError(err);
145
- setVideo(undefined);
146
- setLoading(false);
147
- trackingEvents.current = undefined;
148
- };
149
- const setLoadingState = () => {
150
- setVideoError(undefined);
151
- setVideo(undefined);
152
- setLoading(true);
153
- trackingEvents.current = undefined;
154
- };
155
- const setSuccessState = (video, track) => {
156
- setVideoError(undefined);
157
- setVideo(video);
158
- setLoading(false);
159
- trackingEvents.current = track;
160
- };
161
- const refetch = useCallback(async () => {
162
- if (props === undefined || !apiIsReady || props.enabled === false) {
163
- if (apiHasError) {
164
- setErrorState(apiError);
165
- }
166
- return;
167
- }
168
- setLoadingState();
169
- const request = startRequest(props.zoneId)
170
- .withSurfCategory(props?.category ?? [])
171
- .withVideo(props.size[0], props.size[1], props.minDuration, props.maxDuration, props.mimes)
172
- .build();
173
- const videoResult = await AsyncPipe(requestBids(request))
174
- .then(bidResponse => WrapValue(bidResponse.seatbid?.[0]?.bid?.[0]))
175
- .then(buildVideoResponse)
176
- .result();
177
- setInternalVideo(videoResult);
178
- }, [
179
- apiIsReady,
180
- apiError,
181
- startRequest,
182
- buildVideoResponse,
183
- props?.enabled,
184
- props?.zoneId,
185
- props?.size[0],
186
- props?.size[1],
187
- props?.minDuration,
188
- props?.maxDuration,
189
- props?.mimes,
190
- props?.category
191
- ]);
192
- const analytics = useMemo(() => {
193
- if (video === undefined) {
194
- return undefined;
195
- }
196
- return {
197
- ...trackVideoEvents(trackingEvents.current, logger),
198
- ...trackVideoWin
199
- };
200
- }, [video?.id]);
201
- if (!loading && videoError === undefined && video !== undefined) {
202
- return {
203
- video,
204
- error: videoError,
205
- loading,
206
- isReady: true,
207
- analytics,
208
- refetch
209
- };
210
- }
211
- else if (!loading && videoError !== undefined && video === undefined) {
212
- return {
213
- video,
214
- error: videoError,
215
- loading: loading,
216
- isReady: false,
217
- analytics: undefined,
218
- refetch
219
- };
220
- }
221
- else if (loading && videoError === undefined && video === undefined) {
222
- return {
223
- video,
224
- error: videoError,
225
- loading,
226
- isReady: false,
227
- analytics: undefined,
228
- refetch
229
- };
230
- }
231
- else {
232
- return {
233
- video: undefined,
234
- error: Err(new InvalidVideoStateError(video, videoError, loading)),
235
- loading: false,
236
- isReady: false,
237
- analytics: undefined,
238
- refetch: refetch
239
- };
240
- }
241
- };
242
- export class InvalidVideoStateError extends Error {
243
- video;
244
- error;
245
- loading;
246
- constructor(video, error, loading) {
247
- super('useSurfsideBanner resulted in an invalid state');
248
- this.video = video;
249
- this.error = error;
250
- this.loading = loading;
251
- }
252
- }
253
- ;
254
- const trackVideoWin = (video, logger) => () => {
255
- if (video === undefined) {
256
- return;
257
- }
258
- const log = Ctx(logger)?.with('trackWin');
259
- if (video.bid.nurl !== undefined) {
260
- const url = new URL(video.bid.nurl);
261
- url.searchParams.delete('url');
262
- fetch(url.toString()).then(() => log?.debug('Won auction', video));
263
- }
264
- else {
265
- log?.error('Missing nurl on video bid response! This should never happen', video);
266
- }
267
- };
268
- const trackVideoEvents = (trackingEvents, logger) => {
269
- if (trackingEvents === undefined) {
270
- return;
271
- }
272
- const log = Ctx(logger)?.with('trackVideoEvents');
273
- // Helper to safely return a tracking function or no-op
274
- const getTracker = (eventName) => {
275
- const event = trackingEvents.find((e) => e.event === eventName);
276
- if (event?.url === undefined) {
277
- return () => log?.debug(`No tracker for event: ${eventName}`);
278
- }
279
- return () => {
280
- fetch(event.url).then(() => log?.debug(`Tracked event: ${eventName}`));
281
- };
282
- };
283
- return {
284
- start: getTracker('start'),
285
- firstQuartile: getTracker('firstQuartile'),
286
- midpoint: getTracker('midpoint'),
287
- thirdQuartile: getTracker('thirdQuartile'),
288
- complete: getTracker('complete'),
289
- impression: getTracker('impression'),
290
- win: getTracker('win'),
291
- };
292
- };
293
- //# sourceMappingURL=useSurfsideVideo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSurfsideVideo.js","sourceRoot":"src/","sources":["hooks/useSurfsideVideo.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAE,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gBAAgB,GAAG,CACrB,cAA4C,EAC5C,MAA2B,EACQ,EAAE;IACrC,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO;IACX,CAAC;IAED,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAElD,uDAAuD;IACvD,MAAM,UAAU,GAAG,CAAC,SAAiB,EAA8B,EAAE;QACjE,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;QAChE,IAAI,KAAK,EAAE,GAAG,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,yBAAyB,SAAS,EAAE,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,GAAG,EAAE;YACR,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,kBAAkB,SAAS,EAAE,CAAC,CAAC,CAAC;QAC3E,CAAC,CAAC;IACN,CAAC,CAAC;IAEF,OAAO;QACH,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC;QAC1B,aAAa,EAAE,UAAU,CAAC,eAAe,CAAC;QAC1C,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC;QAChC,aAAa,EAAE,UAAU,CAAC,eAAe,CAAC;QAC1C,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC;QAChC,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC;QACpC,GAAG,EAAE,UAAU,CAAC,KAAK,CAAC;KACzB,CAAC;AACN,CAAC,CAAC"}
package/lib/esm/index.js DELETED
@@ -1,20 +0,0 @@
1
- // Provider
2
- export { useSurfsideContext, SurfsideProvider, InvalidStateError, NotInProviderError, } from './provider';
3
- // Analytics
4
- export { trackProductClick, trackBannerClick, trackProductImpressions, trackBannerImpression, trackVideoImpression, trackVideoEvent, trackZoneEvent, } from './utils';
5
- // Components
6
- export { SurfsideBanner } from './components';
7
- export { SurfsideBannerRenderer, } from './components';
8
- export { SurfsideCarousel, } from './components';
9
- export { SurfsideDynamicZone, DynamicZoneUnmountedError, } from './components';
10
- export { SurfsideProductCard, NoProductsReturnedError, ProductCardUnmountedError, } from './components';
11
- export { SurfsideVideo } from './components';
12
- export { SurfsideVideoRenderer, } from './components';
13
- export { SurfsideBannerVideoRenderer, } from './components';
14
- // Hooks
15
- export { useSurfsideBanner, useSurfsideBannerResponse, InvalidBannerStateError, } from './hooks';
16
- export { useSurfsideDynamicZone, InvalidDynamicZoneState, } from './hooks';
17
- export { useSurfsideProducts, useSurfsideProductsResponse, InvalidStrategyError, InvalidProductsStateError, } from './hooks';
18
- export { useSurfsideVideo, useSurfsideVideoResponse, InvalidVideoStateError, } from './hooks';
19
- export * from './BuildInfo';
20
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,OAAO,EAQH,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,GACrB,MAAO,YAAY,CAAC;AAErB,YAAY;AACZ,OAAO,EAGH,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,cAAc,GACjB,MAAM,SAAS,CAAC;AAEjB,aAAa;AACb,OAAO,EAEH,cAAc,EACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAEH,sBAAsB,GACzB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAMH,gBAAgB,GACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAEH,mBAAmB,EACnB,yBAAyB,GAC5B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAKH,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,GAC5B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAEH,aAAa,EAChB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAEH,qBAAqB,GACxB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAGH,2BAA2B,GAC9B,MAAM,cAAc,CAAC;AAEtB,QAAQ;AACR,OAAO,EASH,iBAAiB,EAEjB,yBAAyB,EACzB,uBAAuB,GAC1B,MAAM,SAAS,CAAC;AAEjB,OAAO,EAmBH,sBAAsB,EACtB,uBAAuB,GAC1B,MAAM,SAAS,CAAC;AAEjB,OAAO,EAmBH,mBAAmB,EACnB,2BAA2B,EAC3B,oBAAoB,EACpB,yBAAyB,GAC5B,MAAM,SAAS,CAAC;AAEjB,OAAO,EAUH,gBAAgB,EAEhB,wBAAwB,EACxB,sBAAsB,GACzB,MAAM,SAAS,CAAC;AAEjB,cAAc,aAAa,CAAC"}
@@ -1,152 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { createContext, useContext, useState, useEffect, useMemo, } from 'react';
4
- import { InitLogger, Ctx, TryDo, Err, GetValueOrThrow, } from '@surfside/ads-core';
5
- import { InitSurfAdsWeb, InitSurfAdsWebInternal } from '@surfside/ads-core-web';
6
- import { InitSurfAdsCoreMock } from '@surfside/ads-core-mock';
7
- ;
8
- ;
9
- ;
10
- const SurfsideContext = createContext(undefined);
11
- /**
12
- * Returns the Surfside Context state, or throws an error if the context failed to return at all (i.e, you are calling
13
- * useSurfsideContext outside of SurfsideProvider node)
14
- *
15
- * @throws {Error} If the context failed to initialize.
16
- */
17
- export const useSurfsideContext = () => {
18
- const context = useContext(SurfsideContext);
19
- if (context === undefined) {
20
- return {
21
- error: Err(new NotInProviderError),
22
- status: 'error',
23
- isReady: false,
24
- setLocationId: () => void 0,
25
- setUserId: () => void 0,
26
- isInitializing: false,
27
- hasError: true
28
- };
29
- }
30
- return context;
31
- };
32
- const searchHasString = (str) => typeof window !== 'undefined' &&
33
- window.location.search.toLowerCase().includes(str);
34
- /**
35
- * The provider for the Surfside ads context.
36
- *
37
- * @see {@link ISurfsideProviderProps}
38
- */
39
- export const SurfsideProvider = ({ accountId, channelId, siteId, locationId: cfgLocationId, userId: cfgUserId, config, onError, children, logger: userLogger }) => {
40
- const [api, setApi] = useState();
41
- const [isInitializing, setIsInitializing] = useState(true);
42
- const [error, setError] = useState();
43
- const [locationId, setLocationId] = useState(cfgLocationId);
44
- const [userId, setUserId] = useState(cfgUserId);
45
- const debug = config?.debug ?? searchHasString('surf_debug=true');
46
- const mock = config?.mock ?? searchHasString('surf_mock=true');
47
- const { mockRecommendedProducts, mockSponsoredProducts } = config?.customMockData ?? {};
48
- const logger = useMemo(() => Ctx(userLogger ?? (debug ? InitLogger() : undefined)), [userLogger]);
49
- const log = Ctx(logger)?.with('SurfsideProvider');
50
- log?.info('Initializing Surfside provider');
51
- useEffect(() => {
52
- let cancel = false;
53
- log?.info('Checking initialization state');
54
- if (locationId === undefined) {
55
- setLoadingState();
56
- return;
57
- }
58
- const initializerPromise = !mock
59
- ? InitSurfAdsWeb(accountId, siteId, channelId, locationId, userId, logger)
60
- : InitSurfAdsWebInternal(InitSurfAdsCoreMock(accountId, channelId, siteId, locationId, userId, InitLogger(), mockSponsoredProducts, mockRecommendedProducts, config?.simulateNoResponse, config?.simulateTimeout));
61
- initializerPromise.then(web => {
62
- if (cancel) {
63
- return;
64
- }
65
- if (!web.ok) {
66
- setErrorState(web);
67
- return;
68
- }
69
- setSuccessState(web.value);
70
- });
71
- return () => {
72
- cancel = true;
73
- };
74
- }, [locationId, accountId, siteId, channelId, userId, logger]);
75
- const setLoadingState = () => {
76
- setIsInitializing(true);
77
- setError(undefined);
78
- setApi(undefined);
79
- };
80
- const setErrorState = (err) => {
81
- setIsInitializing(false);
82
- setError(err);
83
- setApi(undefined);
84
- };
85
- const setSuccessState = (api) => {
86
- setIsInitializing(false);
87
- setError(undefined);
88
- setApi(api);
89
- };
90
- const contextValue = GetValueOrThrow(TryDo(() => {
91
- if (isInitializing) { // Loading state
92
- return {
93
- isInitializing: true,
94
- status: 'initializing',
95
- isReady: false,
96
- error: undefined,
97
- hasError: false,
98
- setLocationId,
99
- setUserId
100
- };
101
- }
102
- else if (error !== undefined) { // error state
103
- return {
104
- isInitializing: false,
105
- status: 'error',
106
- error,
107
- setLocationId,
108
- setUserId,
109
- isReady: false,
110
- hasError: true
111
- };
112
- }
113
- else if (api !== undefined) { // success state
114
- return {
115
- ...api,
116
- isReady: true,
117
- status: 'ready',
118
- setLocationId,
119
- setUserId,
120
- hasError: false,
121
- isInitializing: false
122
- };
123
- }
124
- else { // error - indeterminate state. Set error state
125
- return {
126
- error: Err(new InvalidStateError),
127
- isReady: false,
128
- isInitializing: false,
129
- status: 'error',
130
- setLocationId,
131
- setUserId,
132
- hasError: true
133
- };
134
- }
135
- }));
136
- if (contextValue.status === 'error') {
137
- onError?.(contextValue.error);
138
- }
139
- return (_jsx(SurfsideContext.Provider, { value: contextValue, children: children }));
140
- };
141
- export class InvalidStateError extends Error {
142
- constructor() {
143
- super('Surfside context provider was left in an invalid state. Contact the vendor');
144
- }
145
- }
146
- export class NotInProviderError extends Error {
147
- constructor() {
148
- super('useSurfsideContext must be used within a SurfsideProvider block. Did you forget to add the provider to' +
149
- ' your App.tsx?');
150
- }
151
- }
152
- //# sourceMappingURL=SurfsideContextProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SurfsideContextProvider.js","sourceRoot":"src/","sources":["provider/SurfsideContextProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAGV,aAAa,EACb,UAAU,EACV,QAAQ,EACR,SAAS,EACT,OAAO,GACV,MAAM,OAAO,CAAC;AAEf,OAAO,EAIH,UAAU,EACV,GAAG,EACH,KAAK,EACL,GAAG,EACH,eAAe,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAwB,cAAc,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACtG,OAAO,EAAE,mBAAmB,EAA6B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B,CAAC;IACN,CAAC;CACJ"}
@@ -1,2 +0,0 @@
1
- export { useSurfsideContext, SurfsideProvider, InvalidStateError, NotInProviderError, } from './SurfsideContextProvider';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"src/","sources":["provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAQH,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,GACrB,MAAM,2BAA2B,CAAC"}
@@ -1,171 +0,0 @@
1
- /**
2
- * Track a product click event
3
- * @param product The product that was clicked
4
- * @param zoneId The zone ID where the product was displayed
5
- * @param callback Optional callback for custom tracking
6
- */
7
- export const trackProductClick = (product, zoneId, callback) => {
8
- const analytics = {
9
- timestamp: Date.now(),
10
- zoneId,
11
- productId: product.id,
12
- locationId: undefined, // Will be filled by the hook
13
- };
14
- // Log the click event
15
- console.debug('[Surfside Analytics] Product click:', {
16
- productId: product.id,
17
- zoneId,
18
- timestamp: analytics.timestamp,
19
- });
20
- // Call the callback if provided
21
- if (callback !== undefined) {
22
- callback(product, analytics);
23
- }
24
- };
25
- /**
26
- * Track a banner click event
27
- * @param banner The banner that was clicked
28
- * @param zoneId The zone ID where the banner was displayed
29
- * @param callback Optional callback for custom tracking
30
- */
31
- export const trackBannerClick = (banner, zoneId, callback) => {
32
- const analytics = {
33
- timestamp: Date.now(),
34
- zoneId,
35
- bannerId: banner.id,
36
- locationId: undefined, // Will be filled by the hook
37
- };
38
- // Log the click event
39
- console.debug('[Surfside Analytics] Banner click:', {
40
- bannerId: banner.id,
41
- zoneId,
42
- timestamp: analytics.timestamp,
43
- });
44
- // Call the callback if provided
45
- if (callback !== undefined) {
46
- callback(analytics);
47
- }
48
- };
49
- /**
50
- * Track product impressions
51
- * @param products The products that were impressed
52
- * @param zoneId The zone ID where the products were displayed
53
- * @param callback Optional callback for custom tracking
54
- */
55
- export const trackProductImpressions = (products, zoneId, callback) => {
56
- const analytics = {
57
- timestamp: Date.now(),
58
- zoneId,
59
- productIds: products.map(p => p.id).filter(p => p !== undefined),
60
- locationId: undefined, // Will be filled by the hook
61
- };
62
- // Log the impression event
63
- console.debug('[Surfside Analytics] Product impressions:', {
64
- productIds: analytics.productIds,
65
- zoneId,
66
- timestamp: analytics.timestamp,
67
- });
68
- // Call the callback if provided
69
- if (callback !== undefined) {
70
- callback(products, analytics);
71
- }
72
- };
73
- /**
74
- * Track banner impressions
75
- * @param banner The banner that was impressed
76
- * @param zoneId The zone ID where the banner was displayed
77
- * @param callback Optional callback for custom tracking
78
- */
79
- export const trackBannerImpression = (banner, zoneId, callback) => {
80
- const analytics = {
81
- timestamp: Date.now(),
82
- zoneId,
83
- bannerId: banner.id,
84
- locationId: undefined, // Will be filled by the hook
85
- };
86
- // Log the impression event
87
- console.debug('[Surfside Analytics] Banner impression:', {
88
- bannerId: banner.id,
89
- zoneId,
90
- timestamp: analytics.timestamp,
91
- });
92
- // Call the callback if provided
93
- if (callback !== undefined) {
94
- callback(analytics);
95
- }
96
- };
97
- /**
98
- * Track video impression
99
- * @param video The video that was impressed
100
- * @param zoneId The zone ID where the video was displayed
101
- * @param callback Optional callback for custom tracking
102
- */
103
- export const trackVideoImpression = (video, zoneId, callback) => {
104
- const analytics = {
105
- timestamp: Date.now(),
106
- zoneId,
107
- videoId: video.id,
108
- locationId: undefined, // Will be filled by the hook
109
- };
110
- // Log the impression event
111
- console.debug('[Surfside Analytics] Video impression:', {
112
- videoId: video.id,
113
- zoneId,
114
- timestamp: analytics.timestamp,
115
- });
116
- // Call the callback if provided
117
- if (callback !== undefined) {
118
- callback(analytics);
119
- }
120
- };
121
- /**
122
- * Track video events (play, pause, complete, etc.)
123
- * @param video The video object
124
- * @param zoneId The zone ID where the video was displayed
125
- * @param eventType The type of event (play, pause, complete, etc.)
126
- * @param position Current position in the video (seconds)
127
- * @param callback Optional callback for custom tracking
128
- */
129
- export const trackVideoEvent = (video, zoneId, eventType, position, callback) => {
130
- const analytics = {
131
- timestamp: Date.now(),
132
- zoneId,
133
- videoId: video.id,
134
- eventType,
135
- position,
136
- locationId: undefined, // Will be filled by the hook
137
- };
138
- // Log the event
139
- console.debug('[Surfside Analytics] Video event:', {
140
- videoId: video.id,
141
- eventType,
142
- zoneId,
143
- position,
144
- timestamp: analytics.timestamp,
145
- });
146
- // Call the callback if provided
147
- if (callback !== undefined) {
148
- callback(analytics);
149
- }
150
- };
151
- /**
152
- * Track zone events (ready, no content, error)
153
- * @param zoneId The zone ID
154
- * @param eventType The type of event (ready, no-content, error)
155
- * @param data Additional data for the event
156
- * @param callback Optional callback for custom tracking
157
- */
158
- export const trackZoneEvent = (zoneId, eventType, data, callback) => {
159
- // Log the zone event
160
- console.debug('[Surfside Analytics] Zone event:', {
161
- zoneId,
162
- eventType,
163
- data,
164
- timestamp: Date.now(),
165
- });
166
- // Call the callback if provided
167
- if (callback !== undefined) {
168
- callback(eventType, zoneId, data);
169
- }
170
- };
171
- //# sourceMappingURL=Analytics.js.map