@vercel/analytics
Advanced tools
Comparing version 1.0.0 to 1.0.1-beta.0
@@ -5,6 +5,10 @@ interface PageViewEvent { | ||
} | ||
declare type Event = PageViewEvent; | ||
interface CustomEvent { | ||
type: 'event'; | ||
url: string; | ||
} | ||
declare type BeforeSendEvent = PageViewEvent | CustomEvent; | ||
declare type Mode = 'auto' | 'development' | 'production'; | ||
declare type AllowedPropertyValues = string | number | boolean | null; | ||
declare type BeforeSend = (event: Event) => Event | null; | ||
declare type BeforeSend = (event: BeforeSendEvent) => BeforeSendEvent | null; | ||
interface AnalyticsProps { | ||
@@ -24,3 +28,19 @@ beforeSend?: BeforeSend; | ||
/** | ||
* Injects the Vercel Web Analytics script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/concepts/analytics/package). | ||
* @param [props] - Analytics options. | ||
* @param [props.mode] - The mode to use for the analytics script. Defaults to `auto`. | ||
* - `auto` - Automatically detect the environment. Uses `production` if the environment cannot be determined. | ||
* - `production` - Always use the production script. (Sends events to the server) | ||
* - `development` - Always use the development script. (Logs events to the console) | ||
* @param [props.debug] - Whether to enable debug logging in development. Defaults to `true`. | ||
* @param [props.beforeSend] - A middleware function to modify events before they are sent. Should return the event object or `null` to cancel the event. | ||
*/ | ||
declare function inject(props?: AnalyticsProps): void; | ||
/** | ||
* Tracks a custom event. Please refer to the [documentation](https://vercel.com/docs/concepts/analytics/custom-events) for more information on custom events. | ||
* @param name - The name of the event. | ||
* * Examples: `Purchase`, `Click Button`, or `Play Video`. | ||
* @param [properties] - Additional properties of the event. Nested objects are not supported. Allowed values are `string`, `number`, `boolean`, and `null`. | ||
*/ | ||
declare function track(name: string, properties?: Record<string, AllowedPropertyValues>): void; | ||
@@ -27,0 +47,0 @@ declare const _default: { |
// package.json | ||
var name = "@vercel/analytics"; | ||
var version = "1.0.0"; | ||
var version = "1.0.1-beta.0"; | ||
@@ -5,0 +5,0 @@ // src/queue.ts |
@@ -5,6 +5,10 @@ interface PageViewEvent { | ||
} | ||
declare type Event = PageViewEvent; | ||
interface CustomEvent { | ||
type: 'event'; | ||
url: string; | ||
} | ||
declare type BeforeSendEvent = PageViewEvent | CustomEvent; | ||
declare type Mode = 'auto' | 'development' | 'production'; | ||
declare type AllowedPropertyValues = string | number | boolean | null; | ||
declare type BeforeSend = (event: Event) => Event | null; | ||
declare type BeforeSend = (event: BeforeSendEvent) => BeforeSendEvent | null; | ||
interface AnalyticsProps { | ||
@@ -24,4 +28,33 @@ beforeSend?: BeforeSend; | ||
/** | ||
* Tracks a custom event. Please refer to the [documentation](https://vercel.com/docs/concepts/analytics/custom-events) for more information on custom events. | ||
* @param name - The name of the event. | ||
* * Examples: `Purchase`, `Click Button`, or `Play Video`. | ||
* @param [properties] - Additional properties of the event. Nested objects are not supported. Allowed values are `string`, `number`, `boolean`, and `null`. | ||
*/ | ||
declare function track(name: string, properties?: Record<string, AllowedPropertyValues>): void; | ||
/** | ||
* Injects the Vercel Web Analytics script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/concepts/analytics/package). | ||
* @param [props] - Analytics options. | ||
* @param [props.mode] - The mode to use for the analytics script. Defaults to `auto`. | ||
* - `auto` - Automatically detect the environment. Uses `production` if the environment cannot be determined. | ||
* - `production` - Always use the production script. (Sends events to the server) | ||
* - `development` - Always use the development script. (Logs events to the console) | ||
* @param [props.debug] - Whether to enable debug logging in development. Defaults to `true`. | ||
* @param [props.beforeSend] - A middleware function to modify events before they are sent. Should return the event object or `null` to cancel the event. | ||
* @example | ||
* ```js | ||
* import { Analytics } from '@vercel/analytics/react'; | ||
* | ||
* export default function App() { | ||
* return ( | ||
* <div> | ||
* <Analytics /> | ||
* <h1>My App</h1> | ||
* </div> | ||
* ); | ||
* } | ||
* ``` | ||
*/ | ||
declare function Analytics({ beforeSend, debug, mode, }: AnalyticsProps): null; | ||
@@ -28,0 +61,0 @@ |
@@ -8,3 +8,3 @@ "use client"; | ||
var name = "@vercel/analytics"; | ||
var version = "1.0.0"; | ||
var version = "1.0.1-beta.0"; | ||
@@ -11,0 +11,0 @@ // src/queue.ts |
{ | ||
"name": "@vercel/analytics", | ||
"version": "1.0.0", | ||
"version": "1.0.1-beta.0", | ||
"keywords": [ | ||
@@ -8,2 +8,6 @@ "analytics", | ||
], | ||
"repository": { | ||
"url": "github:vercel/analytics", | ||
"directory": "packages/web" | ||
}, | ||
"license": "MPL-2.0", | ||
@@ -40,2 +44,5 @@ "type": "module", | ||
], | ||
"rules": { | ||
"tsdoc/syntax": "off" | ||
}, | ||
"ignorePatterns": [ | ||
@@ -42,0 +49,0 @@ "jest.setup.ts" |
@@ -9,3 +9,3 @@ ![Analytics](https://github.com/vercel/analytics/blob/main/.github/banner.png) | ||
<span> · </span> | ||
<a href="https://vercel.com/docs/concepts/analytics/audiences/package">Documentation</a> | ||
<a href="https://vercel.com/docs/concepts/analytics/package">Documentation</a> | ||
<span> · </span> | ||
@@ -17,3 +17,3 @@ <a href="https://twitter.com/vercel">Twitter</a> | ||
`@vercel/analytics` allows you to track page views in your Next.js app or any other website that is deployed to Vercel. | ||
`@vercel/analytics` allows you to track page views and custom events in your Next.js app or any other website that is deployed to Vercel. | ||
@@ -32,3 +32,3 @@ All page views are automatically tracked in your app. | ||
- For other frameworks, you can use the `inject` function add the tracking script to your app. | ||
- If you want to use Vercel Web Analytics on a static site without npm, follow the instructions in the [documentation](https://vercel.com/docs/concepts/analytics/audiences/quickstart). | ||
- If you want to use Vercel Web Analytics on a static site without npm, follow the instructions in the [documentation](https://vercel.com/docs/concepts/analytics/quickstart). | ||
@@ -39,2 +39,2 @@ 4. Deploy your app to Vercel and see data flowing in. | ||
Find more details about this package in our [documentation](https://vercel.com/docs/concepts/analytics/audiences/quickstart). | ||
Find more details about this package in our [documentation](https://vercel.com/docs/concepts/analytics/quickstart). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
73702
739
2