mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
update: add analytics event upon group creation/upgrade (temp code & console.logs commented out)
This commit is contained in:
@@ -120,12 +120,12 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<!-- TEMPORARY BUTTON FOR TESTING -->
|
<!-- TEMPORARY BUTTON FOR TESTING -->
|
||||||
<button
|
<!-- <button
|
||||||
class="btn btn-primary btn-payment"
|
class="btn btn-primary btn-payment"
|
||||||
@click="success()"
|
@click="success()"
|
||||||
>
|
>
|
||||||
Clicky click click!
|
Clicky click click!
|
||||||
</button>
|
</button> -->
|
||||||
</div>
|
</div>
|
||||||
</b-modal>
|
</b-modal>
|
||||||
</template>
|
</template>
|
||||||
@@ -234,7 +234,7 @@
|
|||||||
}
|
}
|
||||||
.modal-content {
|
.modal-content {
|
||||||
width: 448px;
|
width: 448px;
|
||||||
height: 436px;
|
max-height: 436px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
box-shadow: 0 14px 28px 0 rgba(26, 24, 29, 0.24), 0 10px 10px 0 rgba(26, 24, 29, 0.28);
|
box-shadow: 0 14px 28px 0 rgba(26, 24, 29, 0.24), 0 10px 10px 0 rgba(26, 24, 29, 0.28);
|
||||||
}
|
}
|
||||||
@@ -277,6 +277,7 @@ export default {
|
|||||||
PAYMENTS: {
|
PAYMENTS: {
|
||||||
AMAZON: 'amazon',
|
AMAZON: 'amazon',
|
||||||
STRIPE: 'stripe',
|
STRIPE: 'stripe',
|
||||||
|
// OTHER: 'tempcode', // TEMP CODE
|
||||||
},
|
},
|
||||||
paymentMethod: '',
|
paymentMethod: '',
|
||||||
newGroup: {
|
newGroup: {
|
||||||
@@ -316,9 +317,11 @@ export default {
|
|||||||
},
|
},
|
||||||
pay (paymentMethod) {
|
pay (paymentMethod) {
|
||||||
const subscriptionKey = 'group_monthly'; // @TODO: Get from content API?
|
const subscriptionKey = 'group_monthly'; // @TODO: Get from content API?
|
||||||
|
const demographicsKey = this.newGroup.demographics;
|
||||||
const paymentData = {
|
const paymentData = {
|
||||||
subscription: subscriptionKey,
|
subscription: subscriptionKey,
|
||||||
coupon: null,
|
coupon: null,
|
||||||
|
demographics: demographicsKey,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.upgradingGroup && this.upgradingGroup._id) {
|
if (this.upgradingGroup && this.upgradingGroup._id) {
|
||||||
@@ -339,6 +342,11 @@ export default {
|
|||||||
this.redirectToStripe(paymentData);
|
this.redirectToStripe(paymentData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TEMP CODE
|
||||||
|
if (this.paymentMethod === this.PAYMENTS.OTHER) {
|
||||||
|
console.log(paymentData);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
// need to figure out where/how to create the event in amplitude
|
// need to figure out where/how to create the event in amplitude
|
||||||
@@ -350,12 +358,13 @@ export default {
|
|||||||
this.sendingInProgress = false;
|
this.sendingInProgress = false;
|
||||||
},
|
},
|
||||||
// temporary function to go with temporary button
|
// temporary function to go with temporary button
|
||||||
success () {
|
// success () {
|
||||||
console.log(this.sendAnalytics());
|
// this.pay(this.PAYMENTS.OTHER);
|
||||||
this.sendAnalytics();
|
// console.log(this.sendAnalytics());
|
||||||
this.$root.$emit('bv::hide::modal', 'create-group');
|
// this.sendAnalytics();
|
||||||
this.$root.$emit('bv::show::modal', 'payments-success-modal');
|
// this.$root.$emit('bv::hide::modal', 'create-group');
|
||||||
},
|
// this.$root.$emit('bv::show::modal', 'payments-success-modal');
|
||||||
|
// },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -105,8 +105,8 @@
|
|||||||
]"
|
]"
|
||||||
class="group-input"
|
class="group-input"
|
||||||
:placeholder="'groupUseDefault'"
|
:placeholder="'groupUseDefault'"
|
||||||
:value="newGroup.demographics"
|
:value="upgradedGroup.demographics"
|
||||||
@select="newGroup.demographics = $event"
|
@select="upgradedGroup.demographics = $event"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -119,7 +119,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<button
|
<button
|
||||||
v-once
|
v-else
|
||||||
class="btn btn-primary"
|
class="btn btn-primary"
|
||||||
@click="close()"
|
@click="close()"
|
||||||
>
|
>
|
||||||
@@ -257,6 +257,9 @@ export default {
|
|||||||
gem: gemIcon,
|
gem: gemIcon,
|
||||||
}),
|
}),
|
||||||
paymentData: {},
|
paymentData: {},
|
||||||
|
upgradedGroup: {
|
||||||
|
demographics: null,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -288,8 +291,8 @@ export default {
|
|||||||
this.$root.$emit('bv::hide::modal', 'payments-success-modal');
|
this.$root.$emit('bv::hide::modal', 'payments-success-modal');
|
||||||
},
|
},
|
||||||
closeGroup () {
|
closeGroup () {
|
||||||
|
console.log(this.updatedGroup.demographics);
|
||||||
this.close();
|
this.close();
|
||||||
return this.groupName.analytics; // this needs to go to Amplitude somehow
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ export default {
|
|||||||
if (data.subscription) postData.sub = sub.key;
|
if (data.subscription) postData.sub = sub.key;
|
||||||
if (data.coupon) postData.coupon = data.coupon;
|
if (data.coupon) postData.coupon = data.coupon;
|
||||||
if (data.groupId) postData.groupId = data.groupId;
|
if (data.groupId) postData.groupId = data.groupId;
|
||||||
|
if (data.demographics) postData.demographics = data.demographics;
|
||||||
|
|
||||||
const response = await axios.post(url, postData);
|
const response = await axios.post(url, postData);
|
||||||
|
|
||||||
@@ -267,6 +268,10 @@ export default {
|
|||||||
this.amazonPayments.groupToCreate = data.groupToCreate;
|
this.amazonPayments.groupToCreate = data.groupToCreate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.demographics) { // sending demographics
|
||||||
|
this.amazonPayments.demographics = data.demographics;
|
||||||
|
}
|
||||||
|
|
||||||
this.amazonPayments.gift = data.gift;
|
this.amazonPayments.gift = data.gift;
|
||||||
this.amazonPayments.type = data.type;
|
this.amazonPayments.type = data.type;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -86,6 +86,13 @@ async function createSubscription (data) {
|
|||||||
user: data.user, groupId: data.groupId, populateLeader: false, groupFields,
|
user: data.user, groupId: data.groupId, populateLeader: false, groupFields,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (group) {
|
||||||
|
analytics.track(
|
||||||
|
this.groupID,
|
||||||
|
data.demographics,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!group) {
|
if (!group) {
|
||||||
throw new NotFound(shared.i18n.t('groupNotFound'));
|
throw new NotFound(shared.i18n.t('groupNotFound'));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user