1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- import GuideActions from 'sentry/actions/guideActions';
- import {Client} from 'sentry/api';
- import ConfigStore from 'sentry/stores/configStore';
- import {trackAnalyticsEvent} from 'sentry/utils/analytics';
- const api = new Client();
- export function fetchGuides() {
- api.request('/assistant/?v2', {
- method: 'GET',
- success: data => {
- GuideActions.fetchSucceeded(data);
- },
- });
- }
- export function registerAnchor(target: string) {
- GuideActions.registerAnchor(target);
- }
- export function unregisterAnchor(target: string) {
- GuideActions.unregisterAnchor(target);
- }
- export function nextStep() {
- GuideActions.nextStep();
- }
- export function toStep(step: number) {
- GuideActions.toStep(step);
- }
- export function closeGuide(dismissed?: boolean) {
- GuideActions.closeGuide(dismissed);
- }
- export function dismissGuide(guide: string, step: number, orgId: string | null) {
- recordDismiss(guide, step, orgId);
- closeGuide(true);
- }
- export function recordFinish(guide: string, orgId: string | null) {
- api.request('/assistant/', {
- method: 'PUT',
- data: {
- guide,
- status: 'viewed',
- },
- });
- const user = ConfigStore.get('user');
- if (!user) {
- return;
- }
- const data = {
- eventKey: 'assistant.guide_finished',
- eventName: 'Assistant Guide Finished',
- guide,
- organization_id: orgId,
- user_id: parseInt(user.id, 10),
- };
- trackAnalyticsEvent(data);
- }
- export function recordDismiss(guide: string, step: number, orgId: string | null) {
- api.request('/assistant/', {
- method: 'PUT',
- data: {
- guide,
- status: 'dismissed',
- },
- });
- const user = ConfigStore.get('user');
- if (!user) {
- return;
- }
- const data = {
- eventKey: 'assistant.guide_dismissed',
- eventName: 'Assistant Guide Dismissed',
- guide,
- step,
- organization_id: orgId,
- user_id: parseInt(user.id, 10),
- };
- trackAnalyticsEvent(data);
- }
|