New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

analytics-client

Package Overview
Dependencies
Maintainers
1
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

analytics-client - npm Package Compare versions

Comparing version 1.0.0-amplitude-init-changes-e8c0da3fd5df71062715c7c041f44e941260d8b0 to 1.1.0-add-navigation-click-method-72253e26d317511bae76b31270041d76a36d381c

5

CHANGELOG.md

@@ -7,2 +7,7 @@ # Change Log

# v1.1.0
## (2021-02-17)
* Add trackNavigationClick [gelbal]
# v1.0.0

@@ -9,0 +14,0 @@ ## (2021-02-17)

2

dist/package.json
{
"name": "analytics-client",
"version": "1.0.0-amplitude-init-changes-e8c0da3fd5df71062715c7c041f44e941260d8b0",
"version": "1.1.0-add-navigation-click-method-72253e26d317511bae76b31270041d76a36d381c",
"description": "Convenient builders to compose analytics tools",

@@ -5,0 +5,0 @@ "repository": {

import { Client, Properties } from './client';
export interface WebTracker {
track(name: string, props?: Properties): void;
trackNavigationClick(href: string, props?: Properties): void;
trackPageView(name?: string): void;
}
export declare function createWebTracker(client: Client, prefix?: string): WebTracker;
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -9,2 +20,5 @@ exports.createWebTracker = void 0;

},
trackNavigationClick: function (href, props) {
this.track('Navigation Click', __assign(__assign({}, props), { href: href, current_url: window.location.href, current_url_path: window.location.pathname }));
},
trackPageView: function (name) {

@@ -11,0 +25,0 @@ this.track(name ? name : 'Page View', {

@@ -22,2 +22,7 @@ "use strict";

};
var ensureNavigationClickProperties = function () {
expect(passedData).toHaveProperty('current_url');
expect(passedData).toHaveProperty('current_url_path');
expect(passedData).toHaveProperty('href');
};
describe('With prefix', function () {

@@ -40,2 +45,11 @@ var tracker = web_1.createWebTracker(client, 'prefix');

});
it('tracks navigation click', function () {
tracker.trackNavigationClick('https://balena.io/docs');
expect(passedEventType).toStrictEqual('[prefix] Navigation Click');
ensureNavigationClickProperties();
tracker.trackNavigationClick('https://balena.io/docs', { p: 0 });
expect(passedEventType).toStrictEqual('[prefix] Navigation Click');
ensureNavigationClickProperties();
expect(passedData.p).toStrictEqual(0);
});
});

@@ -42,0 +56,0 @@ describe('No prefix', function () {

{
"name": "analytics-client",
"version": "1.0.0-amplitude-init-changes-e8c0da3fd5df71062715c7c041f44e941260d8b0",
"version": "1.1.0-add-navigation-click-method-72253e26d317511bae76b31270041d76a36d381c",
"description": "Convenient builders to compose analytics tools",

@@ -5,0 +5,0 @@ "repository": {

@@ -19,3 +19,3 @@ Analytics client

Since most of balena products are maintained on different components/repos (ie Hub, Marketing Site, Cloud, etc) we need to make sure that
when someone navigates between components we can keep identifying it as a same id.
when someone navigates between components we can keep identifying it as a same id.

@@ -47,3 +47,3 @@ So to achieve that we will need to:

## Usage
Tracking a page view. The following reports an event named `[EFP] Page View` with default properties.
Tracking a page view and a navigation click. The following reports an event named `[EFP] Page View` and another event with `[EFP] Navigation Click` with default properties.

@@ -53,4 +53,5 @@ ```typescript

createWebTracker(client, 'EFP') // 2nd parameter defines the prefix of event names
.trackPageView();
const webTracker = createWebTracker(client, 'EFP'); // 2nd parameter defines the prefix of event names
webTracker.trackPageView();
webTracker.trackNavigationClick('https://hub.balena.io'); // User clicks on a button to navigate to the Hub
```

@@ -57,0 +58,0 @@

@@ -8,2 +8,3 @@ import { Client, Properties } from './client';

track(name: string, props?: Properties): void;
trackNavigationClick(href: string, props?: Properties): void;
trackPageView(name?: string): void;

@@ -18,2 +19,11 @@ }

trackNavigationClick(href: string, props?: Properties) {
this.track('Navigation Click', {
...props,
href,
current_url: window.location.href,
current_url_path: window.location.pathname,
});
},
trackPageView(name?: string) {

@@ -20,0 +30,0 @@ this.track(name ? name : 'Page View', {

@@ -24,2 +24,8 @@ import { createClient } from '../src/client';

const ensureNavigationClickProperties = () => {
expect(passedData).toHaveProperty('current_url');
expect(passedData).toHaveProperty('current_url_path');
expect(passedData).toHaveProperty('href');
};
describe('With prefix', () => {

@@ -45,2 +51,13 @@ const tracker = createWebTracker(client, 'prefix');

});
it('tracks navigation click', () => {
tracker.trackNavigationClick('https://balena.io/docs');
expect(passedEventType).toStrictEqual('[prefix] Navigation Click');
ensureNavigationClickProperties();
tracker.trackNavigationClick('https://balena.io/docs', { p: 0 });
expect(passedEventType).toStrictEqual('[prefix] Navigation Click');
ensureNavigationClickProperties();
expect(passedData.p).toStrictEqual(0);
});
});

@@ -47,0 +64,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc