@botonic/plugin-hubtype-analytics 0.35.0-alpha.1 → 0.36.0-alpha.0
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/lib/cjs/event-models/ht-event.d.ts +3 -2
- package/lib/cjs/event-models/ht-event.js +4 -3
- package/lib/cjs/event-models/ht-event.js.map +1 -1
- package/lib/cjs/index.d.ts +1 -5
- package/lib/cjs/index.js +3 -9
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/types.d.ts +3 -2
- package/lib/esm/event-models/ht-event.d.ts +3 -2
- package/lib/esm/event-models/ht-event.js +4 -3
- package/lib/esm/event-models/ht-event.js.map +1 -1
- package/lib/esm/index.d.ts +1 -5
- package/lib/esm/index.js +3 -9
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/types.d.ts +3 -2
- package/package.json +3 -3
- package/src/event-models/ht-event.ts +7 -5
- package/src/index.ts +3 -12
- package/src/types.ts +3 -2
|
@@ -2,12 +2,13 @@ import { EventAction, EventType, HtEventProps, RequestData } from '../types';
|
|
|
2
2
|
export declare class HtEvent {
|
|
3
3
|
chat_id?: string;
|
|
4
4
|
type: EventType;
|
|
5
|
-
chat_language: string;
|
|
6
|
-
chat_country?: string;
|
|
7
5
|
format_version?: number;
|
|
8
6
|
bot_version?: string;
|
|
9
7
|
flow_version?: string;
|
|
10
8
|
action: EventAction;
|
|
11
9
|
bot_interaction_id?: string;
|
|
10
|
+
user_locale: string;
|
|
11
|
+
user_country: string;
|
|
12
|
+
system_locale: string;
|
|
12
13
|
constructor(event: HtEventProps, requestData: RequestData);
|
|
13
14
|
}
|
|
@@ -4,11 +4,12 @@ exports.HtEvent = void 0;
|
|
|
4
4
|
class HtEvent {
|
|
5
5
|
constructor(event, requestData) {
|
|
6
6
|
this.chat_id = requestData.userId;
|
|
7
|
-
this.
|
|
8
|
-
this.chat_country = requestData.country;
|
|
9
|
-
this.format_version = 2;
|
|
7
|
+
this.format_version = 3;
|
|
10
8
|
this.action = event.action;
|
|
11
9
|
this.bot_interaction_id = requestData.botInteractionId;
|
|
10
|
+
this.user_locale = requestData.userLocale;
|
|
11
|
+
this.user_country = requestData.userCountry;
|
|
12
|
+
this.system_locale = requestData.systemLocale;
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
exports.HtEvent = HtEvent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ht-event.js","sourceRoot":"","sources":["../../../src/event-models/ht-event.ts"],"names":[],"mappings":";;;AAGA,MAAa,OAAO;
|
|
1
|
+
{"version":3,"file":"ht-event.js","sourceRoot":"","sources":["../../../src/event-models/ht-event.ts"],"names":[],"mappings":";;;AAGA,MAAa,OAAO;IAYlB,YAAY,KAAmB,EAAE,WAAwB;QACvD,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC,MAAM,CAAA;QACjC,IAAI,CAAC,cAAc,GAAG,CAAC,CAAA;QACvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAA;QAC1B,IAAI,CAAC,kBAAkB,GAAG,WAAW,CAAC,gBAAgB,CAAA;QACtD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,UAAU,CAAA;QACzC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC,WAAW,CAAA;QAC3C,IAAI,CAAC,aAAa,GAAG,WAAW,CAAC,YAAY,CAAA;IAC/C,CAAC;CACF;AArBD,0BAqBC"}
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -2,13 +2,9 @@ import { BotContext, Plugin } from '@botonic/core';
|
|
|
2
2
|
import { HtEventProps, RequestData } from './types';
|
|
3
3
|
export default class BotonicPluginHubtypeAnalytics implements Plugin {
|
|
4
4
|
eventsBaseUrl: string;
|
|
5
|
-
getLanguage: (request: BotContext) => string;
|
|
6
|
-
getCountry: (request: BotContext) => string;
|
|
7
5
|
constructor();
|
|
8
6
|
post(): void;
|
|
9
|
-
trackEvent(request: BotContext, htEventProps: HtEventProps): Promise<
|
|
10
|
-
data: string;
|
|
11
|
-
} | import("axios").AxiosResponse<any, any>>;
|
|
7
|
+
trackEvent(request: BotContext, htEventProps: HtEventProps): Promise<import("axios").AxiosResponse<any, any>>;
|
|
12
8
|
getRequestData(request: BotContext): RequestData;
|
|
13
9
|
private isLambdaEvent;
|
|
14
10
|
private sendEvent;
|
package/lib/cjs/index.js
CHANGED
|
@@ -8,19 +8,12 @@ class BotonicPluginHubtypeAnalytics {
|
|
|
8
8
|
constructor() {
|
|
9
9
|
const hubtypeUrl = process.env.HUBTYPE_API_URL || 'https://api.hubtype.com';
|
|
10
10
|
this.eventsBaseUrl = `${hubtypeUrl}/external/v2/conversational_apps`;
|
|
11
|
-
this.getLanguage = (request) => request.getSystemLocale();
|
|
12
|
-
this.getCountry = (request) => request.getUserCountry();
|
|
13
11
|
}
|
|
14
12
|
post() {
|
|
15
13
|
return;
|
|
16
14
|
}
|
|
17
15
|
trackEvent(request, htEventProps) {
|
|
18
16
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
if (request.session.is_test_integration) {
|
|
20
|
-
return Promise.resolve({
|
|
21
|
-
data: 'Event not sent because it is a test integration',
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
17
|
const requestData = this.getRequestData(request);
|
|
25
18
|
const event = (0, utils_1.createHtEvent)(requestData, htEventProps);
|
|
26
19
|
return this.sendEvent(request, event);
|
|
@@ -29,10 +22,11 @@ class BotonicPluginHubtypeAnalytics {
|
|
|
29
22
|
getRequestData(request) {
|
|
30
23
|
var _a;
|
|
31
24
|
return {
|
|
32
|
-
language: this.getLanguage(request),
|
|
33
|
-
country: this.getCountry(request),
|
|
34
25
|
userId: this.isLambdaEvent(request) ? request.session.user.id : undefined,
|
|
35
26
|
botInteractionId: (_a = request.input) === null || _a === void 0 ? void 0 : _a.bot_interaction_id,
|
|
27
|
+
userLocale: request.getSystemLocale(),
|
|
28
|
+
userCountry: request.getUserCountry(),
|
|
29
|
+
systemLocale: request.getSystemLocale(),
|
|
36
30
|
};
|
|
37
31
|
}
|
|
38
32
|
isLambdaEvent(request) {
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,0DAAyB;AAGzB,mCAA8D;AAC9D,mCAAuC;AAEvC,MAAqB,6BAA6B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,0DAAyB;AAGzB,mCAA8D;AAC9D,mCAAuC;AAEvC,MAAqB,6BAA6B;IAEhD;QACE,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,yBAAyB,CAAA;QAC3E,IAAI,CAAC,aAAa,GAAG,GAAG,UAAU,kCAAkC,CAAA;IACtE,CAAC;IAED,IAAI;QACF,OAAM;IACR,CAAC;IAEK,UAAU,CAAC,OAAmB,EAAE,YAA0B;;YAC9D,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;YAChD,MAAM,KAAK,GAAG,IAAA,qBAAa,EAAC,WAAW,EAAE,YAAY,CAAC,CAAA;YACtD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QACvC,CAAC;KAAA;IAED,cAAc,CAAC,OAAmB;;QAChC,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;YACzE,gBAAgB,EAAE,MAAA,OAAO,CAAC,KAAK,0CAAE,kBAAkB;YACnD,UAAU,EAAE,OAAO,CAAC,eAAe,EAAE;YACrC,WAAW,EAAE,OAAO,CAAC,cAAc,EAAE;YACrC,YAAY,EAAE,OAAO,CAAC,eAAe,EAAE;SACxC,CAAA;IACH,CAAC;IAEO,aAAa,CA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EAAE,KAAK,CAAC,CAAA;IAC/B,CAAC;IAEO,wBAAwB,CAAC,OAAmB,EAAE,KAAc;QAClE,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,aAAa,aAAa,CAAA;QAC9C,MAAM,MAAM,GAAG;YACb,MAAM,EAAE;gBACN,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;aACrC;SACF,CAAA;QACD,OAAO,eAAK,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IACvC,CAAC;CACF;AAvED,gDAuEC;AAED,kDAAuB;AACvB,kDAAuB"}
|
package/lib/cjs/types.d.ts
CHANGED
|
@@ -154,8 +154,9 @@ export interface EventCustom extends HtBaseEventProps {
|
|
|
154
154
|
}
|
|
155
155
|
export type HtEventProps = EventFeedback | EventFeedbackKnowledgebase | EventFlow | EventHandoff | EventHandoffOption | EventIntent | EventKeyword | EventIntentSmart | EventKnowledgeBase | EventFallback | EventWebviewStep | EventWebviewEnd | EventCustom;
|
|
156
156
|
export interface RequestData {
|
|
157
|
-
language: string;
|
|
158
|
-
country: string;
|
|
159
157
|
userId?: string;
|
|
160
158
|
botInteractionId: string;
|
|
159
|
+
userLocale: string;
|
|
160
|
+
userCountry: string;
|
|
161
|
+
systemLocale: string;
|
|
161
162
|
}
|
|
@@ -2,12 +2,13 @@ import { EventAction, EventType, HtEventProps, RequestData } from '../types';
|
|
|
2
2
|
export declare class HtEvent {
|
|
3
3
|
chat_id?: string;
|
|
4
4
|
type: EventType;
|
|
5
|
-
chat_language: string;
|
|
6
|
-
chat_country?: string;
|
|
7
5
|
format_version?: number;
|
|
8
6
|
bot_version?: string;
|
|
9
7
|
flow_version?: string;
|
|
10
8
|
action: EventAction;
|
|
11
9
|
bot_interaction_id?: string;
|
|
10
|
+
user_locale: string;
|
|
11
|
+
user_country: string;
|
|
12
|
+
system_locale: string;
|
|
12
13
|
constructor(event: HtEventProps, requestData: RequestData);
|
|
13
14
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export class HtEvent {
|
|
2
2
|
constructor(event, requestData) {
|
|
3
3
|
this.chat_id = requestData.userId;
|
|
4
|
-
this.
|
|
5
|
-
this.chat_country = requestData.country;
|
|
6
|
-
this.format_version = 2;
|
|
4
|
+
this.format_version = 3;
|
|
7
5
|
this.action = event.action;
|
|
8
6
|
this.bot_interaction_id = requestData.botInteractionId;
|
|
7
|
+
this.user_locale = requestData.userLocale;
|
|
8
|
+
this.user_country = requestData.userCountry;
|
|
9
|
+
this.system_locale = requestData.systemLocale;
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
//# sourceMappingURL=ht-event.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ht-event.js","sourceRoot":"","sources":["../../../src/event-models/ht-event.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,OAAO;
|
|
1
|
+
{"version":3,"file":"ht-event.js","sourceRoot":"","sources":["../../../src/event-models/ht-event.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,OAAO;IAYlB,YAAY,KAAmB,EAAE,WAAwB;QACvD,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC,MAAM,CAAA;QACjC,IAAI,CAAC,cAAc,GAAG,CAAC,CAAA;QACvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAA;QAC1B,IAAI,CAAC,kBAAkB,GAAG,WAAW,CAAC,gBAAgB,CAAA;QACtD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,UAAU,CAAA;QACzC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC,WAAW,CAAA;QAC3C,IAAI,CAAC,aAAa,GAAG,WAAW,CAAC,YAAY,CAAA;IAC/C,CAAC;CACF"}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -3,13 +3,9 @@ import axios from 'axios';
|
|
|
3
3
|
import { HtEventProps, RequestData } from './types';
|
|
4
4
|
export default class BotonicPluginHubtypeAnalytics implements Plugin {
|
|
5
5
|
eventsBaseUrl: string;
|
|
6
|
-
getLanguage: (request: BotContext) => string;
|
|
7
|
-
getCountry: (request: BotContext) => string;
|
|
8
6
|
constructor();
|
|
9
7
|
post(): void;
|
|
10
|
-
trackEvent(request: BotContext, htEventProps: HtEventProps): Promise<
|
|
11
|
-
data: string;
|
|
12
|
-
} | axios.AxiosResponse<any, any>>;
|
|
8
|
+
trackEvent(request: BotContext, htEventProps: HtEventProps): Promise<axios.AxiosResponse<any, any>>;
|
|
13
9
|
getRequestData(request: BotContext): RequestData;
|
|
14
10
|
private isLambdaEvent;
|
|
15
11
|
private sendEvent;
|
package/lib/esm/index.js
CHANGED
|
@@ -6,19 +6,12 @@ export default class BotonicPluginHubtypeAnalytics {
|
|
|
6
6
|
constructor() {
|
|
7
7
|
const hubtypeUrl = process.env.HUBTYPE_API_URL || 'https://api.hubtype.com';
|
|
8
8
|
this.eventsBaseUrl = `${hubtypeUrl}/external/v2/conversational_apps`;
|
|
9
|
-
this.getLanguage = (request) => request.getSystemLocale();
|
|
10
|
-
this.getCountry = (request) => request.getUserCountry();
|
|
11
9
|
}
|
|
12
10
|
post() {
|
|
13
11
|
return;
|
|
14
12
|
}
|
|
15
13
|
trackEvent(request, htEventProps) {
|
|
16
14
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
if (request.session.is_test_integration) {
|
|
18
|
-
return Promise.resolve({
|
|
19
|
-
data: 'Event not sent because it is a test integration',
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
15
|
const requestData = this.getRequestData(request);
|
|
23
16
|
const event = createHtEvent(requestData, htEventProps);
|
|
24
17
|
return this.sendEvent(request, event);
|
|
@@ -27,10 +20,11 @@ export default class BotonicPluginHubtypeAnalytics {
|
|
|
27
20
|
getRequestData(request) {
|
|
28
21
|
var _a;
|
|
29
22
|
return {
|
|
30
|
-
language: this.getLanguage(request),
|
|
31
|
-
country: this.getCountry(request),
|
|
32
23
|
userId: this.isLambdaEvent(request) ? request.session.user.id : undefined,
|
|
33
24
|
botInteractionId: (_a = request.input) === null || _a === void 0 ? void 0 : _a.bot_interaction_id,
|
|
25
|
+
userLocale: request.getSystemLocale(),
|
|
26
|
+
userCountry: request.getUserCountry(),
|
|
27
|
+
systemLocale: request.getSystemLocale(),
|
|
34
28
|
};
|
|
35
29
|
}
|
|
36
30
|
isLambdaEvent(request) {
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAE,SAAS,EAA6B,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,MAAM,CAAC,OAAO,OAAO,6BAA6B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAE,SAAS,EAA6B,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,MAAM,CAAC,OAAO,OAAO,6BAA6B;IAEhD;QACE,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,yBAAyB,CAAA;QAC3E,IAAI,CAAC,aAAa,GAAG,GAAG,UAAU,kCAAkC,CAAA;IACtE,CAAC;IAED,IAAI;QACF,OAAM;IACR,CAAC;IAEK,UAAU,CAAC,OAAmB,EAAE,YAA0B;;YAC9D,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;YAChD,MAAM,KAAK,GAAG,aAAa,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;YACtD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QACvC,CAAC;KAAA;IAED,cAAc,CAAC,OAAmB;;QACh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AAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;SAChD;QAED,OAAO,IAAI,CAAC,wBAAwB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACtD,CAAC;IAEO,mBAAmB,CAAC,OAAmB,EAAE,KAAc;QAC7D,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAA;QACpC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,aAAa,IAAI,KAAK,aAAa,CAAA;QACvD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IAC/B,CAAC;IAEO,wBAAwB,CAAC,OAAmB,EAAE,KAAc;QAClE,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,aAAa,aAAa,CAAA;QAC9C,MAAM,MAAM,GAAG;YACb,MAAM,EAAE;gBACN,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;aACrC;SACF,CAAA;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IACvC,CAAC;CACF;AAED,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
|
package/lib/esm/types.d.ts
CHANGED
|
@@ -154,8 +154,9 @@ export interface EventCustom extends HtBaseEventProps {
|
|
|
154
154
|
}
|
|
155
155
|
export type HtEventProps = EventFeedback | EventFeedbackKnowledgebase | EventFlow | EventHandoff | EventHandoffOption | EventIntent | EventKeyword | EventIntentSmart | EventKnowledgeBase | EventFallback | EventWebviewStep | EventWebviewEnd | EventCustom;
|
|
156
156
|
export interface RequestData {
|
|
157
|
-
language: string;
|
|
158
|
-
country: string;
|
|
159
157
|
userId?: string;
|
|
160
158
|
botInteractionId: string;
|
|
159
|
+
userLocale: string;
|
|
160
|
+
userCountry: string;
|
|
161
|
+
systemLocale: string;
|
|
161
162
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botonic/plugin-hubtype-analytics",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0-alpha.0",
|
|
4
4
|
"description": "Plugin for tracking in the Hubtype backend to see the results in the Hubtype Dashbord",
|
|
5
5
|
"main": "./lib/cjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/runtime": "^7.26.0",
|
|
17
|
-
"@botonic/core": "0.
|
|
18
|
-
"axios": "^1.
|
|
17
|
+
"@botonic/core": "^0.36.0-alpha.0",
|
|
18
|
+
"axios": "^1.9.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/node": "^20.11.17",
|
|
@@ -4,20 +4,22 @@ import { EventAction, EventType, HtEventProps, RequestData } from '../types'
|
|
|
4
4
|
export class HtEvent {
|
|
5
5
|
chat_id?: string
|
|
6
6
|
type: EventType
|
|
7
|
-
chat_language: string
|
|
8
|
-
chat_country?: string
|
|
9
7
|
format_version?: number
|
|
10
8
|
bot_version?: string
|
|
11
9
|
flow_version?: string
|
|
12
10
|
action: EventAction
|
|
13
11
|
bot_interaction_id?: string
|
|
12
|
+
user_locale: string
|
|
13
|
+
user_country: string
|
|
14
|
+
system_locale: string
|
|
14
15
|
|
|
15
16
|
constructor(event: HtEventProps, requestData: RequestData) {
|
|
16
17
|
this.chat_id = requestData.userId
|
|
17
|
-
this.
|
|
18
|
-
this.chat_country = requestData.country
|
|
19
|
-
this.format_version = 2
|
|
18
|
+
this.format_version = 3
|
|
20
19
|
this.action = event.action
|
|
21
20
|
this.bot_interaction_id = requestData.botInteractionId
|
|
21
|
+
this.user_locale = requestData.userLocale
|
|
22
|
+
this.user_country = requestData.userCountry
|
|
23
|
+
this.system_locale = requestData.systemLocale
|
|
22
24
|
}
|
|
23
25
|
}
|
package/src/index.ts
CHANGED
|
@@ -7,13 +7,9 @@ import { createHtEvent } from './utils'
|
|
|
7
7
|
|
|
8
8
|
export default class BotonicPluginHubtypeAnalytics implements Plugin {
|
|
9
9
|
eventsBaseUrl: string
|
|
10
|
-
getLanguage: (request: BotContext) => string
|
|
11
|
-
getCountry: (request: BotContext) => string
|
|
12
10
|
constructor() {
|
|
13
11
|
const hubtypeUrl = process.env.HUBTYPE_API_URL || 'https://api.hubtype.com'
|
|
14
12
|
this.eventsBaseUrl = `${hubtypeUrl}/external/v2/conversational_apps`
|
|
15
|
-
this.getLanguage = (request: BotContext) => request.getSystemLocale()
|
|
16
|
-
this.getCountry = (request: BotContext) => request.getUserCountry()
|
|
17
13
|
}
|
|
18
14
|
|
|
19
15
|
post(): void {
|
|
@@ -21,12 +17,6 @@ export default class BotonicPluginHubtypeAnalytics implements Plugin {
|
|
|
21
17
|
}
|
|
22
18
|
|
|
23
19
|
async trackEvent(request: BotContext, htEventProps: HtEventProps) {
|
|
24
|
-
if (request.session.is_test_integration) {
|
|
25
|
-
return Promise.resolve({
|
|
26
|
-
data: 'Event not sent because it is a test integration',
|
|
27
|
-
})
|
|
28
|
-
}
|
|
29
|
-
|
|
30
20
|
const requestData = this.getRequestData(request)
|
|
31
21
|
const event = createHtEvent(requestData, htEventProps)
|
|
32
22
|
return this.sendEvent(request, event)
|
|
@@ -34,10 +24,11 @@ export default class BotonicPluginHubtypeAnalytics implements Plugin {
|
|
|
34
24
|
|
|
35
25
|
getRequestData(request: BotContext): RequestData {
|
|
36
26
|
return {
|
|
37
|
-
language: this.getLanguage(request),
|
|
38
|
-
country: this.getCountry(request),
|
|
39
27
|
userId: this.isLambdaEvent(request) ? request.session.user.id : undefined,
|
|
40
28
|
botInteractionId: request.input?.bot_interaction_id,
|
|
29
|
+
userLocale: request.getSystemLocale(),
|
|
30
|
+
userCountry: request.getUserCountry(),
|
|
31
|
+
systemLocale: request.getSystemLocale(),
|
|
41
32
|
}
|
|
42
33
|
}
|
|
43
34
|
|
package/src/types.ts
CHANGED
|
@@ -190,8 +190,9 @@ export type HtEventProps =
|
|
|
190
190
|
| EventCustom
|
|
191
191
|
|
|
192
192
|
export interface RequestData {
|
|
193
|
-
language: string
|
|
194
|
-
country: string
|
|
195
193
|
userId?: string
|
|
196
194
|
botInteractionId: string
|
|
195
|
+
userLocale: string
|
|
196
|
+
userCountry: string
|
|
197
|
+
systemLocale: string
|
|
197
198
|
}
|