193 lines
2.0 KiB
JavaScript
193 lines
2.0 KiB
JavaScript
const config = require('../../config');
|
|
const providers = config.providers;
|
|
const crypto = require('crypto');
|
|
const bcrypt = require('bcrypt');
|
|
const moment = require('moment');
|
|
|
|
module.exports = function(sequelize, DataTypes) {
|
|
const tracking_events = sequelize.define(
|
|
'tracking_events',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
event_name: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"landing_viewed",
|
|
|
|
|
|
"signup_started",
|
|
|
|
|
|
"signup_completed",
|
|
|
|
|
|
"login_completed",
|
|
|
|
|
|
"onboarding_started",
|
|
|
|
|
|
"onboarding_completed",
|
|
|
|
|
|
"profile_generated",
|
|
|
|
|
|
"vision_generated",
|
|
|
|
|
|
"career_coach_started",
|
|
|
|
|
|
"career_coach_completed",
|
|
|
|
|
|
"offer_viewed",
|
|
|
|
|
|
"checkout_started",
|
|
|
|
|
|
"checkout_completed",
|
|
|
|
|
|
"member_routed",
|
|
|
|
|
|
"course_entered",
|
|
|
|
|
|
"lesson_started",
|
|
|
|
|
|
"lesson_completed",
|
|
|
|
|
|
"trophy_awarded",
|
|
|
|
|
|
"feedback_submitted",
|
|
|
|
|
|
"limit_blocked",
|
|
|
|
|
|
"other"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
event_label: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
page_path: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
occurred_at: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
metadata_json: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
tracking_events.associate = (db) => {
|
|
|
|
|
|
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//end loop
|
|
|
|
|
|
|
|
db.tracking_events.belongsTo(db.users, {
|
|
as: 'user',
|
|
foreignKey: {
|
|
name: 'userId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
|
|
db.tracking_events.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.tracking_events.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return tracking_events;
|
|
};
|
|
|
|
|