@segment/analytics-browser-actions-replaybird 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/identifyUser/generated-types.d.ts +6 -0
- package/dist/cjs/identifyUser/generated-types.js +3 -0
- package/dist/cjs/identifyUser/generated-types.js.map +1 -0
- package/dist/cjs/identifyUser/index.d.ts +6 -0
- package/dist/cjs/identifyUser/index.js +36 -0
- package/dist/cjs/identifyUser/index.js.map +1 -0
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.js +52 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/trackEvent/generated-types.d.ts +8 -0
- package/dist/cjs/trackEvent/generated-types.js +3 -0
- package/dist/cjs/trackEvent/generated-types.js.map +1 -0
- package/dist/cjs/trackEvent/index.d.ts +6 -0
- package/dist/cjs/trackEvent/index.js +62 -0
- package/dist/cjs/trackEvent/index.js.map +1 -0
- package/dist/cjs/types.d.ts +13 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils.d.ts +8 -0
- package/dist/cjs/utils.js +49 -0
- package/dist/cjs/utils.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/identifyUser/generated-types.d.ts +6 -0
- package/dist/esm/identifyUser/generated-types.js +2 -0
- package/dist/esm/identifyUser/generated-types.js.map +1 -0
- package/dist/esm/identifyUser/index.d.ts +6 -0
- package/dist/esm/identifyUser/index.js +34 -0
- package/dist/esm/identifyUser/index.js.map +1 -0
- package/dist/esm/index.d.ts +11 -0
- package/dist/esm/index.js +48 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/trackEvent/generated-types.d.ts +8 -0
- package/dist/esm/trackEvent/generated-types.js +2 -0
- package/dist/esm/trackEvent/generated-types.js.map +1 -0
- package/dist/esm/trackEvent/index.d.ts +6 -0
- package/dist/esm/trackEvent/index.js +60 -0
- package/dist/esm/trackEvent/index.js.map +1 -0
- package/dist/esm/types.d.ts +13 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils.d.ts +8 -0
- package/dist/esm/utils.js +43 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +25 -0
- package/src/__tests__/index.test.ts +21 -0
- package/src/generated-types.ts +8 -0
- package/src/identifyUser/__tests__/index.test.ts +66 -0
- package/src/identifyUser/generated-types.ts +14 -0
- package/src/identifyUser/index.ts +40 -0
- package/src/index.ts +63 -0
- package/src/trackEvent/__tests__/index.test.ts +39 -0
- package/src/trackEvent/generated-types.ts +22 -0
- package/src/trackEvent/index.ts +68 -0
- package/src/types.ts +14 -0
- package/src/utils.ts +51 -0
- package/tsconfig.json +9 -0
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @segment/analytics-browser-actions-replaybird
|
|
2
|
+
|
|
3
|
+
The Replaybird 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/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 { ReplayBird } from '../types';
|
|
5
|
+
declare const action: BrowserActionDefinition<Settings, ReplayBird, Payload>;
|
|
6
|
+
export default action;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const action = {
|
|
4
|
+
title: 'Identify User',
|
|
5
|
+
description: 'Sets user identifier and user profile details',
|
|
6
|
+
platform: 'web',
|
|
7
|
+
defaultSubscription: 'type = "identify"',
|
|
8
|
+
fields: {
|
|
9
|
+
userId: {
|
|
10
|
+
type: 'string',
|
|
11
|
+
required: true,
|
|
12
|
+
description: 'A unique ID for a known user',
|
|
13
|
+
label: 'User Id',
|
|
14
|
+
default: {
|
|
15
|
+
'@path': '$.userId'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
traits: {
|
|
19
|
+
type: 'object',
|
|
20
|
+
required: false,
|
|
21
|
+
description: 'The Segment traits to be forwarded to ReplayBird',
|
|
22
|
+
label: 'User Traits',
|
|
23
|
+
default: {
|
|
24
|
+
'@path': '$.traits'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
perform: (replaybird, event) => {
|
|
29
|
+
const payload = event.payload || {};
|
|
30
|
+
if (payload.userId) {
|
|
31
|
+
replaybird.identify(payload.userId, payload.traits || {});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.default = action;
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identifyUser/index.ts"],"names":[],"mappings":";;AAMA,MAAM,MAAM,GAA2D;IACrE,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,+CAA+C;IAC5D,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,8BAA8B;YAC3C,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,kDAAkD;YAC/D,KAAK,EAAE,aAAa;YACpB,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;KACF;IACD,OAAO,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE;QAC7B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAA;QACnC,IAAI,OAAO,CAAC,MAAM,EAAE;YAClB,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAA;SAC1D;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 { ReplayBird } from './types';
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
replaybird: ReplayBird;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare const destination: BrowserDestinationDefinition<Settings, ReplayBird>;
|
|
10
|
+
declare const _default: import("@segment/browser-destination-runtime/types").PluginFactory;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
exports.destination = {
|
|
10
|
+
name: 'ReplayBird Web (Actions)',
|
|
11
|
+
slug: 'actions-replaybird-web',
|
|
12
|
+
mode: 'device',
|
|
13
|
+
presets: [
|
|
14
|
+
{
|
|
15
|
+
name: 'Track Event',
|
|
16
|
+
subscribe: 'type = "track" or type = "page"',
|
|
17
|
+
partnerAction: 'trackEvent',
|
|
18
|
+
mapping: actions_core_1.defaultValues(trackEvent_1.default.fields),
|
|
19
|
+
type: 'automatic'
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'Identify User',
|
|
23
|
+
subscribe: 'type = "identify"',
|
|
24
|
+
partnerAction: 'identifyUser',
|
|
25
|
+
mapping: actions_core_1.defaultValues(identifyUser_1.default.fields),
|
|
26
|
+
type: 'automatic'
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
settings: {
|
|
30
|
+
apiKey: {
|
|
31
|
+
description: 'The api key for replaybird',
|
|
32
|
+
label: 'API Key',
|
|
33
|
+
type: 'string',
|
|
34
|
+
required: true
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
initialize: async ({ settings }, deps) => {
|
|
38
|
+
await deps.loadScript(`https://cdn.replaybird.com/agent/latest/replaybird.js`);
|
|
39
|
+
await deps.resolveWhen(() => Object.prototype.hasOwnProperty.call(window, 'replaybird'), 100);
|
|
40
|
+
if (settings.apiKey) {
|
|
41
|
+
window.replaybird.init(settings.apiKey, {});
|
|
42
|
+
window.replaybird.apiKey = settings.apiKey;
|
|
43
|
+
}
|
|
44
|
+
return window.replaybird;
|
|
45
|
+
},
|
|
46
|
+
actions: {
|
|
47
|
+
trackEvent: trackEvent_1.default,
|
|
48
|
+
identifyUser: identifyUser_1.default
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
exports.default = shim_1.browserDestination(exports.destination);
|
|
52
|
+
//# 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;AAS5B,QAAA,WAAW,GAAuD;IAC7E,IAAI,EAAE,0BAA0B;IAChC,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE;QACP;YACE,IAAI,EAAE,aAAa;YACnB,SAAS,EAAE,iCAAiC;YAC5C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
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 { ReplayBird } from '../types';
|
|
5
|
+
declare const action: BrowserActionDefinition<Settings, ReplayBird, Payload>;
|
|
6
|
+
export default action;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const action = {
|
|
4
|
+
title: 'Send Track Events',
|
|
5
|
+
description: 'Send Segment track() events and / or Segment page() events to ReplayBird',
|
|
6
|
+
platform: 'web',
|
|
7
|
+
defaultSubscription: 'type = "track" or type = "page"',
|
|
8
|
+
fields: {
|
|
9
|
+
name: {
|
|
10
|
+
description: 'The track() event name or page() name for the event.',
|
|
11
|
+
label: 'Event Name',
|
|
12
|
+
required: true,
|
|
13
|
+
type: 'string',
|
|
14
|
+
default: {
|
|
15
|
+
'@if': {
|
|
16
|
+
exists: { '@path': '$.event' },
|
|
17
|
+
then: { '@path': '$.event' },
|
|
18
|
+
else: { '@path': '$.name' }
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
properties: {
|
|
23
|
+
description: 'A JSON object containing additional information about the event that will be indexed by replaybird.',
|
|
24
|
+
label: 'Properties',
|
|
25
|
+
required: false,
|
|
26
|
+
type: 'object',
|
|
27
|
+
default: {
|
|
28
|
+
'@path': '$.properties'
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
userId: {
|
|
32
|
+
description: 'A unique ID for a known user',
|
|
33
|
+
label: 'User ID',
|
|
34
|
+
required: false,
|
|
35
|
+
type: 'string',
|
|
36
|
+
default: {
|
|
37
|
+
'@path': '$.userId'
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
anonymousId: {
|
|
41
|
+
description: 'A unique ID for a anonymous user',
|
|
42
|
+
label: 'Anonymous ID',
|
|
43
|
+
required: false,
|
|
44
|
+
type: 'string',
|
|
45
|
+
default: {
|
|
46
|
+
'@path': '$.anonymousId'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
perform: (replaybird, event) => {
|
|
51
|
+
const payload = event.payload;
|
|
52
|
+
if (payload) {
|
|
53
|
+
replaybird.capture(payload.name, {
|
|
54
|
+
...payload.properties,
|
|
55
|
+
userId: payload.userId,
|
|
56
|
+
anonymousId: payload.anonymousId
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
exports.default = action;
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/trackEvent/index.ts"],"names":[],"mappings":";;AAMA,MAAM,MAAM,GAA2D;IACrE,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EAAE,0EAA0E;IACvF,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,iCAAiC;IACtD,MAAM,EAAE;QACN,IAAI,EAAE;YACJ,WAAW,EAAE,sDAAsD;YACnE,KAAK,EAAE,YAAY;YACnB,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,KAAK,EAAE;oBACL,MAAM,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;oBAC9B,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;oBAC5B,IAAI,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;iBAC5B;aACF;SACF;QACD,UAAU,EAAE;YACV,WAAW,EACT,qGAAqG;YACvG,KAAK,EAAE,YAAY;YACnB,QAAQ,EAAE,KAAK;YACf,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,cAAc;aACxB;SACF;QACD,MAAM,EAAE;YACN,WAAW,EAAE,8BAA8B;YAC3C,KAAK,EAAE,SAAS;YAChB,QAAQ,EAAE,KAAK;YACf,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;QACD,WAAW,EAAE;YACX,WAAW,EAAE,kCAAkC;YAC/C,KAAK,EAAE,cAAc;YACrB,QAAQ,EAAE,KAAK;YACf,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,eAAe;aACzB;SACF;KACF;IACD,OAAO,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE;QAE7B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAA;QAC7B,IAAI,OAAO,EAAE;YACX,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE;gBAC/B,GAAG,OAAO,CAAC,UAAU;gBACrB,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,WAAW,EAAE,OAAO,CAAC,WAAW;aACjC,CAAC,CAAA;SACH;IACH,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare type EventProperties = {
|
|
2
|
+
[key: string]: unknown;
|
|
3
|
+
};
|
|
4
|
+
declare type UserProperties = {
|
|
5
|
+
[k: string]: unknown;
|
|
6
|
+
};
|
|
7
|
+
export declare type ReplayBird = {
|
|
8
|
+
apiKey: string;
|
|
9
|
+
capture: (eventName: string, eventProperties: EventProperties) => void;
|
|
10
|
+
identify: (userId: string, traits: UserProperties) => void;
|
|
11
|
+
init: (apiKey: string, options: object) => void;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Subscription } from '@segment/browser-destination-runtime/types';
|
|
2
|
+
import { ReplayBird } from './types';
|
|
3
|
+
export declare const trackSubscription: Subscription;
|
|
4
|
+
export declare const identifySubscription: Subscription;
|
|
5
|
+
export declare const REPLAYBIRD_API_KEY = "secret";
|
|
6
|
+
export declare const createMockedReplaybirdJsSdk: () => ReplayBird;
|
|
7
|
+
export declare const mockReplaybirdJsHttpRequest: () => void;
|
|
8
|
+
export declare const subscriptions: Subscription[];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.subscriptions = exports.mockReplaybirdJsHttpRequest = exports.createMockedReplaybirdJsSdk = exports.REPLAYBIRD_API_KEY = exports.identifySubscription = exports.trackSubscription = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const nock_1 = tslib_1.__importDefault(require("nock"));
|
|
6
|
+
exports.trackSubscription = {
|
|
7
|
+
partnerAction: 'trackEvent',
|
|
8
|
+
name: 'Track',
|
|
9
|
+
enabled: true,
|
|
10
|
+
subscribe: 'type = "track"',
|
|
11
|
+
mapping: {
|
|
12
|
+
name: {
|
|
13
|
+
'@path': '$.name'
|
|
14
|
+
},
|
|
15
|
+
properties: {
|
|
16
|
+
'@path': '$.properties'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.identifySubscription = {
|
|
21
|
+
partnerAction: 'identifyUser',
|
|
22
|
+
name: 'Identify',
|
|
23
|
+
enabled: true,
|
|
24
|
+
subscribe: 'type = "identify"',
|
|
25
|
+
mapping: {
|
|
26
|
+
userId: {
|
|
27
|
+
'@path': '$.userId'
|
|
28
|
+
},
|
|
29
|
+
traits: {
|
|
30
|
+
'@path': '$.traits'
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.REPLAYBIRD_API_KEY = 'secret';
|
|
35
|
+
const createMockedReplaybirdJsSdk = () => {
|
|
36
|
+
return {
|
|
37
|
+
apiKey: exports.REPLAYBIRD_API_KEY,
|
|
38
|
+
init: jest.fn(),
|
|
39
|
+
capture: jest.fn(),
|
|
40
|
+
identify: jest.fn()
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
exports.createMockedReplaybirdJsSdk = createMockedReplaybirdJsSdk;
|
|
44
|
+
const mockReplaybirdJsHttpRequest = () => {
|
|
45
|
+
nock_1.default('https://cdn.replaybird.com').get(`/agent/latest/replaybird.js`).reply(200, {});
|
|
46
|
+
};
|
|
47
|
+
exports.mockReplaybirdJsHttpRequest = mockReplaybirdJsHttpRequest;
|
|
48
|
+
exports.subscriptions = [exports.trackSubscription, exports.identifySubscription];
|
|
49
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;;AACA,wDAAuB;AAGV,QAAA,iBAAiB,GAAiB;IAC7C,aAAa,EAAE,YAAY;IAC3B,IAAI,EAAE,OAAO;IACb,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;KACF;CACF,CAAA;AAEY,QAAA,oBAAoB,GAAiB;IAChD,aAAa,EAAE,cAAc;IAC7B,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,mBAAmB;IAC9B,OAAO,EAAE;QACP,MAAM,EAAE;YACN,OAAO,EAAE,UAAU;SACpB;QACD,MAAM,EAAE;YACN,OAAO,EAAE,UAAU;SACpB;KACF;CACF,CAAA;AAEY,QAAA,kBAAkB,GAAG,QAAQ,CAAA;AAEnC,MAAM,2BAA2B,GAAG,GAAe,EAAE;IAC1D,OAAO;QACL,MAAM,EAAE,0BAAkB;QAC1B,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;QACf,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;QAClB,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;KACpB,CAAA;AACH,CAAC,CAAA;AAPY,QAAA,2BAA2B,+BAOvC;AAGM,MAAM,2BAA2B,GAAG,GAAS,EAAE;IACpD,cAAI,CAAC,4BAA4B,CAAC,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;AACtF,CAAC,CAAA;AAFY,QAAA,2BAA2B,+BAEvC;AAEY,QAAA,aAAa,GAAG,CAAC,yBAAiB,EAAE,4BAAoB,CAAC,CAAA"}
|
|
@@ -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/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 { ReplayBird } from '../types';
|
|
5
|
+
declare const action: BrowserActionDefinition<Settings, ReplayBird, Payload>;
|
|
6
|
+
export default action;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const action = {
|
|
2
|
+
title: 'Identify User',
|
|
3
|
+
description: 'Sets user identifier and user profile details',
|
|
4
|
+
platform: 'web',
|
|
5
|
+
defaultSubscription: 'type = "identify"',
|
|
6
|
+
fields: {
|
|
7
|
+
userId: {
|
|
8
|
+
type: 'string',
|
|
9
|
+
required: true,
|
|
10
|
+
description: 'A unique ID for a known user',
|
|
11
|
+
label: 'User Id',
|
|
12
|
+
default: {
|
|
13
|
+
'@path': '$.userId'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
traits: {
|
|
17
|
+
type: 'object',
|
|
18
|
+
required: false,
|
|
19
|
+
description: 'The Segment traits to be forwarded to ReplayBird',
|
|
20
|
+
label: 'User Traits',
|
|
21
|
+
default: {
|
|
22
|
+
'@path': '$.traits'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
perform: (replaybird, event) => {
|
|
27
|
+
const payload = event.payload || {};
|
|
28
|
+
if (payload.userId) {
|
|
29
|
+
replaybird.identify(payload.userId, payload.traits || {});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export default action;
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identifyUser/index.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,GAA2D;IACrE,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,+CAA+C;IAC5D,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,8BAA8B;YAC3C,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,kDAAkD;YAC/D,KAAK,EAAE,aAAa;YACpB,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;KACF;IACD,OAAO,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE;QAC7B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAA;QACnC,IAAI,OAAO,CAAC,MAAM,EAAE;YAClB,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAA;SAC1D;IACH,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 { ReplayBird } from './types';
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
replaybird: ReplayBird;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare const destination: BrowserDestinationDefinition<Settings, ReplayBird>;
|
|
10
|
+
declare const _default: import("@segment/browser-destination-runtime/types").PluginFactory;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { browserDestination } from '@segment/browser-destination-runtime/shim';
|
|
2
|
+
import { defaultValues } from '@segment/actions-core';
|
|
3
|
+
import trackEvent from './trackEvent';
|
|
4
|
+
import identifyUser from './identifyUser';
|
|
5
|
+
export const destination = {
|
|
6
|
+
name: 'ReplayBird Web (Actions)',
|
|
7
|
+
slug: 'actions-replaybird-web',
|
|
8
|
+
mode: 'device',
|
|
9
|
+
presets: [
|
|
10
|
+
{
|
|
11
|
+
name: 'Track Event',
|
|
12
|
+
subscribe: 'type = "track" or type = "page"',
|
|
13
|
+
partnerAction: 'trackEvent',
|
|
14
|
+
mapping: defaultValues(trackEvent.fields),
|
|
15
|
+
type: 'automatic'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'Identify User',
|
|
19
|
+
subscribe: 'type = "identify"',
|
|
20
|
+
partnerAction: 'identifyUser',
|
|
21
|
+
mapping: defaultValues(identifyUser.fields),
|
|
22
|
+
type: 'automatic'
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
settings: {
|
|
26
|
+
apiKey: {
|
|
27
|
+
description: 'The api key for replaybird',
|
|
28
|
+
label: 'API Key',
|
|
29
|
+
type: 'string',
|
|
30
|
+
required: true
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
initialize: async ({ settings }, deps) => {
|
|
34
|
+
await deps.loadScript(`https://cdn.replaybird.com/agent/latest/replaybird.js`);
|
|
35
|
+
await deps.resolveWhen(() => Object.prototype.hasOwnProperty.call(window, 'replaybird'), 100);
|
|
36
|
+
if (settings.apiKey) {
|
|
37
|
+
window.replaybird.init(settings.apiKey, {});
|
|
38
|
+
window.replaybird.apiKey = settings.apiKey;
|
|
39
|
+
}
|
|
40
|
+
return window.replaybird;
|
|
41
|
+
},
|
|
42
|
+
actions: {
|
|
43
|
+
trackEvent,
|
|
44
|
+
identifyUser
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
export default browserDestination(destination);
|
|
48
|
+
//# 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,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,UAAU,MAAM,cAAc,CAAA;AACrC,OAAO,YAAY,MAAM,gBAAgB,CAAA;AASzC,MAAM,CAAC,MAAM,WAAW,GAAuD;IAC7E,IAAI,EAAE,0BAA0B;IAChC,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE;QACP;YACE,IAAI,EAAE,aAAa;YACnB,SAAS,EAAE,iCAAiC;YAC5C,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;QACR,MAAM,EAAE;YACN,WAAW,EAAE,4BAA4B;YACzC,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;KACF;IAED,UAAU,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE;QAEvC,MAAM,IAAI,CAAC,UAAU,CAAC,uDAAuD,CAAC,CAAA;QAC9E,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,GAAG,CAAC,CAAA;QAE7F,IAAI,QAAQ,CAAC,MAAM,EAAE;YACnB,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;YAC3C,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAA;SAC3C;QACD,OAAO,MAAM,CAAC,UAAU,CAAA;IAC1B,CAAC;IAED,OAAO,EAAE;QACP,UAAU;QACV,YAAY;KACb;CACF,CAAA;AAED,eAAe,kBAAkB,CAAC,WAAW,CAAC,CAAA"}
|
|
@@ -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 { ReplayBird } from '../types';
|
|
5
|
+
declare const action: BrowserActionDefinition<Settings, ReplayBird, Payload>;
|
|
6
|
+
export default action;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const action = {
|
|
2
|
+
title: 'Send Track Events',
|
|
3
|
+
description: 'Send Segment track() events and / or Segment page() events to ReplayBird',
|
|
4
|
+
platform: 'web',
|
|
5
|
+
defaultSubscription: 'type = "track" or type = "page"',
|
|
6
|
+
fields: {
|
|
7
|
+
name: {
|
|
8
|
+
description: 'The track() event name or page() name for the event.',
|
|
9
|
+
label: 'Event Name',
|
|
10
|
+
required: true,
|
|
11
|
+
type: 'string',
|
|
12
|
+
default: {
|
|
13
|
+
'@if': {
|
|
14
|
+
exists: { '@path': '$.event' },
|
|
15
|
+
then: { '@path': '$.event' },
|
|
16
|
+
else: { '@path': '$.name' }
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
properties: {
|
|
21
|
+
description: 'A JSON object containing additional information about the event that will be indexed by replaybird.',
|
|
22
|
+
label: 'Properties',
|
|
23
|
+
required: false,
|
|
24
|
+
type: 'object',
|
|
25
|
+
default: {
|
|
26
|
+
'@path': '$.properties'
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
userId: {
|
|
30
|
+
description: 'A unique ID for a known user',
|
|
31
|
+
label: 'User ID',
|
|
32
|
+
required: false,
|
|
33
|
+
type: 'string',
|
|
34
|
+
default: {
|
|
35
|
+
'@path': '$.userId'
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
anonymousId: {
|
|
39
|
+
description: 'A unique ID for a anonymous user',
|
|
40
|
+
label: 'Anonymous ID',
|
|
41
|
+
required: false,
|
|
42
|
+
type: 'string',
|
|
43
|
+
default: {
|
|
44
|
+
'@path': '$.anonymousId'
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
perform: (replaybird, event) => {
|
|
49
|
+
const payload = event.payload;
|
|
50
|
+
if (payload) {
|
|
51
|
+
replaybird.capture(payload.name, {
|
|
52
|
+
...payload.properties,
|
|
53
|
+
userId: payload.userId,
|
|
54
|
+
anonymousId: payload.anonymousId
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
export default action;
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/trackEvent/index.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,G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O,CAAC,WAAW;aACjC,CAAC,CAAA;SACH;IACH,CAAC;CACF,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare type EventProperties = {
|
|
2
|
+
[key: string]: unknown;
|
|
3
|
+
};
|
|
4
|
+
declare type UserProperties = {
|
|
5
|
+
[k: string]: unknown;
|
|
6
|
+
};
|
|
7
|
+
export declare type ReplayBird = {
|
|
8
|
+
apiKey: string;
|
|
9
|
+
capture: (eventName: string, eventProperties: EventProperties) => void;
|
|
10
|
+
identify: (userId: string, traits: UserProperties) => void;
|
|
11
|
+
init: (apiKey: string, options: object) => void;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Subscription } from '@segment/browser-destination-runtime/types';
|
|
2
|
+
import { ReplayBird } from './types';
|
|
3
|
+
export declare const trackSubscription: Subscription;
|
|
4
|
+
export declare const identifySubscription: Subscription;
|
|
5
|
+
export declare const REPLAYBIRD_API_KEY = "secret";
|
|
6
|
+
export declare const createMockedReplaybirdJsSdk: () => ReplayBird;
|
|
7
|
+
export declare const mockReplaybirdJsHttpRequest: () => void;
|
|
8
|
+
export declare const subscriptions: Subscription[];
|