@segment/analytics-browser-hubble-web 1.1.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/README.md +31 -0
- package/dist/cjs/generated-types.d.ts +3 -0
- package/dist/cjs/generated-types.js +3 -0
- package/dist/cjs/generated-types.js.map +1 -0
- package/dist/cjs/identify/generated-types.d.ts +7 -0
- package/dist/cjs/identify/generated-types.js +3 -0
- package/dist/cjs/identify/generated-types.js.map +1 -0
- package/dist/cjs/identify/index.d.ts +6 -0
- package/dist/cjs/identify/index.js +44 -0
- package/dist/cjs/identify/index.js.map +1 -0
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.js +50 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/track/generated-types.d.ts +8 -0
- package/dist/cjs/track/generated-types.js +3 -0
- package/dist/cjs/track/generated-types.js.map +1 -0
- package/dist/cjs/track/index.d.ts +6 -0
- package/dist/cjs/track/index.js +58 -0
- package/dist/cjs/track/index.js.map +1 -0
- package/dist/cjs/types.d.ts +9 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/generated-types.d.ts +3 -0
- package/dist/esm/generated-types.js +2 -0
- package/dist/esm/generated-types.js.map +1 -0
- package/dist/esm/identify/generated-types.d.ts +7 -0
- package/dist/esm/identify/generated-types.js +2 -0
- package/dist/esm/identify/generated-types.js.map +1 -0
- package/dist/esm/identify/index.d.ts +6 -0
- package/dist/esm/identify/index.js +42 -0
- package/dist/esm/identify/index.js.map +1 -0
- package/dist/esm/index.d.ts +11 -0
- package/dist/esm/index.js +46 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/track/generated-types.d.ts +8 -0
- package/dist/esm/track/generated-types.js +2 -0
- package/dist/esm/track/generated-types.js.map +1 -0
- package/dist/esm/track/index.d.ts +6 -0
- package/dist/esm/track/index.js +56 -0
- package/dist/esm/track/index.js.map +1 -0
- package/dist/esm/types.d.ts +9 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +25 -0
- package/src/__tests__/__snapshots__/index.test.ts.snap +16 -0
- package/src/__tests__/index.test.ts +101 -0
- package/src/generated-types.ts +8 -0
- package/src/identify/__tests__/index.test.ts +92 -0
- package/src/identify/generated-types.ts +18 -0
- package/src/identify/index.ts +49 -0
- package/src/index.ts +64 -0
- package/src/track/__tests__/index.test.ts +84 -0
- package/src/track/generated-types.ts +22 -0
- package/src/track/index.ts +63 -0
- package/src/types.ts +10 -0
- package/tsconfig.json +9 -0
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @segment/analytics-browser-hubble-web
|
|
2
|
+
|
|
3
|
+
The Hubble (actions) browser action destination for use with @segment/analytics-next.
|
|
4
|
+
|
|
5
|
+
## License
|
|
6
|
+
|
|
7
|
+
MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2023 Segment
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
## Contributing
|
|
30
|
+
|
|
31
|
+
All third party contributors acknowledge that any contributions they provide will be made under the same open source license that the open source project is provided under.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../src/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/identify/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
|
|
2
|
+
import { Hubble } from '../types';
|
|
3
|
+
import type { Settings } from '../generated-types';
|
|
4
|
+
import type { Payload } from './generated-types';
|
|
5
|
+
declare const action: BrowserActionDefinition<Settings, Hubble, Payload>;
|
|
6
|
+
export default action;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const action = {
|
|
4
|
+
title: 'Identify',
|
|
5
|
+
description: 'Set identifiers and attributes for a user',
|
|
6
|
+
platform: 'web',
|
|
7
|
+
defaultSubscription: 'type = "identify"',
|
|
8
|
+
fields: {
|
|
9
|
+
userId: {
|
|
10
|
+
description: 'Unique identifer of the user',
|
|
11
|
+
type: 'string',
|
|
12
|
+
required: false,
|
|
13
|
+
label: 'User ID',
|
|
14
|
+
default: {
|
|
15
|
+
'@path': '$.userId'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
anonymousId: {
|
|
19
|
+
description: 'Anonymous identifier of the user',
|
|
20
|
+
type: 'string',
|
|
21
|
+
required: false,
|
|
22
|
+
label: 'Anonymous ID',
|
|
23
|
+
default: {
|
|
24
|
+
'@path': '$.anonymousId'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
attributes: {
|
|
28
|
+
description: 'User traits used to enrich user identification',
|
|
29
|
+
type: 'object',
|
|
30
|
+
required: false,
|
|
31
|
+
label: 'User Attributes (Traits)',
|
|
32
|
+
default: {
|
|
33
|
+
'@path': '$.traits'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
perform: (hubble, event) => {
|
|
38
|
+
const payload = event.payload;
|
|
39
|
+
hubble.identify &&
|
|
40
|
+
hubble.identify({ userId: payload.userId, anonymousId: payload.anonymousId, attributes: payload.attributes });
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.default = action;
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identify/index.ts"],"names":[],"mappings":";;AAMA,MAAM,MAAM,GAAuD;IACjE,KAAK,EAAE,UAAU;IACjB,WAAW,EAAE,2CAA2C;IACxD,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,MAAM,EAAE;YACN,WAAW,EAAE,8BAA8B;YAC3C,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;QACD,WAAW,EAAE;YACX,WAAW,EAAE,kCAAkC;YAC/C,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,cAAc;YACrB,OAAO,EAAE;gBACP,OAAO,EAAE,eAAe;aACzB;SACF;QACD,UAAU,EAAE;YACV,WAAW,EAAE,gDAAgD;YAC7D,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,0BAA0B;YACjC,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;KACF;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACzB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAA;QAE7B,MAAM,CAAC,QAAQ;YACb,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAA;IACjH,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Settings } from './generated-types';
|
|
2
|
+
import type { BrowserDestinationDefinition } from '@segment/browser-destination-runtime/types';
|
|
3
|
+
import { Hubble } from './types';
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
Hubble: Hubble;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare const destination: BrowserDestinationDefinition<Settings, Hubble>;
|
|
10
|
+
declare const _default: import("@segment/browser-destination-runtime/types").PluginFactory;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.destination = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const shim_1 = require("@segment/browser-destination-runtime/shim");
|
|
6
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
7
|
+
const track_1 = tslib_1.__importDefault(require("./track"));
|
|
8
|
+
const identify_1 = tslib_1.__importDefault(require("./identify"));
|
|
9
|
+
exports.destination = {
|
|
10
|
+
name: 'Hubble (actions)',
|
|
11
|
+
slug: 'hubble-web',
|
|
12
|
+
mode: 'device',
|
|
13
|
+
description: 'From design to production, monitor, measure and enhance your user experience with seamless integration with Segment',
|
|
14
|
+
presets: [
|
|
15
|
+
{
|
|
16
|
+
name: 'Identify user',
|
|
17
|
+
subscribe: 'type = "identify"',
|
|
18
|
+
partnerAction: 'identify',
|
|
19
|
+
mapping: actions_core_1.defaultValues(identify_1.default.fields),
|
|
20
|
+
type: 'automatic'
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'Track event',
|
|
24
|
+
subscribe: 'type = "track"',
|
|
25
|
+
partnerAction: 'track',
|
|
26
|
+
mapping: actions_core_1.defaultValues(track_1.default.fields),
|
|
27
|
+
type: 'automatic'
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
settings: {
|
|
31
|
+
id: {
|
|
32
|
+
description: 'Unique identifier for your team (given in Hubble app)',
|
|
33
|
+
label: 'id',
|
|
34
|
+
type: 'string',
|
|
35
|
+
required: true
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
initialize: async ({ settings }, deps) => {
|
|
39
|
+
await deps.loadScript(`https://sdk.hubble.team/api/sdk/${settings.id}`);
|
|
40
|
+
await deps.resolveWhen(() => window?.Hubble?.initialized, 250);
|
|
41
|
+
window?.Hubble?.setSource('__segment__');
|
|
42
|
+
return window.Hubble;
|
|
43
|
+
},
|
|
44
|
+
actions: {
|
|
45
|
+
track: track_1.default,
|
|
46
|
+
identify: identify_1.default
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.default = shim_1.browserDestination(exports.destination);
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAEA,oEAA8E;AAG9E,wDAAqD;AAErD,4DAA2B;AAC3B,kEAAiC;AAQpB,QAAA,WAAW,GAAmD;IACzE,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,YAAY;IAClB,IAAI,EAAE,QAAQ;IACd,WAAW,EACT,qHAAqH;IACvH,OAAO,EAAE;QACP;YACE,IAAI,EAAE,eAAe;YACrB,SAAS,EAAE,mBAAmB;YAC9B,aAAa,EAAE,UAAU;YACzB,OAAO,EAAE,4BAAa,CAAC,kBAAQ,CAAC,MAAM,CAAC;YACvC,IAAI,EAAE,WAAW;SAClB;QACD;YACE,IAAI,EAAE,aAAa;YACnB,SAAS,EAAE,gBAAgB;YAC3B,aAAa,EAAE,OAAO;YACtB,OAAO,EAAE,4BAAa,CAAC,eAAK,CAAC,MAAM,CAAC;YACpC,IAAI,EAAE,WAAW;SAClB;KACF;IAED,QAAQ,EAAE;QACR,EAAE,EAAE;YACF,WAAW,EAAE,uDAAuD;YACpE,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;KACF;IAED,UAAU,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE;QACvC,MAAM,IAAI,CAAC,UAAU,CAAC,mCAAmC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAA;QACvE,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,CAAA;QAG9D,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,aAAa,CAAC,CAAA;QACxC,OAAO,MAAM,CAAC,MAAM,CAAA;IACtB,CAAC;IAED,OAAO,EAAE;QACP,KAAK,EAAL,eAAK;QACL,QAAQ,EAAR,kBAAQ;KACT;CACF,CAAA;AAED,kBAAe,yBAAkB,CAAC,mBAAW,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/track/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
|
|
2
|
+
import { Hubble } from '../types';
|
|
3
|
+
import type { Settings } from '../generated-types';
|
|
4
|
+
import type { Payload } from './generated-types';
|
|
5
|
+
declare const action: BrowserActionDefinition<Settings, Hubble, Payload>;
|
|
6
|
+
export default action;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const action = {
|
|
4
|
+
title: 'Track',
|
|
5
|
+
description: 'Track events to trigger Hubble surveys',
|
|
6
|
+
platform: 'web',
|
|
7
|
+
defaultSubscription: 'type = "track"',
|
|
8
|
+
fields: {
|
|
9
|
+
event: {
|
|
10
|
+
description: 'Event to be tracked',
|
|
11
|
+
label: 'Event',
|
|
12
|
+
required: true,
|
|
13
|
+
type: 'string',
|
|
14
|
+
default: {
|
|
15
|
+
'@path': '$.event'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
attributes: {
|
|
19
|
+
description: 'Object containing the attributes (properties) of the event',
|
|
20
|
+
type: 'object',
|
|
21
|
+
required: false,
|
|
22
|
+
label: 'Event Attributes',
|
|
23
|
+
default: {
|
|
24
|
+
'@path': '$.properties'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
userId: {
|
|
28
|
+
description: 'Unique identifer of the user',
|
|
29
|
+
type: 'string',
|
|
30
|
+
required: false,
|
|
31
|
+
label: 'User ID',
|
|
32
|
+
default: {
|
|
33
|
+
'@path': '$.userId'
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
anonymousId: {
|
|
37
|
+
description: 'Anonymous identifier of the user',
|
|
38
|
+
type: 'string',
|
|
39
|
+
required: false,
|
|
40
|
+
label: 'Anonymous ID',
|
|
41
|
+
default: {
|
|
42
|
+
'@path': '$.anonymousId'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
perform: (hubble, event) => {
|
|
47
|
+
const payload = event.payload;
|
|
48
|
+
hubble.track &&
|
|
49
|
+
hubble.track({
|
|
50
|
+
event: payload.event,
|
|
51
|
+
attributes: payload.attributes,
|
|
52
|
+
userId: payload.userId,
|
|
53
|
+
anonymousId: payload.anonymousId
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
exports.default = action;
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/track/index.ts"],"names":[],"mappings":";;AAMA,MAAM,MAAM,GAAuD;IACjE,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,wCAAwC;IACrD,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAE;QACN,KAAK,EAAE;YACL,WAAW,EAAE,qBAAqB;YAClC,KAAK,EAAE,OAAO;YACd,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,SAAS;aACnB;SACF;QACD,UAAU,EAAE;YACV,WAAW,EAAE,4DAA4D;YACzE,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,kBAAkB;YACzB,OAAO,EAAE;gBACP,OAAO,EAAE,cAAc;aACxB;SACF;QACD,MAAM,EAAE;YACN,WAAW,EAAE,8BAA8B;YAC3C,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;QACD,WAAW,EAAE;YACX,WAAW,EAAE,kCAAkC;YAC/C,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,cAAc;YACrB,OAAO,EAAE;gBACP,OAAO,EAAE,eAAe;aACzB;SACF;KACF;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACzB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAA;QAE7B,MAAM,CAAC,KAAK;YACV,MAAM,CAAC,KAAK,CAAC;gBACX,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,WAAW,EAAE,OAAO,CAAC,WAAW;aACjC,CAAC,CAAA;IACN,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../src/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/identify/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
|
|
2
|
+
import { Hubble } from '../types';
|
|
3
|
+
import type { Settings } from '../generated-types';
|
|
4
|
+
import type { Payload } from './generated-types';
|
|
5
|
+
declare const action: BrowserActionDefinition<Settings, Hubble, Payload>;
|
|
6
|
+
export default action;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const action = {
|
|
2
|
+
title: 'Identify',
|
|
3
|
+
description: 'Set identifiers and attributes for a user',
|
|
4
|
+
platform: 'web',
|
|
5
|
+
defaultSubscription: 'type = "identify"',
|
|
6
|
+
fields: {
|
|
7
|
+
userId: {
|
|
8
|
+
description: 'Unique identifer of the user',
|
|
9
|
+
type: 'string',
|
|
10
|
+
required: false,
|
|
11
|
+
label: 'User ID',
|
|
12
|
+
default: {
|
|
13
|
+
'@path': '$.userId'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
anonymousId: {
|
|
17
|
+
description: 'Anonymous identifier of the user',
|
|
18
|
+
type: 'string',
|
|
19
|
+
required: false,
|
|
20
|
+
label: 'Anonymous ID',
|
|
21
|
+
default: {
|
|
22
|
+
'@path': '$.anonymousId'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
attributes: {
|
|
26
|
+
description: 'User traits used to enrich user identification',
|
|
27
|
+
type: 'object',
|
|
28
|
+
required: false,
|
|
29
|
+
label: 'User Attributes (Traits)',
|
|
30
|
+
default: {
|
|
31
|
+
'@path': '$.traits'
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
perform: (hubble, event) => {
|
|
36
|
+
const payload = event.payload;
|
|
37
|
+
hubble.identify &&
|
|
38
|
+
hubble.identify({ userId: payload.userId, anonymousId: payload.anonymousId, attributes: payload.attributes });
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
export default action;
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identify/index.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,GAAuD;IACjE,KAAK,EAAE,UAAU;IACjB,WAAW,EAAE,2CAA2C;IACxD,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,MAAM,EAAE;YACN,WAAW,EAAE,8BAA8B;YAC3C,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;QACD,WAAW,EAAE;YACX,WAAW,EAAE,kCAAkC;YAC/C,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,cAAc;YACrB,OAAO,EAAE;gBACP,OAAO,EAAE,eAAe;aACzB;SACF;QACD,UAAU,EAAE;YACV,WAAW,EAAE,gDAAgD;YAC7D,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,0BAA0B;YACjC,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;KACF;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACzB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAA;QAE7B,MAAM,CAAC,QAAQ;YACb,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAA;IACjH,CAAC;CACF,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Settings } from './generated-types';
|
|
2
|
+
import type { BrowserDestinationDefinition } from '@segment/browser-destination-runtime/types';
|
|
3
|
+
import { Hubble } from './types';
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
Hubble: Hubble;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare const destination: BrowserDestinationDefinition<Settings, Hubble>;
|
|
10
|
+
declare const _default: import("@segment/browser-destination-runtime/types").PluginFactory;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { browserDestination } from '@segment/browser-destination-runtime/shim';
|
|
2
|
+
import { defaultValues } from '@segment/actions-core';
|
|
3
|
+
import track from './track';
|
|
4
|
+
import identify from './identify';
|
|
5
|
+
export const destination = {
|
|
6
|
+
name: 'Hubble (actions)',
|
|
7
|
+
slug: 'hubble-web',
|
|
8
|
+
mode: 'device',
|
|
9
|
+
description: 'From design to production, monitor, measure and enhance your user experience with seamless integration with Segment',
|
|
10
|
+
presets: [
|
|
11
|
+
{
|
|
12
|
+
name: 'Identify user',
|
|
13
|
+
subscribe: 'type = "identify"',
|
|
14
|
+
partnerAction: 'identify',
|
|
15
|
+
mapping: defaultValues(identify.fields),
|
|
16
|
+
type: 'automatic'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'Track event',
|
|
20
|
+
subscribe: 'type = "track"',
|
|
21
|
+
partnerAction: 'track',
|
|
22
|
+
mapping: defaultValues(track.fields),
|
|
23
|
+
type: 'automatic'
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
settings: {
|
|
27
|
+
id: {
|
|
28
|
+
description: 'Unique identifier for your team (given in Hubble app)',
|
|
29
|
+
label: 'id',
|
|
30
|
+
type: 'string',
|
|
31
|
+
required: true
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
initialize: async ({ settings }, deps) => {
|
|
35
|
+
await deps.loadScript(`https://sdk.hubble.team/api/sdk/${settings.id}`);
|
|
36
|
+
await deps.resolveWhen(() => window?.Hubble?.initialized, 250);
|
|
37
|
+
window?.Hubble?.setSource('__segment__');
|
|
38
|
+
return window.Hubble;
|
|
39
|
+
},
|
|
40
|
+
actions: {
|
|
41
|
+
track,
|
|
42
|
+
identify
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export default browserDestination(destination);
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAA;AAG9E,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAErD,OAAO,KAAK,MAAM,SAAS,CAAA;AAC3B,OAAO,QAAQ,MAAM,YAAY,CAAA;AAQjC,MAAM,CAAC,MAAM,WAAW,GAAmD;IACzE,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,YAAY;IAClB,IAAI,EAAE,QAAQ;IACd,WAAW,EACT,qHAAqH;IACvH,OAAO,EAAE;QACP;YACE,IAAI,EAAE,eAAe;YACrB,SAAS,EAAE,mBAAmB;YAC9B,aAAa,EAAE,UAAU;YACzB,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC;YACvC,IAAI,EAAE,WAAW;SAClB;QACD;YACE,IAAI,EAAE,aAAa;YACnB,SAAS,EAAE,gBAAgB;YAC3B,aAAa,EAAE,OAAO;YACtB,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC;YACpC,IAAI,EAAE,WAAW;SAClB;KACF;IAED,QAAQ,EAAE;QACR,EAAE,EAAE;YACF,WAAW,EAAE,uDAAuD;YACpE,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;KACF;IAED,UAAU,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE;QACvC,MAAM,IAAI,CAAC,UAAU,CAAC,mCAAmC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAA;QACvE,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,CAAA;QAG9D,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,aAAa,CAAC,CAAA;QACxC,OAAO,MAAM,CAAC,MAAM,CAAA;IACtB,CAAC;IAED,OAAO,EAAE;QACP,KAAK;QACL,QAAQ;KACT;CACF,CAAA;AAED,eAAe,kBAAkB,CAAC,WAAW,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/track/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
|
|
2
|
+
import { Hubble } from '../types';
|
|
3
|
+
import type { Settings } from '../generated-types';
|
|
4
|
+
import type { Payload } from './generated-types';
|
|
5
|
+
declare const action: BrowserActionDefinition<Settings, Hubble, Payload>;
|
|
6
|
+
export default action;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const action = {
|
|
2
|
+
title: 'Track',
|
|
3
|
+
description: 'Track events to trigger Hubble surveys',
|
|
4
|
+
platform: 'web',
|
|
5
|
+
defaultSubscription: 'type = "track"',
|
|
6
|
+
fields: {
|
|
7
|
+
event: {
|
|
8
|
+
description: 'Event to be tracked',
|
|
9
|
+
label: 'Event',
|
|
10
|
+
required: true,
|
|
11
|
+
type: 'string',
|
|
12
|
+
default: {
|
|
13
|
+
'@path': '$.event'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
attributes: {
|
|
17
|
+
description: 'Object containing the attributes (properties) of the event',
|
|
18
|
+
type: 'object',
|
|
19
|
+
required: false,
|
|
20
|
+
label: 'Event Attributes',
|
|
21
|
+
default: {
|
|
22
|
+
'@path': '$.properties'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
userId: {
|
|
26
|
+
description: 'Unique identifer of the user',
|
|
27
|
+
type: 'string',
|
|
28
|
+
required: false,
|
|
29
|
+
label: 'User ID',
|
|
30
|
+
default: {
|
|
31
|
+
'@path': '$.userId'
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
anonymousId: {
|
|
35
|
+
description: 'Anonymous identifier of the user',
|
|
36
|
+
type: 'string',
|
|
37
|
+
required: false,
|
|
38
|
+
label: 'Anonymous ID',
|
|
39
|
+
default: {
|
|
40
|
+
'@path': '$.anonymousId'
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
perform: (hubble, event) => {
|
|
45
|
+
const payload = event.payload;
|
|
46
|
+
hubble.track &&
|
|
47
|
+
hubble.track({
|
|
48
|
+
event: payload.event,
|
|
49
|
+
attributes: payload.attributes,
|
|
50
|
+
userId: payload.userId,
|
|
51
|
+
anonymousId: payload.anonymousId
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
export default action;
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/track/index.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,GAAuD;IACjE,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,wCAAwC;IACrD,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAE;QACN,KAAK,EAAE;YACL,WAAW,EAAE,qBAAqB;YAClC,KAAK,EAAE,OAAO;YACd,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,SAAS;aACnB;SACF;QACD,UAAU,EAAE;YACV,WAAW,EAAE,4DAA4D;YACzE,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,kBAAkB;YACzB,OAAO,EAAE;gBACP,OAAO,EAAE,cAAc;aACxB;SACF;QACD,MAAM,EAAE;YACN,WAAW,EAAE,8BAA8B;YAC3C,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;QACD,WAAW,EAAE;YACX,WAAW,EAAE,kCAAkC;YAC/C,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,cAAc;YACrB,OAAO,EAAE;gBACP,OAAO,EAAE,eAAe;aACzB;SACF;KACF;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACzB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAA;QAE7B,MAAM,CAAC,KAAK;YACV,MAAM,CAAC,KAAK,CAAC;gBACX,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,WAAW,EAAE,OAAO,CAAC,WAAW;aACjC,CAAC,CAAA;IACN,CAAC;CACF,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|