0.0.2 • Published 5 months ago

@credenza3/ads v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Credenza3 Ads

Dependencies

Credenza Passport EVM OR Credenza Passport SUI

Installation

with npm

npm install @credenza3/ads

with yarn

yarn add @credenza3/ads

with pnpm

pnpm install @credenza3/ads

or include a script tag

<script src="https://cdn.jsdelivr.net/npm/@credenza3/ads/dist/ads.umd.js"></script>
<script>
  const Ads = window.CredenzaAds
</script>

or with esm

<script type="module">
  import {Ads} from 'https://cdn.jsdelivr.net/npm/@credenza3/ads/+esm'
</script>

Usage

Create the Ads instance

const ads = new Ads(passport) // instance of credenza passport

Static

Ads.ContractTypes (object) Current package version

Methods

activate

const id = ads.activate({
  querySelector: '#container',
  // triggers when the ad is clicked. Returns the rule if matched.
  onClick: ({isOfferMatched}: {isOfferMatched: boolean}) => {
    console.log(isOfferMatched);
  },
  // default snippets for logged in /logged out users
  basicSnippets: {
    loggedIn: string, //html string
    loggedOut: string //html string
  },
  offer: {
    id: string,
    snippet: string // html string
  }
})

deactivate

ads.deactivate(id)
0.0.2

5 months ago

0.0.1

5 months ago