@sho-js/cpa

CPA Networks integration

Usage no npm install needed!

<script type="module">
  import shoJsCpa from 'https://cdn.skypack.dev/@sho-js/cpa';
</script>

README

CPA Integration

This packages created fo commercial products of Wearesho Team Should be used in pair with wearesho-team/bobra-cpa back-end

Integrated:

  • SalesDoubler
  • DoAffiliate
  • LoanGate
  • Cashka
  • AdmitAd
  • PrimeLead
  • LeadsSu
  • FinLine
  • Letmeads
  • LeadGid
  • LinkProfit

Installation

Using npm

npm i --save @sho-js/cpa

Usage

Add after page loaded:

import * as Cpa from "@sho-js/cpa";

(new Cpa.Service).onLoad(new URLSearchParams(window.location.search));

Add after you identify user (LoginForm, bootstrap token found):

import * as Cpa from "@sho-js/cpa";
import Raven from "raven-js";

// configure axios baseURL and authorization token here

try {
    (new Cpa.Service(window.location.hostname)).onLogin(
        /** path to back-end should be generated here */
        (source) => `/lead/${source}`
    );
} catch (error) {
    if (process.env.NODE_ENV !== 'production') {
        throw error;
    }
    Raven.captureException(error);
}

Raven usage is optional

Parsers customization

You can override default parsers if default config is incompatible with your application. Implement ParserInterface and specify it in constructor

import * as Cpa from "@sho-js/cpa"

class CustomAdmitAdParser implements Cpa.ParserInterface {
    // implementation
}

const cookieDomain = location.host;
const cpaIntegration = new Cpa.Service(cookieDomain, {
    [Cpa.Type.admitAd]: CustomAdmitAdParser,
})

Add new CPA

To add new CPA:

License

Proprietary