@segment/analytics-browser-actions-bucket 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.
Files changed (77) hide show
  1. package/dist/cjs/generated-types.d.ts +3 -0
  2. package/dist/cjs/generated-types.js +3 -0
  3. package/dist/cjs/generated-types.js.map +1 -0
  4. package/dist/cjs/group/generated-types.d.ts +7 -0
  5. package/dist/cjs/group/generated-types.js +3 -0
  6. package/dist/cjs/group/generated-types.js.map +1 -0
  7. package/dist/cjs/group/index.d.ts +6 -0
  8. package/dist/cjs/group/index.js +45 -0
  9. package/dist/cjs/group/index.js.map +1 -0
  10. package/dist/cjs/identifyUser/generated-types.d.ts +6 -0
  11. package/dist/cjs/identifyUser/generated-types.js +3 -0
  12. package/dist/cjs/identifyUser/generated-types.js.map +1 -0
  13. package/dist/cjs/identifyUser/index.d.ts +6 -0
  14. package/dist/cjs/identifyUser/index.js +33 -0
  15. package/dist/cjs/identifyUser/index.js.map +1 -0
  16. package/dist/cjs/index.d.ts +11 -0
  17. package/dist/cjs/index.js +66 -0
  18. package/dist/cjs/index.js.map +1 -0
  19. package/dist/cjs/test-utils.d.ts +6 -0
  20. package/dist/cjs/test-utils.js +58 -0
  21. package/dist/cjs/test-utils.js.map +1 -0
  22. package/dist/cjs/trackEvent/generated-types.d.ts +7 -0
  23. package/dist/cjs/trackEvent/generated-types.js +3 -0
  24. package/dist/cjs/trackEvent/generated-types.js.map +1 -0
  25. package/dist/cjs/trackEvent/index.d.ts +6 -0
  26. package/dist/cjs/trackEvent/index.js +45 -0
  27. package/dist/cjs/trackEvent/index.js.map +1 -0
  28. package/dist/cjs/types.d.ts +2 -0
  29. package/dist/cjs/types.js +3 -0
  30. package/dist/cjs/types.js.map +1 -0
  31. package/dist/esm/generated-types.d.ts +3 -0
  32. package/dist/esm/generated-types.js +2 -0
  33. package/dist/esm/generated-types.js.map +1 -0
  34. package/dist/esm/group/generated-types.d.ts +7 -0
  35. package/dist/esm/group/generated-types.js +2 -0
  36. package/dist/esm/group/generated-types.js.map +1 -0
  37. package/dist/esm/group/index.d.ts +6 -0
  38. package/dist/esm/group/index.js +43 -0
  39. package/dist/esm/group/index.js.map +1 -0
  40. package/dist/esm/identifyUser/generated-types.d.ts +6 -0
  41. package/dist/esm/identifyUser/generated-types.js +2 -0
  42. package/dist/esm/identifyUser/generated-types.js.map +1 -0
  43. package/dist/esm/identifyUser/index.d.ts +6 -0
  44. package/dist/esm/identifyUser/index.js +31 -0
  45. package/dist/esm/identifyUser/index.js.map +1 -0
  46. package/dist/esm/index.d.ts +11 -0
  47. package/dist/esm/index.js +62 -0
  48. package/dist/esm/index.js.map +1 -0
  49. package/dist/esm/test-utils.d.ts +6 -0
  50. package/dist/esm/test-utils.js +52 -0
  51. package/dist/esm/test-utils.js.map +1 -0
  52. package/dist/esm/trackEvent/generated-types.d.ts +7 -0
  53. package/dist/esm/trackEvent/generated-types.js +2 -0
  54. package/dist/esm/trackEvent/generated-types.js.map +1 -0
  55. package/dist/esm/trackEvent/index.d.ts +6 -0
  56. package/dist/esm/trackEvent/index.js +43 -0
  57. package/dist/esm/trackEvent/index.js.map +1 -0
  58. package/dist/esm/types.d.ts +2 -0
  59. package/dist/esm/types.js +2 -0
  60. package/dist/esm/types.js.map +1 -0
  61. package/dist/tsconfig.tsbuildinfo +1 -0
  62. package/package.json +26 -0
  63. package/src/__tests__/index.test.ts +116 -0
  64. package/src/generated-types.ts +8 -0
  65. package/src/group/__tests__/index.test.ts +186 -0
  66. package/src/group/generated-types.ts +18 -0
  67. package/src/group/index.ts +49 -0
  68. package/src/identifyUser/__tests__/index.test.ts +78 -0
  69. package/src/identifyUser/generated-types.ts +14 -0
  70. package/src/identifyUser/index.ts +36 -0
  71. package/src/index.ts +85 -0
  72. package/src/test-utils.ts +60 -0
  73. package/src/trackEvent/__tests__/index.test.ts +159 -0
  74. package/src/trackEvent/generated-types.ts +18 -0
  75. package/src/trackEvent/index.ts +49 -0
  76. package/src/types.ts +3 -0
  77. package/tsconfig.json +9 -0
@@ -0,0 +1,3 @@
1
+ export interface Settings {
2
+ trackingKey: string;
3
+ }
@@ -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,7 @@
1
+ export interface Payload {
2
+ groupId: string;
3
+ userId: string;
4
+ traits?: {
5
+ [k: string]: unknown;
6
+ };
7
+ }
@@ -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/group/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 type { Bucket } from '../types';
5
+ declare const action: BrowserActionDefinition<Settings, Bucket, Payload>;
6
+ export default action;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const action = {
4
+ title: 'Identify Company',
5
+ description: 'Creates or updates a Company in Bucket and associates the user with it',
6
+ platform: 'web',
7
+ defaultSubscription: 'type = "group"',
8
+ fields: {
9
+ groupId: {
10
+ type: 'string',
11
+ required: true,
12
+ description: 'Unique identifier for the company',
13
+ label: 'Company ID',
14
+ default: {
15
+ '@path': '$.groupId'
16
+ }
17
+ },
18
+ userId: {
19
+ type: 'string',
20
+ required: true,
21
+ allowNull: false,
22
+ description: 'Unique identifier for the user',
23
+ label: 'User ID',
24
+ default: {
25
+ '@path': '$.userId'
26
+ }
27
+ },
28
+ traits: {
29
+ type: 'object',
30
+ required: false,
31
+ description: 'Additional information to associate with the Company in Bucket',
32
+ label: 'Company Attributes',
33
+ default: {
34
+ '@path': '$.traits'
35
+ }
36
+ }
37
+ },
38
+ perform: (bucket, { payload }) => {
39
+ if (payload.userId) {
40
+ void bucket.company(payload.groupId, payload.traits, payload.userId);
41
+ }
42
+ }
43
+ };
44
+ exports.default = action;
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/group/index.ts"],"names":[],"mappings":";;AAKA,MAAM,MAAM,GAAuD;IACjE,KAAK,EAAE,kBAAkB;IACzB,WAAW,EAAE,wEAAwE;IACrF,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAE;QACN,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,mCAAmC;YAChD,KAAK,EAAE,YAAY;YACnB,OAAO,EAAE;gBACP,OAAO,EAAE,WAAW;aACrB;SACF;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,KAAK;YAChB,WAAW,EAAE,gCAAgC;YAC7C,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,gEAAgE;YAC7E,KAAK,EAAE,oBAAoB;YAC3B,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;KACF;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAE/B,IAAI,OAAO,CAAC,MAAM,EAAE;YAClB,KAAK,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;SACrE;IACH,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -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 type { Bucket } from '../types';
5
+ declare const action: BrowserActionDefinition<Settings, Bucket, Payload>;
6
+ export default action;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const action = {
4
+ title: 'Identify User',
5
+ description: 'Creates or updates a user profile in Bucket. Also initializes Live Satisfaction',
6
+ platform: 'web',
7
+ defaultSubscription: 'type = "identify"',
8
+ fields: {
9
+ userId: {
10
+ type: 'string',
11
+ required: true,
12
+ description: 'Unique identifier for the User',
13
+ label: 'User ID',
14
+ default: {
15
+ '@path': '$.userId'
16
+ }
17
+ },
18
+ traits: {
19
+ type: 'object',
20
+ required: false,
21
+ description: 'Additional information to associate with the User in Bucket',
22
+ label: 'User Attributes',
23
+ default: {
24
+ '@path': '$.traits'
25
+ }
26
+ }
27
+ },
28
+ perform: (bucket, { payload }) => {
29
+ void bucket.user(payload.userId, payload.traits);
30
+ }
31
+ };
32
+ exports.default = action;
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identifyUser/index.ts"],"names":[],"mappings":";;AAKA,MAAM,MAAM,GAAuD;IACjE,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,iFAAiF;IAC9F,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,gCAAgC;YAC7C,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,6DAA6D;YAC1E,KAAK,EAAE,iBAAiB;YACxB,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;KACF;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAC/B,KAAK,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IAClD,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 { Bucket } from './types';
4
+ declare global {
5
+ interface Window {
6
+ bucket: Bucket;
7
+ }
8
+ }
9
+ export declare const destination: BrowserDestinationDefinition<Settings, Bucket>;
10
+ declare const _default: import("@segment/browser-destination-runtime/types").PluginFactory;
11
+ export default _default;
@@ -0,0 +1,66 @@
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 identifyUser_1 = tslib_1.__importDefault(require("./identifyUser"));
7
+ const trackEvent_1 = tslib_1.__importDefault(require("./trackEvent"));
8
+ const actions_core_1 = require("@segment/actions-core");
9
+ const group_1 = tslib_1.__importDefault(require("./group"));
10
+ exports.destination = {
11
+ name: 'Bucket Web (Actions)',
12
+ description: 'Loads the Bucket browser SDK, maps identify(), group() and track() events and enables LiveSatisfaction connections',
13
+ slug: 'bucket-web',
14
+ mode: 'device',
15
+ presets: [
16
+ {
17
+ name: 'Identify User',
18
+ subscribe: 'type = "identify"',
19
+ partnerAction: 'identifyUser',
20
+ mapping: actions_core_1.defaultValues(identifyUser_1.default.fields),
21
+ type: 'automatic'
22
+ },
23
+ {
24
+ name: 'Group',
25
+ subscribe: 'type = "group"',
26
+ partnerAction: 'group',
27
+ mapping: actions_core_1.defaultValues(group_1.default.fields),
28
+ type: 'automatic'
29
+ },
30
+ {
31
+ name: 'Track Event',
32
+ subscribe: 'type = "track"',
33
+ partnerAction: 'trackEvent',
34
+ mapping: actions_core_1.defaultValues(trackEvent_1.default.fields),
35
+ type: 'automatic'
36
+ }
37
+ ],
38
+ settings: {
39
+ trackingKey: {
40
+ description: 'Your Bucket App tracking key, found on the tracking page.',
41
+ label: 'Tracking Key',
42
+ type: 'string',
43
+ required: true
44
+ }
45
+ },
46
+ actions: {
47
+ identifyUser: identifyUser_1.default,
48
+ group: group_1.default,
49
+ trackEvent: trackEvent_1.default
50
+ },
51
+ initialize: async ({ settings, analytics }, deps) => {
52
+ await deps.loadScript('https://cdn.jsdelivr.net/npm/@bucketco/tracking-sdk@2');
53
+ await deps.resolveWhen(() => window.bucket != undefined, 100);
54
+ window.bucket.init(settings.trackingKey);
55
+ const segmentPersistedUserId = analytics.user().id();
56
+ if (segmentPersistedUserId) {
57
+ void window.bucket.user(segmentPersistedUserId, {}, { active: false });
58
+ }
59
+ analytics.on('reset', () => {
60
+ window.bucket.reset();
61
+ });
62
+ return window.bucket;
63
+ }
64
+ };
65
+ exports.default = shim_1.browserDestination(exports.destination);
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAEA,oEAA8E;AAE9E,0EAAyC;AACzC,sEAAqC;AACrC,wDAAqD;AACrD,4DAA2B;AAQd,QAAA,WAAW,GAAmD;I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EAAE,CAAC,EAAE,EAAE,CAAA;QACpD,IAAI,sBAAsB,EAAE;YAC1B,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;SACvE;QAED,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YACzB,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;QACvB,CAAC,CAAC,CAAA;QAEF,OAAO,MAAM,CAAC,MAAM,CAAA;IACtB,CAAC;CACF,CAAA;AAED,kBAAe,yBAAkB,CAAC,mBAAW,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { Bucket } from 'src/types';
2
+ export declare function bucketTestHooks(): void;
3
+ export declare function getBucketCallLog(): {
4
+ method: keyof Bucket;
5
+ args: Array<unknown>;
6
+ }[];
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBucketCallLog = exports.bucketTestHooks = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const nock_1 = tslib_1.__importDefault(require("nock"));
6
+ const bucketTestMock = `
7
+ (() => {
8
+ const noop = () => {};
9
+
10
+ const bucketTestInterface = {
11
+ init: noop,
12
+ user: noop,
13
+ company: noop,
14
+ track: noop,
15
+ reset: noop
16
+ };
17
+
18
+ const callLog = [];
19
+
20
+ window.bucket = new Proxy(bucketTestInterface, {
21
+ get(bucket, property) {
22
+ if (typeof bucket[property] === 'function') {
23
+ return (...args) => {
24
+ callLog.push({ method: property, args })
25
+ return bucket[property](...args)
26
+ }
27
+ }
28
+
29
+ if (property === 'callLog') {
30
+ return callLog;
31
+ }
32
+ }
33
+ });
34
+ })();
35
+ `;
36
+ function bucketTestHooks() {
37
+ beforeAll(() => {
38
+ nock_1.default.disableNetConnect();
39
+ });
40
+ beforeEach(() => {
41
+ nock_1.default('https://cdn.jsdelivr.net').get('/npm/@bucketco/tracking-sdk@2').reply(200, bucketTestMock);
42
+ });
43
+ afterEach(function () {
44
+ if (!nock_1.default.isDone()) {
45
+ this.test.error(new Error('Not all nock interceptors were used!'));
46
+ nock_1.default.cleanAll();
47
+ }
48
+ });
49
+ afterAll(() => {
50
+ nock_1.default.enableNetConnect();
51
+ });
52
+ }
53
+ exports.bucketTestHooks = bucketTestHooks;
54
+ function getBucketCallLog() {
55
+ return window.bucket.callLog;
56
+ }
57
+ exports.getBucketCallLog = getBucketCallLog;
58
+ //# sourceMappingURL=test-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../../src/test-utils.ts"],"names":[],"mappings":";;;;AAAA,wDAAuB;AAGvB,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BtB,CAAA;AAED,SAAgB,eAAe;IAC7B,SAAS,CAAC,GAAG,EAAE;QACb,cAAI,CAAC,iBAAiB,EAAE,CAAA;IAC1B,CAAC,CAAC,CAAA;IAEF,UAAU,CAAC,GAAG,EAAE;QACd,cAAI,CAAC,0BAA0B,CAAC,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,cAAc,CAAC,CAAA;IAClG,CAAC,CAAC,CAAA;IAEF,SAAS,CAAC;QACR,IAAI,CAAC,cAAI,CAAC,MAAM,EAAE,EAAE;YAGlB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC,CAAA;YAClE,cAAI,CAAC,QAAQ,EAAE,CAAA;SAChB;IACH,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,GAAG,EAAE;QACZ,cAAI,CAAC,gBAAgB,EAAE,CAAA;IACzB,CAAC,CAAC,CAAA;AACJ,CAAC;AArBD,0CAqBC;AAED,SAAgB,gBAAgB;IAC9B,OAAQ,MAAM,CAAC,MAAwF,CAAC,OAAO,CAAA;AACjH,CAAC;AAFD,4CAEC"}
@@ -0,0 +1,7 @@
1
+ export interface Payload {
2
+ name: string;
3
+ userId: string;
4
+ properties?: {
5
+ [k: string]: unknown;
6
+ };
7
+ }
@@ -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 type { Bucket } from '../types';
5
+ declare const action: BrowserActionDefinition<Settings, Bucket, Payload>;
6
+ export default action;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const action = {
4
+ title: 'Track Event',
5
+ description: 'Map a Segment track() event to Bucket',
6
+ platform: 'web',
7
+ defaultSubscription: 'type = "track"',
8
+ fields: {
9
+ name: {
10
+ description: 'The event name',
11
+ label: 'Event name',
12
+ required: true,
13
+ type: 'string',
14
+ default: {
15
+ '@path': '$.event'
16
+ }
17
+ },
18
+ userId: {
19
+ type: 'string',
20
+ required: true,
21
+ allowNull: false,
22
+ description: 'Unique identifier for the user',
23
+ label: 'User ID',
24
+ default: {
25
+ '@path': '$.userId'
26
+ }
27
+ },
28
+ properties: {
29
+ type: 'object',
30
+ required: false,
31
+ description: 'Object containing the properties of the event',
32
+ label: 'Event Properties',
33
+ default: {
34
+ '@path': '$.properties'
35
+ }
36
+ }
37
+ },
38
+ perform: (bucket, { payload }) => {
39
+ if (payload.userId) {
40
+ void bucket.track(payload.name, payload.properties, payload.userId);
41
+ }
42
+ }
43
+ };
44
+ exports.default = action;
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/trackEvent/index.ts"],"names":[],"mappings":";;AAKA,MAAM,MAAM,GAAuD;IACjE,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,uCAAuC;IACpD,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAE;QACN,IAAI,EAAE;YACJ,WAAW,EAAE,gBAAgB;YAC7B,KAAK,EAAE,YAAY;YACnB,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,SAAS;aACnB;SACF;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,KAAK;YAChB,WAAW,EAAE,gCAAgC;YAC7C,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;QACD,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,+CAA+C;YAC5D,KAAK,EAAE,kBAAkB;YACzB,OAAO,EAAE;gBACP,OAAO,EAAE,cAAc;aACxB;SACF;KACF;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAE/B,IAAI,OAAO,CAAC,MAAM,EAAE;YAClB,KAAK,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;SACpE;IACH,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,2 @@
1
+ import type bucket from '@bucketco/tracking-sdk';
2
+ export declare type Bucket = typeof bucket;
@@ -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,3 @@
1
+ export interface Settings {
2
+ trackingKey: string;
3
+ }
@@ -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,7 @@
1
+ export interface Payload {
2
+ groupId: string;
3
+ userId: string;
4
+ traits?: {
5
+ [k: string]: unknown;
6
+ };
7
+ }
@@ -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/group/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 type { Bucket } from '../types';
5
+ declare const action: BrowserActionDefinition<Settings, Bucket, Payload>;
6
+ export default action;
@@ -0,0 +1,43 @@
1
+ const action = {
2
+ title: 'Identify Company',
3
+ description: 'Creates or updates a Company in Bucket and associates the user with it',
4
+ platform: 'web',
5
+ defaultSubscription: 'type = "group"',
6
+ fields: {
7
+ groupId: {
8
+ type: 'string',
9
+ required: true,
10
+ description: 'Unique identifier for the company',
11
+ label: 'Company ID',
12
+ default: {
13
+ '@path': '$.groupId'
14
+ }
15
+ },
16
+ userId: {
17
+ type: 'string',
18
+ required: true,
19
+ allowNull: false,
20
+ description: 'Unique identifier for the user',
21
+ label: 'User ID',
22
+ default: {
23
+ '@path': '$.userId'
24
+ }
25
+ },
26
+ traits: {
27
+ type: 'object',
28
+ required: false,
29
+ description: 'Additional information to associate with the Company in Bucket',
30
+ label: 'Company Attributes',
31
+ default: {
32
+ '@path': '$.traits'
33
+ }
34
+ }
35
+ },
36
+ perform: (bucket, { payload }) => {
37
+ if (payload.userId) {
38
+ void bucket.company(payload.groupId, payload.traits, payload.userId);
39
+ }
40
+ }
41
+ };
42
+ export default action;
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/group/index.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,GAAuD;IACjE,KAAK,EAAE,kBAAkB;IACzB,WAAW,EAAE,wEAAwE;IACrF,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAE;QACN,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,mCAAmC;YAChD,KAAK,EAAE,YAAY;YACnB,OAAO,EAAE;gBACP,OAAO,EAAE,WAAW;aACrB;SACF;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,KAAK;YAChB,WAAW,EAAE,gCAAgC;YAC7C,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,gEAAgE;YAC7E,KAAK,EAAE,oBAAoB;YAC3B,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;KACF;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAE/B,IAAI,OAAO,CAAC,MAAM,EAAE;YAClB,KAAK,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;SACrE;IACH,CAAC;CACF,CAAA;AAED,eAAe,MAAM,CAAA"}
@@ -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 type { Bucket } from '../types';
5
+ declare const action: BrowserActionDefinition<Settings, Bucket, Payload>;
6
+ export default action;
@@ -0,0 +1,31 @@
1
+ const action = {
2
+ title: 'Identify User',
3
+ description: 'Creates or updates a user profile in Bucket. Also initializes Live Satisfaction',
4
+ platform: 'web',
5
+ defaultSubscription: 'type = "identify"',
6
+ fields: {
7
+ userId: {
8
+ type: 'string',
9
+ required: true,
10
+ description: 'Unique identifier for the User',
11
+ label: 'User ID',
12
+ default: {
13
+ '@path': '$.userId'
14
+ }
15
+ },
16
+ traits: {
17
+ type: 'object',
18
+ required: false,
19
+ description: 'Additional information to associate with the User in Bucket',
20
+ label: 'User Attributes',
21
+ default: {
22
+ '@path': '$.traits'
23
+ }
24
+ }
25
+ },
26
+ perform: (bucket, { payload }) => {
27
+ void bucket.user(payload.userId, payload.traits);
28
+ }
29
+ };
30
+ export default action;
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identifyUser/index.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,GAAuD;IACjE,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,iFAAiF;IAC9F,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,gCAAgC;YAC7C,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,6DAA6D;YAC1E,KAAK,EAAE,iBAAiB;YACxB,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;KACF;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAC/B,KAAK,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IAClD,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 { Bucket } from './types';
4
+ declare global {
5
+ interface Window {
6
+ bucket: Bucket;
7
+ }
8
+ }
9
+ export declare const destination: BrowserDestinationDefinition<Settings, Bucket>;
10
+ declare const _default: import("@segment/browser-destination-runtime/types").PluginFactory;
11
+ export default _default;
@@ -0,0 +1,62 @@
1
+ import { browserDestination } from '@segment/browser-destination-runtime/shim';
2
+ import identifyUser from './identifyUser';
3
+ import trackEvent from './trackEvent';
4
+ import { defaultValues } from '@segment/actions-core';
5
+ import group from './group';
6
+ export const destination = {
7
+ name: 'Bucket Web (Actions)',
8
+ description: 'Loads the Bucket browser SDK, maps identify(), group() and track() events and enables LiveSatisfaction connections',
9
+ slug: 'bucket-web',
10
+ mode: 'device',
11
+ presets: [
12
+ {
13
+ name: 'Identify User',
14
+ subscribe: 'type = "identify"',
15
+ partnerAction: 'identifyUser',
16
+ mapping: defaultValues(identifyUser.fields),
17
+ type: 'automatic'
18
+ },
19
+ {
20
+ name: 'Group',
21
+ subscribe: 'type = "group"',
22
+ partnerAction: 'group',
23
+ mapping: defaultValues(group.fields),
24
+ type: 'automatic'
25
+ },
26
+ {
27
+ name: 'Track Event',
28
+ subscribe: 'type = "track"',
29
+ partnerAction: 'trackEvent',
30
+ mapping: defaultValues(trackEvent.fields),
31
+ type: 'automatic'
32
+ }
33
+ ],
34
+ settings: {
35
+ trackingKey: {
36
+ description: 'Your Bucket App tracking key, found on the tracking page.',
37
+ label: 'Tracking Key',
38
+ type: 'string',
39
+ required: true
40
+ }
41
+ },
42
+ actions: {
43
+ identifyUser,
44
+ group,
45
+ trackEvent
46
+ },
47
+ initialize: async ({ settings, analytics }, deps) => {
48
+ await deps.loadScript('https://cdn.jsdelivr.net/npm/@bucketco/tracking-sdk@2');
49
+ await deps.resolveWhen(() => window.bucket != undefined, 100);
50
+ window.bucket.init(settings.trackingKey);
51
+ const segmentPersistedUserId = analytics.user().id();
52
+ if (segmentPersistedUserId) {
53
+ void window.bucket.user(segmentPersistedUserId, {}, { active: false });
54
+ }
55
+ analytics.on('reset', () => {
56
+ window.bucket.reset();
57
+ });
58
+ return window.bucket;
59
+ }
60
+ };
61
+ export default browserDestination(destination);
62
+ //# 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;AAE9E,OAAO,YAAY,MAAM,gBAAgB,CAAA;AACzC,OAAO,UAAU,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,MAAM,SAAS,CAAA;AAQ3B,MAAM,CAAC,MAAM,WAAW,GAAmD;IACzE,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EACT,oHAAoH;IACtH,IAAI,EAAE,YAAY;IAClB,IAAI,EAAE,QAAQ;IAEd,OAAO,EAAE;QACP;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;QACD;YACE,IAAI,EAAE,OAAO;YACb,SAAS,EAAE,gBAAgB;YAC3B,aAAa,EAAE,O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AA"}
@@ -0,0 +1,6 @@
1
+ import { Bucket } from 'src/types';
2
+ export declare function bucketTestHooks(): void;
3
+ export declare function getBucketCallLog(): {
4
+ method: keyof Bucket;
5
+ args: Array<unknown>;
6
+ }[];