@sho-js/cpa
TypeScript icon, indicating that this package has built-in type declarations

4.0.1 • Public • Published

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

Dependents (0)

Package Sidebar

Install

npm i @sho-js/cpa

Weekly Downloads

16

Version

4.0.1

License

UNLICENSED

Unpacked Size

30.6 kB

Total Files

22

Last publish

Collaborators

  • horat1us
  • sashabeton