@vivoa/plugin-sdk 0.6.0 → 0.6.2

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/dist/index.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  declare const PAYMENT_PLUGIN_TOKEN: "PAYMENT_PLUGINS";
2
2
  declare const SHIPPING_PLUGIN_TOKEN: "SHIPPING_PLUGINS";
3
3
  declare const SUPPLIERS_PLUGIN_TOKEN: "SUPPLIERS_PLUGINS";
4
+ declare const ANALYTICS_PLUGIN_TOKEN: "ANALYTICS_PLUGINS";
4
5
 
5
6
  declare enum FieldType {
6
7
  String = "string",
@@ -843,6 +844,174 @@ interface ISuppliersPlugin extends IPlugin {
843
844
  isConfigured?(ctx: DispatchContext): boolean;
844
845
  }
845
846
 
847
+ declare enum AnalyticsFeature {
848
+ /** Ecommerce funnel events: view_item, add_to_cart, begin_checkout, purchase. */
849
+ Ecommerce = "ecommerce",
850
+ /** Generic page_view tracking. */
851
+ PageViews = "page-views"
852
+ }
853
+ /**
854
+ * ISO-4217 money in minor units — mirrors the store's Money VO so the host maps
855
+ * 1:1 without a currency guess. Kept local so the SDK stays dependency-free.
856
+ */
857
+ interface AnalyticsMoney {
858
+ amountMinor: number;
859
+ currency: string;
860
+ }
861
+ /** A single line item attached to an ecommerce event. */
862
+ interface AnalyticsItem {
863
+ /** Product id as the store knows it (Meta `content_ids`, GA4 `item_id`). */
864
+ id: string;
865
+ /** Variant id for catalog-level granularity, when the line resolves one. */
866
+ variantId?: string | null;
867
+ name?: string;
868
+ sku?: string | null;
869
+ /** Brand for catalog feeds that key on it. */
870
+ brand?: string | null;
871
+ quantity?: number;
872
+ price?: AnalyticsMoney;
873
+ category?: string | null;
874
+ }
875
+ /**
876
+ * Canonical, provider-agnostic event names the host emits. Closed set: the host
877
+ * only ever maps a domain event to one of these. An adapter that does not care
878
+ * about a given name simply ignores it.
879
+ */
880
+ type AnalyticsEventName = 'page_view' | 'view_item' | 'add_to_cart' | 'remove_from_cart' | 'begin_checkout' | 'purchase';
881
+ /**
882
+ * Where the action physically happened. Maps to Meta `action_source`; other
883
+ * providers ignore it. Defaults to `website` when the host omits it.
884
+ */
885
+ type AnalyticsActionSource = 'website' | 'app' | 'server' | 'phone_call' | 'chat' | 'email' | 'physical_store' | 'other';
886
+ /**
887
+ * Identity + match-quality signals. EVERYTHING here is optional — the host
888
+ * populates whatever it can resolve for the event in scope.
889
+ *
890
+ * @rule The `*Sha256` fields arrive ALREADY hashed by the host (SHA256 hex of
891
+ * the normalized value: lowercased + trimmed; phone in E.164 digits).
892
+ * The plugin NEVER receives raw PII. `externalId`, `clientIpAddress`,
893
+ * `clientUserAgent` and the click ids are the exception — providers
894
+ * require them PLAIN.
895
+ */
896
+ interface AnalyticsUserData {
897
+ emailSha256?: string | null;
898
+ phoneSha256?: string | null;
899
+ firstNameSha256?: string | null;
900
+ lastNameSha256?: string | null;
901
+ citySha256?: string | null;
902
+ stateSha256?: string | null;
903
+ zipSha256?: string | null;
904
+ countrySha256?: string | null;
905
+ genderSha256?: string | null;
906
+ /** Date of birth, YYYYMMDD normalized then SHA256. */
907
+ dobSha256?: string | null;
908
+ /** Store customer/user id — Meta `external_id` (not hashed by spec). */
909
+ externalId?: string | null;
910
+ /** Plain IPv4/IPv6 — never hashed (geo match). */
911
+ clientIpAddress?: string | null;
912
+ /** Plain browser UA — never hashed (device match). */
913
+ clientUserAgent?: string | null;
914
+ /** Meta browser cookie `_fbp`. */
915
+ fbp?: string | null;
916
+ /** Meta click id `_fbc`. */
917
+ fbc?: string | null;
918
+ /** Google Ads click id. */
919
+ gclid?: string | null;
920
+ /** TikTok click id. */
921
+ ttclid?: string | null;
922
+ }
923
+ /** Marketing attribution captured at the session that led to the event. */
924
+ interface AnalyticsUtm {
925
+ source?: string | null;
926
+ medium?: string | null;
927
+ campaign?: string | null;
928
+ term?: string | null;
929
+ content?: string | null;
930
+ }
931
+ /**
932
+ * Consent signals the host resolved for this event. Providers that honor
933
+ * consent (Meta LDU, Google Consent Mode) gate on it; others ignore it.
934
+ */
935
+ interface AnalyticsConsent {
936
+ adStorage?: boolean;
937
+ adUserData?: boolean;
938
+ adPersonalization?: boolean;
939
+ }
940
+ /**
941
+ * Normalized analytics event. The host builds this from a DomainEvent and hands
942
+ * it to every active analytics adapter. The adapter translates it to its own
943
+ * wire format (GA4 event, Meta event, ...). See the @rule SUPERSET note at the
944
+ * top of the module: this is the superset of what Meta CAPI needs.
945
+ */
946
+ interface AnalyticsEvent {
947
+ name: AnalyticsEventName;
948
+ /** ISO-8601 instant the underlying action happened. */
949
+ occurredAt: string;
950
+ /**
951
+ * Stable id for cross-channel deduplication against the browser pixel (Meta
952
+ * `event_id`). For `purchase` the host sets it to the order id so the pixel
953
+ * and the server event collapse into one.
954
+ */
955
+ eventId?: string | null;
956
+ /** Where the action happened — Meta `action_source`. Defaults to `website`. */
957
+ actionSource?: AnalyticsActionSource;
958
+ /**
959
+ * Pseudonymous client identity for sessionization (maps to GA4 `client_id`
960
+ * / Meta `external_id`). Null when the host cannot resolve a stable id.
961
+ */
962
+ clientId?: string | null;
963
+ sessionId?: string | null;
964
+ /** Hashed identity + client signals + click ids. See {@link AnalyticsUserData}. */
965
+ user?: AnalyticsUserData;
966
+ /** Monetary value for value-bearing events (purchase, begin_checkout). */
967
+ value?: AnalyticsMoney | null;
968
+ /** Order id for `purchase` — providers dedupe transactions on it. */
969
+ transactionId?: string | null;
970
+ items?: AnalyticsItem[];
971
+ /** Page context for `page_view`. */
972
+ pageLocation?: string | null;
973
+ /** Referring URL, when the host knows it. */
974
+ pageReferrer?: string | null;
975
+ pageTitle?: string | null;
976
+ /** Marketing attribution for the session that produced the event. */
977
+ utm?: AnalyticsUtm;
978
+ /** Consent signals resolved by the host for this event. */
979
+ consent?: AnalyticsConsent;
980
+ /** Extra params forwarded verbatim as custom dimensions. */
981
+ params?: Record<string, unknown>;
982
+ }
983
+ interface AnalyticsPluginConfig {
984
+ supportedCapabilities: AnalyticsFeature[];
985
+ configSchema: PluginConfigField[];
986
+ /** GLOBAL-scope defaults merged under the tenant DB config by the host. */
987
+ defaultConfig?: Record<string, unknown>;
988
+ }
989
+ interface AnalyticsStaticConfig {
990
+ code: string;
991
+ displayName: string;
992
+ description: string;
993
+ iconUrl?: string;
994
+ supportedCapabilities: AnalyticsFeature[];
995
+ configSchema: PluginConfigField[];
996
+ }
997
+ interface IAnalyticsPlugin extends IPlugin {
998
+ readonly name: string;
999
+ readonly analyticsConfig: AnalyticsPluginConfig;
1000
+ /**
1001
+ * Forward one canonical event to the provider's ingestion API. Stateless: the
1002
+ * tenant's resolved credentials arrive in `ctx.config` on every call.
1003
+ *
1004
+ * @rule BEST-EFFORT — never throw on a transport/provider error. Analytics is
1005
+ * fire-and-forget and MUST NOT break the domain flow that triggered it.
1006
+ */
1007
+ track(event: AnalyticsEvent, ctx: DispatchContext): Promise<void>;
1008
+ /**
1009
+ * Optional readiness probe. Availability = enabled AND isConfigured.
1010
+ * @compat When omitted, the host assumes the adapter is ready.
1011
+ */
1012
+ isConfigured?(ctx: DispatchContext): boolean;
1013
+ }
1014
+
846
1015
  /** A named unit of behaviour a plugin exposes to the host registry. */
847
1016
  interface Capability<T = unknown> {
848
1017
  kind: string;
@@ -864,6 +1033,7 @@ declare function capability<T>(kind: string, impl: T): Capability<T>;
864
1033
  declare function paymentCapability(impl: IPaymentPlugin): Capability<IPaymentPlugin>;
865
1034
  declare function shippingCapability(impl: IShippingPlugin): Capability<IShippingPlugin>;
866
1035
  declare function suppliersCapability(impl: ISuppliersPlugin): Capability<ISuppliersPlugin>;
1036
+ declare function analyticsCapability(impl: IAnalyticsPlugin): Capability<IAnalyticsPlugin>;
867
1037
  /**
868
1038
  * A constructed plugin. `capabilities` is the static declaration the host reads
869
1039
  * up front; `onActivate` runs when the host mounts the plugin for a tenant and
@@ -1001,7 +1171,7 @@ declare function checkPermissions(required: string[], grantedRaw: string[]): Per
1001
1171
  * - MINOR: additive (new optional fields, new tokens) — backwards compatible.
1002
1172
  * - PATCH: docs/fixes with zero shape changes.
1003
1173
  */
1004
- declare const SDK_VERSION = "0.6.0";
1174
+ declare const SDK_VERSION = "0.6.2";
1005
1175
  /**
1006
1176
  * True when a plugin built against `pluginSdkVersion` can run on a host that
1007
1177
  * ships `hostSdkVersion`. Rule: same major, host minor >= plugin minor.
@@ -1010,4 +1180,4 @@ declare const SDK_VERSION = "0.6.0";
1010
1180
  */
1011
1181
  declare function isSdkCompatible(pluginSdkVersion: string, hostSdkVersion: string): boolean;
1012
1182
 
1013
- export { type AccordionBlock, type AccordionSection, type ActionBlock, ActionVariant, type BannerBlock, type Block, type BlockBase, BlockType, type CalloutBlock, type Capability, CapabilityKind, type CardBlock, type CodConfig, type CodFeeConfig, CodFeeType, type ConditionalBlock, type ConditionalEquals, type ConditionalWhen, ConfigScope, type ConfigurablePlugin, type CopyFieldBlock, type CreateShipmentParams, type DispatchContext, type DividerBlock, type DomainEventHandler, type DomainEventName, type FieldBlock, type FieldDefinition, type FieldDependsOn, type FieldMap, type FieldOption, FieldType, FieldVariant, GatewayEnvironment, type GatewayStaticConfig, type GroupBlock, type HostApi, type HttpClient, type HttpRequest, type HttpResponse, type IPaymentPlugin, type IPlugin, type IShippingPlugin, type ISuppliersPlugin, type InlineRowBlock, type KeyValueBlock, type KeyValueRow, LayoutMode, type Logger, type MarkdownBlock, MessageVariant, PAYMENT_PLUGIN_TOKEN, type PaymentCard, type PaymentCustomer, type PaymentGatewayCode, type PaymentPayload, type PaymentPluginConfig, type PaymentResult, type PaymentVerifyPayload, type Permission, type PermissionCheck, type PlaceSupplierOrderInput, type Plugin, type PluginActionContext, type PluginActionResult, type PluginConfigField, type PluginConfigFieldDependency, type PluginConfigResult, type PluginConfigValidation, type PluginFactory, type PluginManifest, PluginType, type RepeaterBlock, RepeaterSource, SDK_VERSION, SHIPPING_PLUGIN_TOKEN, SUPPLIERS_PLUGIN_TOKEN, type SecretStore, type SelectOption, type SequenceStore, type SetupAction, type SetupLayout, type SetupLayoutValidation, type SetupStep, type ShipmentAddress, type ShipmentParcel, type ShipmentResult, type ShippingDefaultConfig, ShippingFeature, type ShippingPluginConfig, type ShippingQuote, type ShippingQuoteParams, type ShippingStaticConfig, StepStatusFrom, type StepStatusFromAction, type StepStatusFromFields, type StepStatusSource, type StorageBroker, type SupplierCatalogQuery, type SupplierFulfillmentEvent, type SupplierListing, type SupplierListingAttribute, type SupplierListingPage, type SupplierListingVariant, type SupplierMoney, type SupplierOrderAddressLevel, type SupplierOrderCustomer, type SupplierOrderLine, type SupplierOrderResult, type SupplierOrderStatus, type SupplierShipTo, type SupplierStock, type SuppliersDefaultConfig, SuppliersFeature, type SuppliersPluginConfig, type SuppliersStaticConfig, type TabItem, type TabsBlock, type ToggleBlock, type TrackingEvent, TransactionStatus, type WebhookSignatureResult, capability, checkPermissions, createPluginConfig, crossValidateSetupLayout, definePlugin, field, isConfigurablePlugin, isPermissionGranted, isPluginFactory, isSdkCompatible, parsePermission, paymentCapability, shippingCapability, suppliersCapability, validateSetupLayout };
1183
+ export { ANALYTICS_PLUGIN_TOKEN, type AccordionBlock, type AccordionSection, type ActionBlock, ActionVariant, type AnalyticsActionSource, type AnalyticsConsent, type AnalyticsEvent, type AnalyticsEventName, AnalyticsFeature, type AnalyticsItem, type AnalyticsMoney, type AnalyticsPluginConfig, type AnalyticsStaticConfig, type AnalyticsUserData, type AnalyticsUtm, type BannerBlock, type Block, type BlockBase, BlockType, type CalloutBlock, type Capability, CapabilityKind, type CardBlock, type CodConfig, type CodFeeConfig, CodFeeType, type ConditionalBlock, type ConditionalEquals, type ConditionalWhen, ConfigScope, type ConfigurablePlugin, type CopyFieldBlock, type CreateShipmentParams, type DispatchContext, type DividerBlock, type DomainEventHandler, type DomainEventName, type FieldBlock, type FieldDefinition, type FieldDependsOn, type FieldMap, type FieldOption, FieldType, FieldVariant, GatewayEnvironment, type GatewayStaticConfig, type GroupBlock, type HostApi, type HttpClient, type HttpRequest, type HttpResponse, type IAnalyticsPlugin, type IPaymentPlugin, type IPlugin, type IShippingPlugin, type ISuppliersPlugin, type InlineRowBlock, type KeyValueBlock, type KeyValueRow, LayoutMode, type Logger, type MarkdownBlock, MessageVariant, PAYMENT_PLUGIN_TOKEN, type PaymentCard, type PaymentCustomer, type PaymentGatewayCode, type PaymentPayload, type PaymentPluginConfig, type PaymentResult, type PaymentVerifyPayload, type Permission, type PermissionCheck, type PlaceSupplierOrderInput, type Plugin, type PluginActionContext, type PluginActionResult, type PluginConfigField, type PluginConfigFieldDependency, type PluginConfigResult, type PluginConfigValidation, type PluginFactory, type PluginManifest, PluginType, type RepeaterBlock, RepeaterSource, SDK_VERSION, SHIPPING_PLUGIN_TOKEN, SUPPLIERS_PLUGIN_TOKEN, type SecretStore, type SelectOption, type SequenceStore, type SetupAction, type SetupLayout, type SetupLayoutValidation, type SetupStep, type ShipmentAddress, type ShipmentParcel, type ShipmentResult, type ShippingDefaultConfig, ShippingFeature, type ShippingPluginConfig, type ShippingQuote, type ShippingQuoteParams, type ShippingStaticConfig, StepStatusFrom, type StepStatusFromAction, type StepStatusFromFields, type StepStatusSource, type StorageBroker, type SupplierCatalogQuery, type SupplierFulfillmentEvent, type SupplierListing, type SupplierListingAttribute, type SupplierListingPage, type SupplierListingVariant, type SupplierMoney, type SupplierOrderAddressLevel, type SupplierOrderCustomer, type SupplierOrderLine, type SupplierOrderResult, type SupplierOrderStatus, type SupplierShipTo, type SupplierStock, type SuppliersDefaultConfig, SuppliersFeature, type SuppliersPluginConfig, type SuppliersStaticConfig, type TabItem, type TabsBlock, type ToggleBlock, type TrackingEvent, TransactionStatus, type WebhookSignatureResult, analyticsCapability, capability, checkPermissions, createPluginConfig, crossValidateSetupLayout, definePlugin, field, isConfigurablePlugin, isPermissionGranted, isPluginFactory, isSdkCompatible, parsePermission, paymentCapability, shippingCapability, suppliersCapability, validateSetupLayout };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  declare const PAYMENT_PLUGIN_TOKEN: "PAYMENT_PLUGINS";
2
2
  declare const SHIPPING_PLUGIN_TOKEN: "SHIPPING_PLUGINS";
3
3
  declare const SUPPLIERS_PLUGIN_TOKEN: "SUPPLIERS_PLUGINS";
4
+ declare const ANALYTICS_PLUGIN_TOKEN: "ANALYTICS_PLUGINS";
4
5
 
5
6
  declare enum FieldType {
6
7
  String = "string",
@@ -843,6 +844,174 @@ interface ISuppliersPlugin extends IPlugin {
843
844
  isConfigured?(ctx: DispatchContext): boolean;
844
845
  }
845
846
 
847
+ declare enum AnalyticsFeature {
848
+ /** Ecommerce funnel events: view_item, add_to_cart, begin_checkout, purchase. */
849
+ Ecommerce = "ecommerce",
850
+ /** Generic page_view tracking. */
851
+ PageViews = "page-views"
852
+ }
853
+ /**
854
+ * ISO-4217 money in minor units — mirrors the store's Money VO so the host maps
855
+ * 1:1 without a currency guess. Kept local so the SDK stays dependency-free.
856
+ */
857
+ interface AnalyticsMoney {
858
+ amountMinor: number;
859
+ currency: string;
860
+ }
861
+ /** A single line item attached to an ecommerce event. */
862
+ interface AnalyticsItem {
863
+ /** Product id as the store knows it (Meta `content_ids`, GA4 `item_id`). */
864
+ id: string;
865
+ /** Variant id for catalog-level granularity, when the line resolves one. */
866
+ variantId?: string | null;
867
+ name?: string;
868
+ sku?: string | null;
869
+ /** Brand for catalog feeds that key on it. */
870
+ brand?: string | null;
871
+ quantity?: number;
872
+ price?: AnalyticsMoney;
873
+ category?: string | null;
874
+ }
875
+ /**
876
+ * Canonical, provider-agnostic event names the host emits. Closed set: the host
877
+ * only ever maps a domain event to one of these. An adapter that does not care
878
+ * about a given name simply ignores it.
879
+ */
880
+ type AnalyticsEventName = 'page_view' | 'view_item' | 'add_to_cart' | 'remove_from_cart' | 'begin_checkout' | 'purchase';
881
+ /**
882
+ * Where the action physically happened. Maps to Meta `action_source`; other
883
+ * providers ignore it. Defaults to `website` when the host omits it.
884
+ */
885
+ type AnalyticsActionSource = 'website' | 'app' | 'server' | 'phone_call' | 'chat' | 'email' | 'physical_store' | 'other';
886
+ /**
887
+ * Identity + match-quality signals. EVERYTHING here is optional — the host
888
+ * populates whatever it can resolve for the event in scope.
889
+ *
890
+ * @rule The `*Sha256` fields arrive ALREADY hashed by the host (SHA256 hex of
891
+ * the normalized value: lowercased + trimmed; phone in E.164 digits).
892
+ * The plugin NEVER receives raw PII. `externalId`, `clientIpAddress`,
893
+ * `clientUserAgent` and the click ids are the exception — providers
894
+ * require them PLAIN.
895
+ */
896
+ interface AnalyticsUserData {
897
+ emailSha256?: string | null;
898
+ phoneSha256?: string | null;
899
+ firstNameSha256?: string | null;
900
+ lastNameSha256?: string | null;
901
+ citySha256?: string | null;
902
+ stateSha256?: string | null;
903
+ zipSha256?: string | null;
904
+ countrySha256?: string | null;
905
+ genderSha256?: string | null;
906
+ /** Date of birth, YYYYMMDD normalized then SHA256. */
907
+ dobSha256?: string | null;
908
+ /** Store customer/user id — Meta `external_id` (not hashed by spec). */
909
+ externalId?: string | null;
910
+ /** Plain IPv4/IPv6 — never hashed (geo match). */
911
+ clientIpAddress?: string | null;
912
+ /** Plain browser UA — never hashed (device match). */
913
+ clientUserAgent?: string | null;
914
+ /** Meta browser cookie `_fbp`. */
915
+ fbp?: string | null;
916
+ /** Meta click id `_fbc`. */
917
+ fbc?: string | null;
918
+ /** Google Ads click id. */
919
+ gclid?: string | null;
920
+ /** TikTok click id. */
921
+ ttclid?: string | null;
922
+ }
923
+ /** Marketing attribution captured at the session that led to the event. */
924
+ interface AnalyticsUtm {
925
+ source?: string | null;
926
+ medium?: string | null;
927
+ campaign?: string | null;
928
+ term?: string | null;
929
+ content?: string | null;
930
+ }
931
+ /**
932
+ * Consent signals the host resolved for this event. Providers that honor
933
+ * consent (Meta LDU, Google Consent Mode) gate on it; others ignore it.
934
+ */
935
+ interface AnalyticsConsent {
936
+ adStorage?: boolean;
937
+ adUserData?: boolean;
938
+ adPersonalization?: boolean;
939
+ }
940
+ /**
941
+ * Normalized analytics event. The host builds this from a DomainEvent and hands
942
+ * it to every active analytics adapter. The adapter translates it to its own
943
+ * wire format (GA4 event, Meta event, ...). See the @rule SUPERSET note at the
944
+ * top of the module: this is the superset of what Meta CAPI needs.
945
+ */
946
+ interface AnalyticsEvent {
947
+ name: AnalyticsEventName;
948
+ /** ISO-8601 instant the underlying action happened. */
949
+ occurredAt: string;
950
+ /**
951
+ * Stable id for cross-channel deduplication against the browser pixel (Meta
952
+ * `event_id`). For `purchase` the host sets it to the order id so the pixel
953
+ * and the server event collapse into one.
954
+ */
955
+ eventId?: string | null;
956
+ /** Where the action happened — Meta `action_source`. Defaults to `website`. */
957
+ actionSource?: AnalyticsActionSource;
958
+ /**
959
+ * Pseudonymous client identity for sessionization (maps to GA4 `client_id`
960
+ * / Meta `external_id`). Null when the host cannot resolve a stable id.
961
+ */
962
+ clientId?: string | null;
963
+ sessionId?: string | null;
964
+ /** Hashed identity + client signals + click ids. See {@link AnalyticsUserData}. */
965
+ user?: AnalyticsUserData;
966
+ /** Monetary value for value-bearing events (purchase, begin_checkout). */
967
+ value?: AnalyticsMoney | null;
968
+ /** Order id for `purchase` — providers dedupe transactions on it. */
969
+ transactionId?: string | null;
970
+ items?: AnalyticsItem[];
971
+ /** Page context for `page_view`. */
972
+ pageLocation?: string | null;
973
+ /** Referring URL, when the host knows it. */
974
+ pageReferrer?: string | null;
975
+ pageTitle?: string | null;
976
+ /** Marketing attribution for the session that produced the event. */
977
+ utm?: AnalyticsUtm;
978
+ /** Consent signals resolved by the host for this event. */
979
+ consent?: AnalyticsConsent;
980
+ /** Extra params forwarded verbatim as custom dimensions. */
981
+ params?: Record<string, unknown>;
982
+ }
983
+ interface AnalyticsPluginConfig {
984
+ supportedCapabilities: AnalyticsFeature[];
985
+ configSchema: PluginConfigField[];
986
+ /** GLOBAL-scope defaults merged under the tenant DB config by the host. */
987
+ defaultConfig?: Record<string, unknown>;
988
+ }
989
+ interface AnalyticsStaticConfig {
990
+ code: string;
991
+ displayName: string;
992
+ description: string;
993
+ iconUrl?: string;
994
+ supportedCapabilities: AnalyticsFeature[];
995
+ configSchema: PluginConfigField[];
996
+ }
997
+ interface IAnalyticsPlugin extends IPlugin {
998
+ readonly name: string;
999
+ readonly analyticsConfig: AnalyticsPluginConfig;
1000
+ /**
1001
+ * Forward one canonical event to the provider's ingestion API. Stateless: the
1002
+ * tenant's resolved credentials arrive in `ctx.config` on every call.
1003
+ *
1004
+ * @rule BEST-EFFORT — never throw on a transport/provider error. Analytics is
1005
+ * fire-and-forget and MUST NOT break the domain flow that triggered it.
1006
+ */
1007
+ track(event: AnalyticsEvent, ctx: DispatchContext): Promise<void>;
1008
+ /**
1009
+ * Optional readiness probe. Availability = enabled AND isConfigured.
1010
+ * @compat When omitted, the host assumes the adapter is ready.
1011
+ */
1012
+ isConfigured?(ctx: DispatchContext): boolean;
1013
+ }
1014
+
846
1015
  /** A named unit of behaviour a plugin exposes to the host registry. */
847
1016
  interface Capability<T = unknown> {
848
1017
  kind: string;
@@ -864,6 +1033,7 @@ declare function capability<T>(kind: string, impl: T): Capability<T>;
864
1033
  declare function paymentCapability(impl: IPaymentPlugin): Capability<IPaymentPlugin>;
865
1034
  declare function shippingCapability(impl: IShippingPlugin): Capability<IShippingPlugin>;
866
1035
  declare function suppliersCapability(impl: ISuppliersPlugin): Capability<ISuppliersPlugin>;
1036
+ declare function analyticsCapability(impl: IAnalyticsPlugin): Capability<IAnalyticsPlugin>;
867
1037
  /**
868
1038
  * A constructed plugin. `capabilities` is the static declaration the host reads
869
1039
  * up front; `onActivate` runs when the host mounts the plugin for a tenant and
@@ -1001,7 +1171,7 @@ declare function checkPermissions(required: string[], grantedRaw: string[]): Per
1001
1171
  * - MINOR: additive (new optional fields, new tokens) — backwards compatible.
1002
1172
  * - PATCH: docs/fixes with zero shape changes.
1003
1173
  */
1004
- declare const SDK_VERSION = "0.6.0";
1174
+ declare const SDK_VERSION = "0.6.2";
1005
1175
  /**
1006
1176
  * True when a plugin built against `pluginSdkVersion` can run on a host that
1007
1177
  * ships `hostSdkVersion`. Rule: same major, host minor >= plugin minor.
@@ -1010,4 +1180,4 @@ declare const SDK_VERSION = "0.6.0";
1010
1180
  */
1011
1181
  declare function isSdkCompatible(pluginSdkVersion: string, hostSdkVersion: string): boolean;
1012
1182
 
1013
- export { type AccordionBlock, type AccordionSection, type ActionBlock, ActionVariant, type BannerBlock, type Block, type BlockBase, BlockType, type CalloutBlock, type Capability, CapabilityKind, type CardBlock, type CodConfig, type CodFeeConfig, CodFeeType, type ConditionalBlock, type ConditionalEquals, type ConditionalWhen, ConfigScope, type ConfigurablePlugin, type CopyFieldBlock, type CreateShipmentParams, type DispatchContext, type DividerBlock, type DomainEventHandler, type DomainEventName, type FieldBlock, type FieldDefinition, type FieldDependsOn, type FieldMap, type FieldOption, FieldType, FieldVariant, GatewayEnvironment, type GatewayStaticConfig, type GroupBlock, type HostApi, type HttpClient, type HttpRequest, type HttpResponse, type IPaymentPlugin, type IPlugin, type IShippingPlugin, type ISuppliersPlugin, type InlineRowBlock, type KeyValueBlock, type KeyValueRow, LayoutMode, type Logger, type MarkdownBlock, MessageVariant, PAYMENT_PLUGIN_TOKEN, type PaymentCard, type PaymentCustomer, type PaymentGatewayCode, type PaymentPayload, type PaymentPluginConfig, type PaymentResult, type PaymentVerifyPayload, type Permission, type PermissionCheck, type PlaceSupplierOrderInput, type Plugin, type PluginActionContext, type PluginActionResult, type PluginConfigField, type PluginConfigFieldDependency, type PluginConfigResult, type PluginConfigValidation, type PluginFactory, type PluginManifest, PluginType, type RepeaterBlock, RepeaterSource, SDK_VERSION, SHIPPING_PLUGIN_TOKEN, SUPPLIERS_PLUGIN_TOKEN, type SecretStore, type SelectOption, type SequenceStore, type SetupAction, type SetupLayout, type SetupLayoutValidation, type SetupStep, type ShipmentAddress, type ShipmentParcel, type ShipmentResult, type ShippingDefaultConfig, ShippingFeature, type ShippingPluginConfig, type ShippingQuote, type ShippingQuoteParams, type ShippingStaticConfig, StepStatusFrom, type StepStatusFromAction, type StepStatusFromFields, type StepStatusSource, type StorageBroker, type SupplierCatalogQuery, type SupplierFulfillmentEvent, type SupplierListing, type SupplierListingAttribute, type SupplierListingPage, type SupplierListingVariant, type SupplierMoney, type SupplierOrderAddressLevel, type SupplierOrderCustomer, type SupplierOrderLine, type SupplierOrderResult, type SupplierOrderStatus, type SupplierShipTo, type SupplierStock, type SuppliersDefaultConfig, SuppliersFeature, type SuppliersPluginConfig, type SuppliersStaticConfig, type TabItem, type TabsBlock, type ToggleBlock, type TrackingEvent, TransactionStatus, type WebhookSignatureResult, capability, checkPermissions, createPluginConfig, crossValidateSetupLayout, definePlugin, field, isConfigurablePlugin, isPermissionGranted, isPluginFactory, isSdkCompatible, parsePermission, paymentCapability, shippingCapability, suppliersCapability, validateSetupLayout };
1183
+ export { ANALYTICS_PLUGIN_TOKEN, type AccordionBlock, type AccordionSection, type ActionBlock, ActionVariant, type AnalyticsActionSource, type AnalyticsConsent, type AnalyticsEvent, type AnalyticsEventName, AnalyticsFeature, type AnalyticsItem, type AnalyticsMoney, type AnalyticsPluginConfig, type AnalyticsStaticConfig, type AnalyticsUserData, type AnalyticsUtm, type BannerBlock, type Block, type BlockBase, BlockType, type CalloutBlock, type Capability, CapabilityKind, type CardBlock, type CodConfig, type CodFeeConfig, CodFeeType, type ConditionalBlock, type ConditionalEquals, type ConditionalWhen, ConfigScope, type ConfigurablePlugin, type CopyFieldBlock, type CreateShipmentParams, type DispatchContext, type DividerBlock, type DomainEventHandler, type DomainEventName, type FieldBlock, type FieldDefinition, type FieldDependsOn, type FieldMap, type FieldOption, FieldType, FieldVariant, GatewayEnvironment, type GatewayStaticConfig, type GroupBlock, type HostApi, type HttpClient, type HttpRequest, type HttpResponse, type IAnalyticsPlugin, type IPaymentPlugin, type IPlugin, type IShippingPlugin, type ISuppliersPlugin, type InlineRowBlock, type KeyValueBlock, type KeyValueRow, LayoutMode, type Logger, type MarkdownBlock, MessageVariant, PAYMENT_PLUGIN_TOKEN, type PaymentCard, type PaymentCustomer, type PaymentGatewayCode, type PaymentPayload, type PaymentPluginConfig, type PaymentResult, type PaymentVerifyPayload, type Permission, type PermissionCheck, type PlaceSupplierOrderInput, type Plugin, type PluginActionContext, type PluginActionResult, type PluginConfigField, type PluginConfigFieldDependency, type PluginConfigResult, type PluginConfigValidation, type PluginFactory, type PluginManifest, PluginType, type RepeaterBlock, RepeaterSource, SDK_VERSION, SHIPPING_PLUGIN_TOKEN, SUPPLIERS_PLUGIN_TOKEN, type SecretStore, type SelectOption, type SequenceStore, type SetupAction, type SetupLayout, type SetupLayoutValidation, type SetupStep, type ShipmentAddress, type ShipmentParcel, type ShipmentResult, type ShippingDefaultConfig, ShippingFeature, type ShippingPluginConfig, type ShippingQuote, type ShippingQuoteParams, type ShippingStaticConfig, StepStatusFrom, type StepStatusFromAction, type StepStatusFromFields, type StepStatusSource, type StorageBroker, type SupplierCatalogQuery, type SupplierFulfillmentEvent, type SupplierListing, type SupplierListingAttribute, type SupplierListingPage, type SupplierListingVariant, type SupplierMoney, type SupplierOrderAddressLevel, type SupplierOrderCustomer, type SupplierOrderLine, type SupplierOrderResult, type SupplierOrderStatus, type SupplierShipTo, type SupplierStock, type SuppliersDefaultConfig, SuppliersFeature, type SuppliersPluginConfig, type SuppliersStaticConfig, type TabItem, type TabsBlock, type ToggleBlock, type TrackingEvent, TransactionStatus, type WebhookSignatureResult, analyticsCapability, capability, checkPermissions, createPluginConfig, crossValidateSetupLayout, definePlugin, field, isConfigurablePlugin, isPermissionGranted, isPluginFactory, isSdkCompatible, parsePermission, paymentCapability, shippingCapability, suppliersCapability, validateSetupLayout };
package/dist/index.js CHANGED
@@ -20,7 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ ANALYTICS_PLUGIN_TOKEN: () => ANALYTICS_PLUGIN_TOKEN,
23
24
  ActionVariant: () => ActionVariant,
25
+ AnalyticsFeature: () => AnalyticsFeature,
24
26
  BlockType: () => BlockType,
25
27
  CapabilityKind: () => CapabilityKind,
26
28
  CodFeeType: () => CodFeeType,
@@ -40,6 +42,7 @@ __export(index_exports, {
40
42
  StepStatusFrom: () => StepStatusFrom,
41
43
  SuppliersFeature: () => SuppliersFeature,
42
44
  TransactionStatus: () => TransactionStatus,
45
+ analyticsCapability: () => analyticsCapability,
43
46
  capability: () => capability,
44
47
  checkPermissions: () => checkPermissions,
45
48
  createPluginConfig: () => createPluginConfig,
@@ -62,6 +65,7 @@ module.exports = __toCommonJS(index_exports);
62
65
  var PAYMENT_PLUGIN_TOKEN = "PAYMENT_PLUGINS";
63
66
  var SHIPPING_PLUGIN_TOKEN = "SHIPPING_PLUGINS";
64
67
  var SUPPLIERS_PLUGIN_TOKEN = "SUPPLIERS_PLUGINS";
68
+ var ANALYTICS_PLUGIN_TOKEN = "ANALYTICS_PLUGINS";
65
69
 
66
70
  // src/plugin.ts
67
71
  var PluginType = /* @__PURE__ */ ((PluginType2) => {
@@ -200,6 +204,13 @@ var SuppliersFeature = /* @__PURE__ */ ((SuppliersFeature2) => {
200
204
  return SuppliersFeature2;
201
205
  })(SuppliersFeature || {});
202
206
 
207
+ // src/analytics.ts
208
+ var AnalyticsFeature = /* @__PURE__ */ ((AnalyticsFeature2) => {
209
+ AnalyticsFeature2["Ecommerce"] = "ecommerce";
210
+ AnalyticsFeature2["PageViews"] = "page-views";
211
+ return AnalyticsFeature2;
212
+ })(AnalyticsFeature || {});
213
+
203
214
  // src/setup-layout.ts
204
215
  var import_superstruct2 = require("superstruct");
205
216
  var FieldVariant = /* @__PURE__ */ ((FieldVariant2) => {
@@ -485,6 +496,9 @@ function shippingCapability(impl) {
485
496
  function suppliersCapability(impl) {
486
497
  return { kind: CapabilityKind.Suppliers, impl };
487
498
  }
499
+ function analyticsCapability(impl) {
500
+ return { kind: CapabilityKind.Analytics, impl };
501
+ }
488
502
  var PLUGIN_FACTORY_BRAND = /* @__PURE__ */ Symbol.for("vivoa.plugin.factory");
489
503
  function definePlugin(factory) {
490
504
  Object.defineProperty(factory, PLUGIN_FACTORY_BRAND, {
@@ -530,7 +544,7 @@ function checkPermissions(required, grantedRaw) {
530
544
  }
531
545
 
532
546
  // src/version.ts
533
- var SDK_VERSION = "0.6.0";
547
+ var SDK_VERSION = "0.6.2";
534
548
  function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
535
549
  const parse = (v) => {
536
550
  const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v);
@@ -547,7 +561,9 @@ function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
547
561
  }
548
562
  // Annotate the CommonJS export names for ESM import in node:
549
563
  0 && (module.exports = {
564
+ ANALYTICS_PLUGIN_TOKEN,
550
565
  ActionVariant,
566
+ AnalyticsFeature,
551
567
  BlockType,
552
568
  CapabilityKind,
553
569
  CodFeeType,
@@ -567,6 +583,7 @@ function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
567
583
  StepStatusFrom,
568
584
  SuppliersFeature,
569
585
  TransactionStatus,
586
+ analyticsCapability,
570
587
  capability,
571
588
  checkPermissions,
572
589
  createPluginConfig,
package/dist/index.mjs CHANGED
@@ -2,6 +2,7 @@
2
2
  var PAYMENT_PLUGIN_TOKEN = "PAYMENT_PLUGINS";
3
3
  var SHIPPING_PLUGIN_TOKEN = "SHIPPING_PLUGINS";
4
4
  var SUPPLIERS_PLUGIN_TOKEN = "SUPPLIERS_PLUGINS";
5
+ var ANALYTICS_PLUGIN_TOKEN = "ANALYTICS_PLUGINS";
5
6
 
6
7
  // src/plugin.ts
7
8
  var PluginType = /* @__PURE__ */ ((PluginType2) => {
@@ -148,6 +149,13 @@ var SuppliersFeature = /* @__PURE__ */ ((SuppliersFeature2) => {
148
149
  return SuppliersFeature2;
149
150
  })(SuppliersFeature || {});
150
151
 
152
+ // src/analytics.ts
153
+ var AnalyticsFeature = /* @__PURE__ */ ((AnalyticsFeature2) => {
154
+ AnalyticsFeature2["Ecommerce"] = "ecommerce";
155
+ AnalyticsFeature2["PageViews"] = "page-views";
156
+ return AnalyticsFeature2;
157
+ })(AnalyticsFeature || {});
158
+
151
159
  // src/setup-layout.ts
152
160
  import {
153
161
  array,
@@ -446,6 +454,9 @@ function shippingCapability(impl) {
446
454
  function suppliersCapability(impl) {
447
455
  return { kind: CapabilityKind.Suppliers, impl };
448
456
  }
457
+ function analyticsCapability(impl) {
458
+ return { kind: CapabilityKind.Analytics, impl };
459
+ }
449
460
  var PLUGIN_FACTORY_BRAND = /* @__PURE__ */ Symbol.for("vivoa.plugin.factory");
450
461
  function definePlugin(factory) {
451
462
  Object.defineProperty(factory, PLUGIN_FACTORY_BRAND, {
@@ -491,7 +502,7 @@ function checkPermissions(required, grantedRaw) {
491
502
  }
492
503
 
493
504
  // src/version.ts
494
- var SDK_VERSION = "0.6.0";
505
+ var SDK_VERSION = "0.6.2";
495
506
  function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
496
507
  const parse = (v) => {
497
508
  const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v);
@@ -507,7 +518,9 @@ function isSdkCompatible(pluginSdkVersion, hostSdkVersion) {
507
518
  return h[1] > p[1] || h[1] === p[1] && h[2] >= p[2];
508
519
  }
509
520
  export {
521
+ ANALYTICS_PLUGIN_TOKEN,
510
522
  ActionVariant,
523
+ AnalyticsFeature,
511
524
  BlockType,
512
525
  CapabilityKind,
513
526
  CodFeeType,
@@ -527,6 +540,7 @@ export {
527
540
  StepStatusFrom,
528
541
  SuppliersFeature,
529
542
  TransactionStatus,
543
+ analyticsCapability,
530
544
  capability,
531
545
  checkPermissions,
532
546
  createPluginConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vivoa/plugin-sdk",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Public contracts for Vivoa plugins (types, DI tokens, config + setup-layout validators)",
5
5
  "license": "MIT",
6
6
  "author": "Vivoa",
@@ -34,14 +34,6 @@
34
34
  "registry": "https://registry.npmjs.org",
35
35
  "access": "public"
36
36
  },
37
- "scripts": {
38
- "build": "tsup src/index.ts --format cjs,esm --dts --clean --target node18",
39
- "dev": "tsup src/index.ts --format cjs,esm --dts --watch --target node18",
40
- "test": "vitest run",
41
- "test:watch": "vitest",
42
- "typecheck": "tsc --noEmit -p tsconfig.json",
43
- "prepublishOnly": "pnpm run typecheck && pnpm run test && pnpm run build"
44
- },
45
37
  "dependencies": {
46
38
  "superstruct": "^2.0.2"
47
39
  },
@@ -51,9 +43,11 @@
51
43
  "typescript": "^5.7.3",
52
44
  "vitest": "^2.1.8"
53
45
  },
54
- "pnpm": {
55
- "onlyBuiltDependencies": [
56
- "esbuild"
57
- ]
46
+ "scripts": {
47
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean --target node18",
48
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch --target node18",
49
+ "test": "vitest run",
50
+ "test:watch": "vitest",
51
+ "typecheck": "tsc --noEmit -p tsconfig.json"
58
52
  }
59
- }
53
+ }