Socket
Book a DemoInstallSign in
Socket

@corca-ai/ads

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@corca-ai/ads

## NPM

0.0.2
latest
npmnpm
Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

Installation

NPM

Install @corca-ai/ads with your package manager.

yarn add @corca-ai/ads
npm install @corca-ai/ads
pnpm add @corca-ai/ads

Usage

Initialize CorcaAds

Initialize the class CorcaAds with your storeId and customerId. You can find storeId in the account management page.

import { CorcaAds } from "@corca-ai/ads";

const corcaAds = new CorcaAds({ storeId: "...", customerId: "..." });

Set Customer ID

You can set customerId to track the user's behavior.

corcaAds.setCustomerId("...");

Log Collection

Page view

await corcaAds.onPageView({ productId: "1234" });

Add to cart

await corcaAds.onAddToCart({ productId: "1234", quantity: 1 });

Purchase

await corcaAds.onPurchase({
  orderId: "20231114010101",
  amount: 29900,
  items: [
    { productId: "1234", quantity: 1 },
  ],
});

Example

import { corcaAds } from "@corca-ai/ads";

const useCorcaAds = () => {
  const [corcaAds, setCorcaAds] = useState<CorcaAds>();
  const { me } = useFetchMe();

  useEffect(() => {
    const corcaAds = new CorcaAds({ storeId: "..." });
    setCorcaAds(corcaAds);
  }, []);

  useEffect(() => {
    if (corcaAds && me) {
      corcaAds.setCustomerId(me?.id);
    }
  }, [corcaAds, me]);

  return corcaAds;
};

export function ProductDetailPage(props: { params: { productId: string } }) {
  const corcaAds = useCorcaAds();

  useEffect(() => {
    if (corcaAds) {
      corcaAds.onPageView({ productId: props.params.productId });
    }
  }, [corcaAds]);

  return (
    <div>
      ...
    </div>
  );
}

FAQs

Package last updated on 24 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.