Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
@getcircuit/analytics
Advanced tools
@getcircuit/analytics
A thin analytics abstraction layer for Circuit's applications. It implements a basic plugin system for integrating with different analytics services.
import {
Analytics,
googleAnalytics,
facebookPixel,
} from '@getcircuit/analytics'
export const analytics = Analytics({
/** Current environment. Accessed by plugins.*/
env: process.env.NODE_ENV,
/** If true, logs every track call that is being made. (default: false) */
debug: process.env.NODE_ENV === 'development',
/** If true, tracking requests are not sent */
dryRun: 'production',
/** List of service plugins */
plugins: [
googleAnalytics({
trackingId: 'UA-XXXXXX-X',
}),
facebookPixel({
pixelId: 'xxxxxxx',
}),
],
/**
* Optional map of hooks => plugin names.
* Any plugin listed here will need to be explicitly included to have the related hook executed.
* */
explicitUse: {
event: [...],
pageview: [...],
...,
}
})
After initializing, you can use the abstraction layer to send:
analytics.event(...)
analytics.pageview(...)
analytics.identify(...)
analytics.anonymize(...)
analytics.info(...)
analytics.warn(...)
analytics.error(...)
Only plugins that implement the hook will be executed. The load
of each plugin is deferred until one of its hooks are executed, which means that any analytics code will only be added to the DOM when sending a tracking request.
A plugin is just an object with a specific set of methods, which we call 'hooks' and a name
property. The only mandatory hook is the load()
, responsible for adding the service script to the DOM.
{
name: string
load: () => MaybePromise
unload?: () => MaybePromise
pageview?: (opts: PageviewOptions) => MaybePromise
event?: (opts: TrackEventOptions) => MaybePromise
identify?: (opts: IdentifyOptions) => MaybePromise
anonymize?: () => MaybePromise
info?: (opts: TraceOptions) => MaybePromise
warn?: (opts: TraceOptions) => MaybePromise
error?: (opts: TraceOptions) => MaybePromise
}
Apart from load
and unload
, each hook correspond to a method in the abstraction layer.
Every hook has access to a this
object which contains:
type PluginContext = {
/** Configs passed onto the library */
config: {
env: string
appName: string
appVersion: string
debug: boolean
}
/** Helper method to assert that an object has received certain props */
assertKeys: (object, requiredKeys) => void
/** Helper method to assert that every passed value is not undefined */
assertValues: (objectOfValues) => void
}
FAQs
Unknown package
The npm package @getcircuit/analytics receives a total of 0 weekly downloads. As such, @getcircuit/analytics popularity was classified as not popular.
We found that @getcircuit/analytics demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 19 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.