@contentful/optimization-core 0.1.0-alpha11 → 0.1.0-alpha12
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 +29 -10
- package/dist/260.mjs +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/index.cjs +49 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -56
- package/dist/index.d.mts +28 -56
- package/dist/index.d.ts +28 -56
- package/dist/index.mjs +49 -62
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -354,6 +354,10 @@ declare abstract class CoreBase<TConfig extends CoreConfig = CoreConfig> {
|
|
|
354
354
|
* @param selectedOptimizations - Optional selected optimization array for the current profile.
|
|
355
355
|
* @returns {@link ResolvedData} containing the resolved entry and
|
|
356
356
|
* selected optimization metadata (if any).
|
|
357
|
+
* @remarks
|
|
358
|
+
* This helper is intended for request-local resolution. When the supplied
|
|
359
|
+
* entry comes from a shared application cache, avoid mutating the returned
|
|
360
|
+
* entry in place unless you first clone it.
|
|
357
361
|
* @example
|
|
358
362
|
* ```ts
|
|
359
363
|
* const { entry, selectedOptimization } = core.resolveOptimizedEntry(
|
|
@@ -370,6 +374,9 @@ declare abstract class CoreBase<TConfig extends CoreConfig = CoreConfig> {
|
|
|
370
374
|
* @param embeddedEntryNodeTarget - The merge-tag entry node to resolve.
|
|
371
375
|
* @param profile - Optional profile used for value lookup.
|
|
372
376
|
* @returns The resolved value (typically a string) or `undefined` if not found.
|
|
377
|
+
* @remarks
|
|
378
|
+
* Use this during request rendering with the current profile. The resolved
|
|
379
|
+
* value is profile-dependent and is not safe for shared-output caching.
|
|
373
380
|
* @example
|
|
374
381
|
* ```ts
|
|
375
382
|
* const name = core.getMergeTagValue(mergeTagNode, profile)
|
|
@@ -631,18 +638,26 @@ declare abstract class CoreBase<TConfig extends CoreConfig = CoreConfig> {
|
|
|
631
638
|
* Core runtime for stateless environments.
|
|
632
639
|
*
|
|
633
640
|
* @public
|
|
634
|
-
* Built on top of `CoreBase`.
|
|
635
|
-
*
|
|
641
|
+
* Built on top of `CoreBase`. Event-emitting methods are exposed directly on
|
|
642
|
+
* the stateless instance and accept request-scoped Experience options as a
|
|
643
|
+
* separate final argument.
|
|
644
|
+
* @remarks
|
|
645
|
+
* The runtime itself is stateless, but event methods still perform outbound
|
|
646
|
+
* Experience and Insights API calls. Cache Contentful delivery data in the
|
|
647
|
+
* host application, not the results of those calls.
|
|
636
648
|
*/
|
|
637
649
|
export declare class CoreStateless extends CoreBase<CoreStatelessConfig> {
|
|
638
650
|
constructor(config: CoreStatelessConfig);
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
651
|
+
identify(payload: StatelessExperiencePayload<IdentifyBuilderArgs>, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData>;
|
|
652
|
+
page(payload?: StatelessExperiencePayload<PageViewBuilderArgs>, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData>;
|
|
653
|
+
screen(payload: StatelessExperiencePayload<ScreenViewBuilderArgs>, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData>;
|
|
654
|
+
track(payload: StatelessExperiencePayload<TrackBuilderArgs>, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData>;
|
|
655
|
+
trackView(payload: StatelessStickyTrackViewPayload | StatelessNonStickyTrackViewPayload, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData | undefined>;
|
|
656
|
+
trackClick(payload: StatelessInsightsPayload<ClickBuilderArgs>, _requestOptions?: CoreStatelessRequestOptions): Promise<void>;
|
|
657
|
+
trackHover(payload: StatelessInsightsPayload<HoverBuilderArgs>, _requestOptions?: CoreStatelessRequestOptions): Promise<void>;
|
|
658
|
+
trackFlagView(payload: StatelessInsightsPayload<FlagViewBuilderArgs>, _requestOptions?: CoreStatelessRequestOptions): Promise<void>;
|
|
659
|
+
private sendExperienceEvent;
|
|
660
|
+
private sendInsightsEvent;
|
|
646
661
|
}
|
|
647
662
|
|
|
648
663
|
/**
|
|
@@ -682,53 +697,6 @@ declare abstract class CoreBase<TConfig extends CoreConfig = CoreConfig> {
|
|
|
682
697
|
export declare interface CoreStatelessRequestOptions extends Pick<ExperienceApiClientRequestOptions, 'ip' | 'locale' | 'plainText' | 'preflight'> {
|
|
683
698
|
}
|
|
684
699
|
|
|
685
|
-
/**
|
|
686
|
-
* Stateless request scope created by {@link CoreStateless.forRequest}.
|
|
687
|
-
*
|
|
688
|
-
* @public
|
|
689
|
-
*/
|
|
690
|
-
export declare class CoreStatelessRequestScope {
|
|
691
|
-
private readonly core;
|
|
692
|
-
private readonly options;
|
|
693
|
-
constructor(core: CoreStateless, options?: CoreStatelessRequestOptions);
|
|
694
|
-
identify(payload: StatelessExperiencePayload<IdentifyBuilderArgs>): Promise<OptimizationData>;
|
|
695
|
-
page(payload?: StatelessExperiencePayload<PageViewBuilderArgs>): Promise<OptimizationData>;
|
|
696
|
-
screen(payload: StatelessExperiencePayload<ScreenViewBuilderArgs>): Promise<OptimizationData>;
|
|
697
|
-
track(payload: StatelessExperiencePayload<TrackBuilderArgs>): Promise<OptimizationData>;
|
|
698
|
-
/**
|
|
699
|
-
* Record an entry view in a stateless runtime.
|
|
700
|
-
*
|
|
701
|
-
* @remarks
|
|
702
|
-
* Non-sticky entry views require `payload.profile.id` for Insights delivery.
|
|
703
|
-
* Sticky entry views may omit `profile`, because the returned Experience
|
|
704
|
-
* profile is reused for the paired Insights event.
|
|
705
|
-
*/
|
|
706
|
-
trackView(payload: StatelessStickyTrackViewPayload | StatelessNonStickyTrackViewPayload): Promise<OptimizationData | undefined>;
|
|
707
|
-
/**
|
|
708
|
-
* Record an entry click in a stateless runtime.
|
|
709
|
-
*
|
|
710
|
-
* @remarks
|
|
711
|
-
* Stateless Insights delivery requires `payload.profile.id`.
|
|
712
|
-
*/
|
|
713
|
-
trackClick(payload: StatelessInsightsPayload<ClickBuilderArgs>): Promise<void>;
|
|
714
|
-
/**
|
|
715
|
-
* Record an entry hover in a stateless runtime.
|
|
716
|
-
*
|
|
717
|
-
* @remarks
|
|
718
|
-
* Stateless Insights delivery requires `payload.profile.id`.
|
|
719
|
-
*/
|
|
720
|
-
trackHover(payload: StatelessInsightsPayload<HoverBuilderArgs>): Promise<void>;
|
|
721
|
-
/**
|
|
722
|
-
* Record a Custom Flag view in a stateless runtime.
|
|
723
|
-
*
|
|
724
|
-
* @remarks
|
|
725
|
-
* Stateless Insights delivery requires `payload.profile.id`.
|
|
726
|
-
*/
|
|
727
|
-
trackFlagView(payload: StatelessInsightsPayload<FlagViewBuilderArgs>): Promise<void>;
|
|
728
|
-
private sendExperienceEvent;
|
|
729
|
-
private sendInsightsEvent;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
700
|
/**
|
|
733
701
|
* Combined observable state exposed by the stateful core.
|
|
734
702
|
*
|
|
@@ -1747,6 +1715,10 @@ declare abstract class CoreBase<TConfig extends CoreConfig = CoreConfig> {
|
|
|
1747
1715
|
* @param profile - Optional profile used for lookup.
|
|
1748
1716
|
* @returns The resolved string, or `undefined` if the entry is invalid and no
|
|
1749
1717
|
* fallback is available.
|
|
1718
|
+
* @remarks
|
|
1719
|
+
* The resolved value depends on the current request profile, so callers
|
|
1720
|
+
* should not reuse rendered output across users or requests unless the
|
|
1721
|
+
* cache varies on the same profile inputs.
|
|
1750
1722
|
* @example
|
|
1751
1723
|
* ```ts
|
|
1752
1724
|
* const text = MergeTagValueResolver.resolve(entry, profile)
|
package/dist/index.d.mts
CHANGED
|
@@ -354,6 +354,10 @@ declare abstract class CoreBase<TConfig extends CoreConfig = CoreConfig> {
|
|
|
354
354
|
* @param selectedOptimizations - Optional selected optimization array for the current profile.
|
|
355
355
|
* @returns {@link ResolvedData} containing the resolved entry and
|
|
356
356
|
* selected optimization metadata (if any).
|
|
357
|
+
* @remarks
|
|
358
|
+
* This helper is intended for request-local resolution. When the supplied
|
|
359
|
+
* entry comes from a shared application cache, avoid mutating the returned
|
|
360
|
+
* entry in place unless you first clone it.
|
|
357
361
|
* @example
|
|
358
362
|
* ```ts
|
|
359
363
|
* const { entry, selectedOptimization } = core.resolveOptimizedEntry(
|
|
@@ -370,6 +374,9 @@ declare abstract class CoreBase<TConfig extends CoreConfig = CoreConfig> {
|
|
|
370
374
|
* @param embeddedEntryNodeTarget - The merge-tag entry node to resolve.
|
|
371
375
|
* @param profile - Optional profile used for value lookup.
|
|
372
376
|
* @returns The resolved value (typically a string) or `undefined` if not found.
|
|
377
|
+
* @remarks
|
|
378
|
+
* Use this during request rendering with the current profile. The resolved
|
|
379
|
+
* value is profile-dependent and is not safe for shared-output caching.
|
|
373
380
|
* @example
|
|
374
381
|
* ```ts
|
|
375
382
|
* const name = core.getMergeTagValue(mergeTagNode, profile)
|
|
@@ -631,18 +638,26 @@ declare abstract class CoreBase<TConfig extends CoreConfig = CoreConfig> {
|
|
|
631
638
|
* Core runtime for stateless environments.
|
|
632
639
|
*
|
|
633
640
|
* @public
|
|
634
|
-
* Built on top of `CoreBase`.
|
|
635
|
-
*
|
|
641
|
+
* Built on top of `CoreBase`. Event-emitting methods are exposed directly on
|
|
642
|
+
* the stateless instance and accept request-scoped Experience options as a
|
|
643
|
+
* separate final argument.
|
|
644
|
+
* @remarks
|
|
645
|
+
* The runtime itself is stateless, but event methods still perform outbound
|
|
646
|
+
* Experience and Insights API calls. Cache Contentful delivery data in the
|
|
647
|
+
* host application, not the results of those calls.
|
|
636
648
|
*/
|
|
637
649
|
export declare class CoreStateless extends CoreBase<CoreStatelessConfig> {
|
|
638
650
|
constructor(config: CoreStatelessConfig);
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
651
|
+
identify(payload: StatelessExperiencePayload<IdentifyBuilderArgs>, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData>;
|
|
652
|
+
page(payload?: StatelessExperiencePayload<PageViewBuilderArgs>, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData>;
|
|
653
|
+
screen(payload: StatelessExperiencePayload<ScreenViewBuilderArgs>, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData>;
|
|
654
|
+
track(payload: StatelessExperiencePayload<TrackBuilderArgs>, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData>;
|
|
655
|
+
trackView(payload: StatelessStickyTrackViewPayload | StatelessNonStickyTrackViewPayload, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData | undefined>;
|
|
656
|
+
trackClick(payload: StatelessInsightsPayload<ClickBuilderArgs>, _requestOptions?: CoreStatelessRequestOptions): Promise<void>;
|
|
657
|
+
trackHover(payload: StatelessInsightsPayload<HoverBuilderArgs>, _requestOptions?: CoreStatelessRequestOptions): Promise<void>;
|
|
658
|
+
trackFlagView(payload: StatelessInsightsPayload<FlagViewBuilderArgs>, _requestOptions?: CoreStatelessRequestOptions): Promise<void>;
|
|
659
|
+
private sendExperienceEvent;
|
|
660
|
+
private sendInsightsEvent;
|
|
646
661
|
}
|
|
647
662
|
|
|
648
663
|
/**
|
|
@@ -682,53 +697,6 @@ declare abstract class CoreBase<TConfig extends CoreConfig = CoreConfig> {
|
|
|
682
697
|
export declare interface CoreStatelessRequestOptions extends Pick<ExperienceApiClientRequestOptions, 'ip' | 'locale' | 'plainText' | 'preflight'> {
|
|
683
698
|
}
|
|
684
699
|
|
|
685
|
-
/**
|
|
686
|
-
* Stateless request scope created by {@link CoreStateless.forRequest}.
|
|
687
|
-
*
|
|
688
|
-
* @public
|
|
689
|
-
*/
|
|
690
|
-
export declare class CoreStatelessRequestScope {
|
|
691
|
-
private readonly core;
|
|
692
|
-
private readonly options;
|
|
693
|
-
constructor(core: CoreStateless, options?: CoreStatelessRequestOptions);
|
|
694
|
-
identify(payload: StatelessExperiencePayload<IdentifyBuilderArgs>): Promise<OptimizationData>;
|
|
695
|
-
page(payload?: StatelessExperiencePayload<PageViewBuilderArgs>): Promise<OptimizationData>;
|
|
696
|
-
screen(payload: StatelessExperiencePayload<ScreenViewBuilderArgs>): Promise<OptimizationData>;
|
|
697
|
-
track(payload: StatelessExperiencePayload<TrackBuilderArgs>): Promise<OptimizationData>;
|
|
698
|
-
/**
|
|
699
|
-
* Record an entry view in a stateless runtime.
|
|
700
|
-
*
|
|
701
|
-
* @remarks
|
|
702
|
-
* Non-sticky entry views require `payload.profile.id` for Insights delivery.
|
|
703
|
-
* Sticky entry views may omit `profile`, because the returned Experience
|
|
704
|
-
* profile is reused for the paired Insights event.
|
|
705
|
-
*/
|
|
706
|
-
trackView(payload: StatelessStickyTrackViewPayload | StatelessNonStickyTrackViewPayload): Promise<OptimizationData | undefined>;
|
|
707
|
-
/**
|
|
708
|
-
* Record an entry click in a stateless runtime.
|
|
709
|
-
*
|
|
710
|
-
* @remarks
|
|
711
|
-
* Stateless Insights delivery requires `payload.profile.id`.
|
|
712
|
-
*/
|
|
713
|
-
trackClick(payload: StatelessInsightsPayload<ClickBuilderArgs>): Promise<void>;
|
|
714
|
-
/**
|
|
715
|
-
* Record an entry hover in a stateless runtime.
|
|
716
|
-
*
|
|
717
|
-
* @remarks
|
|
718
|
-
* Stateless Insights delivery requires `payload.profile.id`.
|
|
719
|
-
*/
|
|
720
|
-
trackHover(payload: StatelessInsightsPayload<HoverBuilderArgs>): Promise<void>;
|
|
721
|
-
/**
|
|
722
|
-
* Record a Custom Flag view in a stateless runtime.
|
|
723
|
-
*
|
|
724
|
-
* @remarks
|
|
725
|
-
* Stateless Insights delivery requires `payload.profile.id`.
|
|
726
|
-
*/
|
|
727
|
-
trackFlagView(payload: StatelessInsightsPayload<FlagViewBuilderArgs>): Promise<void>;
|
|
728
|
-
private sendExperienceEvent;
|
|
729
|
-
private sendInsightsEvent;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
700
|
/**
|
|
733
701
|
* Combined observable state exposed by the stateful core.
|
|
734
702
|
*
|
|
@@ -1747,6 +1715,10 @@ declare abstract class CoreBase<TConfig extends CoreConfig = CoreConfig> {
|
|
|
1747
1715
|
* @param profile - Optional profile used for lookup.
|
|
1748
1716
|
* @returns The resolved string, or `undefined` if the entry is invalid and no
|
|
1749
1717
|
* fallback is available.
|
|
1718
|
+
* @remarks
|
|
1719
|
+
* The resolved value depends on the current request profile, so callers
|
|
1720
|
+
* should not reuse rendered output across users or requests unless the
|
|
1721
|
+
* cache varies on the same profile inputs.
|
|
1750
1722
|
* @example
|
|
1751
1723
|
* ```ts
|
|
1752
1724
|
* const text = MergeTagValueResolver.resolve(entry, profile)
|
package/dist/index.d.ts
CHANGED
|
@@ -354,6 +354,10 @@ declare abstract class CoreBase<TConfig extends CoreConfig = CoreConfig> {
|
|
|
354
354
|
* @param selectedOptimizations - Optional selected optimization array for the current profile.
|
|
355
355
|
* @returns {@link ResolvedData} containing the resolved entry and
|
|
356
356
|
* selected optimization metadata (if any).
|
|
357
|
+
* @remarks
|
|
358
|
+
* This helper is intended for request-local resolution. When the supplied
|
|
359
|
+
* entry comes from a shared application cache, avoid mutating the returned
|
|
360
|
+
* entry in place unless you first clone it.
|
|
357
361
|
* @example
|
|
358
362
|
* ```ts
|
|
359
363
|
* const { entry, selectedOptimization } = core.resolveOptimizedEntry(
|
|
@@ -370,6 +374,9 @@ declare abstract class CoreBase<TConfig extends CoreConfig = CoreConfig> {
|
|
|
370
374
|
* @param embeddedEntryNodeTarget - The merge-tag entry node to resolve.
|
|
371
375
|
* @param profile - Optional profile used for value lookup.
|
|
372
376
|
* @returns The resolved value (typically a string) or `undefined` if not found.
|
|
377
|
+
* @remarks
|
|
378
|
+
* Use this during request rendering with the current profile. The resolved
|
|
379
|
+
* value is profile-dependent and is not safe for shared-output caching.
|
|
373
380
|
* @example
|
|
374
381
|
* ```ts
|
|
375
382
|
* const name = core.getMergeTagValue(mergeTagNode, profile)
|
|
@@ -631,18 +638,26 @@ declare abstract class CoreBase<TConfig extends CoreConfig = CoreConfig> {
|
|
|
631
638
|
* Core runtime for stateless environments.
|
|
632
639
|
*
|
|
633
640
|
* @public
|
|
634
|
-
* Built on top of `CoreBase`.
|
|
635
|
-
*
|
|
641
|
+
* Built on top of `CoreBase`. Event-emitting methods are exposed directly on
|
|
642
|
+
* the stateless instance and accept request-scoped Experience options as a
|
|
643
|
+
* separate final argument.
|
|
644
|
+
* @remarks
|
|
645
|
+
* The runtime itself is stateless, but event methods still perform outbound
|
|
646
|
+
* Experience and Insights API calls. Cache Contentful delivery data in the
|
|
647
|
+
* host application, not the results of those calls.
|
|
636
648
|
*/
|
|
637
649
|
export declare class CoreStateless extends CoreBase<CoreStatelessConfig> {
|
|
638
650
|
constructor(config: CoreStatelessConfig);
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
651
|
+
identify(payload: StatelessExperiencePayload<IdentifyBuilderArgs>, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData>;
|
|
652
|
+
page(payload?: StatelessExperiencePayload<PageViewBuilderArgs>, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData>;
|
|
653
|
+
screen(payload: StatelessExperiencePayload<ScreenViewBuilderArgs>, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData>;
|
|
654
|
+
track(payload: StatelessExperiencePayload<TrackBuilderArgs>, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData>;
|
|
655
|
+
trackView(payload: StatelessStickyTrackViewPayload | StatelessNonStickyTrackViewPayload, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData | undefined>;
|
|
656
|
+
trackClick(payload: StatelessInsightsPayload<ClickBuilderArgs>, _requestOptions?: CoreStatelessRequestOptions): Promise<void>;
|
|
657
|
+
trackHover(payload: StatelessInsightsPayload<HoverBuilderArgs>, _requestOptions?: CoreStatelessRequestOptions): Promise<void>;
|
|
658
|
+
trackFlagView(payload: StatelessInsightsPayload<FlagViewBuilderArgs>, _requestOptions?: CoreStatelessRequestOptions): Promise<void>;
|
|
659
|
+
private sendExperienceEvent;
|
|
660
|
+
private sendInsightsEvent;
|
|
646
661
|
}
|
|
647
662
|
|
|
648
663
|
/**
|
|
@@ -682,53 +697,6 @@ declare abstract class CoreBase<TConfig extends CoreConfig = CoreConfig> {
|
|
|
682
697
|
export declare interface CoreStatelessRequestOptions extends Pick<ExperienceApiClientRequestOptions, 'ip' | 'locale' | 'plainText' | 'preflight'> {
|
|
683
698
|
}
|
|
684
699
|
|
|
685
|
-
/**
|
|
686
|
-
* Stateless request scope created by {@link CoreStateless.forRequest}.
|
|
687
|
-
*
|
|
688
|
-
* @public
|
|
689
|
-
*/
|
|
690
|
-
export declare class CoreStatelessRequestScope {
|
|
691
|
-
private readonly core;
|
|
692
|
-
private readonly options;
|
|
693
|
-
constructor(core: CoreStateless, options?: CoreStatelessRequestOptions);
|
|
694
|
-
identify(payload: StatelessExperiencePayload<IdentifyBuilderArgs>): Promise<OptimizationData>;
|
|
695
|
-
page(payload?: StatelessExperiencePayload<PageViewBuilderArgs>): Promise<OptimizationData>;
|
|
696
|
-
screen(payload: StatelessExperiencePayload<ScreenViewBuilderArgs>): Promise<OptimizationData>;
|
|
697
|
-
track(payload: StatelessExperiencePayload<TrackBuilderArgs>): Promise<OptimizationData>;
|
|
698
|
-
/**
|
|
699
|
-
* Record an entry view in a stateless runtime.
|
|
700
|
-
*
|
|
701
|
-
* @remarks
|
|
702
|
-
* Non-sticky entry views require `payload.profile.id` for Insights delivery.
|
|
703
|
-
* Sticky entry views may omit `profile`, because the returned Experience
|
|
704
|
-
* profile is reused for the paired Insights event.
|
|
705
|
-
*/
|
|
706
|
-
trackView(payload: StatelessStickyTrackViewPayload | StatelessNonStickyTrackViewPayload): Promise<OptimizationData | undefined>;
|
|
707
|
-
/**
|
|
708
|
-
* Record an entry click in a stateless runtime.
|
|
709
|
-
*
|
|
710
|
-
* @remarks
|
|
711
|
-
* Stateless Insights delivery requires `payload.profile.id`.
|
|
712
|
-
*/
|
|
713
|
-
trackClick(payload: StatelessInsightsPayload<ClickBuilderArgs>): Promise<void>;
|
|
714
|
-
/**
|
|
715
|
-
* Record an entry hover in a stateless runtime.
|
|
716
|
-
*
|
|
717
|
-
* @remarks
|
|
718
|
-
* Stateless Insights delivery requires `payload.profile.id`.
|
|
719
|
-
*/
|
|
720
|
-
trackHover(payload: StatelessInsightsPayload<HoverBuilderArgs>): Promise<void>;
|
|
721
|
-
/**
|
|
722
|
-
* Record a Custom Flag view in a stateless runtime.
|
|
723
|
-
*
|
|
724
|
-
* @remarks
|
|
725
|
-
* Stateless Insights delivery requires `payload.profile.id`.
|
|
726
|
-
*/
|
|
727
|
-
trackFlagView(payload: StatelessInsightsPayload<FlagViewBuilderArgs>): Promise<void>;
|
|
728
|
-
private sendExperienceEvent;
|
|
729
|
-
private sendInsightsEvent;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
700
|
/**
|
|
733
701
|
* Combined observable state exposed by the stateful core.
|
|
734
702
|
*
|
|
@@ -1747,6 +1715,10 @@ declare abstract class CoreBase<TConfig extends CoreConfig = CoreConfig> {
|
|
|
1747
1715
|
* @param profile - Optional profile used for lookup.
|
|
1748
1716
|
* @returns The resolved string, or `undefined` if the entry is invalid and no
|
|
1749
1717
|
* fallback is available.
|
|
1718
|
+
* @remarks
|
|
1719
|
+
* The resolved value depends on the current request profile, so callers
|
|
1720
|
+
* should not reuse rendered output across users or requests unless the
|
|
1721
|
+
* cache varies on the same profile inputs.
|
|
1750
1722
|
* @example
|
|
1751
1723
|
* ```ts
|
|
1752
1724
|
* const text = MergeTagValueResolver.resolve(entry, profile)
|
package/dist/index.mjs
CHANGED
|
@@ -1229,76 +1229,89 @@ class CoreStateful extends src_CoreStatefulEventEmitter {
|
|
|
1229
1229
|
}
|
|
1230
1230
|
}
|
|
1231
1231
|
const src_CoreStateful = CoreStateful;
|
|
1232
|
-
const TRACK_CLICK_PROFILE_ERROR = 'CoreStateless.
|
|
1233
|
-
const TRACK_HOVER_PROFILE_ERROR = 'CoreStateless.
|
|
1234
|
-
const TRACK_FLAG_VIEW_PROFILE_ERROR = 'CoreStateless.
|
|
1235
|
-
const NON_STICKY_TRACK_VIEW_PROFILE_ERROR = 'CoreStateless.
|
|
1236
|
-
const STICKY_TRACK_VIEW_PROFILE_ERROR = 'CoreStateless.
|
|
1232
|
+
const TRACK_CLICK_PROFILE_ERROR = 'CoreStateless.trackClick() requires `payload.profile.id` for Insights delivery.';
|
|
1233
|
+
const TRACK_HOVER_PROFILE_ERROR = 'CoreStateless.trackHover() requires `payload.profile.id` for Insights delivery.';
|
|
1234
|
+
const TRACK_FLAG_VIEW_PROFILE_ERROR = 'CoreStateless.trackFlagView() requires `payload.profile.id` for Insights delivery.';
|
|
1235
|
+
const NON_STICKY_TRACK_VIEW_PROFILE_ERROR = 'CoreStateless.trackView() requires `payload.profile.id` when `payload.sticky` is not `true`.';
|
|
1236
|
+
const STICKY_TRACK_VIEW_PROFILE_ERROR = 'CoreStateless.trackView() could not derive a profile from the sticky Experience response. Pass `payload.profile.id` explicitly if you need a fallback.';
|
|
1237
|
+
const CoreStateless_hasDefinedValues = (record)=>Object.values(record).some((value)=>void 0 !== value);
|
|
1237
1238
|
const requireInsightsProfile = (profile, errorMessage)=>{
|
|
1238
1239
|
if (void 0 !== profile) return profile;
|
|
1239
1240
|
throw new Error(errorMessage);
|
|
1240
1241
|
};
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1242
|
+
const createStatelessExperienceApiConfig = (api)=>{
|
|
1243
|
+
if (void 0 === api) return;
|
|
1244
|
+
const experienceConfig = {
|
|
1245
|
+
baseUrl: api.experienceBaseUrl,
|
|
1246
|
+
enabledFeatures: api.enabledFeatures
|
|
1247
|
+
};
|
|
1248
|
+
return CoreStateless_hasDefinedValues(experienceConfig) ? experienceConfig : void 0;
|
|
1249
|
+
};
|
|
1250
|
+
const createStatelessInsightsApiConfig = (api)=>{
|
|
1251
|
+
if (api?.insightsBaseUrl === void 0) return;
|
|
1252
|
+
return {
|
|
1253
|
+
baseUrl: api.insightsBaseUrl
|
|
1254
|
+
};
|
|
1255
|
+
};
|
|
1256
|
+
class CoreStateless extends src_CoreBase {
|
|
1257
|
+
constructor(config){
|
|
1258
|
+
super(config, {
|
|
1259
|
+
experience: createStatelessExperienceApiConfig(config.api),
|
|
1260
|
+
insights: createStatelessInsightsApiConfig(config.api)
|
|
1248
1261
|
});
|
|
1249
1262
|
}
|
|
1250
|
-
async identify(payload) {
|
|
1263
|
+
async identify(payload, requestOptions) {
|
|
1251
1264
|
const { profile, ...builderArgs } = payload;
|
|
1252
|
-
return await this.sendExperienceEvent(this.
|
|
1265
|
+
return await this.sendExperienceEvent(this.eventBuilder.buildIdentify(builderArgs), profile, requestOptions);
|
|
1253
1266
|
}
|
|
1254
|
-
async page(payload = {}) {
|
|
1267
|
+
async page(payload = {}, requestOptions) {
|
|
1255
1268
|
const { profile, ...builderArgs } = payload;
|
|
1256
|
-
return await this.sendExperienceEvent(this.
|
|
1269
|
+
return await this.sendExperienceEvent(this.eventBuilder.buildPageView(builderArgs), profile, requestOptions);
|
|
1257
1270
|
}
|
|
1258
|
-
async screen(payload) {
|
|
1271
|
+
async screen(payload, requestOptions) {
|
|
1259
1272
|
const { profile, ...builderArgs } = payload;
|
|
1260
|
-
return await this.sendExperienceEvent(this.
|
|
1273
|
+
return await this.sendExperienceEvent(this.eventBuilder.buildScreenView(builderArgs), profile, requestOptions);
|
|
1261
1274
|
}
|
|
1262
|
-
async track(payload) {
|
|
1275
|
+
async track(payload, requestOptions) {
|
|
1263
1276
|
const { profile, ...builderArgs } = payload;
|
|
1264
|
-
return await this.sendExperienceEvent(this.
|
|
1277
|
+
return await this.sendExperienceEvent(this.eventBuilder.buildTrack(builderArgs), profile, requestOptions);
|
|
1265
1278
|
}
|
|
1266
|
-
async trackView(payload) {
|
|
1279
|
+
async trackView(payload, requestOptions) {
|
|
1267
1280
|
const { profile, ...builderArgs } = payload;
|
|
1268
1281
|
let result;
|
|
1269
1282
|
let insightsProfile = profile;
|
|
1270
1283
|
if (payload.sticky) {
|
|
1271
|
-
result = await this.sendExperienceEvent(this.
|
|
1284
|
+
result = await this.sendExperienceEvent(this.eventBuilder.buildView(builderArgs), profile, requestOptions);
|
|
1272
1285
|
const { profile: responseProfile } = result;
|
|
1273
1286
|
insightsProfile = responseProfile;
|
|
1274
1287
|
}
|
|
1275
|
-
await this.sendInsightsEvent(this.
|
|
1288
|
+
await this.sendInsightsEvent(this.eventBuilder.buildView(builderArgs), requireInsightsProfile(insightsProfile, payload.sticky ? STICKY_TRACK_VIEW_PROFILE_ERROR : NON_STICKY_TRACK_VIEW_PROFILE_ERROR));
|
|
1276
1289
|
return result;
|
|
1277
1290
|
}
|
|
1278
|
-
async trackClick(payload) {
|
|
1291
|
+
async trackClick(payload, _requestOptions) {
|
|
1279
1292
|
const { profile, ...builderArgs } = payload;
|
|
1280
|
-
await this.sendInsightsEvent(this.
|
|
1293
|
+
await this.sendInsightsEvent(this.eventBuilder.buildClick(builderArgs), requireInsightsProfile(profile, TRACK_CLICK_PROFILE_ERROR));
|
|
1281
1294
|
}
|
|
1282
|
-
async trackHover(payload) {
|
|
1295
|
+
async trackHover(payload, _requestOptions) {
|
|
1283
1296
|
const { profile, ...builderArgs } = payload;
|
|
1284
|
-
await this.sendInsightsEvent(this.
|
|
1297
|
+
await this.sendInsightsEvent(this.eventBuilder.buildHover(builderArgs), requireInsightsProfile(profile, TRACK_HOVER_PROFILE_ERROR));
|
|
1285
1298
|
}
|
|
1286
|
-
async trackFlagView(payload) {
|
|
1299
|
+
async trackFlagView(payload, _requestOptions) {
|
|
1287
1300
|
const { profile, ...builderArgs } = payload;
|
|
1288
|
-
await this.sendInsightsEvent(this.
|
|
1301
|
+
await this.sendInsightsEvent(this.eventBuilder.buildFlagView(builderArgs), requireInsightsProfile(profile, TRACK_FLAG_VIEW_PROFILE_ERROR));
|
|
1289
1302
|
}
|
|
1290
|
-
async sendExperienceEvent(event, profile) {
|
|
1291
|
-
const intercepted = await this.
|
|
1303
|
+
async sendExperienceEvent(event, profile, requestOptions) {
|
|
1304
|
+
const intercepted = await this.interceptors.event.run(event);
|
|
1292
1305
|
const validEvent = (0, __rspack_external__contentful_optimization_api_client_api_schemas_4192893e.parseWithFriendlyError)(__rspack_external__contentful_optimization_api_client_api_schemas_4192893e.ExperienceEvent, intercepted);
|
|
1293
|
-
return await this.
|
|
1306
|
+
return await this.api.experience.upsertProfile({
|
|
1294
1307
|
profileId: profile?.id,
|
|
1295
1308
|
events: [
|
|
1296
1309
|
validEvent
|
|
1297
1310
|
]
|
|
1298
|
-
},
|
|
1311
|
+
}, requestOptions);
|
|
1299
1312
|
}
|
|
1300
1313
|
async sendInsightsEvent(event, profile) {
|
|
1301
|
-
const intercepted = await this.
|
|
1314
|
+
const intercepted = await this.interceptors.event.run(event);
|
|
1302
1315
|
const validEvent = (0, __rspack_external__contentful_optimization_api_client_api_schemas_4192893e.parseWithFriendlyError)(__rspack_external__contentful_optimization_api_client_api_schemas_4192893e.InsightsEvent, intercepted);
|
|
1303
1316
|
const batchEvent = (0, __rspack_external__contentful_optimization_api_client_api_schemas_4192893e.parseWithFriendlyError)(__rspack_external__contentful_optimization_api_client_api_schemas_4192893e.BatchInsightsEventArray, [
|
|
1304
1317
|
{
|
|
@@ -1308,33 +1321,7 @@ class CoreStatelessRequestScope {
|
|
|
1308
1321
|
]
|
|
1309
1322
|
}
|
|
1310
1323
|
]);
|
|
1311
|
-
await this.
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
const CoreStateless_hasDefinedValues = (record)=>Object.values(record).some((value)=>void 0 !== value);
|
|
1315
|
-
const createStatelessExperienceApiConfig = (api)=>{
|
|
1316
|
-
if (void 0 === api) return;
|
|
1317
|
-
const experienceConfig = {
|
|
1318
|
-
baseUrl: api.experienceBaseUrl,
|
|
1319
|
-
enabledFeatures: api.enabledFeatures
|
|
1320
|
-
};
|
|
1321
|
-
return CoreStateless_hasDefinedValues(experienceConfig) ? experienceConfig : void 0;
|
|
1322
|
-
};
|
|
1323
|
-
const createStatelessInsightsApiConfig = (api)=>{
|
|
1324
|
-
if (api?.insightsBaseUrl === void 0) return;
|
|
1325
|
-
return {
|
|
1326
|
-
baseUrl: api.insightsBaseUrl
|
|
1327
|
-
};
|
|
1328
|
-
};
|
|
1329
|
-
class CoreStateless extends src_CoreBase {
|
|
1330
|
-
constructor(config){
|
|
1331
|
-
super(config, {
|
|
1332
|
-
experience: createStatelessExperienceApiConfig(config.api),
|
|
1333
|
-
insights: createStatelessInsightsApiConfig(config.api)
|
|
1334
|
-
});
|
|
1335
|
-
}
|
|
1336
|
-
forRequest(options = {}) {
|
|
1337
|
-
return new CoreStatelessRequestScope(this, options);
|
|
1324
|
+
await this.api.insights.sendBatchEvents(batchEvent);
|
|
1338
1325
|
}
|
|
1339
1326
|
}
|
|
1340
1327
|
const src_CoreStateless = CoreStateless;
|
|
@@ -1383,6 +1370,6 @@ function guardedBy(predicateName, opts) {
|
|
|
1383
1370
|
}
|
|
1384
1371
|
export { ANONYMOUS_ID_COOKIE, ANONYMOUS_ID_COOKIE_LEGACY, ANONYMOUS_ID_KEY, ANONYMOUS_ID_KEY_LEGACY, CHANGES_CACHE_KEY, CONSENT_KEY, DEBUG_FLAG_KEY, OPTIMIZATION_CORE_SDK_NAME, OPTIMIZATION_CORE_SDK_VERSION, PROFILE_CACHE_KEY, SELECTED_OPTIMIZATIONS_CACHE_KEY } from "./260.mjs";
|
|
1385
1372
|
export { PREVIEW_PANEL_SIGNALS_SYMBOL, PREVIEW_PANEL_SIGNAL_FNS_SYMBOL } from "./632.mjs";
|
|
1386
|
-
export { ClickBuilderArgs,
|
|
1373
|
+
export { ClickBuilderArgs, DEFAULT_PAGE_PROPERTIES, EntryInteractionBuilderArgsBase, FlagViewBuilderArgs, HoverBuilderArgs, IdentifyBuilderArgs, InterceptorManager, PageViewBuilderArgs, ScreenViewBuilderArgs, TrackBuilderArgs, UniversalEventBuilderArgs, ViewBuilderArgs, batch, effect, events_EventBuilder as EventBuilder, guardedBy, resolvers_FlagsResolver as FlagsResolver, resolvers_MergeTagValueResolver as MergeTagValueResolver, resolvers_OptimizedEntryResolver as OptimizedEntryResolver, signalFns, signals, src_CoreStateful as CoreStateful, src_CoreStateless as CoreStateless, toDistinctObservable, toObservable };
|
|
1387
1374
|
|
|
1388
1375
|
//# sourceMappingURL=index.mjs.map
|