This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
(function () { | |
var analytics = window.analytics | |
if (!analytics) return | |
var appInstallButton = document.querySelectorAll('.js-partner-tracking'); | |
analytics.ready(function () { | |
ga('create', 'UA-REDACTED', 'auto', 'appTracker'); | |
ga('appTracker.send', 'pageview'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def throttle(start_time) | |
stop_time = Time.zone.now | |
processing_duration = stop_time - start_time | |
wait_time = (0.3 - processing_duration).round(1) | |
Rails.logger.info("THROTTLING: #{wait_time}") | |
sleep wait_time if wait_time > 0.0 | |
Time.zone.now | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TRANSACTIONS_QUERY = ShopifyPartnerAPI.client.parse <<-'GRAPHQL' | |
query($cursor: String) { | |
transactions(types: [APP_SUBSCRIPTION_SALE], after: $cursor, first: 100) { | |
edges { | |
cursor | |
node { | |
id, | |
createdAt, | |
... on AppSubscriptionSale { | |
netAmount { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Transaction < ActiveRecord::Base | |
include ShopifyPartnerAPI | |
THROTTLE_MIN_TIME_PER_CALL = 0.3 | |
TRANSACTIONS_QUERY = ShopifyPartnerAPI.client.parse <<-'GRAPHQL' | |
query($cursor: String) { | |
transactions(types: [APP_SUBSCRIPTION_SALE], after: $cursor, first: 100) { | |
edges { | |
cursor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query ($cursor: String) { | |
transactions(types: [APP_SUBSCRIPTION_SALE], after: $cursor, first: 100) { | |
edges { | |
cursor | |
node { | |
id | |
createdAt | |
... on AppSubscriptionSale { | |
netAmount { | |
amount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query { | |
transactions(types: [APP_SUBSCRIPTION_SALE]) { | |
edges { | |
node { | |
id | |
createdAt | |
... on AppSubscriptionSale { | |
netAmount { | |
amount | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query { | |
transactions(types: [APP_SUBSCRIPTION_SALE]) { | |
edges { | |
node { | |
id | |
createdAt | |
netAmount { | |
amount | |
} | |
app { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query { | |
transactions(types: [APP_SUBSCRIPTION_SALE]) { | |
edges { | |
node { | |
id | |
createdAt | |
... on AppSubscriptionSale { | |
netAmount { | |
amount | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "graphql/client" | |
require "http_client" | |
module ShopifyPartnerAPI | |
class << self | |
delegate :parse, :query, to: :client | |
def client | |
initialize_client_cache | |
cached_client = @_client_cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ShopifyPartnerAPI | |
class HTTPClient < GraphQL::Client::HTTP | |
def initialize | |
super("https://partners.shopify.com/") | |
end | |
def headers(context) | |
{ | |
"X-Shopify-Access-Token": context.fetch(:access_token) | |
} |
NewerOlder