@adobe/alloy 2.30.1-beta.11 → 2.30.1-beta.13
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/libEs5/components/BrandConcierge/constants.js +15 -0
- package/libEs5/components/BrandConcierge/createBuildEndpointUrl.js +33 -0
- package/libEs5/components/BrandConcierge/createConversationServiceRequest.js +35 -0
- package/libEs5/components/BrandConcierge/createSendConversationEvent.js +132 -0
- package/libEs5/components/BrandConcierge/createSendConversationServiceRequest.js +85 -0
- package/libEs5/components/BrandConcierge/createStreamParser.js +96 -0
- package/libEs5/components/BrandConcierge/index.js +104 -0
- package/libEs5/components/BrandConcierge/utils.js +33 -0
- package/libEs5/components/BrandConcierge/validateMessage.js +41 -0
- package/libEs5/components/Context/createComponent.js +1 -2
- package/libEs5/components/Context/implementationDetails.js +7 -9
- package/libEs5/components/Context/index.js +4 -1
- package/libEs5/components/Context/injectDevice.js +2 -2
- package/libEs5/components/Context/injectEnvironment.js +2 -2
- package/libEs5/components/Context/injectHighEntropyUserAgentHints.js +2 -2
- package/libEs5/components/Context/injectOneTimeAnalyticsReferrer.js +49 -0
- package/libEs5/components/Context/injectPlaceContext.js +2 -2
- package/libEs5/components/Context/injectTimestamp.js +2 -3
- package/libEs5/components/Context/injectWeb.js +9 -11
- package/libEs5/components/Personalization/createPersonalizationDetails.js +1 -1
- package/libEs5/components/Personalization/index.js +1 -1
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/constants/surface.js +19 -0
- package/libEs5/core/componentCreators.js +8 -1
- package/libEs5/core/index.js +5 -1
- package/libEs5/utils/dom/createGetPageLocation.js +20 -0
- package/libEs5/utils/index.js +8 -1
- package/libEs5/utils/request/createRequest.js +5 -1
- package/libEs5/utils/surfaceUtils.js +82 -0
- package/libEs6/components/BrandConcierge/constants.js +12 -0
- package/libEs6/components/BrandConcierge/createBuildEndpointUrl.js +30 -0
- package/libEs6/components/BrandConcierge/createConversationServiceRequest.js +31 -0
- package/libEs6/components/BrandConcierge/createSendConversationEvent.js +128 -0
- package/libEs6/components/BrandConcierge/createSendConversationServiceRequest.js +81 -0
- package/libEs6/components/BrandConcierge/createStreamParser.js +92 -0
- package/libEs6/components/BrandConcierge/index.js +100 -0
- package/libEs6/components/BrandConcierge/utils.js +27 -0
- package/libEs6/components/BrandConcierge/validateMessage.js +37 -0
- package/libEs6/components/Context/createComponent.js +1 -2
- package/libEs6/components/Context/implementationDetails.js +7 -9
- package/libEs6/components/Context/index.js +4 -1
- package/libEs6/components/Context/injectDevice.js +3 -3
- package/libEs6/components/Context/injectEnvironment.js +3 -3
- package/libEs6/components/Context/injectHighEntropyUserAgentHints.js +3 -3
- package/libEs6/components/Context/injectOneTimeAnalyticsReferrer.js +46 -0
- package/libEs6/components/Context/injectPlaceContext.js +3 -3
- package/libEs6/components/Context/injectTimestamp.js +2 -3
- package/libEs6/components/Context/injectWeb.js +9 -11
- package/libEs6/components/Personalization/createPersonalizationDetails.js +1 -1
- package/libEs6/components/Personalization/index.js +1 -1
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/constants/surface.js +16 -0
- package/libEs6/core/componentCreators.js +2 -1
- package/libEs6/core/index.js +5 -1
- package/libEs6/utils/dom/createGetPageLocation.js +17 -0
- package/libEs6/utils/index.js +2 -1
- package/libEs6/utils/request/createRequest.js +5 -1
- package/libEs6/utils/surfaceUtils.js +76 -0
- package/package.json +1 -1
- package/types/components/BrandConcierge/constants.d.ts +2 -0
- package/types/components/BrandConcierge/constants.d.ts.map +1 -0
- package/types/components/BrandConcierge/createBuildEndpointUrl.d.ts +9 -0
- package/types/components/BrandConcierge/createBuildEndpointUrl.d.ts.map +1 -0
- package/types/components/BrandConcierge/createConversationServiceRequest.d.ts +7 -0
- package/types/components/BrandConcierge/createConversationServiceRequest.d.ts.map +1 -0
- package/types/components/BrandConcierge/createSendConversationEvent.d.ts +14 -0
- package/types/components/BrandConcierge/createSendConversationEvent.d.ts.map +1 -0
- package/types/components/BrandConcierge/createSendConversationServiceRequest.d.ts +11 -0
- package/types/components/BrandConcierge/createSendConversationServiceRequest.d.ts.map +1 -0
- package/types/components/BrandConcierge/createStreamParser.d.ts +3 -0
- package/types/components/BrandConcierge/createStreamParser.d.ts.map +1 -0
- package/types/components/BrandConcierge/index.d.ts +31 -0
- package/types/components/BrandConcierge/index.d.ts.map +1 -0
- package/types/components/BrandConcierge/utils.d.ts +6 -0
- package/types/components/BrandConcierge/utils.d.ts.map +1 -0
- package/types/components/BrandConcierge/validateMessage.d.ts +5 -0
- package/types/components/BrandConcierge/validateMessage.d.ts.map +1 -0
- package/types/components/Context/createComponent.d.ts +1 -1
- package/types/components/Context/createComponent.d.ts.map +1 -1
- package/types/components/Context/implementationDetails.d.ts +1 -1
- package/types/components/Context/implementationDetails.d.ts.map +1 -1
- package/types/components/Context/index.d.ts +1 -1
- package/types/components/Context/index.d.ts.map +1 -1
- package/types/components/Context/injectDevice.d.ts +1 -1
- package/types/components/Context/injectDevice.d.ts.map +1 -1
- package/types/components/Context/injectEnvironment.d.ts +1 -1
- package/types/components/Context/injectEnvironment.d.ts.map +1 -1
- package/types/components/Context/injectHighEntropyUserAgentHints.d.ts +1 -1
- package/types/components/Context/injectHighEntropyUserAgentHints.d.ts.map +1 -1
- package/types/components/Context/injectOneTimeAnalyticsReferrer.d.ts +3 -0
- package/types/components/Context/injectOneTimeAnalyticsReferrer.d.ts.map +1 -0
- package/types/components/Context/injectPlaceContext.d.ts +1 -1
- package/types/components/Context/injectPlaceContext.d.ts.map +1 -1
- package/types/components/Context/injectTimestamp.d.ts +1 -1
- package/types/components/Context/injectTimestamp.d.ts.map +1 -1
- package/types/components/Context/injectWeb.d.ts +1 -1
- package/types/components/Context/injectWeb.d.ts.map +1 -1
- package/types/components/Personalization/createPersonalizationDetails.d.ts.map +1 -1
- package/types/constants/surface.d.ts +5 -0
- package/types/constants/surface.d.ts.map +1 -0
- package/types/core/componentCreators.d.ts +1 -0
- package/types/core/index.d.ts.map +1 -1
- package/types/utils/dom/createGetPageLocation.d.ts +5 -0
- package/types/utils/dom/createGetPageLocation.d.ts.map +1 -0
- package/types/utils/index.d.ts +1 -0
- package/types/utils/request/createRequest.d.ts.map +1 -1
- package/types/utils/surfaceUtils.d.ts +4 -0
- package/types/utils/surfaceUtils.d.ts.map +1 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.BC_SESSION_COOKIE_NAME = void 0;
|
|
4
|
+
/*
|
|
5
|
+
Copyright 2025 Adobe. All rights reserved.
|
|
6
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
const BC_SESSION_COOKIE_NAME = exports.BC_SESSION_COOKIE_NAME = "bc_session_id";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
/*
|
|
5
|
+
Copyright 2025 Adobe. All rights reserved.
|
|
6
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
var _default = ({
|
|
16
|
+
queryString
|
|
17
|
+
}) => {
|
|
18
|
+
return ({
|
|
19
|
+
edgeDomain,
|
|
20
|
+
request,
|
|
21
|
+
datastreamId
|
|
22
|
+
}) => {
|
|
23
|
+
const params = request.getRequestParams();
|
|
24
|
+
const configId = request.getDatastreamIdOverride() || datastreamId;
|
|
25
|
+
params.requestId = request.getId();
|
|
26
|
+
params.configId = configId;
|
|
27
|
+
const stringifiedRequestParams = queryString.stringify({
|
|
28
|
+
...params
|
|
29
|
+
});
|
|
30
|
+
return "https://" + edgeDomain + request.getEdgeSubPath() + "/" + request.getAction() + "?" + stringifiedRequestParams;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
exports.default = _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _index = require("../../utils/request/index.js");
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
7
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var _default = ({
|
|
17
|
+
payload,
|
|
18
|
+
action = "conversations",
|
|
19
|
+
sessionId
|
|
20
|
+
}) => {
|
|
21
|
+
return (0, _index.createRequest)({
|
|
22
|
+
payload: payload,
|
|
23
|
+
edgeSubPath: "/brand-concierge",
|
|
24
|
+
requestParams: {
|
|
25
|
+
sessionId
|
|
26
|
+
},
|
|
27
|
+
getAction() {
|
|
28
|
+
return action;
|
|
29
|
+
},
|
|
30
|
+
getUseSendBeacon() {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
exports.default = _default;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _index = require("../../utils/request/index.js");
|
|
5
|
+
var _createConversationServiceRequest = require("./createConversationServiceRequest.js");
|
|
6
|
+
var _utils = require("./utils.js");
|
|
7
|
+
var _uuid = require("../../utils/uuid.js");
|
|
8
|
+
var _createStreamParser = require("./createStreamParser.js");
|
|
9
|
+
/*
|
|
10
|
+
Copyright 2025 Adobe. All rights reserved.
|
|
11
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
|
|
15
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
+
governing permissions and limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
var _default = ({
|
|
21
|
+
eventManager,
|
|
22
|
+
loggingCookieJar,
|
|
23
|
+
config,
|
|
24
|
+
logger,
|
|
25
|
+
sendConversationServiceRequest,
|
|
26
|
+
buildEndpointUrl,
|
|
27
|
+
cookieTransfer,
|
|
28
|
+
createResponse,
|
|
29
|
+
decodeKndctrCookie,
|
|
30
|
+
lifecycle
|
|
31
|
+
}) => {
|
|
32
|
+
const {
|
|
33
|
+
edgeDomain,
|
|
34
|
+
edgeBasePath,
|
|
35
|
+
datastreamId,
|
|
36
|
+
onBeforeEventSend
|
|
37
|
+
} = config;
|
|
38
|
+
return options => {
|
|
39
|
+
let streamingEnabled = false;
|
|
40
|
+
const {
|
|
41
|
+
message,
|
|
42
|
+
onStreamResponse,
|
|
43
|
+
xdm,
|
|
44
|
+
data
|
|
45
|
+
} = options;
|
|
46
|
+
const sessionId = (0, _utils.getConciergeSessionCookie)({
|
|
47
|
+
loggingCookieJar,
|
|
48
|
+
config
|
|
49
|
+
}) || (0, _uuid.default)();
|
|
50
|
+
const payload = (0, _index.createDataCollectionRequestPayload)();
|
|
51
|
+
const request = (0, _createConversationServiceRequest.default)({
|
|
52
|
+
payload,
|
|
53
|
+
sessionId: sessionId
|
|
54
|
+
});
|
|
55
|
+
const event = eventManager.createEvent();
|
|
56
|
+
if (message || data) {
|
|
57
|
+
const pageSurface = (0, _utils.getPageSurface)();
|
|
58
|
+
event.mergeQuery({
|
|
59
|
+
conversation: {
|
|
60
|
+
surfaces: [pageSurface],
|
|
61
|
+
message,
|
|
62
|
+
data
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const ecid = decodeKndctrCookie();
|
|
67
|
+
event.mergeXdm({
|
|
68
|
+
identityMap: {
|
|
69
|
+
ECID: [{
|
|
70
|
+
id: ecid
|
|
71
|
+
}]
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
event.mergeXdm({
|
|
75
|
+
...xdm
|
|
76
|
+
});
|
|
77
|
+
if (message || data) {
|
|
78
|
+
streamingEnabled = true;
|
|
79
|
+
}
|
|
80
|
+
const url = buildEndpointUrl({
|
|
81
|
+
edgeDomain,
|
|
82
|
+
edgeBasePath,
|
|
83
|
+
datastreamId,
|
|
84
|
+
request
|
|
85
|
+
});
|
|
86
|
+
return lifecycle.onBeforeEvent({
|
|
87
|
+
event
|
|
88
|
+
}).then(() => {
|
|
89
|
+
try {
|
|
90
|
+
// NOTE: this calls onBeforeEventSend callback (if configured)
|
|
91
|
+
event.finalize(onBeforeEventSend);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
onStreamResponse({
|
|
94
|
+
error
|
|
95
|
+
});
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
payload.addEvent(event);
|
|
99
|
+
cookieTransfer.cookiesToPayload(payload, edgeDomain);
|
|
100
|
+
return sendConversationServiceRequest({
|
|
101
|
+
requestId: (0, _uuid.default)(),
|
|
102
|
+
url,
|
|
103
|
+
request,
|
|
104
|
+
onStreamResponse,
|
|
105
|
+
streamingEnabled
|
|
106
|
+
}).then(response => {
|
|
107
|
+
if (response.status === 204) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const onStreamResponseCallback = event => {
|
|
111
|
+
if (event.error) {
|
|
112
|
+
onStreamResponse({
|
|
113
|
+
error: event.error
|
|
114
|
+
});
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const substr = event.data.replace("data: ", "");
|
|
118
|
+
const responseJson = JSON.parse(substr);
|
|
119
|
+
const response = createResponse({
|
|
120
|
+
content: responseJson
|
|
121
|
+
});
|
|
122
|
+
cookieTransfer.responseToCookies(response);
|
|
123
|
+
logger.info("onStreamResponse callback called with", response.getPayloadsByType("brand-concierge:conversation"));
|
|
124
|
+
onStreamResponse(response.getPayloadsByType("brand-concierge:conversation"));
|
|
125
|
+
};
|
|
126
|
+
const streamParser = (0, _createStreamParser.default)();
|
|
127
|
+
streamParser(response.body, onStreamResponseCallback);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
exports.default = _default;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _index = require("../../utils/index.js");
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2025 Adobe. All rights reserved.
|
|
7
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var _default = ({
|
|
17
|
+
logger,
|
|
18
|
+
fetch
|
|
19
|
+
}) => {
|
|
20
|
+
return async ({
|
|
21
|
+
requestId,
|
|
22
|
+
url,
|
|
23
|
+
request,
|
|
24
|
+
streamingEnabled = true
|
|
25
|
+
}) => {
|
|
26
|
+
const payload = request.getPayload();
|
|
27
|
+
const stringifiedPayload = JSON.stringify(payload);
|
|
28
|
+
const parsedPayload = JSON.parse(stringifiedPayload);
|
|
29
|
+
const headers = {
|
|
30
|
+
"Content-Type": "text/plain"
|
|
31
|
+
};
|
|
32
|
+
if (streamingEnabled) {
|
|
33
|
+
headers.Accept = "text/event-stream";
|
|
34
|
+
} else {
|
|
35
|
+
headers.Accept = "text/plain";
|
|
36
|
+
}
|
|
37
|
+
logger.logOnBeforeNetworkRequest({
|
|
38
|
+
url,
|
|
39
|
+
requestId,
|
|
40
|
+
payload: parsedPayload
|
|
41
|
+
});
|
|
42
|
+
const fetchWithRetries = async (attemptNumber = 1) => {
|
|
43
|
+
const maxAttempts = 4;
|
|
44
|
+
const retryDelays = [2000, 3000, 5000];
|
|
45
|
+
try {
|
|
46
|
+
const response = await fetch(url, {
|
|
47
|
+
method: "POST",
|
|
48
|
+
headers: headers,
|
|
49
|
+
body: stringifiedPayload
|
|
50
|
+
});
|
|
51
|
+
if (!response.ok) {
|
|
52
|
+
throw new Error("Request failed with status " + response.status);
|
|
53
|
+
}
|
|
54
|
+
return response;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (attemptNumber < maxAttempts) {
|
|
57
|
+
const delay = retryDelays[attemptNumber - 1];
|
|
58
|
+
logger.logOnNetworkError({
|
|
59
|
+
requestId,
|
|
60
|
+
url,
|
|
61
|
+
payload: parsedPayload,
|
|
62
|
+
error: new Error("Attempt " + attemptNumber + " failed, retrying in " + delay + "ms: " + error.message)
|
|
63
|
+
});
|
|
64
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
65
|
+
return fetchWithRetries(attemptNumber + 1);
|
|
66
|
+
}
|
|
67
|
+
logger.logOnNetworkError({
|
|
68
|
+
requestId,
|
|
69
|
+
url,
|
|
70
|
+
payload: parsedPayload,
|
|
71
|
+
error
|
|
72
|
+
});
|
|
73
|
+
throw (0, _index.stackError)({
|
|
74
|
+
error,
|
|
75
|
+
message: "Network request failed after all retries."
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const executeRequest = async () => {
|
|
80
|
+
return fetchWithRetries();
|
|
81
|
+
};
|
|
82
|
+
return executeRequest();
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
exports.default = _default;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
/*
|
|
5
|
+
Copyright 2024 Adobe. All rights reserved.
|
|
6
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
var _default = () => {
|
|
16
|
+
// SSE streams are always UTF-8 encoded per specification
|
|
17
|
+
const ENCODING = "utf-8";
|
|
18
|
+
// SSE spec allows three line ending styles: CRLF (\r\n), LF (\n), or CR (\r)
|
|
19
|
+
const LINE_ENDING_REGEX = /\r\n|\r|\n/;
|
|
20
|
+
// Events are separated by blank lines (double line endings)
|
|
21
|
+
const EVENT_SEPARATOR_REGEX = /\r\n\r\n|\n\n|\r\r/;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Parse a single SSE event from raw event data.
|
|
25
|
+
* Follows the Server-Sent Events specification (https://html.spec.whatwg.org/multipage/server-sent-events.html)
|
|
26
|
+
*
|
|
27
|
+
* @param {string} eventData - Raw event data (multi-line string containing SSE fields)
|
|
28
|
+
* @returns {Object|null} - Parsed SSE event with structure { type, data, id } or null if invalid
|
|
29
|
+
*/
|
|
30
|
+
const parseEventFromBuffer = eventData => {
|
|
31
|
+
const lines = eventData.split(LINE_ENDING_REGEX);
|
|
32
|
+
const parsedEvent = {};
|
|
33
|
+
for (const line of lines) {
|
|
34
|
+
const trimmedLine = line.trim();
|
|
35
|
+
if (!trimmedLine) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const colonIndex = trimmedLine.indexOf(":");
|
|
39
|
+
if (colonIndex === -1) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const field = trimmedLine.substring(0, colonIndex).trim();
|
|
43
|
+
const value = trimmedLine.substring(colonIndex + 1).trim();
|
|
44
|
+
if (field === "data") {
|
|
45
|
+
parsedEvent.data = (parsedEvent.data || "") + value;
|
|
46
|
+
} else if (field === "event") {
|
|
47
|
+
parsedEvent.type = value;
|
|
48
|
+
} else if (field === "id") {
|
|
49
|
+
parsedEvent.id = value;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return parsedEvent.data ? parsedEvent : null;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Parse SSE stream using callbacks.
|
|
57
|
+
* Uses modern async iteration (for await...of) for clean, performant stream processing.
|
|
58
|
+
*
|
|
59
|
+
* @param {ReadableStream} stream - The readable stream from fetch response
|
|
60
|
+
* @param {Function} onEvent - Callback function called for each parsed event
|
|
61
|
+
*/
|
|
62
|
+
return async (stream, onEvent) => {
|
|
63
|
+
const decoder = new TextDecoder(ENCODING);
|
|
64
|
+
let buffer = "";
|
|
65
|
+
try {
|
|
66
|
+
for await (const chunk of stream) {
|
|
67
|
+
buffer += decoder.decode(chunk, {
|
|
68
|
+
stream: true
|
|
69
|
+
});
|
|
70
|
+
const events = buffer.split(EVENT_SEPARATOR_REGEX);
|
|
71
|
+
buffer = events.pop() || "";
|
|
72
|
+
for (const eventData of events) {
|
|
73
|
+
const trimmedEvent = eventData.trim();
|
|
74
|
+
if (trimmedEvent) {
|
|
75
|
+
const event = parseEventFromBuffer(trimmedEvent);
|
|
76
|
+
if (event !== null) {
|
|
77
|
+
onEvent(event);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const trimmedBuffer = buffer.trim();
|
|
83
|
+
if (trimmedBuffer) {
|
|
84
|
+
const event = parseEventFromBuffer(trimmedBuffer);
|
|
85
|
+
if (event !== null) {
|
|
86
|
+
onEvent(event);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
} catch (error) {
|
|
90
|
+
onEvent({
|
|
91
|
+
error
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
exports.default = _default;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _validateMessage = require("./validateMessage.js");
|
|
5
|
+
var _createSendConversationEvent = require("./createSendConversationEvent.js");
|
|
6
|
+
var _createBuildEndpointUrl = require("./createBuildEndpointUrl.js");
|
|
7
|
+
var _reactorQueryString = require("@adobe/reactor-query-string");
|
|
8
|
+
var _index = require("../../utils/index.js");
|
|
9
|
+
var _constants = require("./constants.js");
|
|
10
|
+
var _index2 = require("../../utils/validation/index.js");
|
|
11
|
+
var _createDecodeKndctrCookie = require("../../utils/createDecodeKndctrCookie.js");
|
|
12
|
+
var _createSendConversationServiceRequest = require("./createSendConversationServiceRequest.js");
|
|
13
|
+
/*
|
|
14
|
+
Copyright 2024 Adobe. All rights reserved.
|
|
15
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
16
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
17
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
|
|
19
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
20
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
21
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
22
|
+
governing permissions and limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const createConciergeComponent = ({
|
|
26
|
+
loggingCookieJar,
|
|
27
|
+
logger,
|
|
28
|
+
eventManager,
|
|
29
|
+
consent,
|
|
30
|
+
instanceName,
|
|
31
|
+
sendEdgeNetworkRequest,
|
|
32
|
+
config,
|
|
33
|
+
lifecycle,
|
|
34
|
+
cookieTransfer,
|
|
35
|
+
createResponse,
|
|
36
|
+
apexDomain
|
|
37
|
+
}) => {
|
|
38
|
+
const {
|
|
39
|
+
fetch
|
|
40
|
+
} = window;
|
|
41
|
+
if (!config.stickyConversationSession) {
|
|
42
|
+
loggingCookieJar.remove((0, _index.getNamespacedCookieName)(config.orgId, _constants.BC_SESSION_COOKIE_NAME), {
|
|
43
|
+
domain: apexDomain
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const buildEndpointUrl = (0, _createBuildEndpointUrl.default)({
|
|
47
|
+
queryString: _reactorQueryString.default
|
|
48
|
+
});
|
|
49
|
+
const sendConversationServiceRequest = (0, _createSendConversationServiceRequest.default)({
|
|
50
|
+
logger,
|
|
51
|
+
fetch,
|
|
52
|
+
config
|
|
53
|
+
});
|
|
54
|
+
const decodeKndctrCookie = (0, _createDecodeKndctrCookie.default)({
|
|
55
|
+
orgId: config.orgId,
|
|
56
|
+
cookieJar: loggingCookieJar,
|
|
57
|
+
logger
|
|
58
|
+
});
|
|
59
|
+
const sendConversationEvent = (0, _createSendConversationEvent.default)({
|
|
60
|
+
loggingCookieJar,
|
|
61
|
+
logger,
|
|
62
|
+
eventManager,
|
|
63
|
+
consent,
|
|
64
|
+
instanceName,
|
|
65
|
+
sendEdgeNetworkRequest,
|
|
66
|
+
config,
|
|
67
|
+
buildEndpointUrl,
|
|
68
|
+
lifecycle,
|
|
69
|
+
cookieTransfer,
|
|
70
|
+
createResponse,
|
|
71
|
+
sendConversationServiceRequest,
|
|
72
|
+
decodeKndctrCookie
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
lifecycle: {
|
|
76
|
+
onBeforeEvent({
|
|
77
|
+
event
|
|
78
|
+
}) {
|
|
79
|
+
const parsedParams = _reactorQueryString.default.parse(window.location.search);
|
|
80
|
+
if (parsedParams.source) {
|
|
81
|
+
const source = parsedParams.source;
|
|
82
|
+
event.mergeXdm({
|
|
83
|
+
channel: {
|
|
84
|
+
referringSource: source
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
commands: {
|
|
91
|
+
sendConversationEvent: {
|
|
92
|
+
optionsValidator: options => (0, _validateMessage.default)({
|
|
93
|
+
options
|
|
94
|
+
}),
|
|
95
|
+
run: sendConversationEvent
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
createConciergeComponent.namespace = "BrandConcierge";
|
|
101
|
+
createConciergeComponent.configValidators = (0, _index2.objectOf)({
|
|
102
|
+
stickyConversationSession: (0, _index2.boolean)().default(false)
|
|
103
|
+
});
|
|
104
|
+
var _default = exports.default = createConciergeComponent;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.getPageSurface = exports.getConciergeSessionCookie = void 0;
|
|
4
|
+
var _index = require("../../utils/index.js");
|
|
5
|
+
var _surfaceUtils = require("../../utils/surfaceUtils.js");
|
|
6
|
+
var _constants = require("./constants.js");
|
|
7
|
+
/*
|
|
8
|
+
Copyright 2025 Adobe. All rights reserved.
|
|
9
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
governing permissions and limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const getPageSurface = () => {
|
|
20
|
+
const pageLocation = (0, _index.createGetPageLocation)({
|
|
21
|
+
window: window
|
|
22
|
+
});
|
|
23
|
+
return (0, _surfaceUtils.buildPageSurface)(pageLocation);
|
|
24
|
+
};
|
|
25
|
+
exports.getPageSurface = getPageSurface;
|
|
26
|
+
const getConciergeSessionCookie = ({
|
|
27
|
+
loggingCookieJar,
|
|
28
|
+
config
|
|
29
|
+
}) => {
|
|
30
|
+
const cookieName = (0, _index.getNamespacedCookieName)(config.orgId, _constants.BC_SESSION_COOKIE_NAME);
|
|
31
|
+
return loggingCookieJar.get(cookieName);
|
|
32
|
+
};
|
|
33
|
+
exports.getConciergeSessionCookie = getConciergeSessionCookie;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _index = require("../../utils/validation/index.js");
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2025 Adobe. All rights reserved.
|
|
7
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var _default = ({
|
|
17
|
+
options
|
|
18
|
+
}) => {
|
|
19
|
+
const brandConciergeEventValidator = (0, _index.anyOf)([(0, _index.objectOf)({
|
|
20
|
+
message: (0, _index.string)().required()
|
|
21
|
+
}), (0, _index.objectOf)({
|
|
22
|
+
xdm: (0, _index.objectOf)({
|
|
23
|
+
interactionId: (0, _index.string)(),
|
|
24
|
+
conversationId: (0, _index.string)(),
|
|
25
|
+
conversation: (0, _index.objectOf)({
|
|
26
|
+
feedback: (0, _index.objectOf)({
|
|
27
|
+
classification: (0, _index.string)(),
|
|
28
|
+
comment: (0, _index.string)(),
|
|
29
|
+
reasons: (0, _index.arrayOf)((0, _index.string)())
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
}).required(), (0, _index.objectOf)({
|
|
34
|
+
data: (0, _index.objectOf)({
|
|
35
|
+
type: (0, _index.string)().required(),
|
|
36
|
+
payload: (0, _index.objectOf)({})
|
|
37
|
+
}).required()
|
|
38
|
+
})]);
|
|
39
|
+
return brandConciergeEventValidator(options);
|
|
40
|
+
};
|
|
41
|
+
exports.default = _default;
|
|
@@ -27,8 +27,7 @@ var _default = (config, logger, optionalContexts, requiredContexts) => {
|
|
|
27
27
|
onBeforeEvent({
|
|
28
28
|
event
|
|
29
29
|
}) {
|
|
30
|
-
|
|
31
|
-
return Promise.all(contexts.map(context => Promise.resolve(context(xdm, logger)))).then(() => event.mergeXdm(xdm));
|
|
30
|
+
return Promise.all(contexts.map(context => Promise.resolve(context(event, logger))));
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
33
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.default = void 0;
|
|
4
|
-
var _index = require("../../utils/index.js");
|
|
5
4
|
var _libraryName = require("../../constants/libraryName.js");
|
|
6
5
|
var _libraryVersion = require("../../constants/libraryVersion.js");
|
|
7
6
|
/*
|
|
@@ -15,14 +14,13 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
15
14
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
15
|
governing permissions and limitations under the License.
|
|
17
16
|
*/
|
|
18
|
-
var _default =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
implementationDetails
|
|
17
|
+
var _default = event => {
|
|
18
|
+
event.mergeXdm({
|
|
19
|
+
implementationDetails: {
|
|
20
|
+
name: _libraryName.default,
|
|
21
|
+
version: _libraryVersion.default,
|
|
22
|
+
environment: "browser"
|
|
23
|
+
}
|
|
26
24
|
});
|
|
27
25
|
};
|
|
28
26
|
exports.default = _default;
|
|
@@ -9,6 +9,7 @@ var _injectTimestamp = require("./injectTimestamp.js");
|
|
|
9
9
|
var _implementationDetails = require("./implementationDetails.js");
|
|
10
10
|
var _createComponent = require("./createComponent.js");
|
|
11
11
|
var _injectHighEntropyUserAgentHints = require("./injectHighEntropyUserAgentHints.js");
|
|
12
|
+
var _injectOneTimeAnalyticsReferrer = require("./injectOneTimeAnalyticsReferrer.js");
|
|
12
13
|
var _index = require("../../utils/validation/index.js");
|
|
13
14
|
/*
|
|
14
15
|
Copyright 2019 Adobe. All rights reserved.
|
|
@@ -28,6 +29,7 @@ const environment = (0, _injectEnvironment.default)(window);
|
|
|
28
29
|
const placeContext = (0, _injectPlaceContext.default)(() => new Date());
|
|
29
30
|
const timestamp = (0, _injectTimestamp.default)(() => new Date());
|
|
30
31
|
const highEntropyUserAgentHints = (0, _injectHighEntropyUserAgentHints.default)(navigator);
|
|
32
|
+
const oneTimeAnalyticsReferrer = (0, _injectOneTimeAnalyticsReferrer.default)(window);
|
|
31
33
|
const defaultEnabledContexts = {
|
|
32
34
|
web,
|
|
33
35
|
device,
|
|
@@ -35,7 +37,8 @@ const defaultEnabledContexts = {
|
|
|
35
37
|
placeContext
|
|
36
38
|
};
|
|
37
39
|
const defaultDisabledContexts = {
|
|
38
|
-
highEntropyUserAgentHints
|
|
40
|
+
highEntropyUserAgentHints,
|
|
41
|
+
oneTimeAnalyticsReferrer
|
|
39
42
|
};
|
|
40
43
|
const optionalContexts = {
|
|
41
44
|
...defaultEnabledContexts,
|
|
@@ -44,7 +44,7 @@ const getScreenOrientationViaMediaQuery = window => {
|
|
|
44
44
|
return null;
|
|
45
45
|
};
|
|
46
46
|
var _default = window => {
|
|
47
|
-
return
|
|
47
|
+
return event => {
|
|
48
48
|
const {
|
|
49
49
|
screen: {
|
|
50
50
|
width,
|
|
@@ -65,7 +65,7 @@ var _default = window => {
|
|
|
65
65
|
device.screenOrientation = orientation;
|
|
66
66
|
}
|
|
67
67
|
if (Object.keys(device).length > 0) {
|
|
68
|
-
|
|
68
|
+
event.mergeXdm({
|
|
69
69
|
device
|
|
70
70
|
});
|
|
71
71
|
}
|
|
@@ -14,7 +14,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
14
14
|
governing permissions and limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
var _default = window => {
|
|
17
|
-
return
|
|
17
|
+
return event => {
|
|
18
18
|
const {
|
|
19
19
|
document: {
|
|
20
20
|
documentElement: {
|
|
@@ -37,7 +37,7 @@ var _default = window => {
|
|
|
37
37
|
environment.browserDetails = environment.browserDetails || {};
|
|
38
38
|
environment.browserDetails.viewportHeight = viewportHeight;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
event.mergeXdm({
|
|
41
41
|
environment
|
|
42
42
|
});
|
|
43
43
|
};
|