Skip to content

Instantly share code, notes, and snippets.

View arasmussen's full-sized avatar

Andrew Rasmussen arasmussen

View GitHub Profile
componentDidMount() {
initializeCannyChangelog();
}
function initializeCannyChangelog() {
// Load Canny SDK
!function(w,d,i,s){function l(){if(!d.getElementById(i)){var f=d.getElementsByTagName(s)[0],e=d.createElement(s);e.type="text/javascript",e.async=!0,e.src="https://canny.io/sdk.js",f.parentNode.insertBefore(e,f)}}if("function"!=typeof w.Canny){var c=function(){c.q.push(arguments)};c.q=[],w.Canny=c,"complete"===d.readyState?l():w.attachEvent?w.attachEvent("onload",l):w.addEventListener("load",l,!1)}}(window,document,"canny-jssdk","script");
// Find changelog button
const spanTags = document.getElementsByTagName('span');
@arasmussen
arasmussen / CannyWidget.js
Created October 21, 2019 14:23
Render Canny's feedback widget in ReactJS
import PropTypes from 'prop-types';
import React, { Component } from 'react';
const BoardToken = 'YOUR_BOARD_TOKEN';
export default class CannyWidget extends Component {
static contextTypes = {
viewer: PropTypes.shape({
ssoToken: PropTypes.string,
}),
@arasmussen
arasmussen / CannyContainer.js
Last active November 11, 2021 18:49
Canny: Identifying your users with React
import PropTypes from 'prop-types';
import { Component } from 'react';
const AppID = 'Your App ID';
function loadCannySDK() {
!function(w,d,i,s){function l(){if(!d.getElementById(i)){var f=d.getElementsByTagName(s)[0],e=d.createElement(s);e.type="text/javascript",e.async=!0,e.src="https://canny.io/sdk.js",f.parentNode.insertBefore(e,f)}}if("function"!=typeof w.Canny){var c=function(){c.q.push(arguments)};c.q=[],w.Canny=c,"complete"===d.readyState?l():w.attachEvent?w.attachEvent("onload",l):w.addEventListener("load",l,!1)}}(window,document,"canny-jssdk","script");
}
export default class CannyContainer extends Component {
@arasmussen
arasmussen / podia_canny.js
Last active May 3, 2019 16:18
Podia + Canny install
<script type="text/javascript">
// Add this to the "Website tracking code" section
setTimeout(function() {
if (Podia.Customer) {
// Download the Canny SDK
!function(w,d,i,s){function l(){if(!d.getElementById(i)){var f=d.getElementsByTagName(s)[0],e=d.createElement(s);e.type="text/javascript",e.async=!0,e.src="https://canny.io/sdk.js",f.parentNode.insertBefore(e,f)}}if("function"!=typeof w.Canny){var c=function(){c.q.push(arguments)};c.q=[],w.Canny=c,"complete"===d.readyState?l():w.attachEvent?w.attachEvent("onload",l):w.addEventListener("load",l,!1)}}(window,document,"canny-jssdk","script");
// Identify your user
Canny('identify', {
appID: 'YOUR_APP_ID',
@arasmussen
arasmussen / CannySDK.js
Created April 4, 2019 15:00
React example of the widget embed
const CannySDK = {
init: () => {
(function(w, d, i, s) {
if (typeof w.Canny === 'function') {
return;
}
var c = function(){
c.q.push(arguments);
};
@arasmussen
arasmussen / ExternalRedirect.js
Created April 2, 2019 19:42
External redirects for react-router 3.x
import React, { Component, PropTypes } from 'react';
// This file is heavily based on:
// https://github.com/ReactTraining/react-router/blob/v3/modules/Redirect.js
export default class ExternalRedirect extends Component {
static propTypes = {
from: PropTypes.string.isRequired,
to: PropTypes.string.isRequired,
};
function custom_url_rewrite_inbound(&$result, $path, $path_language) {
if (strpos($path, 'feedback/feature-requests') === 0 ||
strpos($path, 'feedback/bug-reports') === 0 ||
strpos($path, 'feedback/feedback-suggestions') === 0 ||
strpos($path, 'feedback/portfolio-reviews') === 0) {
$result = 'node/54'; return;
}
}
<script>!function(w,d,i,s){function l(){if(!d.getElementById(i)){var f=d.getElementsByTagName(s)[0],e=d.createElement(s);e.type="text/javascript",e.async=!0,e.src="https://canny.io/sdk.js",f.parentNode.insertBefore(e,f)}}if("function"!=typeof w.Canny){var c=function(){c.q.push(arguments)};c.q=[],w.Canny=c,"complete"===d.readyState?l():w.attachEvent?w.attachEvent("onload",l):w.addEventListener("load",l,!1)}}(window,document,"canny-jssdk","script");</script>
<script type="text/javascript">
Canny('identify', {
appID: '5ada60c895e6667ef5f73ac6',
user: {
//avatarURL: viewer.avatarURL, // optional
//created: new Date(viewer.created).toISOString(), // optional
email: '<?php echo $_SESSION['email']; ?>',
id: <?php echo $accountID; ?>,
companies: [{
<div data-canny />
<script>!function(w,d,i,s){function l(){if(!d.getElementById(i)){var f=d.getElementsByTagName(s)[0],e=d.createElement(s);e.type="text/javascript",e.async=!0,e.src="https://canny.io/sdk.js",f.parentNode.insertBefore(e,f)}}if("function"!=typeof w.Canny){var c=function(){c.q.push(arguments)};c.q=[],w.Canny=c,"complete"===d.readyState?l():w.attachEvent?w.attachEvent("onload",l):w.addEventListener("load",l,!1)}}(window,document,"canny-jssdk","script");</script>
<script>
Canny('render', {
boardToken: '6855559e-96a4-1cf9-4752-560c9936074e',
basePath: '/listify-customer-feature-requests/',
ssoToken: null, // See step 3
});
</script>
@arasmussen
arasmussen / canny.py
Last active March 24, 2017 17:39 — forked from mattbasta/canny.py
import binascii
import hashlib
import json
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.ciphers import algorithms, Cipher, modes
from django.conf import settings
from pinecast.helpers import gravatar