Code Monkey home page Code Monkey logo

client's Introduction

AppSero Client

Version 2.0.2

Installation

You can install AppSero Client in two ways, via composer and manually.

1. Composer Installation

Add dependency in your project (theme/plugin):

composer require appsero/client

Now add autoload.php in your file if you haven't done already.

require __DIR__ . '/vendor/autoload.php';

2. Manual Installation

Clone the repository in your project.

cd /path/to/your/project/folder
git clone https://github.com/AppSero/client.git appsero

Now include the dependencies in your plugin/theme.

if( !class_exists('Appsero\Client') ) {
    require __DIR__ . '/appsero/src/Client.php';
}

Insights

AppSero can be used in both themes and plugins.

The Appsero\Client class has three parameters:

$client = new Appsero\Client( $hash, $name, $file );
  • hash (string, required) - The unique identifier for a plugin or theme.
  • name (string, required) - The name of the plugin or theme.
  • file (string, required) - The main file path of the plugin. For theme, path to functions.php

Usage Example

Please refer to the installation step before start using the class.

You can obtain the hash for your plugin for the Appsero Dashboard. The 3rd parameter must have to be the main file of the plugin.

/**
 * Initialize the tracker
 *
 * @return void
 */
function appsero_init_tracker_appsero_test() {

    if ( ! class_exists( 'Appsero\Client' ) ) {
        require_once __DIR__ . '/appsero/src/Client.php';
    }

    $client = new Appsero\Client( 'a4a8da5b-b419-4656-98e9-4a42e9044891', 'Akismet', __FILE__ );

    // Active insights
    $client->insights()->init();

    // Active license page and checker
    $args = array(
        'type'       => 'options',
        'menu_title' => 'Akismet',
        'page_title' => 'Akismet License Settings',
        'menu_slug'  => 'akismet_settings',
    );
    $client->license()->add_settings_page( $args );
}

appsero_init_tracker_appsero_test();

Make sure you call this function directly, never use any action hook to call this function.

For plugins example code that needs to be used on your main plugin file. For themes example code that needs to be used on your themes functions.php file.

Using the Updater (to manage Pro plugin updates)

By default the Appsero client doesn't include Updater functionalities in this client. If you want to manage updates for your premium plugins, please include the Updater separately inside your product

More Usage

$client = new Appsero\Client( 'a4a8da5b-b419-4656-98e9-4a42e9044892', 'Twenty Twelve', __FILE__ );

1. Hiding the notice

Sometimes you wouldn't want to show the notice, or want to customize the notice message. You can do that as well.

$client->insights()
       ->hide_notice()
       ->init();

2. Customizing the notice message

$client->insights()
       ->notice( 'My Custom Notice Message' )
       ->init();

3. Adding extra data

You can add extra metadata from your theme or plugin. In that case, the keys has to be whitelisted from the Appsero dashboard. add_extra method also support callback as parameter, If you need database call then callback is best for you.

$metadata = array(
    'key'     => 'value',
    'another' => 'another_value'
);
$client->insights()
       ->add_extra( $metadata )
       ->init();

Or if you want to run a query then pass callback, we will call the function when it is necessary.

$metadata = function () {
    $total_posts = wp_count_posts();

    return array(
        'total_posts' => $total_posts,
        'another'     => 'another_value'
    );
};
$client->insights()
       ->add_extra( $metadata )
       ->init();

4. Set textdomain

You may set your own textdomain to translate text.

$client->set_textdomain( 'your-project-textdomain' );

5. Get Plugin Data

If you want to get the most used plugins with your plugin or theme, send the active plugins' data to Appsero.

$client->insights()
       ->add_plugin_data()
       ->init();

6. Set Notice Message

Change opt-in message text

$client->insights()
       ->notice("Your custom notice text")
       ->init();

Check License Validity

Check your plugin/theme is using with valid license or not, First create a global variable of License object then use it anywhere in your code. If you are using it outside of same function make sure you global the variable before using the condition.

$client = new Appsero\Client( 'a4a8da5b-b419-4656-98e9-4a42e9044892', 'Twenty Twelve', __FILE__ );

$args = array(
    'type'        => 'submenu',
    'menu_title'  => 'Twenty Twelve License',
    'page_title'  => 'Twenty Twelve License Settings',
    'menu_slug'   => 'twenty_twelve_settings',
    'parent_slug' => 'themes.php',
);

global $twenty_twelve_license;
$twenty_twelve_license = $client->license();
$twenty_twelve_license->add_settings_page( $args );

if ( $twenty_twelve_license->is_valid()  ) {
    // Your special code here
}

Or check by pricing plan title

if ( $twenty_twelve_license->is_valid_by( 'title', 'Business' ) ) {
    // Your special code here
}

// Set custom options key for storing the license info
$twenty_twelve_license->set_option_key( 'my_plugin_license' );

Use your own license form

You can easily manage license by creating a form using HTTP request. Call license_form_submit method from License object.

global $twenty_twelve_license; // License object
$twenty_twelve_license->license_form_submit([
    '_nonce'      => wp_create_nonce( 'Twenty Twelve' ), // create a nonce with name
    '_action'     => 'active', // active, deactive
    'license_key' => 'random-license-key', // no need to provide if you want to deactive
]);
if ( ! $twenty_twelve_license->error ) {
    // license activated
    $twenty_twelve_license->success; // Success message is here
} else {
    $twenty_twelve_license->error; // has error message here
}

Set Custom Deactivation Reasons

First set your deactivation reasons in Appsero dashboard then map them in your plugin/theme using filter hook.

  • id is the deactivation slug
  • text is the deactivation title
  • placeholder will show on textarea field
  • icon You can set SVG icon with 23x23 size
add_filter( 'appsero_custom_deactivation_reasons', function () {
    return [
        [
            'id'          => 'looks-buggy',
            'text'        => 'Looks buggy',
            'placeholder' => 'Can you please tell which feature looks buggy?',
            'icon'        => '',
        ],
        [
            'id'          => 'bad-ui',
            'text'        => 'Bad UI',
            'placeholder' => 'Could you tell us a bit more?',
            'icon'        => '',
        ],
    ];
} );


Extended Actions

1. After allowing tracking permission

// Fires after tracking permission allowed (optin)
function sample_tracker_optin(array $data){
    // use data, as it's now permitted to send anywhere
    // Like FLuentCRM
}
add_action('PLUGIN_OR_THEME_SLUG_tracker_optin', 'sample_tracker_optin', 10);

2. After dening tracking permission

// Fires after tracking permission denied (optout)
function sample_tracker_optout(){
    // Don't ask for further permission, respect user's decision 
}
add_action('PLUGIN_OR_THEME_SLUG_tracker_optout', 'sample_tracker_optout', 10);

3. After license is activated

// Fires after license is activated successfully
function sample_license_activated(array $response){
    // use response
    // response has license information
    // Like FLuentCRM
}
add_action('PLUGIN_OR_THEME_SLUG_license_activated', 'sample_license_activated', 10);

4. After license is deactivated

// Fires after license deactivated successfully
function sample_license_deactivated(array $response){
    // use response
    // response has license information
}
add_action('PLUGIN_OR_THEME_SLUG_license_deactivated', 'sample_license_deactivated', 10);

5. After license is refreshed

// Fires after license refreshed successfully
function sample_license_refreshed(){
    // license just refreshed
}
add_action('PLUGIN_OR_THEME_SLUG_license_refreshed', 'sample_license_refreshed', 10);

6. After uninstall reason is submitted

// Fires after uninstall reason submitted
function sample_uninstall_reason_submitted(array $data){
    // use the data
    // Like FLuentCRM
}
add_action('PLUGIN_OR_THEME_SLUG_uninstall_reason_submitted', 'sample_uninstall_reason_submitted', 10);

Credits

Created and maintained by Appsero.

client's People

Contributors

afragen avatar anisaronno avatar bdmehedi avatar dovy avatar imjafran avatar kevinbatdorf avatar nurul-umbhiya avatar saiftheboss7 avatar sourovroy avatar tareq1988 avatar vairafiq 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

client's Issues

Notice messaging is misleading

The wording that is output in the admin notice is maybe a bit misleading.

The notice states that "Site name and Url, your name and email address" are collected. Then immediately states "No sensitive data is tracked".

Screen Shot 2023-04-07 at 1 59 09 PM

I've had users argue that "name and email" are sensitive data and that the messaging here is misleading.

Appsero SDK should work on localhost

https://www.youtube.com/watch?v=zVo13fZw9gM

As the video shows, the popup while deactivating a plugin should come even if the plugin is on localhost. In recent release of the SDK,

  • if a plugin is being deactivated, the Appsero deactivation popup doesn't trigger
  • If a plugin is being installed for the first time, Appsero opt-in top bar doesn't trigger. We need to fix the functionality.

(However, on Appsero Helper end, there should be check so that user cannot add localhost site on Appsero Dashboard. This is not related to SDK implementation)

Appsero SDK Integration is Not Working

Active a Plugin (Managed with Appsero) -> User Data Collection Consent Pop-Up is functionally not working (Pop-Up reappears for both Allow/ No Thanks action and is not closing)
Appsero Dashboard -> Showing SDK Integration is failed

About PLUGIN_OR_THEME_SLUG_license_activated hook

Hi there,

I attempted to do something after activating the license. I used the hook PLUGIN_OR_THEME_SLUG_license_activated as documented, but it seems it doesn't work. I searched the codebase and couldn't find the hook. Which hook should I use when activating the license? Thanks for your help.

i18n for admin menu title

Hi there,

I attempted to localize the page title and discovered that the admin menu title "License Settings" lacks the __trans function. Could you assist me in adding that in the next release? Thank you.
CleanShot 2024-02-21 at 17 36 34

Send list of plugins

Currently the SDK doesn't send the list of plugins (active/inactive). It should send those info as well.

Interested to contribute

We have some extended integration with appsero that requires adding some additional hooks for our purposes, like optin/optout, license activation, deactivation and refreshing.
Also, for manual installation, it conflicts with same library with different project (as the files are loaded more than one time, conflicts the class names).

Could you please allow me to contribute with a new branch?

Make translatable the strings

Hello,
All strings cannot be translated. It should use the text domain of the plugin, in order to translate in translate.wordpress.org.

Regards

PHP Documentation Error

The data type specified in @return tag is wrong for the method Appsero\Insights::data_we_collect. It should be array instead of string.

Current:

/**
 * Explain the user which data we collect
 *
 * @return string
 */

Expected:

/**
* Explain the user which data we collect
*
* @return array
*/

appsero website - app - does not remove the payment card

hello team at WeDevs

look, i have the following situation and I'm really mad at it

last month probably around the middle of the last month, i removed my card from appsero dashboard, to cancel the subscription, as i no longer wish to pay for appsero premium, what is my surprise when today i receive a notification from my bank application, saying that 25 dollars was removed from my card to pay appsero.....

what my surprise that now i go there and i see the card back, the subscription, everything is back there
so my question is, the cancel subscription button is there doing what? a fake button?
did you had a problem on your platform and recovered with a backup? because if so, i got charged by mistake. i canceled the subscription last month, and last week i made sure to go login and check the dashboard to be sure i was at no mistake

is this a joke?

You guys have problem to make your SDK recognize and work in localhost
you guys have problem to make your SDK recognize tracking on the plugin and the stats
basically your SDK does not give any information to the dashboard and people are going blind

and you are not able to have the cards removed from a subscription, when people remove the cards through dashboard
is this sort of a joke?

Im waiting that your website appsero.com comes back online so i can go there and open a support ticket to ask the refund for a product that i wanted no longer to pay, that i removed my card, and no money should had been taken from me
Right now your website is with a 502 bad gateway

Bad gateway Error code 502
Visit cloudflare.com for more information.
2023-11-04 13:37:18 UTC
You
Browser
Working
Madrid
Cloudflare
Working
appsero.com
Host
Error

but expect me to contact you as soon as it is online and I'm going to get the 25 dollars back, believe me, otherwise a law suit will fall on you, I'm not joking, I'm starting to get tired of bad service and bad moves on the wordpress plugins and service providers.

Make pot failed.

Hi there,

I tried to generate the .pot of appsero client but failed. I was sure that I have use $client->set_textdomain method to set my text domain and used the wp cli make-pot to generate. But the .pot file still can't grab the translated string. Could you help me how to process the .pot file? Thanks for your help.

PHP Notice when using WP CLI

PHP Notice:  Undefined index: HTTP_HOST in [...]/includes/modules/appsero/src/Insights.php on line 359
PHP Notice:  Undefined index: SERVER_ADDR in [...]/includes/modules/appsero/src/Insights.php on line 360

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.