@segment/analytics-browser-actions-heap 1.0.0 → 1.3.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.
Files changed (63) hide show
  1. package/.eslintcache +1 -0
  2. package/dist/cjs/constants.d.ts +1 -0
  3. package/dist/cjs/constants.js +5 -0
  4. package/dist/cjs/constants.js.map +1 -0
  5. package/dist/cjs/generated-types.d.ts +8 -0
  6. package/dist/cjs/generated-types.js +3 -0
  7. package/dist/cjs/generated-types.js.map +1 -0
  8. package/dist/cjs/identifyUser/generated-types.d.ts +6 -0
  9. package/dist/cjs/identifyUser/generated-types.js +3 -0
  10. package/dist/cjs/identifyUser/generated-types.js.map +1 -0
  11. package/dist/cjs/identifyUser/index.d.ts +6 -0
  12. package/dist/cjs/identifyUser/index.js +38 -0
  13. package/dist/cjs/identifyUser/index.js.map +1 -0
  14. package/dist/cjs/index.d.ts +11 -0
  15. package/dist/cjs/index.js +95 -0
  16. package/dist/cjs/index.js.map +1 -0
  17. package/dist/cjs/test-utilities.d.ts +7 -0
  18. package/dist/cjs/test-utilities.js +65 -0
  19. package/dist/cjs/test-utilities.js.map +1 -0
  20. package/dist/cjs/trackEvent/generated-types.d.ts +11 -0
  21. package/dist/cjs/trackEvent/generated-types.js +3 -0
  22. package/dist/cjs/trackEvent/generated-types.js.map +1 -0
  23. package/dist/cjs/trackEvent/index.d.ts +6 -0
  24. package/dist/cjs/trackEvent/index.js +100 -0
  25. package/dist/cjs/trackEvent/index.js.map +1 -0
  26. package/dist/cjs/types.d.ts +20 -0
  27. package/dist/cjs/types.js +3 -0
  28. package/dist/cjs/types.js.map +1 -0
  29. package/dist/cjs/utils.d.ts +10 -0
  30. package/dist/cjs/utils.js +51 -0
  31. package/dist/cjs/utils.js.map +1 -0
  32. package/dist/esm/constants.d.ts +1 -0
  33. package/dist/esm/constants.js +2 -0
  34. package/dist/esm/constants.js.map +1 -0
  35. package/dist/esm/generated-types.d.ts +8 -0
  36. package/dist/esm/generated-types.js +2 -0
  37. package/dist/esm/generated-types.js.map +1 -0
  38. package/dist/esm/identifyUser/generated-types.d.ts +6 -0
  39. package/dist/esm/identifyUser/generated-types.js +2 -0
  40. package/dist/esm/identifyUser/generated-types.js.map +1 -0
  41. package/dist/esm/identifyUser/index.d.ts +6 -0
  42. package/dist/esm/identifyUser/index.js +36 -0
  43. package/dist/esm/identifyUser/index.js.map +1 -0
  44. package/dist/esm/index.d.ts +11 -0
  45. package/dist/esm/index.js +91 -0
  46. package/dist/esm/index.js.map +1 -0
  47. package/dist/esm/test-utilities.d.ts +7 -0
  48. package/dist/esm/test-utilities.js +59 -0
  49. package/dist/esm/test-utilities.js.map +1 -0
  50. package/dist/esm/trackEvent/generated-types.d.ts +11 -0
  51. package/dist/esm/trackEvent/generated-types.js +2 -0
  52. package/dist/esm/trackEvent/generated-types.js.map +1 -0
  53. package/dist/esm/trackEvent/index.d.ts +6 -0
  54. package/dist/esm/trackEvent/index.js +98 -0
  55. package/dist/esm/trackEvent/index.js.map +1 -0
  56. package/dist/esm/types.d.ts +20 -0
  57. package/dist/esm/types.js +2 -0
  58. package/dist/esm/types.js.map +1 -0
  59. package/dist/esm/utils.d.ts +10 -0
  60. package/dist/esm/utils.js +45 -0
  61. package/dist/esm/utils.js.map +1 -0
  62. package/dist/tsconfig.tsbuildinfo +1 -0
  63. package/package.json +5 -4
package/.eslintcache ADDED
@@ -0,0 +1 @@
1
+ [{"/home/kaari/action-destinations/packages/browser-destinations/destinations/heap/src/constants.ts":"1","/home/kaari/action-destinations/packages/browser-destinations/destinations/heap/src/generated-types.ts":"2","/home/kaari/action-destinations/packages/browser-destinations/destinations/heap/src/index.ts":"3","/home/kaari/action-destinations/packages/browser-destinations/destinations/heap/src/test-utilities.ts":"4","/home/kaari/action-destinations/packages/browser-destinations/destinations/heap/src/types.ts":"5","/home/kaari/action-destinations/packages/browser-destinations/destinations/heap/src/utils.ts":"6"},{"size":71,"mtime":1686339431100,"results":"7","hashOfConfig":"8"},{"size":1575,"mtime":1686339431100,"results":"9","hashOfConfig":"8"},{"size":4250,"mtime":1686339475060,"results":"10","hashOfConfig":"8"},{"size":1365,"mtime":1686339475060,"results":"11","hashOfConfig":"8"},{"size":481,"mtime":1686339431100,"results":"12","hashOfConfig":"8"},{"size":1172,"mtime":1686339431100,"results":"13","hashOfConfig":"8"},{"filePath":"14","messages":"15","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"11wi5y",{"filePath":"16","messages":"17","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"18","messages":"19","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"20","messages":"21","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"22","messages":"23","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"24","messages":"25","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/home/kaari/action-destinations/packages/browser-destinations/destinations/heap/src/constants.ts",[],"/home/kaari/action-destinations/packages/browser-destinations/destinations/heap/src/generated-types.ts",[],"/home/kaari/action-destinations/packages/browser-destinations/destinations/heap/src/index.ts",[],"/home/kaari/action-destinations/packages/browser-destinations/destinations/heap/src/test-utilities.ts",[],"/home/kaari/action-destinations/packages/browser-destinations/destinations/heap/src/types.ts",[],"/home/kaari/action-destinations/packages/browser-destinations/destinations/heap/src/utils.ts",[]]
@@ -0,0 +1 @@
1
+ export declare const HEAP_SEGMENT_BROWSER_LIBRARY_NAME = "browser-destination";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HEAP_SEGMENT_BROWSER_LIBRARY_NAME = void 0;
4
+ exports.HEAP_SEGMENT_BROWSER_LIBRARY_NAME = 'browser-destination';
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,iCAAiC,GAAG,qBAAqB,CAAA"}
@@ -0,0 +1,8 @@
1
+ export interface Settings {
2
+ appId: string;
3
+ disableTextCapture?: boolean;
4
+ secureCookie?: boolean;
5
+ trackingServer?: string;
6
+ hostname?: string;
7
+ browserArrayLimit?: number;
8
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../src/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export interface Payload {
2
+ userId?: string;
3
+ traits?: {
4
+ [k: string]: unknown;
5
+ };
6
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/identifyUser/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ import { HeapApi } from '../types';
5
+ declare const action: BrowserActionDefinition<Settings, HeapApi, Payload>;
6
+ export default action;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const action = {
4
+ title: 'Identify User',
5
+ description: 'Sets user identity',
6
+ platform: 'web',
7
+ defaultSubscription: 'type = "identify"',
8
+ fields: {
9
+ userId: {
10
+ type: 'string',
11
+ required: false,
12
+ description: "The user's identity",
13
+ label: 'Identity',
14
+ default: {
15
+ '@path': '$.userId'
16
+ }
17
+ },
18
+ traits: {
19
+ type: 'object',
20
+ required: false,
21
+ description: 'The Segment traits to be forwarded to Heap',
22
+ label: 'Traits',
23
+ default: {
24
+ '@path': '$.traits'
25
+ }
26
+ }
27
+ },
28
+ perform: (heap, event) => {
29
+ if (event.payload.traits) {
30
+ heap.addUserProperties(event.payload.traits);
31
+ }
32
+ if (event.payload.userId) {
33
+ heap.identify(event.payload.userId);
34
+ }
35
+ }
36
+ };
37
+ exports.default = action;
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identifyUser/index.ts"],"names":[],"mappings":";;AAKA,MAAM,MAAM,GAAwD;IAClE,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,oBAAoB;IACjC,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,qBAAqB;YAClC,KAAK,EAAE,UAAU;YACjB,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,4CAA4C;YACzD,KAAK,EAAE,QAAQ;YACf,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;KACF;IACD,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACvB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE;YACxB,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;SAC7C;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE;YACxB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;SACpC;IACH,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 { HeapApi } from './types';
4
+ declare global {
5
+ interface Window {
6
+ heap: HeapApi;
7
+ }
8
+ }
9
+ export declare const destination: BrowserDestinationDefinition<Settings, HeapApi>;
10
+ declare const _default: import("@segment/browser-destination-runtime/types").PluginFactory;
11
+ export default _default;
@@ -0,0 +1,95 @@
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 trackEvent_1 = tslib_1.__importDefault(require("./trackEvent"));
8
+ const identifyUser_1 = tslib_1.__importDefault(require("./identifyUser"));
9
+ const utils_1 = require("./utils");
10
+ exports.destination = {
11
+ name: 'Heap Web (Actions)',
12
+ slug: 'actions-heap-web',
13
+ mode: 'device',
14
+ presets: [
15
+ {
16
+ name: 'Track Event',
17
+ subscribe: 'type = "track"',
18
+ partnerAction: 'trackEvent',
19
+ mapping: actions_core_1.defaultValues(trackEvent_1.default.fields)
20
+ },
21
+ {
22
+ name: 'Identify User',
23
+ subscribe: 'type = "identify"',
24
+ partnerAction: 'identifyUser',
25
+ mapping: actions_core_1.defaultValues(identifyUser_1.default.fields)
26
+ }
27
+ ],
28
+ settings: {
29
+ appId: {
30
+ label: 'Heap app ID',
31
+ description: 'The app ID of the environment to which you want to send data. You can find this ID on the [Projects](https://heapanalytics.com/app/manage/projects) page.',
32
+ type: 'string',
33
+ required: true
34
+ },
35
+ disableTextCapture: {
36
+ label: 'Global data redaction via Disabling Text Capture',
37
+ description: 'Setting to true will redact all target text on your website. For more information visit the heap [docs page](https://developers.heap.io/docs/web#global-data-redaction-via-disabling-text-capture).',
38
+ type: 'boolean',
39
+ required: false
40
+ },
41
+ secureCookie: {
42
+ label: 'Secure Cookie',
43
+ description: 'This option is turned off by default to accommodate websites not served over HTTPS. If your application uses HTTPS, we recommend enabling secure cookies to prevent Heap cookies from being observed by unauthorized parties. For more information visit the heap [docs page](https://developers.heap.io/docs/web#securecookie).',
44
+ type: 'boolean',
45
+ required: false
46
+ },
47
+ trackingServer: {
48
+ label: 'Tracking Server',
49
+ description: 'This is an optional setting. This is used to set up first-party data collection. For most cased this should not be set. For more information visit the heap [docs page](https://developers.heap.io/docs/set-up-first-party-data-collection-in-heap).',
50
+ type: 'string',
51
+ required: false
52
+ },
53
+ hostname: {
54
+ label: 'Hostname',
55
+ description: 'This is an optional setting used to set the host that loads heap-js. This setting is used when heapJS is self-hosted. In most cased this should be left unset. The hostname should not contain https or app id it will be populated like so: https://${hostname}/js/heap-${appId}.js. For more information visit the heap [docs page](https://developers.heap.io/docs/self-hosting-heapjs).',
56
+ type: 'string',
57
+ required: false
58
+ },
59
+ browserArrayLimit: {
60
+ label: 'Browser Array Limit',
61
+ description: 'This is an optional setting. When set, nested array items will be sent in as new Heap events. Defaults to 0.',
62
+ type: 'number',
63
+ required: false
64
+ }
65
+ },
66
+ initialize: async ({ settings }, deps) => {
67
+ if (window.heap) {
68
+ return window.heap;
69
+ }
70
+ const config = {
71
+ disableTextCapture: settings.disableTextCapture || false,
72
+ secureCookie: settings.secureCookie || false
73
+ };
74
+ if (settings.trackingServer) {
75
+ config.trackingServer = settings.trackingServer;
76
+ }
77
+ window.heap = window.heap || [];
78
+ window.heap.appid = settings.appId;
79
+ window.heap.config = config;
80
+ if (utils_1.isDefined(settings.hostname)) {
81
+ await deps.loadScript(`https://${settings.hostname}/js/heap-${settings.appId}.js`);
82
+ }
83
+ else {
84
+ await deps.loadScript(`https://cdn.heapanalytics.com/js/heap-${settings.appId}.js`);
85
+ }
86
+ await deps.resolveWhen(() => Object.prototype.hasOwnProperty.call(window, 'heap'), 100);
87
+ return window.heap;
88
+ },
89
+ actions: {
90
+ trackEvent: trackEvent_1.default,
91
+ identifyUser: identifyUser_1.default
92
+ }
93
+ };
94
+ exports.default = shim_1.browserDestination(exports.destination);
95
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAEA,oEAA8E;AAE9E,wDAAqD;AACrD,sEAAqC;AACrC,0EAAyC;AACzC,mCAAmC;AAStB,QAAA,WAAW,GAAoD;IAC1E,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE;QACP;YACE,IAAI,EAAE,aAAa;YACnB,SAAS,EAAE,gBAAgB;YAC3B,aAAa,EAAE,YAAY;YAC3B,OAAO,EAAE,4BAAa,CAAC,oBAAU,CAAC,MAAM,CAAC;SAC1C;QACD;YACE,IAAI,EAAE,eAAe;YACrB,SAAS,EAAE,mBAAmB;YAC9B,aAAa,EAAE,cAAc;YAC7B,OAAO,EAAE,4BAAa,CAAC,sBAAY,CAAC,MAAM,CAAC;SAC5C;KACF;IACD,QAAQ,EAAE;QAER,KAAK,EAAE;YACL,KAAK,EAAE,aAAa;YACpB,WAAW,EACT,2JAA2J;YAC7J,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;QACD,kBAAkB,EAAE;YAClB,KAAK,EAAE,kDAAkD;YACzD,WAAW,EACT,qMAAqM;YACvM,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,KAAK;SAChB;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,eAAe;YACtB,WAAW,EACT,kUAAkU;YACpU,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,KAAK;SAChB;QACD,cAAc,EAAE;YACd,KAAK,EAAE,iBAAiB;YACxB,WAAW,EACT,sPAAsP;YACxP,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;SAChB;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,UAAU;YACjB,WAAW,EACT,6XAA6X;YAC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AO,EAAE;QACP,UAAU,EAAV,oBAAU;QACV,YAAY,EAAZ,sBAAY;KACb;CACF,CAAA;AAED,kBAAe,yBAAkB,CAAC,mBAAW,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { HeapApi } from './types';
2
+ import { Subscription } from '@segment/browser-destination-runtime/types';
3
+ export declare const HEAP_TEST_ENV_ID = "1";
4
+ export declare const createMockedHeapJsSdk: () => HeapApi;
5
+ export declare const trackEventSubscription: Subscription;
6
+ export declare const identifyUserSubscription: Subscription;
7
+ export declare const mockHeapJsHttpRequest: () => void;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mockHeapJsHttpRequest = exports.identifyUserSubscription = exports.trackEventSubscription = exports.createMockedHeapJsSdk = exports.HEAP_TEST_ENV_ID = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const nock_1 = tslib_1.__importDefault(require("nock"));
6
+ exports.HEAP_TEST_ENV_ID = '1';
7
+ const createMockedHeapJsSdk = () => {
8
+ return {
9
+ appid: exports.HEAP_TEST_ENV_ID,
10
+ config: {
11
+ disableTextCapture: true,
12
+ secureCookie: true
13
+ },
14
+ load: jest.fn(),
15
+ track: jest.fn(),
16
+ identify: jest.fn(),
17
+ addUserProperties: jest.fn()
18
+ };
19
+ };
20
+ exports.createMockedHeapJsSdk = createMockedHeapJsSdk;
21
+ exports.trackEventSubscription = {
22
+ partnerAction: 'trackEvent',
23
+ name: 'Track Event',
24
+ enabled: true,
25
+ subscribe: 'type = "track"',
26
+ mapping: {
27
+ name: {
28
+ '@path': '$.name'
29
+ },
30
+ properties: {
31
+ '@path': '$.properties'
32
+ },
33
+ identity: {
34
+ '@path': '$.userId'
35
+ },
36
+ anonymousId: {
37
+ '@path': '$.anonymousId'
38
+ },
39
+ traits: {
40
+ '@path': '$.context.traits'
41
+ }
42
+ }
43
+ };
44
+ exports.identifyUserSubscription = {
45
+ partnerAction: 'identifyUser',
46
+ name: 'Identify User',
47
+ enabled: true,
48
+ subscribe: 'type = "identify"',
49
+ mapping: {
50
+ anonymousId: {
51
+ '@path': '$.anonymousId'
52
+ },
53
+ userId: {
54
+ '@path': '$.userId'
55
+ },
56
+ traits: {
57
+ '@path': '$.traits'
58
+ }
59
+ }
60
+ };
61
+ const mockHeapJsHttpRequest = () => {
62
+ nock_1.default('https://cdn.heapanalytics.com').get(`/js/heap-${exports.HEAP_TEST_ENV_ID}.js`).reply(200, {});
63
+ };
64
+ exports.mockHeapJsHttpRequest = mockHeapJsHttpRequest;
65
+ //# sourceMappingURL=test-utilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utilities.js","sourceRoot":"","sources":["../../src/test-utilities.ts"],"names":[],"mappings":";;;;AAEA,wDAAuB;AAEV,QAAA,gBAAgB,GAAG,GAAG,CAAA;AAE5B,MAAM,qBAAqB,GAAG,GAAY,EAAE;IACjD,OAAO;QACL,KAAK,EAAE,wBAAgB;QACvB,MAAM,EAAE;YACN,kBAAkB,EAAE,IAAI;YACxB,YAAY,EAAE,IAAI;SACnB;QACD,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;QACf,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;QAChB,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;QACnB,iBAAiB,EAAE,IAAI,CAAC,EAAE,EAAE;KAC7B,CAAA;AACH,CAAC,CAAA;AAZY,QAAA,qBAAqB,yBAYjC;AACY,QAAA,sBAAsB,GAAiB;IAClD,aAAa,EAAE,YAAY;IAC3B,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,gBAAgB;IAC3B,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,OAAO,EAAE,QAAQ;SAClB;QACD,UAAU,EAAE;YACV,OAAO,EAAE,cAAc;SACxB;QACD,QAAQ,EAAE;YACR,OAAO,EAAE,UAAU;SACpB;QACD,WAAW,EAAE;YACX,OAAO,EAAE,eAAe;SACzB;QACD,MAAM,EAAE;YACN,OAAO,EAAE,kBAAkB;SAC5B;KACF;CACF,CAAA;AAEY,QAAA,wBAAwB,GAAiB;IACpD,aAAa,EAAE,cAAc;IAC7B,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,mBAAmB;IAC9B,OAAO,EAAE;QACP,WAAW,EAAE;YACX,OAAO,EAAE,eAAe;SACzB;QACD,MAAM,EAAE;YACN,OAAO,EAAE,UAAU;SACpB;QACD,MAAM,EAAE;YACN,OAAO,EAAE,UAAU;SACpB;KACF;CACF,CAAA;AAEM,MAAM,qBAAqB,GAAG,GAAS,EAAE;IAC9C,cAAI,CAAC,+BAA+B,CAAC,CAAC,GAAG,CAAC,YAAY,wBAAgB,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;AAC7F,CAAC,CAAA;AAFY,QAAA,qBAAqB,yBAEjC"}
@@ -0,0 +1,11 @@
1
+ export interface Payload {
2
+ name: string;
3
+ properties?: {
4
+ [k: string]: unknown;
5
+ };
6
+ identity?: string;
7
+ anonymousId?: string;
8
+ traits?: {
9
+ [k: string]: unknown;
10
+ };
11
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/trackEvent/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ import { HeapApi } from '../types';
5
+ declare const action: BrowserActionDefinition<Settings, HeapApi, Payload>;
6
+ export default action;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const constants_1 = require("../constants");
4
+ const utils_1 = require("../utils");
5
+ const action = {
6
+ title: 'Track Event',
7
+ description: 'Track events',
8
+ platform: 'web',
9
+ defaultSubscription: 'type = "track"',
10
+ fields: {
11
+ name: {
12
+ description: 'The name of the event.',
13
+ label: 'Name',
14
+ required: true,
15
+ type: 'string',
16
+ default: {
17
+ '@path': '$.event'
18
+ }
19
+ },
20
+ properties: {
21
+ description: 'A JSON object containing additional information about the event that will be indexed by Heap.',
22
+ label: 'Properties',
23
+ required: false,
24
+ type: 'object',
25
+ default: {
26
+ '@path': '$.properties'
27
+ }
28
+ },
29
+ identity: {
30
+ type: 'string',
31
+ required: false,
32
+ label: 'Identity',
33
+ description: 'a string that uniquely identifies a user, such as an email, handle, or username. This means no two users in one environment may share the same identity. More on identify: https://developers.heap.io/docs/using-identify'
34
+ },
35
+ anonymousId: {
36
+ type: 'string',
37
+ required: false,
38
+ description: 'The segment anonymous identifier for the user',
39
+ label: 'Anonymous ID',
40
+ default: {
41
+ '@path': '$.anonymousId'
42
+ }
43
+ },
44
+ traits: {
45
+ label: 'User Properties',
46
+ type: 'object',
47
+ description: 'An object with key-value properties you want associated with the user. Each property must either be a number or string with fewer than 1024 characters.',
48
+ default: {
49
+ '@path': '$.context.traits'
50
+ }
51
+ }
52
+ },
53
+ perform: (heap, event) => {
54
+ if (event.payload.anonymousId || utils_1.isDefined(event.payload?.traits)) {
55
+ const traits = utils_1.flat(event.payload?.traits);
56
+ heap.addUserProperties({
57
+ ...(utils_1.isDefined(event.payload.anonymousId) && { anonymous_id: event.payload.anonymousId }),
58
+ ...(utils_1.isDefined(traits) && traits)
59
+ });
60
+ }
61
+ if (event.payload?.identity && utils_1.isDefined(event.payload?.identity)) {
62
+ heap.identify(event.payload.identity);
63
+ }
64
+ let eventProperties = Object.assign({}, event.payload.properties);
65
+ const eventName = event.payload.name;
66
+ const browserArrayLimit = event.settings.browserArrayLimit || 0;
67
+ const browserArrayLimitSet = !!browserArrayLimit;
68
+ let arrayEventsCount = 0;
69
+ for (const [key, value] of Object.entries(eventProperties)) {
70
+ if (browserArrayLimitSet && arrayEventsCount >= browserArrayLimit) {
71
+ break;
72
+ }
73
+ if (!Array.isArray(value)) {
74
+ continue;
75
+ }
76
+ delete eventProperties[key];
77
+ eventProperties = { ...eventProperties, ...utils_1.flat({ [key]: value }) };
78
+ const arrayLength = value.length;
79
+ let arrayPropertyValues;
80
+ if (browserArrayLimitSet && arrayLength + arrayEventsCount > browserArrayLimit) {
81
+ arrayPropertyValues = value.splice(0, browserArrayLimit - arrayEventsCount);
82
+ }
83
+ else {
84
+ arrayPropertyValues = value;
85
+ }
86
+ arrayEventsCount += arrayLength;
87
+ arrayPropertyValues.forEach((arrayPropertyValue) => {
88
+ const arrayProperties = utils_1.flattenProperties(arrayPropertyValue);
89
+ heapTrack(heap, `${eventName} ${key} item`, arrayProperties);
90
+ });
91
+ }
92
+ heapTrack(heap, eventName, eventProperties);
93
+ }
94
+ };
95
+ const heapTrack = (heap, eventName, properties) => {
96
+ properties.segment_library = constants_1.HEAP_SEGMENT_BROWSER_LIBRARY_NAME;
97
+ heap.track(eventName, properties);
98
+ };
99
+ exports.default = action;
100
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/trackEvent/index.ts"],"names":[],"mappings":";;AAIA,4CAAgE;AAChE,oCAA6D;AAE7D,MAAM,MAAM,GAAwD;IAClE,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,cAAc;IAC3B,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAE;QACN,IAAI,EAAE;YACJ,WAAW,EAAE,wBAAwB;YACrC,KAAK,EAAE,MAAM;YACb,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,SAAS;aACnB;SACF;QACD,UAAU,EAAE;YACV,WAAW,EAAE,+FAA+F;YAC5G,KAAK,EAAE,YAAY;YACnB,QAAQ,EAAE,KAAK;YACf,IAAI,EA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D,CAAC,CAAC,CAAA;SACH;QACD,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,eAAe,CAAC,CAAA;IAC7C,CAAC;CACF,CAAA;AAED,MAAM,SAAS,GAAG,CAChB,IAAa,EACb,SAAiB,EACjB,UAEC,EACD,EAAE;IACF,UAAU,CAAC,eAAe,GAAG,6CAAiC,CAAA;IAC9D,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;AACnC,CAAC,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,20 @@
1
+ export declare type UserConfig = {
2
+ trackingServer?: string;
3
+ disableTextCapture: boolean;
4
+ secureCookie: boolean;
5
+ };
6
+ declare type UserProperties = {
7
+ [k: string]: unknown;
8
+ };
9
+ declare type EventProperties = {
10
+ [key: string]: unknown;
11
+ };
12
+ export declare type HeapApi = {
13
+ appid: string;
14
+ track: (eventName: string, eventProperties: EventProperties, library?: string) => void;
15
+ load: () => void;
16
+ config: UserConfig;
17
+ identify: (identity: string) => void;
18
+ addUserProperties: (properties: UserProperties) => void;
19
+ };
20
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ export declare function isDefined(value: string | undefined | null | number | object): boolean;
2
+ export declare type Properties = {
3
+ [k: string]: unknown;
4
+ };
5
+ declare type FlattenProperties = object & {
6
+ [k: string]: string;
7
+ };
8
+ export declare function flat(data?: Properties, prefix?: string): FlattenProperties | undefined;
9
+ export declare const flattenProperties: (arrayPropertyValue: any) => {};
10
+ export {};
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.flattenProperties = exports.flat = exports.isDefined = void 0;
4
+ function isDefined(value) {
5
+ if (typeof value === 'object') {
6
+ return !!value && Object.keys(value).length !== 0;
7
+ }
8
+ return !(value === undefined || value === null || value === '' || value === 0 || value === '0');
9
+ }
10
+ exports.isDefined = isDefined;
11
+ function flat(data, prefix = '') {
12
+ if (!isDefined(data)) {
13
+ return undefined;
14
+ }
15
+ let result = {};
16
+ for (const key in data) {
17
+ if (typeof data[key] == 'object' && data[key] !== null) {
18
+ const flatten = flat(data[key], prefix + '.' + key);
19
+ result = { ...result, ...flatten };
20
+ }
21
+ else {
22
+ const stringifiedValue = stringify(data[key]);
23
+ result[(prefix + '.' + key).replace(/^\./, '')] = stringifiedValue;
24
+ }
25
+ }
26
+ return result;
27
+ }
28
+ exports.flat = flat;
29
+ const flattenProperties = (arrayPropertyValue) => {
30
+ let arrayProperties = {};
31
+ for (const [key, value] of Object.entries(arrayPropertyValue)) {
32
+ if (typeof value == 'object' && value !== null) {
33
+ arrayProperties = { ...arrayProperties, ...flat({ [key]: value }) };
34
+ }
35
+ else {
36
+ arrayProperties = Object.assign(arrayProperties, { [key]: value });
37
+ }
38
+ }
39
+ return arrayProperties;
40
+ };
41
+ exports.flattenProperties = flattenProperties;
42
+ function stringify(value) {
43
+ if (typeof value === 'string') {
44
+ return value;
45
+ }
46
+ if (typeof value === 'number' || typeof value === 'boolean') {
47
+ return value.toString();
48
+ }
49
+ return JSON.stringify(value);
50
+ }
51
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAAA,SAAgB,SAAS,CAAC,KAAkD;IAC1E,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAA;KAClD;IACD,OAAO,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,IAAI,KA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YACL,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;SACnE;KACF;IACD,OAAO,eAAe,CAAA;AACxB,CAAC,CAAA;AAVY,QAAA,iBAAiB,qBAU7B;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,KAAK,CAAA;KACb;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;QAC3D,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAA;KACxB;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const HEAP_SEGMENT_BROWSER_LIBRARY_NAME = "browser-destination";
@@ -0,0 +1,2 @@
1
+ export const HEAP_SEGMENT_BROWSER_LIBRARY_NAME = 'browser-destination';
2
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iCAAiC,GAAG,qBAAqB,CAAA"}
@@ -0,0 +1,8 @@
1
+ export interface Settings {
2
+ appId: string;
3
+ disableTextCapture?: boolean;
4
+ secureCookie?: boolean;
5
+ trackingServer?: string;
6
+ hostname?: string;
7
+ browserArrayLimit?: number;
8
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../src/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export interface Payload {
2
+ userId?: string;
3
+ traits?: {
4
+ [k: string]: unknown;
5
+ };
6
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/identifyUser/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ import { HeapApi } from '../types';
5
+ declare const action: BrowserActionDefinition<Settings, HeapApi, Payload>;
6
+ export default action;
@@ -0,0 +1,36 @@
1
+ const action = {
2
+ title: 'Identify User',
3
+ description: 'Sets user identity',
4
+ platform: 'web',
5
+ defaultSubscription: 'type = "identify"',
6
+ fields: {
7
+ userId: {
8
+ type: 'string',
9
+ required: false,
10
+ description: "The user's identity",
11
+ label: 'Identity',
12
+ default: {
13
+ '@path': '$.userId'
14
+ }
15
+ },
16
+ traits: {
17
+ type: 'object',
18
+ required: false,
19
+ description: 'The Segment traits to be forwarded to Heap',
20
+ label: 'Traits',
21
+ default: {
22
+ '@path': '$.traits'
23
+ }
24
+ }
25
+ },
26
+ perform: (heap, event) => {
27
+ if (event.payload.traits) {
28
+ heap.addUserProperties(event.payload.traits);
29
+ }
30
+ if (event.payload.userId) {
31
+ heap.identify(event.payload.userId);
32
+ }
33
+ }
34
+ };
35
+ export default action;
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identifyUser/index.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,GAAwD;IAClE,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,oBAAoB;IACjC,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,qBAAqB;YAClC,KAAK,EAAE,UAAU;YACjB,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,4CAA4C;YACzD,KAAK,EAAE,QAAQ;YACf,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;KACF;IACD,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACvB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE;YACxB,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;SAC7C;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE;YACxB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;SACpC;IACH,CAAC;CACF,CAAA;AAED,eAAe,MAAM,CAAA"}