-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add typings for TypeScript interop #11
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,309 @@ | ||
export interface IGAnalyticsOptions { | ||
|
||
/** | ||
* Anonymize the sender's IP address. | ||
* See [Anonymize IP](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#aip). | ||
*/ | ||
aip?: number; | ||
|
||
/** | ||
* Specifies the application's name. | ||
* See [Application Name](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#an). | ||
*/ | ||
an?: string; | ||
|
||
/** | ||
* Specifies the application identifier. | ||
* See [Application ID](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#aid). | ||
*/ | ||
aid?: string; | ||
|
||
/** | ||
* Specifies the application installer identifier. | ||
* See [Installer ID](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#aiid). | ||
*/ | ||
aiid?: string; | ||
|
||
/** | ||
* Specifies the application verison. | ||
* See [Version](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#av). | ||
*/ | ||
av?: string; | ||
|
||
/** | ||
* Indicates the data source type of the hit; eg web or app. | ||
* See [Data Source](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#ds). | ||
*/ | ||
ds?: string; | ||
} | ||
|
||
export interface IEventParams { | ||
/** | ||
* Specifies the event category. Must not be empty. | ||
* Max length: 150 bytes. | ||
*/ | ||
ec: string; | ||
|
||
/** | ||
* Specifies the event action. Must not be empty. | ||
* Max length: 500 bytes. | ||
*/ | ||
ea: string; | ||
|
||
/** | ||
* Specifies the event label. | ||
* Max length: 500 bytes. | ||
*/ | ||
el?: string; | ||
|
||
/** | ||
* Specifies the event value. Values must be non-negative. | ||
*/ | ||
ev?: number; | ||
} | ||
|
||
export interface IExceptionParams { | ||
/** | ||
* Specifies the description of an exception. | ||
*/ | ||
exd?: string; | ||
|
||
/** | ||
* Specifies whether the exception was fatal. | ||
*/ | ||
exf?: string; | ||
} | ||
|
||
export interface IPageviewParams { | ||
/** | ||
* Use this parameter to send the full URL (document location) of the page on which content resides. | ||
* Max length: 2048 bytes. | ||
*/ | ||
dl?: string; | ||
|
||
/** | ||
* Specifies the hostname from which content was hosted. | ||
* Max length: 100 bytes. | ||
*/ | ||
dh?: string; | ||
|
||
/** | ||
* The path portion of the page URL. Should begin with '/'. For 'pageview' hits, either &dl or both &dh and &dp have to be specified for the hit to be valid. | ||
* Max length: 2048 bytes. | ||
*/ | ||
dp?: string; | ||
|
||
/** | ||
* The title of the page / document. | ||
*/ | ||
dt?: string; | ||
|
||
/** | ||
* The ID of a clicked DOM element, used to disambiguate multiple links to the same URL in In-Page Analytics reports when Enhanced Link Attribution is enabled for the property. | ||
*/ | ||
linkid: string; | ||
|
||
/** | ||
* You can have up to 5 content groupings, each of which has an associated index between 1 and 5, inclusive. Each content grouping can have up to 100 content groups. | ||
* Max length: 100 bytes. | ||
*/ | ||
cg1?: string; | ||
|
||
/** | ||
* You can have up to 5 content groupings, each of which has an associated index between 1 and 5, inclusive. Each content grouping can have up to 100 content groups. | ||
* Max length: 100 bytes. | ||
*/ | ||
cg2?: string; | ||
|
||
/** | ||
* You can have up to 5 content groupings, each of which has an associated index between 1 and 5, inclusive. Each content grouping can have up to 100 content groups. | ||
* Max length: 100 bytes. | ||
*/ | ||
cg3?: string; | ||
|
||
/** | ||
* You can have up to 5 content groupings, each of which has an associated index between 1 and 5, inclusive. Each content grouping can have up to 100 content groups. | ||
* Max length: 100 bytes. | ||
*/ | ||
cg4?: string; | ||
|
||
/** | ||
* You can have up to 5 content groupings, each of which has an associated index between 1 and 5, inclusive. Each content grouping can have up to 100 content groups. | ||
* Max length: 100 bytes. | ||
*/ | ||
cg5?: string; | ||
} | ||
|
||
export interface IScreenviewParams extends IPageviewParams { | ||
/** | ||
* This parameter is optional on web properties, and required on mobile properties for screenview hits, where it is used for the 'Screen Name' of the screenview hit. | ||
* Max length: 2048 bytes. | ||
*/ | ||
cd: string; | ||
} | ||
|
||
export interface ISocialParams { | ||
/** | ||
* Specifies the social network, for example Facebook or Google Plus. | ||
* Max length: 50 bytes. | ||
*/ | ||
sn: string; | ||
|
||
/** | ||
* Specifies the social interaction action. For example on Google Plus when a user clicks the +1 button, the social action is 'plus'. | ||
* Max length: 50 bytes. | ||
*/ | ||
sa: string; | ||
|
||
/** | ||
* Specifies the target of a social interaction. This value is typically a URL but can be any text. | ||
* Max length: 2048 bytes. | ||
*/ | ||
st: string; | ||
} | ||
|
||
export interface ITimingParams { | ||
/** | ||
* Specifies the user timing category. | ||
* Max length: 150 bytes. | ||
*/ | ||
utc: string; | ||
|
||
/** | ||
* Specifies the user timing variable. | ||
* Max length: 500 bytes. | ||
*/ | ||
utv: string; | ||
|
||
/** | ||
* Specifies the user timing value. The value is in milliseconds. | ||
*/ | ||
utt: number; | ||
|
||
/** | ||
* Specifies the user timing label. | ||
* Max length: 500 bytes. | ||
*/ | ||
utl?: string; | ||
|
||
/** | ||
* Specifies the time it took for a page to load. The value is in milliseconds. | ||
*/ | ||
plt?: number; | ||
|
||
/** | ||
* Specifies the time it took to do a DNS lookup. The value is in milliseconds. | ||
*/ | ||
dns?: number; | ||
|
||
/** | ||
* Specifies the time it took for the page to be downloaded. The value is in milliseconds. | ||
*/ | ||
pdt?: number; | ||
|
||
/** | ||
* Specifies the time it took for any redirects to happen. The value is in millseconds. | ||
*/ | ||
rrt?: number; | ||
|
||
/** | ||
* Specifies the time it took for a TCP connection to be made. The value is in milliseconds. | ||
*/ | ||
tcp?: number; | ||
|
||
/** | ||
* Specifies the time it took for the server to respond after the connect time. The value is in milliseconds. | ||
*/ | ||
srt?: number; | ||
|
||
/** | ||
* Specifies the time it took for Document.readyState to be 'interactive'. The value is in milliseconds. | ||
*/ | ||
dit?: number; | ||
|
||
/** | ||
* Specifies the time it took for the DomContentLoaded Event to fire. The value is in milliseconds. | ||
*/ | ||
clt?: number; | ||
} | ||
|
||
export interface IItemParams { | ||
/** | ||
* Specifies the item name. | ||
* Max length: 500 bytes. | ||
*/ | ||
in: string; | ||
|
||
/** | ||
* Specifies the price for a single item / unit. | ||
*/ | ||
ip?: number; | ||
|
||
/** | ||
* Specifies the number of items purchased. | ||
*/ | ||
iq: number; | ||
|
||
/** | ||
* Specifies the SKU or item code. | ||
* Max length: 500 bytes. | ||
*/ | ||
ic: string; | ||
|
||
/** | ||
* Specifies the category that the item belongs to. | ||
* Max length: 500 bytes. | ||
*/ | ||
iv: string; | ||
} | ||
|
||
export interface ITransactionParams { | ||
/** | ||
* A unique identifier for the transaction. This value should be the same for both the Transaction hit and Items hits associated to the particular transaction. | ||
* Max length: 500 bytes. | ||
*/ | ||
ti: string; | ||
|
||
/** | ||
* Specifies the affiliation or store name. | ||
* Max length: 500 bytes. | ||
*/ | ||
ta?: string; | ||
|
||
/** | ||
* Specifies the total revenue associated with the transaction. This value should include any shipping or tax costs. | ||
*/ | ||
tr?: number; | ||
|
||
/** | ||
* Specifies the total shipping cost of the transaction. | ||
*/ | ||
ts?: number; | ||
|
||
/** | ||
* Specifies the total tax of the transaction. | ||
*/ | ||
tt?: number; | ||
} | ||
|
||
export interface IGAnalytics { | ||
send(kind: "event", params: IEventParams): void; | ||
send(kind: "social", params: ISocialParams): void; | ||
send(kind: "pageview", params: IPageviewParams): void; | ||
send(kind: "exception", params: IExceptionParams): void; | ||
send(kind: "item", params: IItemParams): void; | ||
send(kind: "screenview", params: IScreenviewParams): void; | ||
send(kind: "timing", params: ITimingParams): void; | ||
send(kind: "transaction", params: ITransactionParams): void; | ||
} | ||
|
||
declare namespace ganalytics { | ||
/** | ||
* @param trackerID Your Google Analytics tracker ID; eg UA-XXXXXXXX-X | ||
* @param options Options | ||
* @param toWait When truthy, a pageview event will not be sent immediately upon initialization. | ||
*/ | ||
function GAnalyticsFactory(trackerID: string, options?: Partial<IGAnalyticsOptions>, toWait?: boolean): IGAnalytics; | ||
} | ||
|
||
export default ganalytics.GAnalyticsFactory; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the
Partial
keyword, we don't have to add?
to every key