Open soplan opened 6 months ago
Hello @soplan . Sorry for any inconvenience while upgrading to v6. As a work around could you emit the missing events while authenticating using the Pinpoint record API ?
Hello @soplan . Sorry for any inconvenience while upgrading to v6. As a work around could you emit the missing events while authenticating using the Pinpoint record API ?
Well if I could I would. But the thing is that adding a record event to a button I can’t distinguish between sign in or sign up.
Using social login so people use the same button for sign in as sign up.
if you are using social login you can listen to the signInWithRedirect
hub event and record the sign-in
event. When it comes to sign-up with social login there is not a way for the library to know if the user has created an account on their IdP as the registration process is completed outside of the App. You can record the sign-up
event after successfully creating an user with the signUp
API
@soplan, were you basing your events that were recorded in the Pinpoint console for _userauth.sign_in
, _userauth.sign_up
, and _userauth.auth_fail
off of the v5 Hub events that are emitted from the Auth channel? I don't see where you're importing Hub in this v6 version of your app either.
@soplan, were you basing your events that were recorded in the Pinpoint console for
_userauth.sign_in
,_userauth.sign_up
, and_userauth.auth_fail
off of the v5 Hub events that are emitted from the Auth channel? I don't see where you're importing Hub in this v6 version of your app either.
We migrated back to v5, exact same setup as v6 but this time the sign in, sign up and auth_fail events appear without having to import hub.
I really like Amplify and using AWS Pinpoint but v6 is making it unusable for us.
Amplify.utils.ts
import { Analytics } from "aws-amplify";
import { UserNotifications, UserProfile } from "../interfaces";
export const initializeTracking = async () => {
Analytics.autoTrack("event", {
enable: true,
});
Analytics.autoTrack("session", {
enable: true,
});
Analytics.autoTrack("pageView", {
enable: true,
eventName: "pageView",
type: "SPA",
});
};
export const updateEndpoint = async (updatedProfile: UserProfile) => {
const endpointConfig = {
userId: updatedProfile.id,
Address: updatedProfile.email,
ChannelType: "EMAIL",
OptOut: "NONE",
demographic: {
locale: updatedProfile.locale,
timezone: updatedProfile.timeZone,
},
userAttributes: {
UserId: [updatedProfile.id],
Name: [updatedProfile.name],
Locale: [updatedProfile.locale],
Timezone: [updatedProfile.timeZone],
EmailPreferences: (Object.keys(updatedProfile.notifications) as (keyof UserNotifications)[]).map(
(key) => updatedProfile.notifications[key]
),
CreatedAt: [new Date(updatedProfile.createdAt * 1000).toISOString()],
UpdatedAt: [new Date(updatedProfile.updatedAt * 1000).toISOString()],
AllowedAddresses: [updatedProfile.allowedAddresses],
UserType: [updatedProfile.type],
},
};
await Analytics.updateEndpoint(endpointConfig);
};
Main.tsx
// import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App.tsx";
import "./index.css";
import { Amplify, Auth } from 'aws-amplify';
import "./services/apiService";
import * as Sentry from "@sentry/react";
import { initializeTracking } from "./utils/amplify.utils.ts";
// const isDevelopment = import.meta.env.VITE_ENV === 'dev';
Sentry.init({
dsn: import.meta.env.VITE_SENTRY_DSN,
integrations: [
Sentry.replayIntegration({
maskAllText: false,
blockAllMedia: false,
}),
],
replaysSessionSampleRate: 0.0,
replaysOnErrorSampleRate: 1.0,
tracesSampleRate: 0.0
});
Amplify.configure({
Auth: {
region: import.meta.env.VITE_AWS_REGION,
userPoolId: import.meta.env.VITE_COGNITO_USER_POOL_ID,
userPoolWebClientId: import.meta.env.VITE_COGNITO_CLIENT_ID,
identityPoolId: import.meta.env.VITE_COGNITO_IDENTITY_POOL_ID,
oauth: {
domain: import.meta.env.VITE_COGNITO_DOMAIN,
scope: ["email", "openid", "profile"],
redirectSignIn: import.meta.env.VITE_COGNITO_OAUTH_REDIRECT,
redirectSignOut: import.meta.env.VITE_COGNITO_OAUTH_REDIRECT,
responseType: "code",
},
},
Analytics: {
AWSPinpoint: {
mandatorySignIn: false,
appId: import.meta.env.VITE_PINPOINT_ANALYTICS,
region: import.meta.env.VITE_AWS_REGION,
}
}
});
async function updateAnalyticsConfig() {
try {
const session = await Auth.currentSession();
const idToken = session.getIdToken();
const payload = idToken.payload;
Amplify.configure({
Analytics: {
AWSPinpoint: {
mandatorySignIn: false,
appId: import.meta.env.VITE_PINPOINT_ANALYTICS,
region: import.meta.env.VITE_AWS_REGION,
endpointId: payload?.sub,
}
}
});
initializeTracking();
} catch (error) { /* empty */ }
}
updateAnalyticsConfig();
initializeTracking();
const container = document.getElementById("root");
if (container) {
const root = ReactDOM.createRoot(container);
root.render(<App />);
}
@soplan I think I understand your concern. May I ask how you are authenticating your users? Which Amplify APIs you are using to signIn and signUp users?
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Analytics
Amplify Version
v6
Amplify Categories
analytics
Backend
Other
Environment information
Describe the bug
In v5 I receive all session events like, _userauth.sign_in, _userauth.sign_up, _userauth.auth_fail
But since v6 I only continue to receive _session.start and _session.stop
I need sign_in, sign_up events to send e-mails using PinPoint journeys for newly signed up users.
Expected behavior
Show all session events as in v5
Reproduction steps
Migrate from v5 to v6. Analytics is working but I am missing some session events.
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
_session.start and stop work fine.
But sign_in won't appear..
And in Pinpoint console it stays 0