Giter Club home page Giter Club logo

affiliate's Introduction

Hi 👋, I'm Russell.

My Toolset

React  Material UI  Go  CSS  HTML  TypeScript  JavaScript  Gatsby  NodeJS  Terraform  Sass  MongoDB  Git

Certifications

affiliate's People

Contributors

dependabot[bot] avatar russellsteadman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

affiliate's Issues

Decouple affiliate utilities from DOM functionality

Hi,

I'm very interested in the library but I think it would be better to separate the affiliate utilities from the DOM related functionality. This way could be used for more projects, for example, creating the affiliates in a backend with Node where the DOM functionality is not needed. Also, both packages could be maintained independently.

I've been doing tests and got it to work without the DOM functionality using the 'convert' function but still this code is loaded in the application.

const aff = window.Affiliate.create({
  tags: [
    {
      hosts: ['amazon.es', 'www.amazon.es'],
      query: {
        tag: 'my-super-affiliate', // This means ?ref=my-tag
      },
    },
  ],
});

console.log(aff.convert('https://www.amazon.es/LEGO-10212-Star-Lanzadera-imperial/dp/B0041I0N9A/?_encoding=UTF8&pd_rd_w=Mqdi6&content-id=amzn1.sym.dfbf490a-d858-4445-bf49-2916dec94084&pf_rd_p=dfbf490a-d858-4445-bf49-2916dec94084&pf_rd_r=XAQC9NM704AV77FZ278M&pd_rd_wg=rmQ9K&pd_rd_r=e03e1afd-e5f6-426d-90ef-602a0a48d39b&ref_=pd_gw_ci_mcx_mr_hp_atf_m&tag=test')); // convert a provided URL or string
console.log(aff.convert('https://www.amazon.es/dp/B0041I0N9A')); // convert a provided URL or string

// Output
"https://www.amazon.es/LEGO-10212-Star-Lanzadera-imperial/dp/B0041I0N9A/?_encoding=UTF8&pd_rd_w=Mqdi6&content-id=amzn1.sym.dfbf490a-d858-4445-bf49-2916dec94084&pf_rd_p=dfbf490a-d858-4445-bf49-2916dec94084&pf_rd_r=XAQC9NM704AV77FZ278M&pd_rd_wg=rmQ9K&pd_rd_r=e03e1afd-e5f6-426d-90ef-602a0a48d39b&ref_=pd_gw_ci_mcx_mr_hp_atf_m&tag=my-super-affiliate"
"https://www.amazon.es/dp/B0041I0N9A?tag=my-super-affiliate"

What do you think of my proposal?

Thank you very much for the work, and I am willing to collaborate in the project if you need my help or I see something to improve 🚀

Typescript?

First off, thank you for building Affiliate. It's got a pretty ergonomic API and does exactly what it says on the box.

Now, I use Affiliate on a few websites for clients of my side hustle. The sites use a pretty common stack: Next.js (React.js) w/ TypeScript & a headless CMS of some sort. Because I use TS, I try to keep all my dependencies typed if I can. One of the few dependencies that I currently make an exception for is Affiliate because it's basically the only game in town.

So, the reason for this issue is to let you know I'd really appreciate Typescript support. If it's a non-starter I totally get it, but I figured it'd be worthwhile to show support for adding it just in-case you were on the fence about it.

How to use programmatically?

Let's say I have a simple form with an input field where I would insert an Amazon product URL https://www.amazon.com/dp/B01MRZFBBH

On form submit, I would like this Amazon product URL to turn into https://www.amazon.com/dp/B01MRZFBBH?tag=us-tag and display below the form to the end user to copy.

How can I accomplish that with this library?

[Affiliate] TypeError: e.set is not a function

Hi @russellsteadman,

I'm implementing now Affiliate and AffiliatePluginAmazon with the intention to use the new aff.convert() method, added in v5 after our last thread here: #31 (comment)

However, as I'm putting it all together in my React app, I noticed it is throwing me out an error in the console when the aff.convert() method is called.

2023-02-12_17-09

I'm adding below parts of the relevant Affiliate and AffiliatePluginAmazon code for a greater context of what I have running over here that produce this error.

// ...

import Affiliate from "affiliate";
import AffiliatePluginAmazon from "affiliate-plugin-amazon";

// ...

const amazonAff = AffiliatePluginAmazon(Affiliate, {
    tags: {
      us: "amzapplink-20", // for USA, required
      gb: "", // for UK
      de: "", // for Germany
      fr: "", // for France
      jp: "", // for Japan
      ca: "", // for Canada
      cn: "", // for China
      it: "", // for Italy
      es: "", // for Spain
      in: "", // for India
      br: "", // for Brazil
      mx: "", // for Mexico
    },
    debug: false, // verbose logging into the console, default off
    locale: null, // manually set the country code of the browser, default automatic
    modifyDomain: true, // modify domains like amazon.com to amazon.co.uk based on locale, default on
  });
  
// ...

// Testing convert function.
console.log(amazonAff.convert("https://www.amazon.com"));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.