@qredex/vue

Vue wrapper for Qredex Agent
1,817
Install
npm install @qredex/vue
Latest Version:1.1.5
Vue:3
License:Apache-2.0
Last Updated:May 26, 2026
Links: GitHub  ·  npm
Maintainer: bobai

@qredex/vue

Thin Vue bindings for @qredex/agent.

CI Release npm version license

Install

npm install @qredex/vue

Attribution Flow

Vue wrapper attribution flow

Call useQredexAgent(), then forward merchant cart state with agent.handleCartChange(...), read the PIT with agent.getPurchaseIntentToken(), and clear attribution with agent.handleCartEmpty(). Only call agent.handlePaymentSuccess() if your platform has no cart-empty step after checkout.

Merchant Integration Checklist

  • Register the plugin once in the browser app
  • Report every real merchant cart transition with agent.handleCartChange(...)
  • Read PIT during checkout or order assembly
  • Send order + PIT to your backend or direct ingestion path
  • Clear attribution with agent.handleCartEmpty() or agent.handlePaymentSuccess()

Register the plugin once, then use useQredexAgent() inside the cart surface you already control. The merchant still owns cart APIs, totals, checkout, and order submission. Qredex only needs the cart transition so the core runtime can lock IIT to PIT. After lock, the merchant reads that PIT and carries it with the normal order payload to the merchant backend or direct Qredex ingestion path.

// main.ts
import { createApp } from 'vue';
import App from './App.vue';
import { createQredexPlugin } from '@qredex/vue';

const app = createApp(App);
app.use(createQredexPlugin());
app.mount('#app');
<script setup lang="ts">
import { ref, watch } from 'vue';
import { useQredexAgent } from '@qredex/vue';

const { agent, state } = useQredexAgent();
const itemCount = ref(0);
const previousCount = ref(0);

watch(itemCount, (nextCount) => {
  // [Qredex] Report the cart transition after your merchant cart changes.
  agent.handleCartChange({
    itemCount: nextCount,
    previousCount: previousCount.value,
  });

  // [Merchant] Keep your local snapshot ready for the next transition.
  previousCount.value = nextCount;
}, { immediate: true });

async function clearCart() {
  // [Merchant] Clear the real cart in your own backend/storefront first.
  await fetch('/api/cart/clear', {
    method: 'POST',
  });

  // [Qredex] Clear attribution because the merchant cart is now empty.
  agent.handleCartEmpty();
}

async function submitOrder() {
  // [Qredex] Read PIT from wrapper state, with the core runtime as fallback.
  const pit = state.value.pit ?? agent.getPurchaseIntentToken();

  // [Merchant] Send the PIT as part of your normal order payload so the
  // backend can carry order + PIT into attribution ingestion.
  await fetch('/api/orders', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      orderId: 'order-123',
      qredex_pit: pit,
    }),
  });

  // [Merchant + Qredex] Reuse the same clear path after checkout succeeds.
  await clearCart();
}
</script>

<template>
  <div>
    <span>Qredex status: {{ state.locked ? 'locked' : 'waiting' }}</span>
    <button @click="clearCart">Clear cart</button>
    <button :disabled="!state.hasPIT" @click="submitOrder">
      Send PIT to backend
    </button>
  </div>
</template>

What To Call When

Merchant event Call Why
Cart becomes non-empty agent.handleCartChange({ itemCount, previousCount }) Gives Qredex the live cart state so IIT can lock to PIT
Cart changes while still non-empty agent.handleCartChange(...) Safe retry path on the next merchant-reported non-empty cart event if a previous lock failed
Clear cart action clearCart() -> agent.handleCartEmpty() Clears IIT/PIT from the live session
Need PIT for order submission state.value.pit or agent.getPurchaseIntentToken() Attach PIT to the checkout payload
Checkout completes without a cart-empty step agent.handlePaymentSuccess() Optional explicit cleanup path

API Surface

Export Use
createQredexPlugin() Registers the core agent in the Vue app
useQredexAgent() Primary Vue composable. Returns { agent, state }
useQredex() Deprecated alias for useQredexAgent()
useInjectedQredexAgent() Direct access to the injected agent
getQredexAgent() Direct access to the singleton runtime
initQredex() Explicit browser init when needed
QredexAgent Re-export of the core agent

Related Packages

@skoup/analytics-nuxt

Skoup Analytics for Nuxt 3 — a module: page views on navigation, useSkoup() ever...

630 1
@skoup/analytics-vue

Skoup Analytics for Vue 3 — plugin, composable, page views on router navigation.

497 1
@alexpodify/browser-sdk

BotCiu browser tracker — public, privacy-first interaction events (page/listing...

469
@indiebob/tracker

Privacy-first analytics SDK for web applications. <5KB gzipped. No cookies.

1,131
@nurdd/web-sdk

Framework-agnostic attribution & analytics SDK for the browser. Works with Vanil...

661

Version History

Version Released Vue License
1.1.5 ^3.4.0 Apache-2.0
1.1.4 ^3.4.0 Apache-2.0
1.1.3 ^3.4.0 Apache-2.0
1.1.2 ^3.4.0 Apache-2.0
1.1.1 ^3.4.0 MIT