@cmpsr/analytics
Advanced tools
Comparing version 0.3.1 to 0.4.0-canary-20240717175243
import React from 'react'; | ||
import { IUser, Track, Page, Identify, Group } from './types'; | ||
import { IUser, Track, Page, Identify, Group, Revenue } from './types'; | ||
export interface IAnalyticsContext { | ||
@@ -10,3 +10,4 @@ identify: Identify; | ||
reset: () => void; | ||
revenue?: Revenue; | ||
} | ||
export declare const AnalyticsContext: React.Context<IAnalyticsContext>; |
@@ -37,3 +37,6 @@ "use strict"; | ||
return null; | ||
}, | ||
revenue: function() { | ||
return null; | ||
} | ||
}); |
@@ -153,2 +153,8 @@ /* eslint-disable prefer-rest-params */ "use strict"; | ||
proxyToIntegrations(integrations, "reset", Array.from(arguments)); | ||
}, | ||
revenue: function revenue() { | ||
if (!integrations.includes("amplitude")) return; | ||
proxyToIntegrations([ | ||
integrations["amplitude"] | ||
], "revenue", Array.from(arguments)); | ||
} | ||
@@ -155,0 +161,0 @@ }; |
@@ -11,2 +11,3 @@ import { Identify, Group, Page, Track } from 'types'; | ||
reset: () => void; | ||
revenue: (price: any, quantity: any, type: any) => void; | ||
} |
@@ -129,4 +129,10 @@ "use strict"; | ||
}); | ||
_define_property(this, "revenue", function(price, quantity, type) { | ||
console.log("Revenueing!! Please delete this log"); | ||
var amplitude = window.amplitude; | ||
var event = new amplitude.revenue().setPrice(price).setQuantity(quantity).setRevenueType(type); | ||
amplitude.revenue(event); | ||
}); | ||
var amplitude = (0, _loadAmplitude.loadAmplitude)(); | ||
amplitude.init(config.apiKey); | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { Track, Page, Identify, Group } from '../types'; | ||
import { Track, Page, Identify, Group, Revenue } from '../types'; | ||
export interface IIntegration { | ||
@@ -8,2 +8,3 @@ identify: Identify; | ||
reset: () => void; | ||
revenue?: Revenue; | ||
} |
@@ -22,4 +22,5 @@ export interface IIdentifyTraits { | ||
export type Track = (eventName: string, traits?: ITrackTraits) => void; | ||
export type Revenue = (price: number, quantity: number, type: string) => void; | ||
export interface IUser { | ||
anonymousId: string; | ||
} |
@@ -10,3 +10,3 @@ { | ||
}, | ||
"version": "0.3.1", | ||
"version": "0.4.0-canary-20240717175243", | ||
"author": "Steve Cox <stevejcox@me.com>", | ||
@@ -13,0 +13,0 @@ "license": "MIT", |
40935
1166