From c90211a1f28c46b9792c4a4753bf4065dc6632b6 Mon Sep 17 00:00:00 2001 From: teodorus-nathaniel Date: Thu, 31 Aug 2023 22:28:31 +0700 Subject: [PATCH 1/3] Fix queued event to use new deviceId --- src/stores/analytics.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/stores/analytics.ts b/src/stores/analytics.ts index 9fa997ebb..59b3165de 100644 --- a/src/stores/analytics.ts +++ b/src/stores/analytics.ts @@ -111,7 +111,10 @@ export const useAnalytics = create()((set, get) => { set({ amp, deviceId }) queuedEvents.forEach((props) => { - amp?.logEvent(props) + amp?.logEvent({ + ...props, + device_id: deviceId, + }) }) }, } From 7decce584f46951ea6b9ea122a97b87b6a39c8cc Mon Sep 17 00:00:00 2001 From: teodorus-nathaniel Date: Thu, 31 Aug 2023 22:34:36 +0700 Subject: [PATCH 2/3] Update amplitude version --- package.json | 4 +- src/analytics/amplitude.tsx | 3 +- yarn.lock | 91 ++++++++++++++++++------------------- 3 files changed, 47 insertions(+), 51 deletions(-) diff --git a/package.json b/package.json index 6cba8a588..f093a461e 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "start-storybook": "node ./.storybook/index.js" }, "dependencies": { - "@amplitude/analytics-browser": "^1.9.1", + "@amplitude/analytics-browser": "^2.2.2", "@dicebear/bottts": "^5.3.4", "@dicebear/core": "^5.3.4", "@ethersproject/hash": "^5.7.0", @@ -59,8 +59,8 @@ "eslint": "8.34.0", "eslint-config-next": "13.2.1", "ethers": "^6.3.0", - "firebase": "^10.1.0", "express": "^4.18.2", + "firebase": "^10.1.0", "formidable": "^3.4.0", "graphql": "^16.6.0", "graphql-request": "^6.0.0", diff --git a/src/analytics/amplitude.tsx b/src/analytics/amplitude.tsx index a74564d6c..ef3166c45 100644 --- a/src/analytics/amplitude.tsx +++ b/src/analytics/amplitude.tsx @@ -8,7 +8,8 @@ export async function createAmplitudeInstance() { try { const amp = createInstance() - await amp.init(getAmpId(), undefined, { disableCookies: true }).promise + await amp.init(getAmpId(), undefined, { identityStorage: 'localStorage' }) + .promise return amp } catch (e) { console.error('Error initializing amplitude', e) diff --git a/yarn.lock b/yarn.lock index a52a068ec..c099ccc13 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12,70 +12,65 @@ resolved "https://registry.yarnpkg.com/@alloc/quick-lru/-/quick-lru-5.2.0.tgz#7bf68b20c0a350f936915fcae06f58e32007ce30" integrity sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw== -"@amplitude/analytics-browser@^1.9.1": - version "1.10.3" - resolved "https://registry.yarnpkg.com/@amplitude/analytics-browser/-/analytics-browser-1.10.3.tgz#0abfa2eb424c00fb3ecfdf448509ec89587914a3" - integrity sha512-u9xnHVLMtoWawZssZDC1wYR7GjuXF9DWL09fCdxf5j0Gp9CtRurzt+kUx9KC8IzrBmNSYZ7jG8xhwUWCbIFodg== - dependencies: - "@amplitude/analytics-client-common" "^0.7.0" - "@amplitude/analytics-core" "^0.13.3" - "@amplitude/analytics-types" "^0.20.0" - "@amplitude/plugin-page-view-tracking-browser" "^0.8.0" - "@amplitude/plugin-web-attribution-browser" "^0.7.0" - "@amplitude/ua-parser-js" "^0.7.31" +"@amplitude/analytics-browser@^2.2.2": + version "2.2.2" + resolved "https://registry.yarnpkg.com/@amplitude/analytics-browser/-/analytics-browser-2.2.2.tgz#910d999c269ff325d26c3f9fdce20b8f71974b91" + integrity sha512-7H2lp6fu2umjmrOvBS3DeCkf7hEiM4+M9VYB9Dvn8QwlaeLhQrk/+TLyew12lmApOowI/C1f8TAupSIKB5MucQ== + dependencies: + "@amplitude/analytics-client-common" "^2.0.5" + "@amplitude/analytics-core" "^2.0.4" + "@amplitude/analytics-types" "^2.1.2" + "@amplitude/plugin-page-view-tracking-browser" "^2.0.8" + "@amplitude/plugin-web-attribution-browser" "^2.0.8" tslib "^2.4.1" -"@amplitude/analytics-client-common@^0.7.0": - version "0.7.0" - resolved "https://registry.yarnpkg.com/@amplitude/analytics-client-common/-/analytics-client-common-0.7.0.tgz#b099a97853d8622cdb371329d5e70afc6d9dca10" - integrity sha512-fKBR5DSo6qTqFcCFnLopRdWv6Zieox3YnzyXG2Zg1hR9MDeX96GoMEwwT2VB5MPzGxE1wYW6kQPvU2C/xpn5ww== +"@amplitude/analytics-client-common@^2.0.5": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@amplitude/analytics-client-common/-/analytics-client-common-2.0.5.tgz#164140e24529f6de3215db4f3e3c1bf3dbbe3267" + integrity sha512-5BrGl188h4Ayx4Z2e1x4I3Z8ykC+ap65cy8ShBByiaBBrR40gnXSuLZR7xeex3lvTp2b5lMBcVCqArdRbeZrgQ== dependencies: - "@amplitude/analytics-connector" "^1.4.5" - "@amplitude/analytics-core" "^0.13.3" - "@amplitude/analytics-types" "^0.20.0" + "@amplitude/analytics-connector" "^1.4.8" + "@amplitude/analytics-core" "^2.0.4" + "@amplitude/analytics-types" "^2.1.2" tslib "^2.4.1" -"@amplitude/analytics-connector@^1.4.5": - version "1.4.8" - resolved "https://registry.yarnpkg.com/@amplitude/analytics-connector/-/analytics-connector-1.4.8.tgz#dd801303db2662bc51be7e0194eeb8bd72267c42" - integrity sha512-dFW7c7Wb6Ng7vbmzwbaXZSpqfBx37ukamJV9ErFYYS8vGZK/Hkbt3M7fZHBI4WFU6CCwakr2ZXPme11uGPYWkQ== +"@amplitude/analytics-connector@^1.4.8": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@amplitude/analytics-connector/-/analytics-connector-1.5.0.tgz#89a78b8c6463abe4de1d621db4af6c62f0d62b0a" + integrity sha512-T8mOYzB9RRxckzhL0NTHwdge9xuFxXEOplC8B1Y3UX3NHa3BLh7DlBUZlCOwQgMc2nxDfnSweDL5S3bhC+W90g== -"@amplitude/analytics-core@^0.13.3": - version "0.13.3" - resolved "https://registry.yarnpkg.com/@amplitude/analytics-core/-/analytics-core-0.13.3.tgz#c1c99751dd25ec616b6dc242d65997f83659f564" - integrity sha512-lLLmUwi78iqGsCPgd15yH488K+3FPYQ19fCdA3OemoEK9959xCzMZe/KYafQKkgZmI4ZiZLOp3pjamKWc6mcdQ== +"@amplitude/analytics-core@^2.0.4": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@amplitude/analytics-core/-/analytics-core-2.0.4.tgz#a4ea5c95e95ff75d760a6b57a2ed2be2c763f244" + integrity sha512-AM4g1ucaAJuFqaMBg7FiqwKHveyV2QpZ3yPxw3OxNCgZz2QmqeYE1bp47x4FlfzNsoGyuYqRKs1mCbmGobAYWA== dependencies: - "@amplitude/analytics-types" "^0.20.0" + "@amplitude/analytics-types" "^2.1.2" tslib "^2.4.1" -"@amplitude/analytics-types@^0.20.0": - version "0.20.0" - resolved "https://registry.yarnpkg.com/@amplitude/analytics-types/-/analytics-types-0.20.0.tgz#9efc83b758fdbf3929f0b00a8ba3e5a7262e1c7a" - integrity sha512-OYoUrf7QUl5sL4mqcQJBu+0GuSar7ga5prJv0HDtPT4LGu7Adv8S3AWljGiEJuTS/YaOMzvTe2qyKZbwyiNrMw== +"@amplitude/analytics-types@^2.1.2": + version "2.1.2" + resolved "https://registry.yarnpkg.com/@amplitude/analytics-types/-/analytics-types-2.1.2.tgz#7a2a7a22fba192639189bb03eda5dd8287487cf2" + integrity sha512-ASKwH9g+5gglTHr7h7miK8J/ofIzuEtGRDCjnZAtRbE6+laoOfCLYPPJXMYz0k1x+rIhLO/6I6WWjT7zchmpyA== -"@amplitude/plugin-page-view-tracking-browser@^0.8.0": - version "0.8.0" - resolved "https://registry.yarnpkg.com/@amplitude/plugin-page-view-tracking-browser/-/plugin-page-view-tracking-browser-0.8.0.tgz#e3bd74ee699276377bd20992fde0d0b10bce033e" - integrity sha512-Bun7aGo7woxsnupDEY1YugLQyAXDRtFhQsXnJKKCIkyeeRCq4qsuaAz0wI8w1QV+3IhaAf0lBuSqSuBIhPFDLQ== +"@amplitude/plugin-page-view-tracking-browser@^2.0.8": + version "2.0.8" + resolved "https://registry.yarnpkg.com/@amplitude/plugin-page-view-tracking-browser/-/plugin-page-view-tracking-browser-2.0.8.tgz#3083f90bd5f35b6125b68ac495bc91d19237a4ae" + integrity sha512-TwZuJZj5x1x98Dg8e/Papq9NmP5smKQiHg0/N7MY+qXELsM0zJ53TsXC0Eo2J9U8Ok6jfZSRoYCp/s7mQ2zDoA== dependencies: - "@amplitude/analytics-client-common" "^0.7.0" - "@amplitude/analytics-types" "^0.20.0" + "@amplitude/analytics-client-common" "^2.0.5" + "@amplitude/analytics-types" "^2.1.2" tslib "^2.4.1" -"@amplitude/plugin-web-attribution-browser@^0.7.0": - version "0.7.0" - resolved "https://registry.yarnpkg.com/@amplitude/plugin-web-attribution-browser/-/plugin-web-attribution-browser-0.7.0.tgz#0e2baeefce6d90e481a095df1efa1a79b6283297" - integrity sha512-PKC6SHIVGXvxhxO4CZQOYidoo+aKApLRFGBbRfDEVdSxEDY1b1wTHtqTJomxodqvw4pLocSDiuwC1s7B0p4zAQ== +"@amplitude/plugin-web-attribution-browser@^2.0.8": + version "2.0.8" + resolved "https://registry.yarnpkg.com/@amplitude/plugin-web-attribution-browser/-/plugin-web-attribution-browser-2.0.8.tgz#44d89b8d77a4713c919dead38cff7228d2be3fc3" + integrity sha512-ZRk67ErKc+uNFKpgPEtdT+7kut3RkdiuZa52c3rX6OeUYpFpVlwWnH565AnpNh/clBPlqJPL7T90Dq0ku9QZtg== dependencies: - "@amplitude/analytics-client-common" "^0.7.0" - "@amplitude/analytics-types" "^0.20.0" + "@amplitude/analytics-client-common" "^2.0.5" + "@amplitude/analytics-core" "^2.0.4" + "@amplitude/analytics-types" "^2.1.2" tslib "^2.4.1" -"@amplitude/ua-parser-js@^0.7.31": - version "0.7.33" - resolved "https://registry.yarnpkg.com/@amplitude/ua-parser-js/-/ua-parser-js-0.7.33.tgz#26441a0fb2e956a64e4ede50fb80b848179bb5db" - integrity sha512-wKEtVR4vXuPT9cVEIJkYWnlF++Gx3BdLatPBM+SZ1ztVIvnhdGBZR/mn9x/PzyrMcRlZmyi6L56I2J3doVBnjA== - "@ampproject/remapping@^2.2.0": version "2.2.1" resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.2.1.tgz#99e8e11851128b8702cd57c33684f1d0f260b630" From 33b2999da0e79841a38a7bc260f0a62ec399d575 Mon Sep 17 00:00:00 2001 From: teodorus-nathaniel Date: Thu, 31 Aug 2023 22:38:36 +0700 Subject: [PATCH 3/3] Add notice for enabled push notification --- src/components/auth/ProfileModal/ProfileModal.tsx | 2 +- .../contents/notifications/PushNotificationContent.tsx | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/auth/ProfileModal/ProfileModal.tsx b/src/components/auth/ProfileModal/ProfileModal.tsx index d859d0f2c..330aa55a0 100644 --- a/src/components/auth/ProfileModal/ProfileModal.tsx +++ b/src/components/auth/ProfileModal/ProfileModal.tsx @@ -124,7 +124,7 @@ export default function ProfileModal({ }, 'push-notifications': { title: '🔔 Push Notifications', - desc: 'Enable Push Notifications on your browser to receive direct updates from Grill.', + desc: 'Push notifications allow you to receive direct updates from Grill in your browser.', withBackButton: 'notifications', }, } diff --git a/src/components/auth/ProfileModal/contents/notifications/PushNotificationContent.tsx b/src/components/auth/ProfileModal/contents/notifications/PushNotificationContent.tsx index c4774df0b..aac810ae0 100644 --- a/src/components/auth/ProfileModal/contents/notifications/PushNotificationContent.tsx +++ b/src/components/auth/ProfileModal/contents/notifications/PushNotificationContent.tsx @@ -1,4 +1,5 @@ import Button from '@/components/Button' +import Notice from '@/components/Notice' import Toast from '@/components/Toast' import { useLinkFcm } from '@/services/api/notifications/mutation' import { getMessageToken } from '@/services/firebase/messaging' @@ -35,7 +36,13 @@ export default function PushNotificationContent(props: ContentProps) { const permission = Notification.permission if (permission === 'granted' && isRegistered) { return ( - +
+ Push Notifications Enabled + +
) }