@segment/analytics-browser-actions-heap 1.70.1 → 1.72.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/dist/cjs/generated-types.d.ts +1 -0
- package/dist/cjs/index.d.ts +5 -1
- package/dist/cjs/index.js +22 -15
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/init-script.d.ts +2 -0
- package/dist/cjs/init-script.js +55 -0
- package/dist/cjs/init-script.js.map +1 -0
- package/dist/cjs/test-utilities.d.ts +41 -5
- package/dist/cjs/test-utilities.js +23 -8
- package/dist/cjs/test-utilities.js.map +1 -1
- package/dist/cjs/types.d.ts +9 -2
- package/dist/esm/generated-types.d.ts +1 -0
- package/dist/esm/index.d.ts +5 -1
- package/dist/esm/index.js +22 -15
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/init-script.d.ts +2 -0
- package/dist/esm/init-script.js +51 -0
- package/dist/esm/init-script.js.map +1 -0
- package/dist/esm/test-utilities.d.ts +41 -5
- package/dist/esm/test-utilities.js +22 -5
- package/dist/esm/test-utilities.js.map +1 -1
- package/dist/esm/types.d.ts +9 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/__tests__/index.test.ts +45 -8
- package/src/generated-types.ts +8 -4
- package/src/identifyUser/__tests__/index.test.ts +1 -9
- package/src/index.ts +31 -19
- package/src/init-script.ts +69 -0
- package/src/test-utilities.ts +26 -10
- package/src/trackEvent/__tests__/index.test.ts +1 -7
- package/src/types.ts +32 -2
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { Settings } from './generated-types';
|
|
2
2
|
import type { BrowserDestinationDefinition } from '@segment/browser-destination-runtime/types';
|
|
3
|
-
import { HeapApi } from './types';
|
|
3
|
+
import type { HeapApi, HeapMethods } from './types';
|
|
4
4
|
declare global {
|
|
5
5
|
interface Window {
|
|
6
|
+
heapReadyCb: Array<{
|
|
7
|
+
name: HeapMethods;
|
|
8
|
+
fn: () => void;
|
|
9
|
+
}>;
|
|
6
10
|
heap: HeapApi;
|
|
7
11
|
}
|
|
8
12
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -6,6 +6,7 @@ const shim_1 = require("@segment/browser-destination-runtime/shim");
|
|
|
6
6
|
const actions_core_1 = require("@segment/actions-core");
|
|
7
7
|
const trackEvent_1 = tslib_1.__importDefault(require("./trackEvent"));
|
|
8
8
|
const identifyUser_1 = tslib_1.__importDefault(require("./identifyUser"));
|
|
9
|
+
const init_script_1 = require("./init-script");
|
|
9
10
|
const utils_1 = require("./utils");
|
|
10
11
|
exports.destination = {
|
|
11
12
|
name: 'Heap Web (Actions)',
|
|
@@ -36,25 +37,31 @@ exports.destination = {
|
|
|
36
37
|
},
|
|
37
38
|
disableTextCapture: {
|
|
38
39
|
label: 'Global data redaction via Disabling Text Capture',
|
|
39
|
-
description: 'Setting to true will redact all target text on your website. For more information visit the
|
|
40
|
+
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).',
|
|
40
41
|
type: 'boolean',
|
|
41
42
|
required: false
|
|
42
43
|
},
|
|
43
44
|
secureCookie: {
|
|
44
45
|
label: 'Secure Cookie',
|
|
45
|
-
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
|
|
46
|
+
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).',
|
|
46
47
|
type: 'boolean',
|
|
47
48
|
required: false
|
|
48
49
|
},
|
|
49
50
|
trackingServer: {
|
|
50
|
-
label: 'Tracking Server',
|
|
51
|
-
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
|
|
51
|
+
label: 'Tracking Server (deprecated)',
|
|
52
|
+
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). This field is deprecated in favor of `ingestServer`. If `trackingServer` is set and `ingestServer` is not set, then the Classic SDK will be loaded. If both are set, `ingestServer` will take precedence, and the latest stable version of the Heap SDK will be loaded.',
|
|
53
|
+
type: 'string',
|
|
54
|
+
required: false
|
|
55
|
+
},
|
|
56
|
+
ingestServer: {
|
|
57
|
+
label: 'Ingest Server',
|
|
58
|
+
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/web#ingestserver).',
|
|
52
59
|
type: 'string',
|
|
53
60
|
required: false
|
|
54
61
|
},
|
|
55
62
|
hostname: {
|
|
56
63
|
label: 'Hostname',
|
|
57
|
-
description: 'This is an optional setting used to set the host that loads
|
|
64
|
+
description: 'This is an optional setting used to set the host that loads the Heap SDK. This setting is used when the Heap SDK is self-hosted. In most cased this should be left unset. The hostname should not contain https or app id. When _both_ `hostname` and `trackingServer` are set, the Classic SDK will be loaded via: `https://${hostname}/js/heap-${appId}.js`. If `hostname` is set and `trackingServer` is not set, then the latest version of the Heap SDK will be loaded via: `https://${settings.hostname}/config/${settings.appId}/heap_config.js`. For more information visit the Heap [docs page](https://developers.heap.io/docs/self-hosting-heapjs).',
|
|
58
65
|
type: 'string',
|
|
59
66
|
required: false
|
|
60
67
|
},
|
|
@@ -71,21 +78,21 @@ exports.destination = {
|
|
|
71
78
|
}
|
|
72
79
|
const config = {
|
|
73
80
|
disableTextCapture: settings.disableTextCapture || false,
|
|
74
|
-
secureCookie: settings.secureCookie || false
|
|
81
|
+
secureCookie: settings.secureCookie || false,
|
|
82
|
+
...(settings.ingestServer && { ingestServer: settings.ingestServer }),
|
|
83
|
+
...(settings.trackingServer && { trackingServer: settings.trackingServer })
|
|
75
84
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
window.heap = window.heap || [];
|
|
80
|
-
window.heap.appid = settings.appId;
|
|
81
|
-
window.heap.config = config;
|
|
82
|
-
if (utils_1.isDefined(settings.hostname)) {
|
|
85
|
+
init_script_1.initScript(settings.appId, config);
|
|
86
|
+
if (utils_1.isDefined(settings.hostname) && utils_1.isDefined(settings.trackingServer)) {
|
|
83
87
|
await deps.loadScript(`https://${settings.hostname}/js/heap-${settings.appId}.js`);
|
|
84
88
|
}
|
|
89
|
+
else if (utils_1.isDefined(settings.hostname) && !utils_1.isDefined(settings.trackingServer)) {
|
|
90
|
+
await deps.loadScript(`https://${settings.hostname}/config/${settings.appId}/heap_config.js`);
|
|
91
|
+
}
|
|
85
92
|
else {
|
|
86
|
-
await deps.loadScript(`https://cdn.
|
|
93
|
+
await deps.loadScript(`https://cdn.us.heap-api.com/config/${settings.appId}/heap_config.js`);
|
|
87
94
|
}
|
|
88
|
-
await deps.resolveWhen(() =>
|
|
95
|
+
await deps.resolveWhen(() => window.heap.loaded === true, 300);
|
|
89
96
|
return window.heap;
|
|
90
97
|
},
|
|
91
98
|
actions: {
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAEA,oEAA8E;AAE9E,wDAAqD;AACrD,sEAAqC;AACrC,0EAAyC;AACzC,mCAAmC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAEA,oEAA8E;AAE9E,wDAAqD;AACrD,sEAAqC;AACrC,0EAAyC;AACzC,+CAA0C;AAC1C,mCAAmC;AAUtB,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,aA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sBAAY;KACb;CACF,CAAA;AAED,kBAAe,yBAAkB,CAAC,mBAAW,CAAC,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initScript = void 0;
|
|
4
|
+
const initScript = (envId, config) => {
|
|
5
|
+
window.heapReadyCb = window.heapReadyCb || [];
|
|
6
|
+
window.heap = window.heap || {};
|
|
7
|
+
window.heap.load = function (envId, clientConfig = { disableTextCapture: false, secureCookie: false }) {
|
|
8
|
+
window.heap.envId = envId;
|
|
9
|
+
window.heap.clientConfig = clientConfig;
|
|
10
|
+
window.heap.clientConfig.shouldFetchServerConfig = false;
|
|
11
|
+
const methods = [
|
|
12
|
+
'init',
|
|
13
|
+
'startTracking',
|
|
14
|
+
'stopTracking',
|
|
15
|
+
'track',
|
|
16
|
+
'resetIdentity',
|
|
17
|
+
'identify',
|
|
18
|
+
'identifyHashed',
|
|
19
|
+
'getSessionId',
|
|
20
|
+
'getUserId',
|
|
21
|
+
'getIdentity',
|
|
22
|
+
'addUserProperties',
|
|
23
|
+
'addEventProperties',
|
|
24
|
+
'removeEventProperty',
|
|
25
|
+
'clearEventProperties',
|
|
26
|
+
'addAccountProperties',
|
|
27
|
+
'addAdapter',
|
|
28
|
+
'addTransformer',
|
|
29
|
+
'addTransformerFn',
|
|
30
|
+
'onReady',
|
|
31
|
+
'addPageviewProperties',
|
|
32
|
+
'removePageviewProperty',
|
|
33
|
+
'clearPageviewProperties',
|
|
34
|
+
'trackPageview'
|
|
35
|
+
];
|
|
36
|
+
const createMethodProxy = (methodName) => {
|
|
37
|
+
return function (...args) {
|
|
38
|
+
window.heapReadyCb.push({
|
|
39
|
+
name: methodName,
|
|
40
|
+
fn: () => {
|
|
41
|
+
if (window.heap[methodName]) {
|
|
42
|
+
window.heap[methodName](...args);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
for (const method of methods) {
|
|
49
|
+
window.heap[method] = createMethodProxy(method);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
window.heap.load(envId, config);
|
|
53
|
+
};
|
|
54
|
+
exports.initScript = initScript;
|
|
55
|
+
//# sourceMappingURL=init-script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-script.js","sourceRoot":"","sources":["../../src/init-script.ts"],"names":[],"mappings":";;;AAKO,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,MAAkB,EAAE,EAAE;IAE9D,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,EAAE,CAAA;IAG7C,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,IAAK,EAAU,CAAA;IAExC,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,UACjB,KAAa,EACb,eAA2B,EAAE,kBAAkB,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE;QAE7E,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QACzB,MAAM,CAAC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QACvC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,uBAAuB,GAAG,KAAK,CAAA;QAGxD,MAAM,OAAO,GAAkB;YAC7B,MAAM;YACN,eAAe;YACf,cAAc;YACd,OAAO;YACP,eAAe;YACf,UAAU;YACV,gBAAgB;YAChB,cAAc;YACd,WAAW;YACX,aAAa;YACb,mBAAmB;YACnB,oBAAoB;YACpB,qBAAqB;YACrB,sBAAsB;YACtB,sBAAsB;YACtB,YAAY;YACZ,gBAAgB;YAChB,kBAAkB;YAClB,SAAS;YACT,uBAAuB;YACvB,wBAAwB;YACxB,yBAAyB;YACzB,eAAe;SAChB,CAAA;QAED,MAAM,iBAAiB,GAAG,CAAC,UAAuB,EAAE,EAAE;YACpD,OAAO,UAAU,GAAG,IAAW;gBAE7B,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;oBACtB,IAAI,EAAE,UAAU;oBAChB,EAAE,EAAE,GAAG,EAAE;wBACP,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;4BAC3B,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;yBACjC;oBACH,CAAC;iBACF,CAAC,CAAA;YACJ,CAAC,CAAA;QACH,CAAC,CAAA;QAGD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAA;SAChD;IACH,CAAC,CAAA;IAED,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AACjC,CAAC,CAAA;AA/DY,QAAA,UAAU,cA+DtB"}
|
|
@@ -1,7 +1,43 @@
|
|
|
1
|
-
import { HeapApi } from './types';
|
|
2
|
-
import { Subscription } from '@segment/browser-destination-runtime/types';
|
|
1
|
+
import type { HeapApi } from './types';
|
|
3
2
|
export declare const HEAP_TEST_ENV_ID = "1";
|
|
4
3
|
export declare const createMockedHeapJsSdk: () => HeapApi;
|
|
5
|
-
export declare const trackEventSubscription:
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export declare const trackEventSubscription: {
|
|
5
|
+
partnerAction: string;
|
|
6
|
+
name: string;
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
subscribe: string;
|
|
9
|
+
mapping: {
|
|
10
|
+
name: {
|
|
11
|
+
'@path': string;
|
|
12
|
+
};
|
|
13
|
+
properties: {
|
|
14
|
+
'@path': string;
|
|
15
|
+
};
|
|
16
|
+
identity: {
|
|
17
|
+
'@path': string;
|
|
18
|
+
};
|
|
19
|
+
anonymousId: {
|
|
20
|
+
'@path': string;
|
|
21
|
+
};
|
|
22
|
+
traits: {
|
|
23
|
+
'@path': string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const identifyUserSubscription: {
|
|
28
|
+
partnerAction: string;
|
|
29
|
+
name: string;
|
|
30
|
+
enabled: boolean;
|
|
31
|
+
subscribe: string;
|
|
32
|
+
mapping: {
|
|
33
|
+
anonymousId: {
|
|
34
|
+
'@path': string;
|
|
35
|
+
};
|
|
36
|
+
userId: {
|
|
37
|
+
'@path': string;
|
|
38
|
+
};
|
|
39
|
+
traits: {
|
|
40
|
+
'@path': string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const nock_1 = tslib_1.__importDefault(require("nock"));
|
|
3
|
+
exports.identifyUserSubscription = exports.trackEventSubscription = exports.createMockedHeapJsSdk = exports.HEAP_TEST_ENV_ID = void 0;
|
|
6
4
|
exports.HEAP_TEST_ENV_ID = '1';
|
|
7
5
|
const createMockedHeapJsSdk = () => {
|
|
8
6
|
return {
|
|
9
7
|
appid: exports.HEAP_TEST_ENV_ID,
|
|
8
|
+
envId: exports.HEAP_TEST_ENV_ID,
|
|
10
9
|
config: {
|
|
11
10
|
disableTextCapture: true,
|
|
12
11
|
secureCookie: true
|
|
@@ -14,7 +13,27 @@ const createMockedHeapJsSdk = () => {
|
|
|
14
13
|
load: jest.fn(),
|
|
15
14
|
track: jest.fn(),
|
|
16
15
|
identify: jest.fn(),
|
|
17
|
-
addUserProperties: jest.fn()
|
|
16
|
+
addUserProperties: jest.fn(),
|
|
17
|
+
init: jest.fn(),
|
|
18
|
+
startTracking: jest.fn(),
|
|
19
|
+
stopTracking: jest.fn(),
|
|
20
|
+
resetIdentity: jest.fn(),
|
|
21
|
+
identifyHashed: jest.fn(),
|
|
22
|
+
getSessionId: jest.fn(),
|
|
23
|
+
getUserId: jest.fn(),
|
|
24
|
+
getIdentity: jest.fn(),
|
|
25
|
+
addEventProperties: jest.fn(),
|
|
26
|
+
removeEventProperty: jest.fn(),
|
|
27
|
+
clearEventProperties: jest.fn(),
|
|
28
|
+
addAccountProperties: jest.fn(),
|
|
29
|
+
addAdapter: jest.fn(),
|
|
30
|
+
addTransformer: jest.fn(),
|
|
31
|
+
addTransformerFn: jest.fn(),
|
|
32
|
+
onReady: jest.fn(),
|
|
33
|
+
addPageviewProperties: jest.fn(),
|
|
34
|
+
removePageviewProperty: jest.fn(),
|
|
35
|
+
clearPageviewProperties: jest.fn(),
|
|
36
|
+
trackPageview: jest.fn()
|
|
18
37
|
};
|
|
19
38
|
};
|
|
20
39
|
exports.createMockedHeapJsSdk = createMockedHeapJsSdk;
|
|
@@ -58,8 +77,4 @@ exports.identifyUserSubscription = {
|
|
|
58
77
|
}
|
|
59
78
|
}
|
|
60
79
|
};
|
|
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
80
|
//# sourceMappingURL=test-utilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utilities.js","sourceRoot":"","sources":["../../src/test-utilities.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-utilities.js","sourceRoot":"","sources":["../../src/test-utilities.ts"],"names":[],"mappings":";;;AAEa,QAAA,gBAAgB,GAAG,GAAG,CAAA;AAE5B,MAAM,qBAAqB,GAAG,GAAY,EAAE;IACjD,OAAO;QACL,KAAK,EAAE,wBAAgB;QACvB,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,EAA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;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,GAAG;IACtC,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"}
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare type UserConfig = {
|
|
2
2
|
trackingServer?: string;
|
|
3
|
+
ingestServer?: string;
|
|
3
4
|
disableTextCapture: boolean;
|
|
4
5
|
secureCookie: boolean;
|
|
5
6
|
};
|
|
@@ -9,12 +10,18 @@ declare type UserProperties = {
|
|
|
9
10
|
declare type EventProperties = {
|
|
10
11
|
[key: string]: unknown;
|
|
11
12
|
};
|
|
12
|
-
export declare type HeapApi = {
|
|
13
|
+
export declare type HeapApi = Record<HeapMethods, (...args: any[]) => void> & {
|
|
13
14
|
appid: string;
|
|
15
|
+
envId: string;
|
|
14
16
|
track: (eventName: string, eventProperties: EventProperties, library?: string) => void;
|
|
15
|
-
load: () => void;
|
|
17
|
+
load: (envId: string, clientConfig?: UserConfig) => void;
|
|
18
|
+
loaded?: boolean;
|
|
16
19
|
config: UserConfig;
|
|
20
|
+
clientConfig?: Partial<UserConfig> & {
|
|
21
|
+
shouldFetchServerConfig?: boolean;
|
|
22
|
+
};
|
|
17
23
|
identify: (identity: string) => void;
|
|
18
24
|
addUserProperties: (properties: UserProperties) => void;
|
|
19
25
|
};
|
|
26
|
+
export declare type HeapMethods = 'init' | 'startTracking' | 'stopTracking' | 'track' | 'resetIdentity' | 'identify' | 'identifyHashed' | 'getSessionId' | 'getUserId' | 'getIdentity' | 'addUserProperties' | 'addEventProperties' | 'removeEventProperty' | 'clearEventProperties' | 'addAccountProperties' | 'addAdapter' | 'addTransformer' | 'addTransformerFn' | 'onReady' | 'addPageviewProperties' | 'removePageviewProperty' | 'clearPageviewProperties' | 'trackPageview';
|
|
20
27
|
export {};
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { Settings } from './generated-types';
|
|
2
2
|
import type { BrowserDestinationDefinition } from '@segment/browser-destination-runtime/types';
|
|
3
|
-
import { HeapApi } from './types';
|
|
3
|
+
import type { HeapApi, HeapMethods } from './types';
|
|
4
4
|
declare global {
|
|
5
5
|
interface Window {
|
|
6
|
+
heapReadyCb: Array<{
|
|
7
|
+
name: HeapMethods;
|
|
8
|
+
fn: () => void;
|
|
9
|
+
}>;
|
|
6
10
|
heap: HeapApi;
|
|
7
11
|
}
|
|
8
12
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { browserDestination } from '@segment/browser-destination-runtime/shim';
|
|
|
2
2
|
import { defaultValues } from '@segment/actions-core';
|
|
3
3
|
import trackEvent from './trackEvent';
|
|
4
4
|
import identifyUser from './identifyUser';
|
|
5
|
+
import { initScript } from './init-script';
|
|
5
6
|
import { isDefined } from './utils';
|
|
6
7
|
export const destination = {
|
|
7
8
|
name: 'Heap Web (Actions)',
|
|
@@ -32,25 +33,31 @@ export const destination = {
|
|
|
32
33
|
},
|
|
33
34
|
disableTextCapture: {
|
|
34
35
|
label: 'Global data redaction via Disabling Text Capture',
|
|
35
|
-
description: 'Setting to true will redact all target text on your website. For more information visit the
|
|
36
|
+
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).',
|
|
36
37
|
type: 'boolean',
|
|
37
38
|
required: false
|
|
38
39
|
},
|
|
39
40
|
secureCookie: {
|
|
40
41
|
label: 'Secure Cookie',
|
|
41
|
-
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
|
|
42
|
+
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).',
|
|
42
43
|
type: 'boolean',
|
|
43
44
|
required: false
|
|
44
45
|
},
|
|
45
46
|
trackingServer: {
|
|
46
|
-
label: 'Tracking Server',
|
|
47
|
-
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
|
|
47
|
+
label: 'Tracking Server (deprecated)',
|
|
48
|
+
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). This field is deprecated in favor of `ingestServer`. If `trackingServer` is set and `ingestServer` is not set, then the Classic SDK will be loaded. If both are set, `ingestServer` will take precedence, and the latest stable version of the Heap SDK will be loaded.',
|
|
49
|
+
type: 'string',
|
|
50
|
+
required: false
|
|
51
|
+
},
|
|
52
|
+
ingestServer: {
|
|
53
|
+
label: 'Ingest Server',
|
|
54
|
+
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/web#ingestserver).',
|
|
48
55
|
type: 'string',
|
|
49
56
|
required: false
|
|
50
57
|
},
|
|
51
58
|
hostname: {
|
|
52
59
|
label: 'Hostname',
|
|
53
|
-
description: 'This is an optional setting used to set the host that loads
|
|
60
|
+
description: 'This is an optional setting used to set the host that loads the Heap SDK. This setting is used when the Heap SDK is self-hosted. In most cased this should be left unset. The hostname should not contain https or app id. When _both_ `hostname` and `trackingServer` are set, the Classic SDK will be loaded via: `https://${hostname}/js/heap-${appId}.js`. If `hostname` is set and `trackingServer` is not set, then the latest version of the Heap SDK will be loaded via: `https://${settings.hostname}/config/${settings.appId}/heap_config.js`. For more information visit the Heap [docs page](https://developers.heap.io/docs/self-hosting-heapjs).',
|
|
54
61
|
type: 'string',
|
|
55
62
|
required: false
|
|
56
63
|
},
|
|
@@ -67,21 +74,21 @@ export const destination = {
|
|
|
67
74
|
}
|
|
68
75
|
const config = {
|
|
69
76
|
disableTextCapture: settings.disableTextCapture || false,
|
|
70
|
-
secureCookie: settings.secureCookie || false
|
|
77
|
+
secureCookie: settings.secureCookie || false,
|
|
78
|
+
...(settings.ingestServer && { ingestServer: settings.ingestServer }),
|
|
79
|
+
...(settings.trackingServer && { trackingServer: settings.trackingServer })
|
|
71
80
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
window.heap = window.heap || [];
|
|
76
|
-
window.heap.appid = settings.appId;
|
|
77
|
-
window.heap.config = config;
|
|
78
|
-
if (isDefined(settings.hostname)) {
|
|
81
|
+
initScript(settings.appId, config);
|
|
82
|
+
if (isDefined(settings.hostname) && isDefined(settings.trackingServer)) {
|
|
79
83
|
await deps.loadScript(`https://${settings.hostname}/js/heap-${settings.appId}.js`);
|
|
80
84
|
}
|
|
85
|
+
else if (isDefined(settings.hostname) && !isDefined(settings.trackingServer)) {
|
|
86
|
+
await deps.loadScript(`https://${settings.hostname}/config/${settings.appId}/heap_config.js`);
|
|
87
|
+
}
|
|
81
88
|
else {
|
|
82
|
-
await deps.loadScript(`https://cdn.
|
|
89
|
+
await deps.loadScript(`https://cdn.us.heap-api.com/config/${settings.appId}/heap_config.js`);
|
|
83
90
|
}
|
|
84
|
-
await deps.resolveWhen(() =>
|
|
91
|
+
await deps.resolveWhen(() => window.heap.loaded === true, 300);
|
|
85
92
|
return window.heap;
|
|
86
93
|
},
|
|
87
94
|
actions: {
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAA;AAE9E,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,UAAU,MAAM,cAAc,CAAA;AACrC,OAAO,YAAY,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAA;AAE9E,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,UAAU,MAAM,cAAc,CAAA;AACrC,OAAO,YAAY,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAUnC,MAAM,CAAC,MAAM,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,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC;YACzC,IAAI,EAAE,WAAW;SAClB;QACD;YACE,IAAI,EAAE,eAAe;YACrB,SAAS,EAAE,mBAAmB;YAC9B,aAAa,EAAE,cAAc;YAC7B,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,MAAM,CAAC;YAC3C,IAAI,EAAE,WAAW;SAClB;KACF;IACD,QAAQ,EAAE;QAER,KAAK,EAAE;YACL,KAAK,EAAE,aAAa;YACpB,WAAW,EACT,2JAA2J;YAC7J,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IA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AED,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAGlC,IAAI,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE;YACtE,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,QAAQ,CAAC,QAAQ,YAAY,QAAQ,CAAC,KAAK,KAAK,CAAC,CAAA;SACnF;aAEI,IAAI,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE;YAC5E,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,QAAQ,CAAC,QAAQ,WAAW,QAAQ,CAAC,KAAK,iBAAiB,CAAC,CAAA;SAC9F;aAEI;YACH,MAAM,IAAI,CAAC,UAAU,CAAC,sCAAsC,QAAQ,CAAC,KAAK,iBAAiB,CAAC,CAAA;SAC7F;QAGD,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,GAAG,CAAC,CAAA;QAE9D,OAAO,MAAM,CAAC,IAAI,CAAA;IACpB,CAAC;IAED,OAAO,EAAE;QACP,UAAU;QACV,YAAY;KACb;CACF,CAAA;AAED,eAAe,kBAAkB,CAAC,WAAW,CAAC,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export const initScript = (envId, config) => {
|
|
2
|
+
window.heapReadyCb = window.heapReadyCb || [];
|
|
3
|
+
window.heap = window.heap || {};
|
|
4
|
+
window.heap.load = function (envId, clientConfig = { disableTextCapture: false, secureCookie: false }) {
|
|
5
|
+
window.heap.envId = envId;
|
|
6
|
+
window.heap.clientConfig = clientConfig;
|
|
7
|
+
window.heap.clientConfig.shouldFetchServerConfig = false;
|
|
8
|
+
const methods = [
|
|
9
|
+
'init',
|
|
10
|
+
'startTracking',
|
|
11
|
+
'stopTracking',
|
|
12
|
+
'track',
|
|
13
|
+
'resetIdentity',
|
|
14
|
+
'identify',
|
|
15
|
+
'identifyHashed',
|
|
16
|
+
'getSessionId',
|
|
17
|
+
'getUserId',
|
|
18
|
+
'getIdentity',
|
|
19
|
+
'addUserProperties',
|
|
20
|
+
'addEventProperties',
|
|
21
|
+
'removeEventProperty',
|
|
22
|
+
'clearEventProperties',
|
|
23
|
+
'addAccountProperties',
|
|
24
|
+
'addAdapter',
|
|
25
|
+
'addTransformer',
|
|
26
|
+
'addTransformerFn',
|
|
27
|
+
'onReady',
|
|
28
|
+
'addPageviewProperties',
|
|
29
|
+
'removePageviewProperty',
|
|
30
|
+
'clearPageviewProperties',
|
|
31
|
+
'trackPageview'
|
|
32
|
+
];
|
|
33
|
+
const createMethodProxy = (methodName) => {
|
|
34
|
+
return function (...args) {
|
|
35
|
+
window.heapReadyCb.push({
|
|
36
|
+
name: methodName,
|
|
37
|
+
fn: () => {
|
|
38
|
+
if (window.heap[methodName]) {
|
|
39
|
+
window.heap[methodName](...args);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
for (const method of methods) {
|
|
46
|
+
window.heap[method] = createMethodProxy(method);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
window.heap.load(envId, config);
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=init-script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-script.js","sourceRoot":"","sources":["../../src/init-script.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,MAAkB,EAAE,EAAE;IAE9D,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,EAAE,CAAA;IAG7C,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,IAAK,EAAU,CAAA;IAExC,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,UACjB,KAAa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
|
-
import { HeapApi } from './types';
|
|
2
|
-
import { Subscription } from '@segment/browser-destination-runtime/types';
|
|
1
|
+
import type { HeapApi } from './types';
|
|
3
2
|
export declare const HEAP_TEST_ENV_ID = "1";
|
|
4
3
|
export declare const createMockedHeapJsSdk: () => HeapApi;
|
|
5
|
-
export declare const trackEventSubscription:
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export declare const trackEventSubscription: {
|
|
5
|
+
partnerAction: string;
|
|
6
|
+
name: string;
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
subscribe: string;
|
|
9
|
+
mapping: {
|
|
10
|
+
name: {
|
|
11
|
+
'@path': string;
|
|
12
|
+
};
|
|
13
|
+
properties: {
|
|
14
|
+
'@path': string;
|
|
15
|
+
};
|
|
16
|
+
identity: {
|
|
17
|
+
'@path': string;
|
|
18
|
+
};
|
|
19
|
+
anonymousId: {
|
|
20
|
+
'@path': string;
|
|
21
|
+
};
|
|
22
|
+
traits: {
|
|
23
|
+
'@path': string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const identifyUserSubscription: {
|
|
28
|
+
partnerAction: string;
|
|
29
|
+
name: string;
|
|
30
|
+
enabled: boolean;
|
|
31
|
+
subscribe: string;
|
|
32
|
+
mapping: {
|
|
33
|
+
anonymousId: {
|
|
34
|
+
'@path': string;
|
|
35
|
+
};
|
|
36
|
+
userId: {
|
|
37
|
+
'@path': string;
|
|
38
|
+
};
|
|
39
|
+
traits: {
|
|
40
|
+
'@path': string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import nock from 'nock';
|
|
2
1
|
export const HEAP_TEST_ENV_ID = '1';
|
|
3
2
|
export const createMockedHeapJsSdk = () => {
|
|
4
3
|
return {
|
|
5
4
|
appid: HEAP_TEST_ENV_ID,
|
|
5
|
+
envId: HEAP_TEST_ENV_ID,
|
|
6
6
|
config: {
|
|
7
7
|
disableTextCapture: true,
|
|
8
8
|
secureCookie: true
|
|
@@ -10,7 +10,27 @@ export const createMockedHeapJsSdk = () => {
|
|
|
10
10
|
load: jest.fn(),
|
|
11
11
|
track: jest.fn(),
|
|
12
12
|
identify: jest.fn(),
|
|
13
|
-
addUserProperties: jest.fn()
|
|
13
|
+
addUserProperties: jest.fn(),
|
|
14
|
+
init: jest.fn(),
|
|
15
|
+
startTracking: jest.fn(),
|
|
16
|
+
stopTracking: jest.fn(),
|
|
17
|
+
resetIdentity: jest.fn(),
|
|
18
|
+
identifyHashed: jest.fn(),
|
|
19
|
+
getSessionId: jest.fn(),
|
|
20
|
+
getUserId: jest.fn(),
|
|
21
|
+
getIdentity: jest.fn(),
|
|
22
|
+
addEventProperties: jest.fn(),
|
|
23
|
+
removeEventProperty: jest.fn(),
|
|
24
|
+
clearEventProperties: jest.fn(),
|
|
25
|
+
addAccountProperties: jest.fn(),
|
|
26
|
+
addAdapter: jest.fn(),
|
|
27
|
+
addTransformer: jest.fn(),
|
|
28
|
+
addTransformerFn: jest.fn(),
|
|
29
|
+
onReady: jest.fn(),
|
|
30
|
+
addPageviewProperties: jest.fn(),
|
|
31
|
+
removePageviewProperty: jest.fn(),
|
|
32
|
+
clearPageviewProperties: jest.fn(),
|
|
33
|
+
trackPageview: jest.fn()
|
|
14
34
|
};
|
|
15
35
|
};
|
|
16
36
|
export const trackEventSubscription = {
|
|
@@ -53,7 +73,4 @@ export const identifyUserSubscription = {
|
|
|
53
73
|
}
|
|
54
74
|
}
|
|
55
75
|
};
|
|
56
|
-
export const mockHeapJsHttpRequest = () => {
|
|
57
|
-
nock('https://cdn.heapanalytics.com').get(`/js/heap-${HEAP_TEST_ENV_ID}.js`).reply(200, {});
|
|
58
|
-
};
|
|
59
76
|
//# sourceMappingURL=test-utilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utilities.js","sourceRoot":"","sources":["../../src/test-utilities.ts"],"names":[],"mappings":"AAEA,
|
|
1
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