Hyperse
  • Pricing
  • FAQs
Newsletter

Subscribe to our newsletter

Receive weekly updates with latest collections and exclusive offers, straight to your inbox.

Hyperse

Headless commerce solutions for brands, developers, and modern ecommerce teams.

Explore

  • Home
  • About Us
  • Partners
  • FAQs

Legal & resources

  • Proposal
  • Privacy Policy
  • Terms & Conditions

© 2026 Hyperse. All rights reserved.


  1. Home
  2. Vendure Plugins
  3. hps-plugin-campaign
hps-plugin-campaign

hps-plugin-campaign

By Yingchun Tian

hps-plugin-campaign is a Campaign plugin in the Hub Growth group.hps-plugin-campaign provides Campaign plugin capabilities for Hub Growth. Growth, campaigns, loyalty, and customer engagement features. It is especially useful for growth workflows.

CoreVendure Plugins

Specifications

Technical details and package information for this product.

Package

@hyperse-hub/hps-plugin-campaign

Support by

Yingchun Tian

Support languages

TypeScript, JavaScript, CSS, Prolog, Shell

Integration type

Core

Category

Vendure Plugins

Compatible with

^3.0.0

Latest version

1.0.18

Downloads

0

Repository

https://github.com/hyperse-hub/hub-growth

Last published

July 14, 2026

Description
Changelog
loading...

@hyperse-hub/hps-plugin-campaign

Vendure plugin for marketing campaigns: translatable campaign content, optional Vendure promotions, coupon claim flows (with reCAPTCHA), campaign bundles, and storefront helpers on Order, Customer, and Collection.

Requirements

  • Vendure >= 3.6 (plugin compatibility >= 3.0.0)
  • Node >= 16
  • Companion Hyperse plugins used at runtime:
    • @hyperse-hub/hps-plugin-core
    • @hyperse-hub/hps-plugin-email (email templates and job pipeline)
  • The shop API references RecaptchaInput for claim mutations; your combined Shop API schema must define it (for example via another Hyperse/Vendure extension that supplies reCAPTCHA).

Installation

Add the package to your Vendure server project and install peer dependencies (@vendure/core, Nest, GraphQL, TypeORM, etc.) as usual for your stack.

Registering the plugin

Import HpsPluginCampaign and register it together with HpsPluginCore and HpsPluginEmail (the campaign plugin declares these as imports).

Minimal example:

import { HpsPluginCore } from '@hyperse-hub/hps-plugin-core'; import { HpsPluginEmail } from '@hyperse-hub/hps-plugin-email'; import { HpsPluginCampaign } from '@hyperse-hub/hps-plugin-campaign'; export const config = { plugins: [ HpsPluginCore.init({}), HpsPluginEmail.init({/* email plugin options */}), HpsPluginCampaign.init({ // optional — see Configuration }), ], };

Local dev server reference: config/dev-server.ts in this package.

Configuration

Pass options to HpsPluginCampaign.init({ ... }):

OptionTypeDescription
initialCampaignsCreateCampaignInput[] or (ctx: { channelId: string }) => CreateCampaignInput[] | Promise<...>If set, campaigns are upserted on bootstrap (server process), scoped per channel.
facetCampaignConfigFields(defaultFields: StructFieldConfig[]) => StructFieldConfig[]Extend the struct stored on FacetValue.campaignConfigData. Default includes an endsAt datetime field; override to add shop-specific fields (e.g. lens promos).
expiredCouponRetentionDaysnumberDays after coupon endsAt before the scheduled cleanup deletes rows. Default: 90.

Types are declared in HpsPluginCampaignOptions (src/types.ts).

Concepts

Campaign types

CampaignType describes the business pattern (for example direct discount vs. new-user coupon). Values include:

  • DirectDiscount
  • NewUserFixedAmount
  • AllUserFixedAmount
  • BuyXGetYFreeWithLensDiscount
  • NewUserFirstPair

The enum is part of the plugin GraphQL schema and re-exported from the package entry for TypeScript consumers.

Facet for catalog tagging

The plugin defines a facet code constant: CAMPAIGN_FACET_CODE = 'campaign' (see src/constants.ts). Use this facet to tag product variants or attributes that belong to campaign merchandising; optional FacetValue struct field campaignConfigData can hold per-value campaign metadata (end dates, custom promo data).

Promotions and coupons

  • A campaign may reference a Vendure promotionId.
  • When requiresCouponClaim is true, shoppers obtain CampaignCoupon rows via shop mutations; couponValidityDays controls lifetime after claim.
  • Bundles group multiple campaigns and support a single “claim all” flow (claimCampaignBundleCoupons).

Custom fields

Registered on bootstrap:

EntityFieldPurpose
CollectioncampaignOptional relation to Campaign for themed collection / PLP hero content. Public for shop resolution.
FacetValuecampaignConfigDataOptional struct for direct-discount / per-option promo display; shape extended via facetCampaignConfigFields.

GraphQL API (overview)

Admin API

  • Queries: campaign, campaigns, campaignByCode
  • Mutations: createCampaign, updateCampaign, disableCampaign, deleteCampaign
  • Additional admin operations exist for campaign coupons and campaign bundles (list/create/update/delete as defined in the bundled schema).

Inputs include localized CampaignTranslationInput with CampaignClaimFormContentInput and CampaignClaimResultContentInput for landing / post-claim UI copy and assets.

Shop API

  • Queries: campaignByCode, availableCampaigns, campaignBundleByCode
  • Mutations: claimCampaignCoupon, claimCampaignBundleCoupons — both take code, emailAddress, and recaptcha: RecaptchaInput!
  • Extended types:
    • Order.availableCoupons
    • Customer.availableCoupons
    • Collection.campaign

availableCampaigns returns storefront-visible campaigns (enabled + within optional date window). It optionally accepts campaignTypes: [CampaignType!] so clients can group campaigns by campaignType when building coupons pages.

Claim results use CampaignCouponClaimStatus: CREATED, REFRESHED, or REJECTED, with optional message.

Scheduled task

The plugin registers a daily task (midnight cron) clean-expired-campaign-coupons-task that removes expired coupon rows according to expiredCouponRetentionDays.

Email

On bootstrap the plugin registers an external email handler campaign-coupon-claimed with HpsPluginEmail, using templates from the built templates/dist output. Ensure your email plugin is configured (transport, from address, etc.) so claim confirmation emails can be queued.

Events

CampaignCouponEvent is emitted when campaign coupons are created, updated, or deleted (src/events/campaign-coupon-event.ts). Subscribe in your Vendure EventBus for integrations or auditing.

Package exports

From @hyperse-hub/hps-plugin-campaign:

  • HpsPluginCampaign plugin class
  • CampaignType enum type
  • Entities and events (e.g. CampaignCouponEvent)
  • Services: CampaignService, CampaignCouponService, CampaignBundleService, CampaignProductVariantService

License

MIT — see LICENSE.

On this page

  • @hyperse-hub/hps-plugin-campaign
    • Requirements
    • Installation
    • Registering the plugin
    • Configuration
    • Concepts
      • Campaign types
      • Facet for catalog tagging
      • Promotions and coupons
    • Custom fields
    • GraphQL API (overview)
      • Admin API
      • Shop API
    • Scheduled task
    • Email
    • Events
    • Package exports
    • License