Store current Url in the responses meta data (#566)

* url add to link-survey

* fixed

* fixed

* fixed

* fixed

* ran pnpm format

* make url optional in response input to not break existing integrations

---------

Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
This commit is contained in:
Meet Patel
2023-07-24 20:35:54 +05:30
committed by GitHub
parent f743fb18fb
commit 6b3f977d83
4 changed files with 9 additions and 0 deletions
@@ -45,6 +45,7 @@ export async function POST(request: Request): Promise<NextResponse> {
let response: TResponse;
try {
const meta = {
url: responseInput?.meta?.url ?? "",
userAgent: {
browser: agent?.browser.name,
device: agent?.device.type,
+3
View File
@@ -108,6 +108,9 @@ export const useLinkSurveyUtils = (survey: Survey) => {
personId: personId,
finished,
data,
meta: {
url: window.location.href,
},
};
if (!responseId && !isPreview) {
const response = await createResponse(
@@ -187,6 +187,9 @@ export default function SurveyView({ config, survey, close, errorHandler }: Surv
personId: config.state.person.id,
finished,
data,
meta: {
url: window.location.href,
},
};
if (!responseId) {
const [response, _] = await Promise.all([
+2
View File
@@ -28,6 +28,7 @@ const ZResponseNote = z.object({
export type TResponseNote = z.infer<typeof ZResponseNote>;
export const ZResponseMeta = z.object({
url: z.string(),
userAgent: z.object({
browser: z.string().optional(),
os: z.string().optional(),
@@ -67,6 +68,7 @@ export const ZResponseInput = z.object({
data: ZResponseData,
meta: z
.object({
url: z.string().optional(),
userAgent: z
.object({
browser: z.string().optional(),