@capillarytech/creatives-library 3.4.3 → 3.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "3.4.3",
4
+ "version": "3.4.4",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -13,6 +13,7 @@
13
13
  "license": "LicenseRef-LICENSE",
14
14
  "dependencies": {
15
15
  "@babel/polyfill": "7.4.3",
16
+ "@capillarytech/cap-ui-utils": "1.0.8",
16
17
  "babel-cli": "^6.26.0",
17
18
  "chalk": "1.1.3",
18
19
  "jquery": "^3.3.1",
@@ -12,3 +12,33 @@ export const getTopbarMenuDataValue = () => ([
12
12
  { label: <FormattedMessage {...globalMessages.incentive} />, link: '/coupons/ui/', key: 'incentive' },
13
13
  { label: <FormattedMessage {...globalMessages.creatives} />, link: '/creatives/ui/v2', key: 'creatives' },
14
14
  ]);
15
+
16
+ export const TRACK_CREATE_SMS = 'createSms';
17
+ export const TRACK_CREATE_EMAIL = 'createEmail';
18
+ export const TRACK_CREATE_MPUSH = 'createMpush';
19
+ export const TRACK_CREATE_WECHAT = 'createWeChat';
20
+ export const TRACK_CREATE_IMAGE = 'createImage';
21
+
22
+
23
+ export const TRACK_EDIT_SMS = 'editSms';
24
+ export const TRACK_EDIT_EMAIL = 'editEmail';
25
+ export const TRACK_EDIT_MPUSH = 'editMpush';
26
+ export const TRACK_EDIT_WECHAT = 'editWeChat';
27
+ export const TRACK_EDIT_IMAGE = 'editImage';
28
+
29
+ export const CHANNEL_CREATE_TRACK_MAPPING = {
30
+ sms: TRACK_CREATE_SMS,
31
+ email: TRACK_CREATE_EMAIL,
32
+ mobilepush: TRACK_CREATE_MPUSH,
33
+ wechat: TRACK_CREATE_WECHAT,
34
+ gallery: TRACK_CREATE_IMAGE,
35
+ };
36
+
37
+ export const CHANNEL_EDIT_TRACK_MAPPING = {
38
+ sms: TRACK_EDIT_SMS,
39
+ email: TRACK_EDIT_EMAIL,
40
+ mobilepush: TRACK_EDIT_MPUSH,
41
+ wechat: TRACK_EDIT_WECHAT,
42
+ gallery: TRACK_EDIT_IMAGE,
43
+ };
44
+ export const GTM_TRACKING_ID = 'UA-152081629-1';
@@ -9,6 +9,7 @@ import { createStructuredSelector } from 'reselect';
9
9
  import _ from 'lodash';
10
10
  import moment from 'moment';
11
11
  // import 'moment/locale/zh-cn';
12
+ import { GA } from '@capillarytech/cap-ui-utils';
12
13
  import { injectIntl, FormattedMessage } from 'react-intl';
13
14
  import messages from './messages';
14
15
  import { makeSelectAuthenticated, makeSelectUser } from './selectors';
@@ -18,6 +19,8 @@ import * as appActions from '../App/actions';
18
19
  import config from '../../config/app';
19
20
  import NavigationBar from '../../v2Components/NavigationBar';
20
21
  import { engagePlusPublicPath } from '../../config/path';
22
+ import { GTM_TRACKING_ID } from '../App/constants';
23
+
21
24
  import {
22
25
  HELP_URL,
23
26
  ORG_SETTINGS_URL,
@@ -33,6 +36,8 @@ const CapWrapper = styled.div`
33
36
  flex-direction: column;
34
37
  `;
35
38
 
39
+ GA.initialize({ accessKey: GTM_TRACKING_ID });
40
+
36
41
  export class Cap extends React.Component { // eslint-disable-line react/prefer-stateless-function
37
42
 
38
43
  constructor(props) {
@@ -29,6 +29,8 @@ import EmailPreview from '../../v2Components/EmailPreview';
29
29
  import Pagination from '../../v2Components/Pagination';
30
30
  import * as creativesContainerActions from '../CreativesContainer/actions';
31
31
  import withCreatives from '../../hoc/withCreatives';
32
+ import { GA } from '@capillarytech/cap-ui-utils';
33
+ import { TRACK_CREATE_EMAIL, TRACK_EDIT_EMAIL } from '../App/constants';
32
34
 
33
35
  const {CapCustomCardList} = CapCustomCard;
34
36
  export class Email extends React.Component { // eslint-disable-line react/prefer-stateless-function
@@ -620,10 +622,16 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
620
622
  });
621
623
  }
622
624
  onUpdateTemplateComplete = (createResponse) => {
625
+ const isEdit = this.state.isEdit;
626
+ GA.timeTracker.stopTimer(isEdit ? TRACK_EDIT_EMAIL : TRACK_CREATE_EMAIL, {
627
+ category: 'Creatives',
628
+ action: isEdit ? 'Create' : 'Edit',
629
+ label: 'using editor',
630
+ });
623
631
  if (createResponse && createResponse.templateId) {
624
632
  // this.resetSchema();
625
633
  let message;
626
- if (this.state.isEdit) {
634
+ if (isEdit) {
627
635
  message = this.props.intl.formatMessage(messages.emailEditSuccess);
628
636
  } else {
629
637
  message = this.props.intl.formatMessage(messages.emailCreateSuccess);
@@ -7,6 +7,7 @@ import PropTypes from 'prop-types';
7
7
  import React from 'react';
8
8
  import { connect } from 'react-redux';
9
9
  import { FormattedMessage, injectIntl, intlShape } from 'react-intl';
10
+ import { GA } from '@capillarytech/cap-ui-utils';
10
11
  import { createStructuredSelector } from 'reselect';
11
12
  import { bindActionCreators } from 'redux';
12
13
  import _ from 'lodash';
@@ -19,7 +20,10 @@ import * as templatesActionsCreators from '../Templates/actions';
19
20
  import Email from '../Email';
20
21
  import CmsTemplatesComponent from '../../v2Components/CmsTemplatesComponent';
21
22
  import messages from './messages';
23
+ import { CHANNEL_CREATE_TRACK_MAPPING } from '../App/constants'
24
+
22
25
  const CapRadioCardWithLabel = ComponentWithLabelHOC(CapRadioCard);
26
+ const { timeTracker } = GA;
23
27
  const CardContainer = styled.div`
24
28
  margin-top: 16px;
25
29
  .ant-radio-group{
@@ -106,7 +110,16 @@ export class EmailWrapper extends React.Component { // eslint-disable-line react
106
110
  };
107
111
  CapNotification.error(message);
108
112
  }
113
+ stopTimerGA=()=>{
114
+ // stop timer
115
+ timeTracker.stopTimer(CHANNEL_CREATE_TRACK_MAPPING['email'], {
116
+ category: 'Creatives',
117
+ action: 'Create',
118
+ label: 'uploadZip',
119
+ });
120
+ }
109
121
  handleFileUpload = (file) => {
122
+
110
123
  const { templatesActions, intl, showNextStep, isUploading } = this.props;
111
124
  if (!isUploading) {
112
125
  const fileExtension = file.name.split('.').pop();
@@ -116,7 +129,9 @@ export class EmailWrapper extends React.Component { // eslint-disable-line react
116
129
  if (supportedZipFormats.indexOf(fileExtension.toLowerCase()) !== -1) {
117
130
  templatesActions.handleZipUpload(file.originFileObj, () => { //handle upload success
118
131
  this.setState({ modeContent: { file } }, showNextStep);
132
+ stopTimerGA();
119
133
  }, this.handleZipUploadError);
134
+
120
135
  } else if (fileExtension === 'html' || fileExtension === 'htm') {
121
136
  const reader = new FileReader();
122
137
  reader.onload = () => {
@@ -124,7 +139,6 @@ export class EmailWrapper extends React.Component { // eslint-disable-line react
124
139
  this.setState({ modeContent: { file } }, () => {
125
140
  templatesActions.handleHtmlUpload(text);
126
141
  });
127
-
128
142
  // showNextStep();
129
143
  };
130
144
  reader.readAsText(file.originFileObj);
@@ -25,6 +25,8 @@ import {getMessageObject} from '../../../utils/messageUtils';
25
25
  import { makeSelectTemplates } from '../../Templates/selectors';
26
26
  import messages from './messages';
27
27
  import getEventsMap from '../eventsMap';
28
+ import { GA } from '@capillarytech/cap-ui-utils';
29
+ import { TRACK_CREATE_MPUSH } from '../../App/constants';
28
30
 
29
31
  const PrefixWrapper = styled.div`
30
32
  margin-right: 16px;
@@ -1402,7 +1404,13 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1402
1404
  saveFormData = (formData) => {
1403
1405
  //this function gets called from form bulder only when the form data is valid
1404
1406
  const obj = this.getTransformedData(formData);
1407
+ const label = this.props.location.pathname.indexOf('image') >= 0 ? 'image' : 'text';
1405
1408
  this.props.actions.createTemplate(obj, () => {
1409
+ GA.timeTracker.stopTimer(TRACK_CREATE_MPUSH, {
1410
+ category: 'Creatives',
1411
+ action: 'Create',
1412
+ label,
1413
+ });
1406
1414
  this.discardValues();
1407
1415
  const message = this.props.intl.formatMessage(messages.messageCreateSuccess);
1408
1416
  CapNotification.success({message, key: 'createMpushSuccess'});
@@ -29,6 +29,8 @@ import withCreatives from '../../../hoc/withCreatives';
29
29
 
30
30
  import getEventsMap from '../eventsMap';
31
31
  import {getPrimaryCtaFields, getSecondaryCtaFields, getLinkTypeFields} from '../commonMethods';
32
+ import { GA } from '@capillarytech/cap-ui-utils';
33
+ import { TRACK_EDIT_MPUSH } from '../../App/constants';
32
34
 
33
35
  const PrefixWrapper = styled.div`
34
36
  margin-right: 16px;
@@ -271,6 +273,12 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
271
273
  };
272
274
  onUpdateTemplateComplete = () => {
273
275
  console.log('reseting schema');
276
+ const label = this.props.location.pathname.indexOf('image') >= 0 ? 'image' : 'text';
277
+ GA.timeTracker.stopTimer(TRACK_EDIT_MPUSH, {
278
+ category: 'Creatives',
279
+ action: 'Edit',
280
+ label,
281
+ });
274
282
  this.resetSchema();
275
283
  this.setState({
276
284
  formData: {},
@@ -26,7 +26,8 @@ import {SMS} from '../../CreativesContainer/constants';
26
26
  // import callNativeEvent from '../../../utils/callNativeEvent';
27
27
  import {showError} from '../commonMethods';
28
28
  import withCreatives from '../../../hoc/withCreatives';
29
-
29
+ import { GA } from '@capillarytech/cap-ui-utils';
30
+ import { TRACK_CREATE_SMS } from '../../App/constants'
30
31
  export class Create extends React.Component { // eslint-disable-line react/prefer-stateless-function
31
32
  constructor(props) {
32
33
  super(props);
@@ -201,6 +202,10 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
201
202
  this.setState({currentTab: data});
202
203
  }
203
204
  onCreateTemplateComplete = (editResponse) => {
205
+ GA.timeTracker.stopTimer(TRACK_CREATE_SMS, {
206
+ category: 'Creatives',
207
+ action: 'Create',
208
+ });
204
209
  if (editResponse.templateId) {
205
210
  this.resetSchema();
206
211
  this.setState({
@@ -25,7 +25,8 @@ import * as creativesContainerActions from '../../CreativesContainer/actions';
25
25
  // import callNativeEvent from '../../../utils/callNativeEvent';
26
26
  import {showError} from '../commonMethods';
27
27
  import withCreatives from '../../../hoc/withCreatives';
28
-
28
+ import { TRACK_EDIT_SMS } from '../../App/constants'
29
+ import { GA } from '@capillarytech/cap-ui-utils';
29
30
  export class Edit extends React.Component { // eslint-disable-line react/prefer-stateless-function
30
31
  constructor(props) {
31
32
  super(props);
@@ -219,6 +220,10 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
219
220
  this.setState({currentTab: data});
220
221
  }
221
222
  onUpdateTemplateComplete = (editResponse) => {
223
+ GA.timeTracker.stopTimer(TRACK_EDIT_SMS, {
224
+ category: 'Creatives',
225
+ action: 'Edit',
226
+ });
222
227
  if (editResponse.templateId) {
223
228
  this.resetSchema();
224
229
  this.setState({
@@ -50,13 +50,14 @@ import Pagination from '../../v2Components/Pagination';
50
50
  import EmailPreview from '../../v2Components/EmailPreview';
51
51
  import CreativesContainer from '../CreativesContainer';
52
52
  import WechatRichmediaTemplatePreview from '../../v2Components/TemplatePreview/WechatRichmediaTemplatePreview';
53
+ import { CHANNEL_CREATE_TRACK_MAPPING, CHANNEL_EDIT_TRACK_MAPPING } from '../App/constants'
53
54
  import { MOBILE_PUSH, WECHAT, SMS, EMAIL, EBILL, LINE } from '../CreativesContainer/constants';
54
55
  import emailIllustration from '../Assets/images/emailIllustration.svg';
55
56
  import smsIllustration from '../Assets/images/smsIllustration.svg';
56
57
  import pushIllustration from '../Assets/images/pushIllustration.svg';
57
58
  import { CAP_SPACE_16 } from '@capillarytech/cap-ui-library/styled/variables';
58
-
59
-
59
+ import { GA } from '@capillarytech/cap-ui-utils';
60
+ const { timeTracker } = GA;
60
61
  const {CapCustomCardList} = CapCustomCard;
61
62
  const InlineDiv = styled.div`
62
63
  display: inline;
@@ -75,6 +76,8 @@ const WECHAT_FILTERS = {
75
76
  RICHMEDIA: 'richmedia',
76
77
  MAPTEMPLATES: 'maptemplate',
77
78
  };
79
+
80
+
78
81
  export class Templates extends React.Component { // eslint-disable-line react/prefer-stateless-function
79
82
  constructor(props) {
80
83
  super(props);
@@ -163,6 +166,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
163
166
  }
164
167
 
165
168
  componentDidMount() {
169
+
166
170
  if (this.props.location.query.type === 'embedded' && this.isEnabledInLibraryModule("setLocale")) {
167
171
  this.setLocale();
168
172
  }
@@ -922,13 +926,14 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
922
926
  break;
923
927
  }
924
928
  };
925
-
929
+
926
930
  createTemplate(ev) {
927
931
  const type = this.props.location.query.type;
928
932
  const module = this.props.location.query.module ? this.props.location.query.module : 'default';
929
933
  const channel = this.state.channel.toLowerCase();
930
934
  //const keyType = ev.key && ev.key.toLowerCase() !== undefined ? ev.state.toLowerCase() : '';
931
935
  let routeParams = {};
936
+ timeTracker.startTimer(CHANNEL_CREATE_TRACK_MAPPING[channel]);
932
937
  if (this.isEnabledInLibraryModule("callCreateFromProps")) {
933
938
  this.props.createNew();
934
939
  } else if (ev.key && (ev.key.toLowerCase() === "text" || ev.key.toLowerCase() === "image")) {
@@ -1123,6 +1128,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1123
1128
  };
1124
1129
 
1125
1130
  handleEditClick(e, template, modeType, path) {
1131
+ timeTracker.startTimer(CHANNEL_EDIT_TRACK_MAPPING[this.state.channel.toLowerCase()]);
1126
1132
  if (modeType && modeType !== undefined) {
1127
1133
  this.setState({modeType});
1128
1134
  }
@@ -29,6 +29,8 @@ import {getMessageObject} from '../../../utils/messageUtils';
29
29
  import * as templateActions from '../../Templates/actions';
30
30
  import './_mapTemplates.scss';
31
31
  import withCreatives from '../../../hoc/withCreatives';
32
+ import { GA } from '@capillarytech/cap-ui-utils';
33
+ import { TRACK_CREATE_WECHAT, TRACK_EDIT_WECHAT } from '../../App/constants'
32
34
 
33
35
  const SELECT_TEMPLATE_MODE = "selectTemplate";
34
36
  const MAP_TEMPLATE_MODE = "mapTemplateMode";
@@ -955,8 +957,9 @@ export class MapTemplates extends React.Component { // eslint-disable-line react
955
957
  saveFormData(formData) {
956
958
  const obj = {};
957
959
  let selectedWechatData = {};
960
+ const isEdit = this.state.isEdit;
958
961
  const { getFormData } = this.props;
959
- if (this.state.isEdit) {
962
+ if (isEdit) {
960
963
  obj['_id'] = this.state.editTemplateData._id;
961
964
  selectedWechatData = {
962
965
  'template_id': this.state.editTemplateData.versions.base.template_id,
@@ -1010,6 +1013,11 @@ export class MapTemplates extends React.Component { // eslint-disable-line react
1010
1013
  getFormData(this.getFormData(obj));
1011
1014
  }, 0);
1012
1015
  }
1016
+ GA.timeTracker.stopTimer(isEdit ? TRACK_EDIT_WECHAT : TRACK_CREATE_WECHAT, {
1017
+ category: 'Creatives',
1018
+ action: isEdit ? 'Edit' : 'Create',
1019
+ label : 'MapTemplates',
1020
+ });
1013
1021
  console.log("Template created successfully", response, obj);
1014
1022
  });
1015
1023
  }
@@ -28,7 +28,8 @@ import WechatRichmediaTemplatePreview from '../../../../v2Components/TemplatePre
28
28
  import noImage from '../../../../assets/noImage.png';
29
29
  import Pagination from '../../../../v2Components/Pagination';
30
30
  import { CAP_SPACE_08, CAP_SPACE_12, CAP_SPACE_20, CAP_SPACE_16 } from '@capillarytech/cap-ui-library/styled/variables';
31
-
31
+ import { GA } from '@capillarytech/cap-ui-utils';
32
+ import { TRACK_CREATE_WECHAT, TRACK_EDIT_WECHAT } from '../../../App/constants'
32
33
  export class Create extends React.Component { // eslint-disable-line react/prefer-stateless-function
33
34
  constructor(props) {
34
35
  super(props);
@@ -544,7 +545,8 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
544
545
  msgtype: "MPNEWS",
545
546
  msgcontent: "RICH_MEDIA_WECHAT",
546
547
  };
547
- if (this.state.isEdit) {
548
+ const isEdit = this.state.isEdit;
549
+ if (isEdit) {
548
550
  saveObj._id = this.props.templateId;
549
551
  saveObj.mediaId = this.props.mediaId;
550
552
  saveObj.type = "WECHAT";
@@ -554,6 +556,11 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
554
556
  // CapNotification.success({
555
557
  // message: this.props.intl.formatMessage(messages.saveSuccess),
556
558
  // });
559
+ GA.timeTracker.stopTimer(isEdit ? TRACK_EDIT_WECHAT : TRACK_CREATE_WECHAT, {
560
+ category: 'Creatives',
561
+ action: isEdit ? 'Edit' : 'Create',
562
+ label : 'RichMedia',
563
+ });
557
564
  if (getFormData) {
558
565
  getFormData(this.getFormData({
559
566
  mediaId: response.mediaId,