CustomerIOSharp 1.0.0.26

Implementation of Customer.io's write-only API for .NET.

Install-Package CustomerIOSharp -Version 1.0.0.26
dotnet add package CustomerIOSharp --version 1.0.0.26
<PackageReference Include="CustomerIOSharp" Version="1.0.0.26" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CustomerIOSharp --version 1.0.0.26
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Customer.io API C# implementation

Implementation of Customer.io's write-only API for .NET.

Installation

Using Nuget:

Install-Package CustomerIOSharp

Usage

We recommend you implement the ICustomerFactory interface yourself. Here is a suggested implementation used in one of my projects:

    public class CustomerFactory : ICustomerFactory
    {
        public ICustomerDetails GetCustomerDetails()
        {
            var user = MembershipHelper.GetCurrentUser();
            return user == null 
                ? null 
                : user.AsCustomer();
        }

        public string GetCustomerId()
        {
            var user = MembershipHelper.GetCurrentUser();
            return user == null
                ? null
                : user.UserId.ToString();
        }
    }

Then instantiate CustomerIo and call IdentifyAsync():

var customerIo = new CustomerIo(
    "siteid", 
    "apikey", 
    new CustomerFactory());
await customerIo.IdentifyAsync();

You should most likely only call IdentifyAsync() whenever the user logs in or is changed.

If you do not want to implement ICustomerFactory, you can simply provide the required details to each call:

await customerIo.IdentifyAsync(User.AsCustomer());

Whatever you do, you will have to provide customer data implementing ICustomerDetails. It has only two required properties, but any properties you supply in your implementation will be forwarded to customer.io:

public class Customer : ICustomerDetails 
{
    // these two fields are required:
    public string Id { get; set; }
    public string Email { get; set; }
    // these are my custom fields:
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

Custom events

Track a custom event by calling TrackEvent(). It takes an event name as the first parameter, the second parameter is any serializable object. Note that it automatically posts using the correct customer (using ICustomerFactory), but you can also supply your own.

await customerIo.TrackEventAsync("signup", new {
	UserGroup = "trial",
	Referrer = "email campaign"
});

// this event has no data and uses a different customer
await customerIo.TrackEventAsync("signup", customerId: "foo");

Note that these two variables will be camelcased before being sent to customer.io, so userGroup and referrer will be available in your transactional campaigns.

License

Dual licensed under the MIT and the GPL license.

You don’t have to do anything special to choose one license or the other and you don’t have to notify anyone which license you are using.

MIT license

The MIT License (MIT)

Copyright (c) 2013-2017 Digital Creations AS.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

GPL license

Copyright (c) 2013-2017 Digital Creations AS.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Customer.io API C# implementation

Implementation of Customer.io's write-only API for .NET.

Installation

Using Nuget:

Install-Package CustomerIOSharp

Usage

We recommend you implement the ICustomerFactory interface yourself. Here is a suggested implementation used in one of my projects:

    public class CustomerFactory : ICustomerFactory
    {
        public ICustomerDetails GetCustomerDetails()
        {
            var user = MembershipHelper.GetCurrentUser();
            return user == null 
                ? null 
                : user.AsCustomer();
        }

        public string GetCustomerId()
        {
            var user = MembershipHelper.GetCurrentUser();
            return user == null
                ? null
                : user.UserId.ToString();
        }
    }

Then instantiate CustomerIo and call IdentifyAsync():

var customerIo = new CustomerIo(
    "siteid", 
    "apikey", 
    new CustomerFactory());
await customerIo.IdentifyAsync();

You should most likely only call IdentifyAsync() whenever the user logs in or is changed.

If you do not want to implement ICustomerFactory, you can simply provide the required details to each call:

await customerIo.IdentifyAsync(User.AsCustomer());

Whatever you do, you will have to provide customer data implementing ICustomerDetails. It has only two required properties, but any properties you supply in your implementation will be forwarded to customer.io:

public class Customer : ICustomerDetails 
{
    // these two fields are required:
    public string Id { get; set; }
    public string Email { get; set; }
    // these are my custom fields:
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

Custom events

Track a custom event by calling TrackEvent(). It takes an event name as the first parameter, the second parameter is any serializable object. Note that it automatically posts using the correct customer (using ICustomerFactory), but you can also supply your own.

await customerIo.TrackEventAsync("signup", new {
	UserGroup = "trial",
	Referrer = "email campaign"
});

// this event has no data and uses a different customer
await customerIo.TrackEventAsync("signup", customerId: "foo");

Note that these two variables will be camelcased before being sent to customer.io, so userGroup and referrer will be available in your transactional campaigns.

License

Dual licensed under the MIT and the GPL license.

You don’t have to do anything special to choose one license or the other and you don’t have to notify anyone which license you are using.

MIT license

The MIT License (MIT)

Copyright (c) 2013-2017 Digital Creations AS.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

GPL license

Copyright (c) 2013-2017 Digital Creations AS.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Release Notes

Removes dependency on FubarCoder.RestSharp.Portable, and is now multi-targeting netstandard1.1 and netstandard2.0

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.0.26 3,399 10/12/2017
0.5.0 14,691 9/30/2015
0.4.1 386 6/22/2015
0.4.0 420 4/24/2015
0.3.0 1,123 8/12/2014
0.2.1 716 5/21/2013
0.2.0 464 5/21/2013
0.1.0 447 5/15/2013