@sho-js/cpa
v4.0.1
Published
CPA Networks integration
Downloads
2
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:
- Create parser in src/
- Add your parser to index.ts exports
- Add your parser to Type.ts enum
- Add your parser to Service.parsers
- Extend CPA networks list in README
License
Proprietary