@patternfly/chatbot 2.2.0-prerelease.43 → 2.2.0-prerelease.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/tracking/console_tracking_provider.d.ts +4 -5
- package/dist/cjs/tracking/console_tracking_provider.js +22 -15
- package/dist/cjs/tracking/posthog_tracking_provider.d.ts +2 -2
- package/dist/cjs/tracking/posthog_tracking_provider.js +21 -12
- package/dist/cjs/tracking/segment_tracking_provider.d.ts +2 -2
- package/dist/cjs/tracking/segment_tracking_provider.js +21 -12
- package/dist/cjs/tracking/trackingProviderProxy.d.ts +1 -1
- package/dist/cjs/tracking/trackingProviderProxy.js +2 -2
- package/dist/cjs/tracking/tracking_api.d.ts +1 -1
- package/dist/cjs/tracking/tracking_registry.js +46 -12
- package/dist/cjs/tracking/tracking_spi.d.ts +15 -5
- package/dist/cjs/tracking/tracking_spi.js +9 -0
- package/dist/cjs/tracking/umami_tracking_provider.d.ts +6 -2
- package/dist/cjs/tracking/umami_tracking_provider.js +66 -22
- package/dist/esm/tracking/console_tracking_provider.d.ts +4 -5
- package/dist/esm/tracking/console_tracking_provider.js +22 -15
- package/dist/esm/tracking/posthog_tracking_provider.d.ts +2 -2
- package/dist/esm/tracking/posthog_tracking_provider.js +21 -12
- package/dist/esm/tracking/segment_tracking_provider.d.ts +2 -2
- package/dist/esm/tracking/segment_tracking_provider.js +21 -12
- package/dist/esm/tracking/trackingProviderProxy.d.ts +1 -1
- package/dist/esm/tracking/trackingProviderProxy.js +2 -2
- package/dist/esm/tracking/tracking_api.d.ts +1 -1
- package/dist/esm/tracking/tracking_registry.js +46 -12
- package/dist/esm/tracking/tracking_spi.d.ts +15 -5
- package/dist/esm/tracking/tracking_spi.js +8 -1
- package/dist/esm/tracking/umami_tracking_provider.d.ts +6 -2
- package/dist/esm/tracking/umami_tracking_provider.js +66 -22
- package/package.json +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Analytics/Analytics.md +18 -14
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.tsx +4 -3
- package/src/tracking/console_tracking_provider.ts +21 -17
- package/src/tracking/posthog_tracking_provider.ts +20 -13
- package/src/tracking/segment_tracking_provider.ts +20 -13
- package/src/tracking/trackingProviderProxy.ts +2 -2
- package/src/tracking/tracking_api.ts +1 -1
- package/src/tracking/tracking_registry.ts +46 -13
- package/src/tracking/tracking_spi.ts +18 -7
- package/src/tracking/umami_tracking_provider.ts +76 -20
@@ -1,10 +1,9 @@
|
|
1
|
-
import { TrackingSpi } from './tracking_spi';
|
1
|
+
import { InitProps, TrackingSpi } from './tracking_spi';
|
2
2
|
import { TrackingApi, TrackingEventProperties } from './tracking_api';
|
3
3
|
export declare class ConsoleTrackingProvider implements TrackingSpi, TrackingApi {
|
4
|
+
private verbose;
|
4
5
|
trackPageView(url: string | undefined): void;
|
5
|
-
|
6
|
-
|
7
|
-
identify(userID: string): void;
|
6
|
+
initialize(props: InitProps): void;
|
7
|
+
identify(userID: string, userProperties?: TrackingEventProperties): void;
|
8
8
|
trackSingleItem(item: string, properties?: TrackingEventProperties): void;
|
9
|
-
getKey(): string;
|
10
9
|
}
|
@@ -2,26 +2,33 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.ConsoleTrackingProvider = void 0;
|
4
4
|
class ConsoleTrackingProvider {
|
5
|
+
constructor() {
|
6
|
+
this.verbose = false;
|
7
|
+
}
|
5
8
|
trackPageView(url) {
|
6
|
-
|
7
|
-
|
9
|
+
if (this.verbose) {
|
10
|
+
// eslint-disable-next-line no-console
|
11
|
+
console.log('ConsoleProvider pageView ', url);
|
12
|
+
}
|
8
13
|
}
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
+
initialize(props) {
|
15
|
+
this.verbose = props.verbose;
|
16
|
+
if (this.verbose) {
|
17
|
+
// eslint-disable-next-line no-console
|
18
|
+
console.log('ConsoleProvider initialize');
|
19
|
+
}
|
14
20
|
}
|
15
|
-
identify(userID) {
|
16
|
-
|
17
|
-
|
21
|
+
identify(userID, userProperties = {}) {
|
22
|
+
if (this.verbose) {
|
23
|
+
// eslint-disable-next-line no-console
|
24
|
+
console.log('ConsoleProvider identify ', userID, userProperties);
|
25
|
+
}
|
18
26
|
}
|
19
27
|
trackSingleItem(item, properties) {
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
return 'console';
|
28
|
+
if (this.verbose) {
|
29
|
+
// eslint-disable-next-line no-console
|
30
|
+
console.log('ConsoleProvider: ' + item, properties);
|
31
|
+
}
|
25
32
|
}
|
26
33
|
}
|
27
34
|
exports.ConsoleTrackingProvider = ConsoleTrackingProvider;
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { TrackingApi, TrackingEventProperties } from './tracking_api';
|
2
2
|
import { InitProps, TrackingSpi } from './tracking_spi';
|
3
3
|
export declare class PosthogTrackingProvider implements TrackingSpi, TrackingApi {
|
4
|
-
|
4
|
+
private verbose;
|
5
5
|
initialize(props: InitProps): void;
|
6
|
-
identify(userID: string): void;
|
6
|
+
identify(userID: string, userProperties?: TrackingEventProperties): void;
|
7
7
|
trackPageView(url: string | undefined): void;
|
8
8
|
trackSingleItem(item: string, properties?: TrackingEventProperties): void;
|
9
9
|
}
|
@@ -3,12 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PosthogTrackingProvider = void 0;
|
4
4
|
const posthog_js_1 = require("posthog-js");
|
5
5
|
class PosthogTrackingProvider {
|
6
|
-
|
7
|
-
|
6
|
+
constructor() {
|
7
|
+
this.verbose = false;
|
8
8
|
}
|
9
9
|
initialize(props) {
|
10
|
-
|
11
|
-
|
10
|
+
this.verbose = props.verbose;
|
11
|
+
if (this.verbose) {
|
12
|
+
// eslint-disable-next-line no-console
|
13
|
+
console.log('PosthogProvider initialize');
|
14
|
+
}
|
12
15
|
const posthogKey = props.posthogKey;
|
13
16
|
posthog_js_1.posthog.init(posthogKey, {
|
14
17
|
// eslint-disable-next-line camelcase
|
@@ -17,20 +20,26 @@ class PosthogTrackingProvider {
|
|
17
20
|
person_profiles: 'identified_only' // or 'always' to create profiles for anonymous users as well
|
18
21
|
});
|
19
22
|
}
|
20
|
-
identify(userID) {
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
identify(userID, userProperties = {}) {
|
24
|
+
if (this.verbose) {
|
25
|
+
// eslint-disable-next-line no-console
|
26
|
+
console.log('PosthogProvider userID: ' + userID);
|
27
|
+
}
|
28
|
+
posthog_js_1.posthog.identify(userID, userProperties);
|
24
29
|
}
|
25
30
|
trackPageView(url) {
|
26
|
-
|
27
|
-
|
31
|
+
if (this.verbose) {
|
32
|
+
// eslint-disable-next-line no-console
|
33
|
+
console.log('PostHogProvider url ', url);
|
34
|
+
}
|
28
35
|
// TODO posthog seems to record that automatically.
|
29
36
|
// How to not clash with this here? Just leave as no-op?
|
30
37
|
}
|
31
38
|
trackSingleItem(item, properties) {
|
32
|
-
|
33
|
-
|
39
|
+
if (this.verbose) {
|
40
|
+
// eslint-disable-next-line no-console
|
41
|
+
console.log('PosthogProvider: trackSingleItem ' + item, properties);
|
42
|
+
}
|
34
43
|
posthog_js_1.posthog.capture(item, { properties });
|
35
44
|
}
|
36
45
|
}
|
@@ -2,9 +2,9 @@ import { TrackingApi, TrackingEventProperties } from './tracking_api';
|
|
2
2
|
import { InitProps, TrackingSpi } from './tracking_spi';
|
3
3
|
export declare class SegmentTrackingProvider implements TrackingSpi, TrackingApi {
|
4
4
|
private analytics;
|
5
|
-
|
5
|
+
private verbose;
|
6
6
|
initialize(props: InitProps): void;
|
7
|
-
identify(userID: string): void;
|
7
|
+
identify(userID: string, userProperties?: TrackingEventProperties): void;
|
8
8
|
trackPageView(url: string | undefined): void;
|
9
9
|
trackSingleItem(item: string, properties?: TrackingEventProperties): void;
|
10
10
|
}
|
@@ -3,12 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SegmentTrackingProvider = void 0;
|
4
4
|
const analytics_next_1 = require("@segment/analytics-next");
|
5
5
|
class SegmentTrackingProvider {
|
6
|
-
|
7
|
-
|
6
|
+
constructor() {
|
7
|
+
this.verbose = false;
|
8
8
|
}
|
9
9
|
initialize(props) {
|
10
|
-
|
11
|
-
|
10
|
+
this.verbose = props.verbose;
|
11
|
+
if (this.verbose) {
|
12
|
+
// eslint-disable-next-line no-console
|
13
|
+
console.log('SegmentProvider initialize');
|
14
|
+
}
|
12
15
|
const segmentKey = props.segmentKey;
|
13
16
|
// We need to create an object here, as ts lint is unhappy otherwise
|
14
17
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -20,16 +23,20 @@ class SegmentTrackingProvider {
|
|
20
23
|
integrations: Object.assign({}, integrations)
|
21
24
|
});
|
22
25
|
}
|
23
|
-
identify(userID) {
|
24
|
-
|
25
|
-
|
26
|
+
identify(userID, userProperties = {}) {
|
27
|
+
if (this.verbose) {
|
28
|
+
// eslint-disable-next-line no-console
|
29
|
+
console.log('SegmentProvider userID: ' + userID);
|
30
|
+
}
|
26
31
|
if (this.analytics) {
|
27
|
-
this.analytics.identify(userID);
|
32
|
+
this.analytics.identify(userID, userProperties);
|
28
33
|
}
|
29
34
|
}
|
30
35
|
trackPageView(url) {
|
31
|
-
|
32
|
-
|
36
|
+
if (this.verbose) {
|
37
|
+
// eslint-disable-next-line no-console
|
38
|
+
console.log('SegmentProvider url ', url);
|
39
|
+
}
|
33
40
|
if (this.analytics) {
|
34
41
|
if (url) {
|
35
42
|
this.analytics.page(url);
|
@@ -40,8 +47,10 @@ class SegmentTrackingProvider {
|
|
40
47
|
}
|
41
48
|
}
|
42
49
|
trackSingleItem(item, properties) {
|
43
|
-
|
44
|
-
|
50
|
+
if (this.verbose) {
|
51
|
+
// eslint-disable-next-line no-console
|
52
|
+
console.log('SegmentProvider: trackSingleItem ' + item, properties);
|
53
|
+
}
|
45
54
|
if (this.analytics) {
|
46
55
|
this.analytics.track(item, { properties });
|
47
56
|
}
|
@@ -2,7 +2,7 @@ import { TrackingApi, TrackingEventProperties } from './tracking_api';
|
|
2
2
|
declare class TrackingProviderProxy implements TrackingApi {
|
3
3
|
providers: TrackingApi[];
|
4
4
|
constructor(providers: TrackingApi[]);
|
5
|
-
identify(userID: string): void;
|
5
|
+
identify(userID: string, userProperties?: TrackingEventProperties): void;
|
6
6
|
trackSingleItem(eventName: string, properties?: TrackingEventProperties): void;
|
7
7
|
trackPageView(url: string | undefined): void;
|
8
8
|
}
|
@@ -5,9 +5,9 @@ class TrackingProviderProxy {
|
|
5
5
|
this.providers = [];
|
6
6
|
this.providers = providers;
|
7
7
|
}
|
8
|
-
identify(userID) {
|
8
|
+
identify(userID, userProperties = {}) {
|
9
9
|
for (const provider of this.providers) {
|
10
|
-
provider.identify(userID);
|
10
|
+
provider.identify(userID, userProperties);
|
11
11
|
}
|
12
12
|
}
|
13
13
|
trackSingleItem(eventName, properties) {
|
@@ -2,7 +2,7 @@ export interface TrackingEventProperties {
|
|
2
2
|
[key: string]: string | number | boolean | undefined;
|
3
3
|
}
|
4
4
|
export interface TrackingApi {
|
5
|
-
identify: (userID: string) => void;
|
5
|
+
identify: (userID: string, userProperties: TrackingEventProperties) => void;
|
6
6
|
trackPageView: (url: string | undefined) => void;
|
7
7
|
trackSingleItem: (eventName: string, properties: TrackingEventProperties | undefined) => void;
|
8
8
|
}
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.getTrackingProviders = void 0;
|
7
|
+
const tracking_spi_1 = require("./tracking_spi");
|
7
8
|
const trackingProviderProxy_1 = __importDefault(require("./trackingProviderProxy"));
|
8
9
|
const console_tracking_provider_1 = require("./console_tracking_provider");
|
9
10
|
const segment_tracking_provider_1 = require("./segment_tracking_provider");
|
@@ -11,23 +12,56 @@ const posthog_tracking_provider_1 = require("./posthog_tracking_provider");
|
|
11
12
|
const umami_tracking_provider_1 = require("./umami_tracking_provider");
|
12
13
|
const getTrackingProviders = (initProps) => {
|
13
14
|
const providers = [];
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
if (initProps.activeProviders) {
|
16
|
+
let tmpProps = initProps.activeProviders;
|
17
|
+
// Theoretically we get an array of provider names, but it could also be a CSV string...
|
18
|
+
if (!Array.isArray(initProps.activeProviders)) {
|
19
|
+
const tmpString = initProps.activeProviders;
|
20
|
+
if (tmpString && tmpString.indexOf(',') !== -1) {
|
21
|
+
tmpProps = tmpString.split(',');
|
22
|
+
}
|
23
|
+
else {
|
24
|
+
tmpProps = [tmpString];
|
25
|
+
}
|
26
|
+
}
|
27
|
+
tmpProps.forEach((provider) => {
|
28
|
+
switch (tracking_spi_1.Providers[provider]) {
|
29
|
+
case tracking_spi_1.Providers.Segment:
|
30
|
+
providers.push(new segment_tracking_provider_1.SegmentTrackingProvider());
|
31
|
+
break;
|
32
|
+
case tracking_spi_1.Providers.Umami:
|
33
|
+
providers.push(new umami_tracking_provider_1.UmamiTrackingProvider());
|
34
|
+
break;
|
35
|
+
case tracking_spi_1.Providers.Posthog:
|
36
|
+
providers.push(new posthog_tracking_provider_1.PosthogTrackingProvider());
|
37
|
+
break;
|
38
|
+
case tracking_spi_1.Providers.Console:
|
39
|
+
providers.push(new console_tracking_provider_1.ConsoleTrackingProvider());
|
40
|
+
break;
|
41
|
+
case tracking_spi_1.Providers.None: // Do nothing, just a placeholder
|
42
|
+
break;
|
43
|
+
default:
|
44
|
+
if (providers.length > 1) {
|
45
|
+
if (initProps.verbose) {
|
46
|
+
// eslint-disable-next-line no-console
|
47
|
+
console.error("Unknown provider '" + provider);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
break;
|
51
|
+
}
|
52
|
+
});
|
53
|
+
}
|
18
54
|
// Initialize them
|
19
|
-
const enabledProviders = [];
|
20
55
|
for (const provider of providers) {
|
21
|
-
|
22
|
-
if (Object.keys(initProps).indexOf(key) > -1) {
|
56
|
+
try {
|
23
57
|
provider.initialize(initProps);
|
24
|
-
|
58
|
+
}
|
59
|
+
catch (e) {
|
60
|
+
// eslint-disable-next-line no-console
|
61
|
+
console.error(e);
|
25
62
|
}
|
26
63
|
}
|
27
|
-
|
28
|
-
const consoleTrackingProvider = new console_tracking_provider_1.ConsoleTrackingProvider();
|
29
|
-
enabledProviders.push(consoleTrackingProvider); // TODO noop- provider?
|
30
|
-
return new trackingProviderProxy_1.default(enabledProviders);
|
64
|
+
return new trackingProviderProxy_1.default(providers);
|
31
65
|
};
|
32
66
|
exports.getTrackingProviders = getTrackingProviders;
|
33
67
|
exports.default = exports.getTrackingProviders;
|
@@ -1,9 +1,19 @@
|
|
1
|
-
import { TrackingApi
|
2
|
-
export
|
3
|
-
|
1
|
+
import { TrackingApi } from './tracking_api';
|
2
|
+
export declare enum Providers {
|
3
|
+
None = 0,
|
4
|
+
Segment = 1,
|
5
|
+
Umami = 2,
|
6
|
+
Posthog = 3,
|
7
|
+
Console = 4
|
8
|
+
}
|
9
|
+
export type ProviderAsString = keyof typeof Providers;
|
10
|
+
export interface BaseProps {
|
11
|
+
verbose: boolean;
|
12
|
+
activeProviders: [ProviderAsString];
|
4
13
|
}
|
14
|
+
export type InitProps = {
|
15
|
+
[key: string]: string | number | boolean;
|
16
|
+
} & BaseProps;
|
5
17
|
export interface TrackingSpi extends TrackingApi {
|
6
|
-
getKey: () => string;
|
7
18
|
initialize: (props: InitProps) => void;
|
8
|
-
trackSingleItem: (item: string, properties?: TrackingEventProperties) => void;
|
9
19
|
}
|
@@ -1,2 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Providers = void 0;
|
4
|
+
var Providers;
|
5
|
+
(function (Providers) {
|
6
|
+
Providers[Providers["None"] = 0] = "None";
|
7
|
+
Providers[Providers["Segment"] = 1] = "Segment";
|
8
|
+
Providers[Providers["Umami"] = 2] = "Umami";
|
9
|
+
Providers[Providers["Posthog"] = 3] = "Posthog";
|
10
|
+
Providers[Providers["Console"] = 4] = "Console";
|
11
|
+
})(Providers || (exports.Providers = Providers = {}));
|
@@ -6,9 +6,13 @@ declare global {
|
|
6
6
|
}
|
7
7
|
}
|
8
8
|
export declare class UmamiTrackingProvider implements TrackingSpi, TrackingApi {
|
9
|
-
|
9
|
+
private verbose;
|
10
|
+
private websiteId;
|
11
|
+
private queue;
|
10
12
|
initialize(props: InitProps): void;
|
11
|
-
identify(userID: string): void;
|
13
|
+
identify(userID: string, userProperties?: TrackingEventProperties): void;
|
12
14
|
trackPageView(url: string | undefined): void;
|
13
15
|
trackSingleItem(item: string, properties?: TrackingEventProperties): void;
|
16
|
+
flushQueue(): void;
|
17
|
+
log(msg: string): void;
|
14
18
|
}
|
@@ -2,43 +2,87 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.UmamiTrackingProvider = void 0;
|
4
4
|
class UmamiTrackingProvider {
|
5
|
-
|
6
|
-
|
5
|
+
constructor() {
|
6
|
+
this.verbose = false;
|
7
|
+
this.queue = [];
|
7
8
|
}
|
8
9
|
initialize(props) {
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
this.verbose = props.verbose;
|
11
|
+
this.log('UmamiProvider initialize');
|
12
|
+
this.websiteId = props.umamiKey;
|
12
13
|
const hostUrl = props.umamiHostUrl;
|
13
14
|
const script = document.createElement('script');
|
14
15
|
script.src = hostUrl + '/script.js';
|
15
16
|
script.async = true;
|
16
17
|
script.defer = true;
|
17
18
|
// Configure Umami properties
|
18
|
-
script.setAttribute('data-website-id',
|
19
|
-
script.setAttribute('data-
|
19
|
+
script.setAttribute('data-website-id', this.websiteId);
|
20
|
+
script.setAttribute('data-host-url', hostUrl);
|
20
21
|
script.setAttribute('data-auto-track', 'false');
|
21
|
-
script.setAttribute('data-
|
22
|
-
|
22
|
+
script.setAttribute('data-exclude-search', 'false');
|
23
|
+
// Now get from config, which may override some of the above.
|
24
|
+
const UMAMI_PREFIX = 'umami-';
|
25
|
+
for (const prop in props) {
|
26
|
+
if (prop.startsWith(UMAMI_PREFIX)) {
|
27
|
+
const att = 'data-' + prop.substring(UMAMI_PREFIX.length);
|
28
|
+
const val = props[prop];
|
29
|
+
script.setAttribute(att, String(val));
|
30
|
+
}
|
31
|
+
}
|
32
|
+
script.onload = () => {
|
33
|
+
this.log('UmamiProvider script loaded');
|
34
|
+
this.flushQueue();
|
35
|
+
};
|
23
36
|
document.body.appendChild(script);
|
24
37
|
}
|
25
|
-
identify(userID) {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
38
|
+
identify(userID, userProperties = {}) {
|
39
|
+
this.log('UmamiProvider userID: ' + userID + ' => ' + JSON.stringify(userProperties));
|
40
|
+
if (window.umami) {
|
41
|
+
window.umami.identify({ userID, userProperties });
|
42
|
+
}
|
43
|
+
else {
|
44
|
+
this.queue.push({ what: 'i', name: userID, payload: userProperties });
|
45
|
+
}
|
30
46
|
}
|
31
47
|
trackPageView(url) {
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
48
|
+
this.log('UmamiProvider url ' + url);
|
49
|
+
if (window.umami) {
|
50
|
+
window.umami.track({ url, website: this.websiteId });
|
51
|
+
}
|
52
|
+
else {
|
53
|
+
this.queue.push({ what: 'p', name: String(url) });
|
54
|
+
}
|
36
55
|
}
|
37
56
|
trackSingleItem(item, properties) {
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
57
|
+
this.log('UmamiProvider: trackSingleItem ' + item + JSON.stringify(properties));
|
58
|
+
if (window.umami) {
|
59
|
+
window.umami.track(item, properties);
|
60
|
+
}
|
61
|
+
else {
|
62
|
+
this.queue.push({ what: 't', name: item, payload: properties });
|
63
|
+
}
|
64
|
+
}
|
65
|
+
flushQueue() {
|
66
|
+
for (const item of this.queue) {
|
67
|
+
this.log('Queue flush ' + JSON.stringify(item));
|
68
|
+
switch (item.what) {
|
69
|
+
case 'i':
|
70
|
+
this.identify(item.name, item.payload);
|
71
|
+
break;
|
72
|
+
case 't':
|
73
|
+
this.trackSingleItem(item.name, item.payload);
|
74
|
+
break;
|
75
|
+
case 'p':
|
76
|
+
this.trackPageView(item.name);
|
77
|
+
break;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
log(msg) {
|
82
|
+
if (this.verbose) {
|
83
|
+
// eslint-disable-next-line no-console
|
84
|
+
console.debug('UmamiProvider: ', msg);
|
85
|
+
}
|
42
86
|
}
|
43
87
|
}
|
44
88
|
exports.UmamiTrackingProvider = UmamiTrackingProvider;
|
@@ -1,10 +1,9 @@
|
|
1
|
-
import { TrackingSpi } from './tracking_spi';
|
1
|
+
import { InitProps, TrackingSpi } from './tracking_spi';
|
2
2
|
import { TrackingApi, TrackingEventProperties } from './tracking_api';
|
3
3
|
export declare class ConsoleTrackingProvider implements TrackingSpi, TrackingApi {
|
4
|
+
private verbose;
|
4
5
|
trackPageView(url: string | undefined): void;
|
5
|
-
|
6
|
-
|
7
|
-
identify(userID: string): void;
|
6
|
+
initialize(props: InitProps): void;
|
7
|
+
identify(userID: string, userProperties?: TrackingEventProperties): void;
|
8
8
|
trackSingleItem(item: string, properties?: TrackingEventProperties): void;
|
9
|
-
getKey(): string;
|
10
9
|
}
|
@@ -1,23 +1,30 @@
|
|
1
1
|
export class ConsoleTrackingProvider {
|
2
|
+
constructor() {
|
3
|
+
this.verbose = false;
|
4
|
+
}
|
2
5
|
trackPageView(url) {
|
3
|
-
|
4
|
-
|
6
|
+
if (this.verbose) {
|
7
|
+
// eslint-disable-next-line no-console
|
8
|
+
console.log('ConsoleProvider pageView ', url);
|
9
|
+
}
|
5
10
|
}
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
+
initialize(props) {
|
12
|
+
this.verbose = props.verbose;
|
13
|
+
if (this.verbose) {
|
14
|
+
// eslint-disable-next-line no-console
|
15
|
+
console.log('ConsoleProvider initialize');
|
16
|
+
}
|
11
17
|
}
|
12
|
-
identify(userID) {
|
13
|
-
|
14
|
-
|
18
|
+
identify(userID, userProperties = {}) {
|
19
|
+
if (this.verbose) {
|
20
|
+
// eslint-disable-next-line no-console
|
21
|
+
console.log('ConsoleProvider identify ', userID, userProperties);
|
22
|
+
}
|
15
23
|
}
|
16
24
|
trackSingleItem(item, properties) {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
return 'console';
|
25
|
+
if (this.verbose) {
|
26
|
+
// eslint-disable-next-line no-console
|
27
|
+
console.log('ConsoleProvider: ' + item, properties);
|
28
|
+
}
|
22
29
|
}
|
23
30
|
}
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { TrackingApi, TrackingEventProperties } from './tracking_api';
|
2
2
|
import { InitProps, TrackingSpi } from './tracking_spi';
|
3
3
|
export declare class PosthogTrackingProvider implements TrackingSpi, TrackingApi {
|
4
|
-
|
4
|
+
private verbose;
|
5
5
|
initialize(props: InitProps): void;
|
6
|
-
identify(userID: string): void;
|
6
|
+
identify(userID: string, userProperties?: TrackingEventProperties): void;
|
7
7
|
trackPageView(url: string | undefined): void;
|
8
8
|
trackSingleItem(item: string, properties?: TrackingEventProperties): void;
|
9
9
|
}
|
@@ -1,11 +1,14 @@
|
|
1
1
|
import { posthog } from 'posthog-js';
|
2
2
|
export class PosthogTrackingProvider {
|
3
|
-
|
4
|
-
|
3
|
+
constructor() {
|
4
|
+
this.verbose = false;
|
5
5
|
}
|
6
6
|
initialize(props) {
|
7
|
-
|
8
|
-
|
7
|
+
this.verbose = props.verbose;
|
8
|
+
if (this.verbose) {
|
9
|
+
// eslint-disable-next-line no-console
|
10
|
+
console.log('PosthogProvider initialize');
|
11
|
+
}
|
9
12
|
const posthogKey = props.posthogKey;
|
10
13
|
posthog.init(posthogKey, {
|
11
14
|
// eslint-disable-next-line camelcase
|
@@ -14,20 +17,26 @@ export class PosthogTrackingProvider {
|
|
14
17
|
person_profiles: 'identified_only' // or 'always' to create profiles for anonymous users as well
|
15
18
|
});
|
16
19
|
}
|
17
|
-
identify(userID) {
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
identify(userID, userProperties = {}) {
|
21
|
+
if (this.verbose) {
|
22
|
+
// eslint-disable-next-line no-console
|
23
|
+
console.log('PosthogProvider userID: ' + userID);
|
24
|
+
}
|
25
|
+
posthog.identify(userID, userProperties);
|
21
26
|
}
|
22
27
|
trackPageView(url) {
|
23
|
-
|
24
|
-
|
28
|
+
if (this.verbose) {
|
29
|
+
// eslint-disable-next-line no-console
|
30
|
+
console.log('PostHogProvider url ', url);
|
31
|
+
}
|
25
32
|
// TODO posthog seems to record that automatically.
|
26
33
|
// How to not clash with this here? Just leave as no-op?
|
27
34
|
}
|
28
35
|
trackSingleItem(item, properties) {
|
29
|
-
|
30
|
-
|
36
|
+
if (this.verbose) {
|
37
|
+
// eslint-disable-next-line no-console
|
38
|
+
console.log('PosthogProvider: trackSingleItem ' + item, properties);
|
39
|
+
}
|
31
40
|
posthog.capture(item, { properties });
|
32
41
|
}
|
33
42
|
}
|
@@ -2,9 +2,9 @@ import { TrackingApi, TrackingEventProperties } from './tracking_api';
|
|
2
2
|
import { InitProps, TrackingSpi } from './tracking_spi';
|
3
3
|
export declare class SegmentTrackingProvider implements TrackingSpi, TrackingApi {
|
4
4
|
private analytics;
|
5
|
-
|
5
|
+
private verbose;
|
6
6
|
initialize(props: InitProps): void;
|
7
|
-
identify(userID: string): void;
|
7
|
+
identify(userID: string, userProperties?: TrackingEventProperties): void;
|
8
8
|
trackPageView(url: string | undefined): void;
|
9
9
|
trackSingleItem(item: string, properties?: TrackingEventProperties): void;
|
10
10
|
}
|