analytics-client
Advanced tools
Comparing version 0.5.2 to 0.5.3-roman-web-225c513baba708a6600cae624f5c6e85c37a8b43
@@ -7,2 +7,7 @@ # Change Log | ||
# v0.5.3 | ||
## (2020-04-16) | ||
* Make web tracker more flexible [Roman Mazur] | ||
# v0.5.2 | ||
@@ -9,0 +14,0 @@ ## (2020-04-13) |
{ | ||
"name": "analytics-client", | ||
"version": "0.5.2", | ||
"version": "0.5.3-roman-web-225c513baba708a6600cae624f5c6e85c37a8b43", | ||
"description": "Convenient builders to compose analytics tools", | ||
@@ -5,0 +5,0 @@ "repository": { |
import { Client } from './client'; | ||
export interface WebTracker { | ||
trackPageView(name?: string): void; | ||
trackPageView(prefix?: string, name?: string): void; | ||
} | ||
export declare function createWebTracker(client: Client): WebTracker; |
@@ -5,4 +5,4 @@ "use strict"; | ||
return { | ||
trackPageView: function (name) { | ||
client.track(name ? name : 'Page View', { | ||
trackPageView: function (prefix, name) { | ||
client.track("" + (prefix ? "[" + prefix + "] " : '') + (name ? name : 'Page View'), { | ||
current_url: window.location.href, | ||
@@ -9,0 +9,0 @@ current_url_path: window.location.pathname, |
@@ -23,5 +23,7 @@ "use strict"; | ||
expect(passedData).toHaveProperty('current_url_path'); | ||
tracker.trackPageView('test event'); | ||
tracker.trackPageView('prefix'); | ||
expect(passedEventType).toStrictEqual('[prefix] Page View'); | ||
tracker.trackPageView('', 'test event'); | ||
expect(passedEventType).toStrictEqual('test event'); | ||
}); | ||
//# sourceMappingURL=web.test.js.map |
{ | ||
"name": "analytics-client", | ||
"version": "0.5.2", | ||
"version": "0.5.3-roman-web-225c513baba708a6600cae624f5c6e85c37a8b43", | ||
"description": "Convenient builders to compose analytics tools", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -46,2 +46,8 @@ Analytics client | ||
Tracking a page view. | ||
```typescript | ||
import { createClient, WebTracker, createWebTracker } from 'analytics-client'; | ||
const client = createClient({ projectName: 'my-project' }); | ||
createWebTracker(client).trackPageView(); | ||
``` | ||
@@ -48,0 +54,0 @@ ## Using without npm packages |
@@ -7,3 +7,3 @@ import { Client } from './client'; | ||
export interface WebTracker { | ||
trackPageView(name?: string): void; | ||
trackPageView(prefix?: string, name?: string): void; | ||
} | ||
@@ -13,8 +13,11 @@ | ||
return { | ||
trackPageView(name?: string): void { | ||
client.track(name ? name : 'Page View', { | ||
current_url: window.location.href, | ||
current_url_path: window.location.pathname, | ||
metrics: getPageloadMetrics(), | ||
}); | ||
trackPageView(prefix?: string, name?: string): void { | ||
client.track( | ||
`${prefix ? `[${prefix}] ` : ''}${name ? name : 'Page View'}`, | ||
{ | ||
current_url: window.location.href, | ||
current_url_path: window.location.pathname, | ||
metrics: getPageloadMetrics(), | ||
}, | ||
); | ||
}, | ||
@@ -21,0 +24,0 @@ }; |
@@ -25,4 +25,7 @@ import { createClient } from '../src/client'; | ||
tracker.trackPageView('test event'); | ||
tracker.trackPageView('prefix'); | ||
expect(passedEventType).toStrictEqual('[prefix] Page View'); | ||
tracker.trackPageView('', 'test event'); | ||
expect(passedEventType).toStrictEqual('test event'); | ||
}); |
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
251270
1568
63