@atlaskit/editor-plugin-engagement-platform 2.0.0 → 2.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/CHANGELOG.md +21 -0
- package/README.md +65 -14
- package/dist/cjs/actions/startMessage.js +66 -0
- package/dist/cjs/actions/stopMessage.js +66 -0
- package/dist/cjs/actions/types.js +5 -0
- package/dist/cjs/engagementPlatformPlugin.js +14 -6
- package/dist/cjs/pmPlugins/engagementPlatformPmPlugin/commands/setMessageState.js +22 -0
- package/dist/cjs/pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPlugin.js +48 -0
- package/dist/cjs/pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPluginKey.js +8 -0
- package/dist/cjs/pmPlugins/engagementPlatformPmPlugin/types.js +5 -0
- package/dist/es2019/actions/startMessage.js +34 -0
- package/dist/es2019/actions/stopMessage.js +34 -0
- package/dist/es2019/actions/types.js +1 -0
- package/dist/es2019/engagementPlatformPlugin.js +14 -6
- package/dist/es2019/pmPlugins/engagementPlatformPmPlugin/commands/setMessageState.js +14 -0
- package/dist/es2019/pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPlugin.js +38 -0
- package/dist/es2019/pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPluginKey.js +2 -0
- package/dist/es2019/pmPlugins/engagementPlatformPmPlugin/types.js +1 -0
- package/dist/esm/actions/startMessage.js +59 -0
- package/dist/esm/actions/stopMessage.js +59 -0
- package/dist/esm/actions/types.js +1 -0
- package/dist/esm/engagementPlatformPlugin.js +14 -6
- package/dist/esm/pmPlugins/engagementPlatformPmPlugin/commands/setMessageState.js +15 -0
- package/dist/esm/pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPlugin.js +41 -0
- package/dist/esm/pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPluginKey.js +2 -0
- package/dist/esm/pmPlugins/engagementPlatformPmPlugin/types.js +1 -0
- package/dist/types/actions/startMessage.d.ts +3 -0
- package/dist/types/actions/stopMessage.d.ts +3 -0
- package/dist/types/actions/types.d.ts +2 -0
- package/dist/types/engagementPlatformPluginType.d.ts +58 -15
- package/dist/types/index.d.ts +1 -1
- package/dist/types/pmPlugins/engagementPlatformPmPlugin/commands/setMessageState.d.ts +3 -0
- package/dist/types/pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPlugin.d.ts +4 -0
- package/dist/types/pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPluginKey.d.ts +3 -0
- package/dist/types/pmPlugins/engagementPlatformPmPlugin/types.d.ts +25 -0
- package/dist/types-ts4.5/actions/startMessage.d.ts +3 -0
- package/dist/types-ts4.5/actions/stopMessage.d.ts +3 -0
- package/dist/types-ts4.5/actions/types.d.ts +2 -0
- package/dist/types-ts4.5/engagementPlatformPluginType.d.ts +58 -14
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/pmPlugins/engagementPlatformPmPlugin/commands/setMessageState.d.ts +3 -0
- package/dist/types-ts4.5/pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPlugin.d.ts +4 -0
- package/dist/types-ts4.5/pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPluginKey.d.ts +3 -0
- package/dist/types-ts4.5/pmPlugins/engagementPlatformPmPlugin/types.d.ts +25 -0
- package/package.json +3 -2
- package/dist/cjs/pm-plugins/main.js +0 -29
- package/dist/es2019/pm-plugins/main.js +0 -23
- package/dist/esm/pm-plugins/main.js +0 -23
- package/dist/types/pm-plugins/main.d.ts +0 -9
- package/dist/types-ts4.5/pm-plugins/main.d.ts +0 -9
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { setMessageState } from '../pmPlugins/engagementPlatformPmPlugin/commands/setMessageState';
|
|
5
|
+
export function stopMessage(api, coordinationClient) {
|
|
6
|
+
return /*#__PURE__*/function () {
|
|
7
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(messageId) {
|
|
8
|
+
var _api$engagementPlatfo, _api$engagementPlatfo2;
|
|
9
|
+
var messageStates, isActive, isStopped, _api$analytics;
|
|
10
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
11
|
+
while (1) switch (_context.prev = _context.next) {
|
|
12
|
+
case 0:
|
|
13
|
+
if (api) {
|
|
14
|
+
_context.next = 2;
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
return _context.abrupt("return", false);
|
|
18
|
+
case 2:
|
|
19
|
+
messageStates = (_api$engagementPlatfo = (_api$engagementPlatfo2 = api.engagementPlatform.sharedState.currentState()) === null || _api$engagementPlatfo2 === void 0 ? void 0 : _api$engagementPlatfo2.messageStates) !== null && _api$engagementPlatfo !== void 0 ? _api$engagementPlatfo : {};
|
|
20
|
+
isActive = messageStates[messageId];
|
|
21
|
+
if (isActive) {
|
|
22
|
+
_context.next = 6;
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
return _context.abrupt("return", true);
|
|
26
|
+
case 6:
|
|
27
|
+
_context.prev = 6;
|
|
28
|
+
_context.next = 9;
|
|
29
|
+
return coordinationClient.stop(messageId);
|
|
30
|
+
case 9:
|
|
31
|
+
isStopped = _context.sent;
|
|
32
|
+
if (isStopped) {
|
|
33
|
+
api.core.actions.execute(setMessageState(messageId, false));
|
|
34
|
+
}
|
|
35
|
+
return _context.abrupt("return", isStopped);
|
|
36
|
+
case 14:
|
|
37
|
+
_context.prev = 14;
|
|
38
|
+
_context.t0 = _context["catch"](6);
|
|
39
|
+
(_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
|
|
40
|
+
action: ACTION.ERRORED,
|
|
41
|
+
actionSubject: ACTION_SUBJECT.ENGAGEMENT_PLATFORM,
|
|
42
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
43
|
+
attributes: {
|
|
44
|
+
error: _context.t0 instanceof Error ? _context.t0.message : "".concat(_context.t0),
|
|
45
|
+
errorStack: _context.t0 instanceof Error ? _context.t0.stack : undefined
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return _context.abrupt("return", false);
|
|
49
|
+
case 18:
|
|
50
|
+
case "end":
|
|
51
|
+
return _context.stop();
|
|
52
|
+
}
|
|
53
|
+
}, _callee, null, [[6, 14]]);
|
|
54
|
+
}));
|
|
55
|
+
return function (_x) {
|
|
56
|
+
return _ref.apply(this, arguments);
|
|
57
|
+
};
|
|
58
|
+
}();
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,21 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { startMessage } from './actions/startMessage';
|
|
2
|
+
import { stopMessage } from './actions/stopMessage';
|
|
3
|
+
import { engagementPlatformPmPlugin } from './pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPlugin';
|
|
4
|
+
import { engagementPlatformPmPluginKey } from './pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPluginKey';
|
|
2
5
|
export var engagementPlatformPlugin = function engagementPlatformPlugin(_ref) {
|
|
3
|
-
var config = _ref.config
|
|
6
|
+
var config = _ref.config,
|
|
7
|
+
api = _ref.api;
|
|
4
8
|
return {
|
|
5
9
|
name: 'engagementPlatform',
|
|
10
|
+
actions: {
|
|
11
|
+
startMessage: startMessage(api, config.coordinationClient),
|
|
12
|
+
stopMessage: stopMessage(api, config.coordinationClient)
|
|
13
|
+
},
|
|
6
14
|
pmPlugins: function pmPlugins() {
|
|
7
15
|
return [{
|
|
8
|
-
name: '
|
|
16
|
+
name: 'engagementPlatformPmPlugin',
|
|
9
17
|
plugin: function plugin() {
|
|
10
|
-
return
|
|
18
|
+
return engagementPlatformPmPlugin(config);
|
|
11
19
|
}
|
|
12
20
|
}];
|
|
13
21
|
},
|
|
14
22
|
getSharedState: function getSharedState(editorState) {
|
|
15
|
-
if (!
|
|
23
|
+
if (!editorState) {
|
|
16
24
|
return undefined;
|
|
17
25
|
}
|
|
18
|
-
return
|
|
26
|
+
return engagementPlatformPmPluginKey.getState(editorState);
|
|
19
27
|
}
|
|
20
28
|
};
|
|
21
29
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import { engagementPlatformPmPluginKey } from '../engagementPlatformPmPluginKey';
|
|
5
|
+
/** Set the state of a message in the Engagement Platform plugin */
|
|
6
|
+
export var setMessageState = function setMessageState(messageIs, state) {
|
|
7
|
+
return function (_ref) {
|
|
8
|
+
var _tr$getMeta;
|
|
9
|
+
var tr = _ref.tr;
|
|
10
|
+
var meta = {
|
|
11
|
+
newMessageStates: _objectSpread(_objectSpread({}, (_tr$getMeta = tr.getMeta(engagementPlatformPmPluginKey)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.messageStates), {}, _defineProperty({}, messageIs, state))
|
|
12
|
+
};
|
|
13
|
+
return tr.setMeta(engagementPlatformPmPluginKey, meta);
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
|
+
import { engagementPlatformPmPluginKey } from './engagementPlatformPmPluginKey';
|
|
7
|
+
export var engagementPlatformPmPlugin = function engagementPlatformPmPlugin(pluginConfig) {
|
|
8
|
+
return new SafePlugin({
|
|
9
|
+
key: engagementPlatformPmPluginKey,
|
|
10
|
+
state: {
|
|
11
|
+
init: function init() {
|
|
12
|
+
return {
|
|
13
|
+
messageStates: {},
|
|
14
|
+
epComponents: pluginConfig.epComponents,
|
|
15
|
+
epHooks: pluginConfig.epHooks,
|
|
16
|
+
coordinationClient: pluginConfig.coordinationClient
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
apply: function apply(tr, pluginState) {
|
|
20
|
+
var meta = tr.getMeta(engagementPlatformPmPluginKey);
|
|
21
|
+
if (!meta) {
|
|
22
|
+
return pluginState;
|
|
23
|
+
}
|
|
24
|
+
var newState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
25
|
+
messageStates: _objectSpread(_objectSpread({}, pluginState.messageStates), meta.newMessageStates)
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Remove false message states to save memory
|
|
29
|
+
Object.entries(newState.messageStates).forEach(function (_ref) {
|
|
30
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
31
|
+
key = _ref2[0],
|
|
32
|
+
value = _ref2[1];
|
|
33
|
+
if (!value) {
|
|
34
|
+
delete newState.messageStates[key];
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return newState;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CoordinationClient } from '../engagementPlatformPluginType';
|
|
2
|
+
import type { EngagementPlatformPluginApi } from './types';
|
|
3
|
+
export declare function startMessage(api: EngagementPlatformPluginApi | undefined, coordinationClient: CoordinationClient): (messageId: string, variationId?: string) => Promise<boolean>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CoordinationClient } from '../engagementPlatformPluginType';
|
|
2
|
+
import type { EngagementPlatformPluginApi } from './types';
|
|
3
|
+
export declare function stopMessage(api: EngagementPlatformPluginApi | undefined, coordinationClient: CoordinationClient): (messageId: string) => Promise<boolean>;
|
|
@@ -1,38 +1,81 @@
|
|
|
1
|
-
import type { PropsWithChildren, ReactNode } from 'react';
|
|
2
|
-
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { ComponentType, PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
|
+
import type { EngagementPlatformPmPluginState } from './pmPlugins/engagementPlatformPmPlugin/types';
|
|
3
5
|
export type EngagementPlatformPlugin = NextEditorPlugin<'engagementPlatform', {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
actions: {
|
|
7
|
+
/**
|
|
8
|
+
* Start an Engagement Platform external message with given ID and optional variation ID.
|
|
9
|
+
*
|
|
10
|
+
* This API action requires the `coordinationClient` to be provided in the plugin configuration.
|
|
11
|
+
*
|
|
12
|
+
* WARNING: Don't forget to STOP
|
|
13
|
+
*
|
|
14
|
+
* You must call {@link stopMessage} when your message has finished being displayed to a user.
|
|
15
|
+
* If you do not call {@link stopMessage}, your message will prevent the user from seeing any other
|
|
16
|
+
* messages until the Expiry time for the message is reached.
|
|
17
|
+
*
|
|
18
|
+
* @see https://developer.atlassian.com/platform/personalization/engagement/guides/external/create-external-message/#using-the-lower-level-react-class-directly---coordinationclient
|
|
19
|
+
*/
|
|
20
|
+
startMessage: (messageId: string, variationId?: string) => Promise<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Stop an Engagement Platform external message with given ID.
|
|
23
|
+
*
|
|
24
|
+
* This API action requires the `coordinationClient` to be provided in the plugin configuration.
|
|
25
|
+
*
|
|
26
|
+
* @see https://developer.atlassian.com/platform/personalization/engagement/guides/external/create-external-message/#using-the-lower-level-react-class-directly---coordinationclient
|
|
27
|
+
*/
|
|
28
|
+
stopMessage: (messageId: string) => Promise<boolean>;
|
|
29
|
+
};
|
|
30
|
+
pluginConfiguration: EngagementPlatformPluginConfig;
|
|
31
|
+
dependencies: [OptionalPlugin<AnalyticsPlugin>];
|
|
6
32
|
sharedState: EngagementPlatformPluginState;
|
|
7
33
|
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Engagement Platform coordination client.
|
|
36
|
+
*
|
|
37
|
+
* This type should be the same as the `CoordinationClientType`
|
|
38
|
+
* from the `@atlassiansox/engagekit-ts` package.
|
|
39
|
+
*/
|
|
8
40
|
export interface CoordinationClient {
|
|
9
41
|
start(messageId: string, variationId?: string): Promise<boolean>;
|
|
10
42
|
stop(messageId: string): Promise<boolean>;
|
|
11
43
|
}
|
|
12
|
-
export type
|
|
44
|
+
export type EngagementPlatformPluginConfig = {
|
|
13
45
|
epComponents: EpComponents;
|
|
14
46
|
epHooks: EpHooks;
|
|
47
|
+
/**
|
|
48
|
+
* Engagement Platform API client.
|
|
49
|
+
*
|
|
50
|
+
* This client is used to start and stop external messages in the Engagement Platform.
|
|
51
|
+
* It should be provided by a product.
|
|
52
|
+
*
|
|
53
|
+
* Without this client the next Engagement Platform plugin api calls will not work:
|
|
54
|
+
* - `startMessage`
|
|
55
|
+
* - `stopMessage`
|
|
56
|
+
* - `getMessageActivities`
|
|
57
|
+
* - `isMessageActive`
|
|
58
|
+
*
|
|
59
|
+
* The client lives in the `@atlassiansox/engagekit-ts` package.
|
|
60
|
+
*/
|
|
15
61
|
coordinationClient: CoordinationClient;
|
|
16
62
|
};
|
|
17
63
|
export type EpComponents = {
|
|
18
|
-
|
|
19
|
-
EngagementSpotlight: React.ComponentType<{
|
|
64
|
+
EngagementSpotlight: ComponentType<{
|
|
20
65
|
engagementId: string;
|
|
21
66
|
}>;
|
|
22
|
-
EngagementInlineDialog:
|
|
67
|
+
EngagementInlineDialog: ComponentType<PropsWithChildren<{
|
|
23
68
|
engagementId: string;
|
|
24
69
|
}>>;
|
|
25
|
-
Coordination:
|
|
70
|
+
Coordination: ComponentType<{
|
|
26
71
|
client: CoordinationClient;
|
|
27
72
|
messageId: string;
|
|
28
73
|
fallback: ReactNode;
|
|
29
|
-
|
|
74
|
+
children: JSX.Element;
|
|
75
|
+
}>;
|
|
30
76
|
};
|
|
31
77
|
export type EpHooks = {
|
|
32
78
|
useCoordination: (client: CoordinationClient, messageId: string) => [boolean, (force?: boolean) => Promise<void>];
|
|
33
79
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
epHooks: EpHooks;
|
|
37
|
-
coordinationClient: CoordinationClient;
|
|
38
|
-
} | undefined;
|
|
80
|
+
/** Shared state of the Engagement Platform plugin. */
|
|
81
|
+
export type EngagementPlatformPluginState = EngagementPlatformPmPluginState | undefined;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { engagementPlatformPlugin } from './engagementPlatformPlugin';
|
|
2
|
-
export type { EngagementPlatformPlugin,
|
|
2
|
+
export type { EngagementPlatformPlugin, EngagementPlatformPluginConfig, EpComponents, EpHooks, CoordinationClient, } from './engagementPlatformPluginType';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import type { EngagementPlatformPluginConfig } from '../../engagementPlatformPluginType';
|
|
3
|
+
import type { EngagementPlatformPmPluginState } from './types';
|
|
4
|
+
export declare const engagementPlatformPmPlugin: (pluginConfig: EngagementPlatformPluginConfig) => SafePlugin<EngagementPlatformPmPluginState>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CoordinationClient, EpComponents, EpHooks } from '../../engagementPlatformPluginType';
|
|
2
|
+
export interface EngagementPlatformPmPluginState {
|
|
3
|
+
/**
|
|
4
|
+
* State of Engagement Platform messages in the Editor.
|
|
5
|
+
*
|
|
6
|
+
* Contains a map of message IDs to their active state.
|
|
7
|
+
*/
|
|
8
|
+
messageStates: {
|
|
9
|
+
[messageId: string]: boolean;
|
|
10
|
+
};
|
|
11
|
+
/** Engagement Platform coordination client */
|
|
12
|
+
coordinationClient: CoordinationClient;
|
|
13
|
+
epComponents: EpComponents;
|
|
14
|
+
epHooks: EpHooks;
|
|
15
|
+
}
|
|
16
|
+
export interface EngagementPlatformPmPluginTrMeta {
|
|
17
|
+
/**
|
|
18
|
+
* New state of Engagement Platform messages in the Editor.
|
|
19
|
+
*
|
|
20
|
+
* This state will be merged (NOT REPLACED) with the existing state.
|
|
21
|
+
*/
|
|
22
|
+
newMessageStates: {
|
|
23
|
+
[messageId: string]: boolean;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CoordinationClient } from '../engagementPlatformPluginType';
|
|
2
|
+
import type { EngagementPlatformPluginApi } from './types';
|
|
3
|
+
export declare function startMessage(api: EngagementPlatformPluginApi | undefined, coordinationClient: CoordinationClient): (messageId: string, variationId?: string) => Promise<boolean>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CoordinationClient } from '../engagementPlatformPluginType';
|
|
2
|
+
import type { EngagementPlatformPluginApi } from './types';
|
|
3
|
+
export declare function stopMessage(api: EngagementPlatformPluginApi | undefined, coordinationClient: CoordinationClient): (messageId: string) => Promise<boolean>;
|
|
@@ -1,33 +1,80 @@
|
|
|
1
|
-
import type { PropsWithChildren, ReactNode } from 'react';
|
|
2
|
-
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { ComponentType, PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
|
+
import type { EngagementPlatformPmPluginState } from './pmPlugins/engagementPlatformPmPlugin/types';
|
|
3
5
|
export type EngagementPlatformPlugin = NextEditorPlugin<'engagementPlatform', {
|
|
4
|
-
|
|
6
|
+
actions: {
|
|
7
|
+
/**
|
|
8
|
+
* Start an Engagement Platform external message with given ID and optional variation ID.
|
|
9
|
+
*
|
|
10
|
+
* This API action requires the `coordinationClient` to be provided in the plugin configuration.
|
|
11
|
+
*
|
|
12
|
+
* WARNING: Don't forget to STOP
|
|
13
|
+
*
|
|
14
|
+
* You must call {@link stopMessage} when your message has finished being displayed to a user.
|
|
15
|
+
* If you do not call {@link stopMessage}, your message will prevent the user from seeing any other
|
|
16
|
+
* messages until the Expiry time for the message is reached.
|
|
17
|
+
*
|
|
18
|
+
* @see https://developer.atlassian.com/platform/personalization/engagement/guides/external/create-external-message/#using-the-lower-level-react-class-directly---coordinationclient
|
|
19
|
+
*/
|
|
20
|
+
startMessage: (messageId: string, variationId?: string) => Promise<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Stop an Engagement Platform external message with given ID.
|
|
23
|
+
*
|
|
24
|
+
* This API action requires the `coordinationClient` to be provided in the plugin configuration.
|
|
25
|
+
*
|
|
26
|
+
* @see https://developer.atlassian.com/platform/personalization/engagement/guides/external/create-external-message/#using-the-lower-level-react-class-directly---coordinationclient
|
|
27
|
+
*/
|
|
28
|
+
stopMessage: (messageId: string) => Promise<boolean>;
|
|
29
|
+
};
|
|
30
|
+
pluginConfiguration: EngagementPlatformPluginConfig;
|
|
5
31
|
dependencies: [
|
|
32
|
+
OptionalPlugin<AnalyticsPlugin>
|
|
6
33
|
];
|
|
7
34
|
sharedState: EngagementPlatformPluginState;
|
|
8
35
|
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Engagement Platform coordination client.
|
|
38
|
+
*
|
|
39
|
+
* This type should be the same as the `CoordinationClientType`
|
|
40
|
+
* from the `@atlassiansox/engagekit-ts` package.
|
|
41
|
+
*/
|
|
9
42
|
export interface CoordinationClient {
|
|
10
43
|
start(messageId: string, variationId?: string): Promise<boolean>;
|
|
11
44
|
stop(messageId: string): Promise<boolean>;
|
|
12
45
|
}
|
|
13
|
-
export type
|
|
46
|
+
export type EngagementPlatformPluginConfig = {
|
|
14
47
|
epComponents: EpComponents;
|
|
15
48
|
epHooks: EpHooks;
|
|
49
|
+
/**
|
|
50
|
+
* Engagement Platform API client.
|
|
51
|
+
*
|
|
52
|
+
* This client is used to start and stop external messages in the Engagement Platform.
|
|
53
|
+
* It should be provided by a product.
|
|
54
|
+
*
|
|
55
|
+
* Without this client the next Engagement Platform plugin api calls will not work:
|
|
56
|
+
* - `startMessage`
|
|
57
|
+
* - `stopMessage`
|
|
58
|
+
* - `getMessageActivities`
|
|
59
|
+
* - `isMessageActive`
|
|
60
|
+
*
|
|
61
|
+
* The client lives in the `@atlassiansox/engagekit-ts` package.
|
|
62
|
+
*/
|
|
16
63
|
coordinationClient: CoordinationClient;
|
|
17
64
|
};
|
|
18
65
|
export type EpComponents = {
|
|
19
|
-
|
|
20
|
-
EngagementSpotlight: React.ComponentType<{
|
|
66
|
+
EngagementSpotlight: ComponentType<{
|
|
21
67
|
engagementId: string;
|
|
22
68
|
}>;
|
|
23
|
-
EngagementInlineDialog:
|
|
69
|
+
EngagementInlineDialog: ComponentType<PropsWithChildren<{
|
|
24
70
|
engagementId: string;
|
|
25
71
|
}>>;
|
|
26
|
-
Coordination:
|
|
72
|
+
Coordination: ComponentType<{
|
|
27
73
|
client: CoordinationClient;
|
|
28
74
|
messageId: string;
|
|
29
75
|
fallback: ReactNode;
|
|
30
|
-
|
|
76
|
+
children: JSX.Element;
|
|
77
|
+
}>;
|
|
31
78
|
};
|
|
32
79
|
export type EpHooks = {
|
|
33
80
|
useCoordination: (client: CoordinationClient, messageId: string) => [
|
|
@@ -35,8 +82,5 @@ export type EpHooks = {
|
|
|
35
82
|
(force?: boolean) => Promise<void>
|
|
36
83
|
];
|
|
37
84
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
epHooks: EpHooks;
|
|
41
|
-
coordinationClient: CoordinationClient;
|
|
42
|
-
} | undefined;
|
|
85
|
+
/** Shared state of the Engagement Platform plugin. */
|
|
86
|
+
export type EngagementPlatformPluginState = EngagementPlatformPmPluginState | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { engagementPlatformPlugin } from './engagementPlatformPlugin';
|
|
2
|
-
export type { EngagementPlatformPlugin,
|
|
2
|
+
export type { EngagementPlatformPlugin, EngagementPlatformPluginConfig, EpComponents, EpHooks, CoordinationClient, } from './engagementPlatformPluginType';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import type { EngagementPlatformPluginConfig } from '../../engagementPlatformPluginType';
|
|
3
|
+
import type { EngagementPlatformPmPluginState } from './types';
|
|
4
|
+
export declare const engagementPlatformPmPlugin: (pluginConfig: EngagementPlatformPluginConfig) => SafePlugin<EngagementPlatformPmPluginState>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CoordinationClient, EpComponents, EpHooks } from '../../engagementPlatformPluginType';
|
|
2
|
+
export interface EngagementPlatformPmPluginState {
|
|
3
|
+
/**
|
|
4
|
+
* State of Engagement Platform messages in the Editor.
|
|
5
|
+
*
|
|
6
|
+
* Contains a map of message IDs to their active state.
|
|
7
|
+
*/
|
|
8
|
+
messageStates: {
|
|
9
|
+
[messageId: string]: boolean;
|
|
10
|
+
};
|
|
11
|
+
/** Engagement Platform coordination client */
|
|
12
|
+
coordinationClient: CoordinationClient;
|
|
13
|
+
epComponents: EpComponents;
|
|
14
|
+
epHooks: EpHooks;
|
|
15
|
+
}
|
|
16
|
+
export interface EngagementPlatformPmPluginTrMeta {
|
|
17
|
+
/**
|
|
18
|
+
* New state of Engagement Platform messages in the Editor.
|
|
19
|
+
*
|
|
20
|
+
* This state will be merged (NOT REPLACED) with the existing state.
|
|
21
|
+
*/
|
|
22
|
+
newMessageStates: {
|
|
23
|
+
[messageId: string]: boolean;
|
|
24
|
+
};
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-engagement-platform",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Engagement platform plugin for @atlaskit/editor-core“",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
".": "./src/index.ts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@atlaskit/editor-common": "^93.
|
|
36
|
+
"@atlaskit/editor-common": "^93.3.0",
|
|
37
|
+
"@atlaskit/editor-plugin-analytics": "^1.9.0",
|
|
37
38
|
"@atlaskit/editor-prosemirror": "6.0.0",
|
|
38
39
|
"@babel/runtime": "^7.0.0"
|
|
39
40
|
},
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.engagementPlatformPluginKey = exports.createPlugin = void 0;
|
|
7
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
|
-
var engagementPlatformPluginKey = exports.engagementPlatformPluginKey = new _state.PluginKey('engagementPlatformPlugin');
|
|
10
|
-
var createPlugin = exports.createPlugin = function createPlugin(pluginOptions) {
|
|
11
|
-
return new _safePlugin.SafePlugin({
|
|
12
|
-
key: engagementPlatformPluginKey,
|
|
13
|
-
state: {
|
|
14
|
-
init: function init() {
|
|
15
|
-
if (!pluginOptions) {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
epComponents: pluginOptions.epComponents,
|
|
20
|
-
epHooks: pluginOptions.epHooks,
|
|
21
|
-
coordinationClient: pluginOptions.coordinationClient
|
|
22
|
-
};
|
|
23
|
-
},
|
|
24
|
-
apply: function apply(_tr, pluginState) {
|
|
25
|
-
return pluginState;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
export const engagementPlatformPluginKey = new PluginKey('engagementPlatformPlugin');
|
|
4
|
-
export const createPlugin = pluginOptions => {
|
|
5
|
-
return new SafePlugin({
|
|
6
|
-
key: engagementPlatformPluginKey,
|
|
7
|
-
state: {
|
|
8
|
-
init: () => {
|
|
9
|
-
if (!pluginOptions) {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
return {
|
|
13
|
-
epComponents: pluginOptions.epComponents,
|
|
14
|
-
epHooks: pluginOptions.epHooks,
|
|
15
|
-
coordinationClient: pluginOptions.coordinationClient
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
|
-
apply: (_tr, pluginState) => {
|
|
19
|
-
return pluginState;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
export var engagementPlatformPluginKey = new PluginKey('engagementPlatformPlugin');
|
|
4
|
-
export var createPlugin = function createPlugin(pluginOptions) {
|
|
5
|
-
return new SafePlugin({
|
|
6
|
-
key: engagementPlatformPluginKey,
|
|
7
|
-
state: {
|
|
8
|
-
init: function init() {
|
|
9
|
-
if (!pluginOptions) {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
return {
|
|
13
|
-
epComponents: pluginOptions.epComponents,
|
|
14
|
-
epHooks: pluginOptions.epHooks,
|
|
15
|
-
coordinationClient: pluginOptions.coordinationClient
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
|
-
apply: function apply(_tr, pluginState) {
|
|
19
|
-
return pluginState;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type { EngagementPlatformPluginOptions, EngagementPlatformPluginState } from '../engagementPlatformPluginType';
|
|
4
|
-
export declare const engagementPlatformPluginKey: PluginKey<EngagementPlatformPluginState>;
|
|
5
|
-
export declare const createPlugin: (pluginOptions: EngagementPlatformPluginOptions) => SafePlugin<{
|
|
6
|
-
epComponents: import("../engagementPlatformPluginType").EpComponents;
|
|
7
|
-
epHooks: import("../engagementPlatformPluginType").EpHooks;
|
|
8
|
-
coordinationClient: import("../engagementPlatformPluginType").CoordinationClient;
|
|
9
|
-
} | undefined>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type { EngagementPlatformPluginOptions, EngagementPlatformPluginState } from '../engagementPlatformPluginType';
|
|
4
|
-
export declare const engagementPlatformPluginKey: PluginKey<EngagementPlatformPluginState>;
|
|
5
|
-
export declare const createPlugin: (pluginOptions: EngagementPlatformPluginOptions) => SafePlugin<{
|
|
6
|
-
epComponents: import("../engagementPlatformPluginType").EpComponents;
|
|
7
|
-
epHooks: import("../engagementPlatformPluginType").EpHooks;
|
|
8
|
-
coordinationClient: import("../engagementPlatformPluginType").CoordinationClient;
|
|
9
|
-
} | undefined>;
|